I have a pointer to a function (which i get from a vtable) and I want to edit the function by changing the assembler code (changing a few bytes) at runtime. I tried using memset and also tried assigning the new value directly (something like mPtr[0] = X, mPtr[1] = Y etc.) but I keep getting segmentation fault. How can I change the code?
(I'm using C++)
OS is windows.
In generally: if memory is allocated with API call VirtualAlloc than you can change the memory attributes with API call VirtualProtect. Check first memory attributes with API call VirtualQuery
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