Before assigning values to the player (alive, life, lifemax etc.), we rightly need to first find it to do so, let's go through a code example in C and ASM to see how it is done:
- Assembly
BITS 32
;The standards for these codes are those of the NASM assembler
;Code by S_Sak
mov eax,[0x4B5B4C] ;0x4B5B4C is pGaveVar,Get the value pointed to by the pointer
startEnum:
xor ecx,ecx
enumPlayerLoop:
inc ecx ;If we are entering the loop for the first time, the initial ecx value is 1
mov ebx,[eax+0xB750+ecx*4] ;0xB750 is an C-style array,just like DWORD player[64]
;Please pay attention,index 0 and 61 to 63 is always empty
cmp ecx,4 ;this will only enumerate the real players
ja endEnum
cmp ebx,0x4B4000 ;Is this an valid address?
jb enumPlayerLoop
;Now ebx is the base address of a Player
jmp startEnum ;After a loop, we will continue check till we don't use this anymore
endEnum:
;otherCode
- C Language
//Code by S_Sak
#include <windows.h>
//Note:The C language style of these codes is MSVC
//Codes by S_Sak
void WINAPI enumPlayer()
{
UINT pGameVar = *(PUINT)0x4B5B4C;
for (int i = 0; i < 4; i++)
{
UINT player = 0;
player = *(PUINT)(pGameVar + i * 4);
if (player < 0x4B4000)
{
continue;
}
/*
TODO:Do any access you want to this player.
*/
*(PUINT)(player + 0xE24) = 1;//Example: keep alive
}
}