views:

29

answers:

2

So if I want to read some information at the offset 00A2E63C (e.g.)... and I need to have it as a DWORD,

how can I convert the "00A2E63C" String to a proper DWORD?

help is appreciated

A: 
std::stringstream hai;
// insert string into hai here
DWORD d;
hai >> d;
void* ptr = (void*)d;
// INVOKE HIDEOUSLY UNSAFE AND UNDEFINED BEHAVIOUR HERE

I don't actually remember if it's undefined. But it's almost certainly hideously unsafe.

DeadMG
@DeadMG: You'll probably want to add `std::hex` in there somewhere.
Matti Virkkunen
+1  A: 
unsigned long x = strtoul("00A2E63C", NULL, 16);

This would convert the string "00A2E63C" into unsigned long.

Chubsdad