I'm writing a .SO that gets called by another program and I want to be able to flip a value in memory through a function in the .SO
What I have so far is :
int
axptrace( int numArguments, char* pMessageBuffer, int* pMessageBufferSize,
char* pData[], int* pDataLength[] )
{
printf("Beginning dump attempt..\n");
unsigned int* wkptr =(int*)0x7f793db70040;
printf("At %llx, the value was %d\n\n",(long long)wkptr,*wkptr);
if(*wkptr == 1){
printf("Switching the value.\n");
*wkptr = 0;
printf("At %llx, the value is now %d\n\n",(long long)wkptr,*wkptr);
printf("Switched!\n\n");
}
printf("Ending dump attempt..\n");
}
As the program runs, I get the messages I expected:
Beginning dump attempt..
At 7f793db70040, the value was 1
Switching the value.
At 7f793db70040, the value is now 0
Switched!
Ending dump attempt..
Beginning dump attempt..
At 7f793db70040, the value was 0
Ending dump attempt..
If I run the same function again though, instead of seeing the value 0 in the first part, I see the value 1 again. I thought it had changed the value at 0x7f793db70040, but apparently it went back to the old value.
Also, the 0xf793db70040 was gotten through a debugger. Is there a way to see if a 'symbol' or something like that points to that address, and a way to use that in my code?