-1

I have an ULONG64 variable from SYMBOL_INFO structure that contains virtual address represented as 18446744073709551572 value and I need to convert it to the void* so I can pass it to the ReadProcessMemory function.

If I just do

reinterpret_cast<void*>(pSymInfo->Address)

it gives me FFFFFFD4.

Why? What am I doing wrong? How can I fix it?

Thanks in advance.

FrozenHeart
  • 19,844
  • 33
  • 126
  • 242
  • 1
    That value converts to `0xFFFFFFFFFFFFFFD4` in hex, so it looks like your cast is simply truncating that to 32-bits - suggesting you only have a 32-bit build. As a signed value it equals `-44`. Either way it's not a valid pointer - where did the value come from? – Jonathan Potter Nov 19 '14 at 11:15
  • @Jonathan Potter It came from the following code -- http://pastie.org/9728688 – FrozenHeart Nov 19 '14 at 12:21
  • That doesn't look like a real address. Unless you provide code and details and context, you aren't likely to get much more than has been written above – David Heffernan Nov 19 '14 at 13:40
  • @David Heffernan You can see it here -- http://pastie.org/9728688 – FrozenHeart Nov 19 '14 at 13:57
  • Offsite code. Not ideal. We don't know anything about it. Which line you are referring to. What the code is attempting to do. Why you expect to fit that value into a 32 bit type. Etc. You are aware that your process is 32 bit right? – David Heffernan Nov 19 '14 at 14:12

1 Answers1

0

Not sure why the reinterpret_cast is not working as it should but I usually use ULongToPtr to do these kind of things.

ReadProcessMemory(process, ULongToPtr(virtual_address), &content, sizeof content, nullptr);
mmphs
  • 1
  • 2