I'm looking for a way to have an event get triggered and trapped when accessing a specific read-only section of a program's memory. Specifically, if I have a section of program memory that contains a number of constant values (read-only) and I want to trap an event on access to any of those values, where the event handler can perform some processing (some sort of augmentation to the data) and return the augmented value instead. so, I have a few questions:
- Is this possible?
- If so, how would one go about doing it?
- What kinds of privileges would be required (there is no need to access another processes memory)?
- Is there any documentation on techniques that can be used?
Here is a bit more information, but I'm still trying to figure out exactly the specifics.
What I'm trying to do is either programmatically or during compile/link time, mark a area of memory (probably a page or more) where, when accessed, an event will be triggered which will cause an event handler I wrote to be called and allow me to "fix" the issue that caused the event and return the value that was trying to be accessed. The goal is to be able to have code that is executing and when it tries to access the memory in question, the event handler will be called and can resolve the access and return back to the original code with the access corrected/fixed, so that the original code does not have to be modified. Say for a printf format string, where I want to be able to have the event called and the format string adjusted or replaced and the printf code continues on its merry way.
Does that make sense?