edit: misread. removed.
Which line are you referring to?
(DWORD*)GetModuleHandleA("example.dll")
or
*(DWORD*)(playerpointer)
I have one question:
Example:
Code:#include<windows.h> #define playerpointer 0xABC12375 int main() { DWORD DllThePointerIsStoredIn = (DWORD*)GetModuleHandleA("example.dll"); DWORD playerPtr = *(DWORD*)(playerpointer); }
I found this in MPGH and why using a cast to convert a value to a pointer in DWORD for a function?
so thanks for answering (and thanks for the answer before)
Last edited by Nik08154; 11-26-2013 at 07:15 AM.
edit: misread. removed.
Which line are you referring to?
(DWORD*)GetModuleHandleA("example.dll")
or
*(DWORD*)(playerpointer)
Last edited by abuckau907; 11-26-2013 at 10:10 AM.
'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
--
Handles returned from GetModuleHandle are not true handles. GetModuleHandle returns the image base of the loaded image.
Ah maybe I see what he means...
DWORD DllThePointerIsStoredIn = (DWORD*)GetModuleHandleA("example.dll");
DWORD == DWORD*
How can a DWORD be set equal to a DWORD Pointer ? (without using dereference operator) I'd expect it to throw some type of "invalid asignment" error, but I don't know C++ very well.
edit:tested, and got compiler errors : /
If you're wondering what the return value of GetModuleHandleA() is / what it could be converted to
@OP To answer your question, it's invalid code and won't compile. (?) Though I don't have much of an explanation for you, sry.
Last edited by abuckau907; 11-26-2013 at 05:07 PM.
'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
--
Ofc this won't work
and what is this meaning?
I mean what does this *(DWORD*) mean?Code:DWORD pWeaponMgr = *(DWORD*)(CShell + WeaponMgr);
abuckau907 (11-28-2013)
*(TYPE*) is a 2 step process. (and with Cshell + WeaponMgr; 3 steps)
In the example, DWORD pWeaponMgr = *(DWORD*) (an addr);
step 1. numeric add CShell + weaponMgr --> the result is simply a numeric : a memory address.
step 2. read an address from the location in step 1. If 32 bit cpu, read 4 bytes; if 64 bit, read 8 bytes.
--the value we read is ANOTHER MEMORY ADDRESS.
step 3. read a value from the addr we got in step 2
assuming CShell + WeaponMgr == some number, let's say 0x11223344
step 1. add CShell + weaponMgr == 0x11223344
step 2. (assuming 32 bit..as most current/old games were 32 bit) Read 4 bytes starting at 0x11223344
-Pretend those 4 bytes hold the value 0x22446688
step 3. Since we're going to store this in a DWORD, and dword size is 4 bytes, we read 4 bytes starting at 0x22446688
We dereferenced the pointer at 0x11223344 : ) The type inside *(TYPE*) dictates how many bytes are read from the final addr (22446688) in step 3.
big_struct myObj = *(big_struct*)0x11223344; would read a different number of bytes starting at 0x22446688.
Last edited by abuckau907; 11-28-2013 at 07:14 PM.
'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
--