I want to be able to detect when a write to memory address occurs -- for example by setting a callback attached to an interrupt. Does anyone know how?
I'd like to be able to do this at runtime (possibly gdb has this feature, but my particular application causes gdb to crash).
If you want to intercept writes to a range of addresses, you can use mprotect()
to mark the memory in question as non-writeable, and install a signal handler using sigaction()
to catch the resulting SIGSEGV, do your logging or whatever and mark the page as writeable again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With