
Originally Posted by
drlunar
dwBase is the 'base' address, we then TRY to add OFF_1 to grab the address 'profile' is located at in the virtualized mem. space.
Then, to obtain the final address, I want to add a hex value atop of the address that (dwBase+OFF_1) point to.
(Sorry for delay, stepped out of the house - if you prefer Skype over communicating via forum, add me: username is same as here on mpgh)
Code:
BOOL WriteMultiPtr(DWORD dwBase, DWORD OFF_1 = 0, DWORD OFF_2 = 0, INT Value = 0)
{
__try {
DWORD ptrLoc = dwBase + OFF_1; // actual base address
ptrLoc = *(DWORD)* ptrLoc; // read the value(which is a 4 byte memory address) at ptrLoc. Ie. Dereference*
ptrLoc += OFF_2; // add offset to the value we got
*(DWORD*) ptrLoc = Value; // Write a new value at that address
return TRUE;
}
__except (EXCEPTION_EXECUTE_HANDLER) { return FALSE; }
}
I think. ?
edit
dwBase is the 'base' address, we then TRY to add OFF_1...
So dwBase + off_1 is
still a constant
ie. 1000000 + 15 is the same as using 1000015 ...
You should* be adding the first offset to your 'base base address'
BEFORE calling the WriteMultiPtr function,
not inside it.
That is..
Code:
BOOL WriteMultiPtr(DWORD dwBase, DWORD OFF_1 = 0, INT Value = 0)
{
__try {
ptrLoc = *(DWORD)* ptrLoc; // Dereference ptrLoc
ptrLoc += OFF_2; // add offset to the value we got
*(DWORD*) ptrLoc = Value; // Write a new value at that address
return TRUE;
}
__except (EXCEPTION_EXECUTE_HANDLER) { return FALSE; }
}
used as:
Code:
DWORD base = 0x10000000;
const INT OFFSET_1 = 0x****;
const INT OFFSET_2 = 0x****;
DWORD actualBase = base + OFFSET_1;
WriteMultiPtr(actualBase, OFFSET_2, 1000); // 1000 is value written
//Calculate the actual baseAddress HERE, NOT inside the WriteMultiPtr function.
//Otherwise any time you call that function, it will add the offset to your baseAddress. That is NOT what you want. At that point, it's not a generic function anymore.
Design choice. You'll see once you try to add more functionality to your code.