How to add 0x padding to a uintptr_t in a variable?

  c++, cout, hex

So I’m trying to figure out how can I add 0x padding to a uintptr_t. The current value of it is: 400000.

However I would like it to be 0x400000. So currently to achieve this I am adding the 0x padding when I’m printing this out. However how would I go about this so I can store the padded value of uintprt_t?

uintptr_t modBase = GetModuleBaseAddress(pID, "ac_client.exe");
cout << "0x" << hex << modBase <<endl; //Output is 0x400000

The reason for trying to achieve this is that later I would like to find a dynamic base address as shown here:

uintptr_t dynamicBaseAddress = modBase + 0x10f4f4;
cout << "DynamicBaseAddress is: " << dynamicBaseAddress << endl; // Again var is missing 0x

And again the result is: 50f4f4 without the padding.

Source: Windows Questions C++

LEAVE A COMMENT