1

I have a HMODULE value that equals: 00007FF695820000 and I need it to be 0x7FF695820000 but because the value is the correct hex value converting it to hex just makes it an even bigger hex value.

Does anyone know a way I can simply add 0x to the start or make my ReadProcessMemory think this is a hex value not a decimal value.

The reason it's a HMODULE variable is because I'm using it to get the base address for Solitare.exe but currently can't read addresses from it because my ReadProcessMemory just converts it to hex first so reads the wrong address.

Tom
  • 13
  • 5
  • how does "converting it to hex just makes it an even bigger hex value"? – phuclv Sep 01 '16 at 04:23
  • Those are 64 bit numbers, leave them be. Treat them as `void*` and `HANDLE`. Show the rest of your code. – Barmak Shemirani Sep 01 '16 at 05:29
  • "Does anyone know a way I can simply add 0x to the start" - are you sure you understand the difference between representation and actual value. You treat the number as if it's stored as a string inside memory. Hex and decimal are just string REPRESENTATIONS of numbers. The number is the same otherwise. – sashoalm Sep 01 '16 at 06:12
  • @ Lưu Vĩnh Phúc It makes it a bigger hex value because Visual Studio thinks it's a decimal number. – Tom Sep 01 '16 at 21:04

1 Answers1

1

Mentioned address 00007FF695820000 is an uint64_t integer number. To call the function you should care about variable type, but not it's visual representation.

You can read the process memory in the following way:

UINT_PTR addr = (UINT_PTR)GetModuleHandle("Solitare.exe");
ReadProcessMemory(hProc, (void*)addr, pBuffer, nSize, &BytesRead);

To use ReadProcessMemory your hProc handle should have PROCESS_VM_READ access permission.

Nikita
  • 6,270
  • 2
  • 24
  • 37
  • @Tom Nice to hear. If my answer is helpful to you, accept it please by ticking it on left side – Nikita Sep 03 '16 at 09:12