[Help] Reading Pointer

07/25/2012 20:55 jonyboy#1
recently i was learning to make dll for injection and i found this func code:

Code:
unsigned long ReadPointer(unsigned long ulBase, int iOffset)
{
   __try { return *(unsigned long*)(*(unsigned long*)ulBase + iOffset); }
   __except (EXCEPTION_EXECUTE_HANDLER) { return 0; }
}
for example :
addr = 0x0012345
off = 0x10

readpointer(addr, off) -> let say this read value (DWORD) = 1701277249 and char/string value = egnA

DWORD/unsigned long is 4 byte which mean can contain up to 4 char.

i wanna ask how to get value into char/string which have control size that could contain up to 24 char.

ps : im newbie c++
07/25/2012 22:21 phize#2
Code:
std::string my_string((char*)0xdeadbeef, 24);
07/26/2012 00:27 jonyboy#3
thanks for your help.

but, the problem was the result of ReadPointer is DWORD, then how to make it to value ascii char?

ex. : 979899100101102103 = abcdefg
07/30/2012 16:23 tnd0#4
create a new pString or lpStr var and point it to the return value. acessing it should be simple enough. your values seem to be ansi, so make sure you use pAnsiString / lpAnsiString or pChar.
07/31/2012 18:26 jonyboy#5
moderator can close this now..

here solution i got..

Code:
LPCSTR ReadStringPointer(unsigned long ulBase, int iOffset)
{
__try { return (LPCSTR)(*(unsigned long*)ulBase + iOffset); }
__except (EXCEPTION_EXECUTE_HANDLER) { return "-"; }
}
thx all..