Results 1 to 10 of 10
  1. #1
    Nik08154's Avatar
    Join Date
    Nov 2013
    Gender
    male
    Posts
    15
    Reputation
    10
    Thanks
    3

    DWORD combined with a pointer + using this in a function

    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.

  2. #2
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    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.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  3. #3
    Nik08154's Avatar
    Join Date
    Nov 2013
    Gender
    male
    Posts
    15
    Reputation
    10
    Thanks
    3
    Quote Originally Posted by abuckau907 View Post
    edit: misread. removed.

    Which line are you referring to?
    (DWORD*)GetModuleHandleA("example.dll")
    or
    *(DWORD*)(playerpointer)

    (DWORD*)GetModuleHandleA("example.dll")

  4. #4
    Fovea's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Posts
    325
    Reputation
    101
    Thanks
    411
    My Mood
    Amused
    Handles returned from GetModuleHandle are not true handles. GetModuleHandle returns the image base of the loaded image.

  5. #5
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    Quote Originally Posted by Fovea View Post
    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.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  6. #6
    Biesi's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    4,993
    Reputation
    374
    Thanks
    8,808
    My Mood
    Twisted
    Ofc this won't work


  7. #7
    Nik08154's Avatar
    Join Date
    Nov 2013
    Gender
    male
    Posts
    15
    Reputation
    10
    Thanks
    3
    and what is this meaning?

    Code:
    DWORD pWeaponMgr = *(DWORD*)(CShell + WeaponMgr);
    I mean what does this *(DWORD*) mean?

  8. #8
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Quote Originally Posted by Nik08154 View Post
    and what is this meaning?

    Code:
    DWORD pWeaponMgr = *(DWORD*)(CShell + WeaponMgr);
    I mean what does this *(DWORD*) mean?
    Dereference a pointer, you get the value of what CShell+WeaponMgr points to
    Ah we-a blaze the fyah, make it bun dem!

  9. The Following User Says Thank You to Hell_Demon For This Useful Post:

    abuckau907 (11-28-2013)

  10. #9
    Akar's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Location
    İstanbul
    Posts
    40
    Reputation
    10
    Thanks
    0
    My Mood
    Cool
    Quote Originally Posted by Nik08154 View Post
    and what is this meaning?

    Code:
    DWORD pWeaponMgr = *(DWORD*)(CShell + WeaponMgr);
    I mean what does this *(DWORD*) mean?
    DWORD = Read 4 Bytes // use for pointer,example = 0x11223344
    WORD = Read 2 Bytes // use for offset, expamle = 0x1122

    these two values ​​is use to read information from memory
    Last edited by Akar; 11-28-2013 at 06:12 PM.

  11. #10
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    Quote Originally Posted by Nik08154 View Post
    and what is this meaning?

    Code:
    DWORD pWeaponMgr = *(DWORD*)(CShell + WeaponMgr);
    I mean what does this *(DWORD*) mean?
    *(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.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

Similar Threads

  1. [Solved] if someone is using crossfire wall hack with chams pleases click this
    By stanley00003 in forum CrossFire Help
    Replies: 2
    Last Post: 11-06-2012, 01:23 PM
  2. How to Use VB.net and Combine with Combat Arms
    By User1 in forum Combat Arms Discussions
    Replies: 56
    Last Post: 09-24-2009, 09:17 PM
  3. Use this
    By gurl4u in forum WarRock - International Hacks
    Replies: 10
    Last Post: 02-22-2007, 07:17 PM
  4. i need some help dealing with warrock pointers
    By shakib in forum Hack Requests
    Replies: 1
    Last Post: 02-11-2007, 12:37 PM