-1

I browsed through some code, which basically is a hook (dll injection). In the code I discovered the following:

int Address = 0x12345678; //Address of a memory location of target process
int *Pointer = *(int**) Address; //What happens here?

So it looks like 0x12345678 (address is just a example) is a pointer. So the value we want to get is stored at memory address 0x12345678. Am I guessing right, that the following happens:

-Cast Address to an int-pointer and dereference it, to get the value stored at 0x12345678

-Treat the value at memory address 0x12345678 as a int-pointer too

Thank you very much in advance and sorry for my bad english!

Haxx0r
  • 9
  • 3

1 Answers1

0

-Cast Address to an int-pointer and dereference it, to get the value stored at 0x12345678

No. It casts Address to a pointer to a pointer to an int. And dereferences it, to get the pointer to an int stored at 0x12345678

-Treat the value at memory address 0x12345678 as a int-pointer too

Yes.

Drew Dormann
  • 59,987
  • 13
  • 123
  • 180
  • Thank you very much for your answer! So it is basically the same as this? `int Address = 0x12345678; //Address of a memory location of target process int FirstPointerAddress = *(int*) Address; int *FinalPointer = (int*) FirstPointerAddress;` – Haxx0r May 06 '18 at 13:03
  • I can not promise that it's the same, because an arbitrary address does not necessarily fit in an `int`. If you have questions about that, you should post a new question, as this site is not designed to host back-and-forth conversations. – Drew Dormann May 06 '18 at 15:41