Results 1 to 2 of 2
  1. #1
    Retoxified's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Posts
    148
    Reputation
    8
    Thanks
    171

    [AssaultCube]Get player entities

    AC Sourcecode tells us:
    Code:
    playerent *ge***ient(int cn)   // ensure valid entity
    {
        return players.inrange(cn) ? players[cn] : NULL;
    }
    
    void ini***ient()
    {
        clientmap[0] = 0;
        newname("unarmed");
        changeteam(rnd(2), false);
    }
    We wan't ge***ient, but that has nothing easy to search for...
    Lets take ini***ient, which has "unarmed"!

    Rough estimation of what we will encounter:
    1. the string "unarmed" will be somewhere near the top of the function
    2. near the bottom we should find something to do with teams.

    RVSF and CLA are the team names in AC, so we'll encounter one of those probably.

    First unarmed I encountered with olly contined stuff with 'your current name is', so, its not the one we want.
    But the second unarmed I find is a whole lot more interesting!
    It contains both unarmed and team related stuff

    Now if you scroll up a bit from there, you'll see this function:
    Code:
    004205C0  /$ 85C0           TEST EAX,EAX
    004205C2  |. 7C 12          JL SHORT ac_clien.004205D6
    004205C4  |. 3B05 983C4D00  CMP EAX,DWORD PTR DS:[4D3C98]
    004205CA  |. 7D 0A          JGE SHORT ac_clien.004205D6
    004205CC  |. 8B0D 903C4D00  MOV ECX,DWORD PTR DS:[4D3C90]
    004205D2  |. 8B0481         MOV EAX,DWORD PTR DS:[ECX+EAX*4]
    004205D5  |. C3             RETN
    004205D6  |> 33C0           XOR EAX,EAX
    004205D8  \. C3             RETN
    now compare that to this:
    Code:
    playerent *ge***ient(int cn)   // ensure valid entity
    {
        return players.inrange(cn) ? players[cn] : NULL;
    }
    Did we just find ourselves the function???
    YES!

    First off eax is tested against itself, and its followed JL(jump if lower), thts probably because there are no players for negative indexes.

    next off its compared to the value at DWORD pointer 0x4D3C98, and then tested with JGE(jump if greater/equal)
    Which is because there are no players after playercount-1, so if the index specified is equal to the playercount or bigger, we return 0.

    Now
    0x4D3C90 is moved into ECX, thats the base address for the player list.
    Now take a look at this:
    Code:
    MOV EAX,DWORD PTR DS:[ECX+EAX*4]
    What do you think that does?
    if you didnt think 'oh, they add the index we specified * 4 because a pointer is 4 bytes on my 32 bit OS to the base address we just saw', then you're either a retard or you suck at assembly.

    Anyway, its exactly what I just written above. They take the base pointer 0x4D3C90, add 4*index to it to get the pointer of the player we want.

    Now finally some C++ code:

    Code:
    int playercount = *(DWORD*)0x004D3C98;
    for(int i = 0; i < playercount-1; i++)
    {
        DWORD pTable = *(DWORD*)0x004D3C90;
        playerent *pPlayer = (playerent*)(pTable+(0x4*playercount));
        pPlayer->health = 0;
    }
    Feel free to add this to the AssaultCube tutorials posted by Hell_Demon(kinda weird to talk about yourself in third person o__O)

    edit: the *** is t-c-l, no idea why they block it...
    Last edited by Retoxified; 04-03-2010 at 02:51 PM.

  2. The Following User Says Thank You to Retoxified For This Useful Post:

    why06 (04-03-2010)

  3. #2
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    +1
    Excellent explanation of using source code to hack.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

Similar Threads

  1. [Release] Get Player XYZ
    By ppl2pass in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 8
    Last Post: 11-14-2010, 02:28 PM
  2. Getting players in team
    By Boon Pek in forum Call of Duty Modern Warfare 2 GSC Modding Help/Discussion
    Replies: 2
    Last Post: 10-21-2010, 06:15 PM
  3. [Help?] Get Player Position
    By DreadKyller in forum Combat Arms Coding Help & Discussion
    Replies: 22
    Last Post: 10-11-2010, 05:11 PM
  4. [AssaultCube]Get local player entity
    By Retoxified in forum C++/C Programming
    Replies: 1
    Last Post: 04-04-2010, 10:24 PM
  5. [AssaultCube]Getting TraceLine
    By Retoxified in forum C++/C Programming
    Replies: 2
    Last Post: 04-03-2010, 07:37 PM