Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to modify next instruction before it fetches, in best answer of this question in foo function, *p points to the next instruction in main function. I want to modify content of where *p points at. For example I want to change the next instruction to a jump instruction. How to I can do this?

Objective-C
void foo()
{
    void** p = search((void**)&p, __builtin_return_address(0));
    // modify content of where *p points at.
}

int main()
{

    foo();
    //next instruction. *p points here
    return 0;
}



I want to do this with gcc compiler, on intel Core-i7 3632QM processor.
Posted

1 solution

Probably, you can't: most code resides in memory segments marked as "executable" or "read only" and attempts to change them generally result in access violation errors.

And more to the point, why?
Self modifying code is often a sign that you have done something very, very wrong, and often causes more problems than it solves.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900