const DWORD posBase = 0xCE997C;
void GetPlayerPosition(DWORD processID, int & finalX, int & finalY)
{
// Open the process
HANDLE hProcess = OpenProcess(PROCESS_VM_READ, false, processID);
// Registers
DWORD EAX = 0, EBX = 0, ECX = 0, EDX = 0, EBP = 0, EDI = 0, ESI = 0;
// MOV ECX,DWORD PTR DS:[CAD56C]
ReadProcessMemory(hProcess, UlongToPtr(posBase), &ECX, sizeof(DWORD), NULL);
// MOV AX,WORD PTR DS:[ECX+78]
ReadProcessMemory(hProcess, UlongToPtr(ECX + 0x78), &EAX, sizeof(WORD), NULL);
// MOVZX EBX,AX
EBX = EAX;
// MOV EDI,EBX
EDI = EBX;
// MOV EBP,EBX
EBP = EBX;
// MOV WORD PTR SS:[ESP+1C],AX
DWORD ESP_1C = 0;
ESP_1C = EAX;
// AND EDI,0FF
EDI &= 0xFF;
//MOV DWORD PTR DS:[ESI+424],EDI
//
//SHR EBP,8
EBP >>= 0x08;
//MOV DWORD PTR DS:[ESI+428],EBP
//
// MOV EAX,DWORD PTR DS:[CAD56C]
ReadProcessMemory(hProcess, UlongToPtr(posBase), &EAX, sizeof(DWORD), NULL);
// MOV EDX,DWORD PTR DS:[EAX+7C]
ReadProcessMemory(hProcess, UlongToPtr(EAX + 0x7C), &EDX, sizeof(DWORD), NULL);
//ADD EAX,7C
EAX += 0x7C;
// MOV DWORD PTR DS:[ESI+3E0],EDX
DWORD ESI_3E0 = 0;
ESI_3E0 = EDX;
// MOV ECX,DWORD PTR DS:[EAX+4]
ReadProcessMemory(hProcess, UlongToPtr(EAX + 0x04), &ECX, sizeof(DWORD), NULL);
// MOV DWORD PTR DS:[ESI+3E4],ECX
DWORD ESI_3E4 = 0;
ESI_3E4 = ECX;
// MOV EDX,DWORD PTR DS:[EAX+8]
ReadProcessMemory(hProcess, UlongToPtr(EAX + 0x08), &EDX, sizeof(DWORD), NULL);
// MOV DWORD PTR DS:[ESI+3E8],EDX
DWORD ESI_3E8 = 0;
ESI_3E8 = EDX;
// MOV EAX,DWORD PTR DS:[CAD56C]
ReadProcessMemory(hProcess, UlongToPtr(posBase), &EAX, sizeof(DWORD), NULL);
float fTmp1 = 0;
ReadProcessMemory(hProcess, UlongToPtr(EAX + 0x88), &fTmp1, sizeof(float), NULL);
// FSTP DWORD PTR SS:[ESP+14]
//
// FLD DWORD PTR SS:[ESP+14]
//
// FSUB QWORD PTR DS:[C09668]
double fTmp2 = 1.570796370506287;
//ReadProcessMemory(hProcess, UlongToPtr(0xC09668), &fTmp2, sizeof(double), NULL);
// FSTP DWORD PTR DS:[ESI+3EC]
DWORD ESI_3EC = 0;
float fTmp3 = 0;
fTmp3 = fTmp1 - fTmp2;
memcpy(&ESI_3EC, &fTmp3, sizeof(float));
// MOV ECX,DWORD PTR DS:[CAD56C]
ReadProcessMemory(hProcess, UlongToPtr(posBase), &ECX, sizeof(DWORD), NULL);
//----
// CALL sro_clie.00830700
//
EAX = 0; // check this function ^
// FLD DWORD PTR DS:[ESI+3E0]
float fTmp4 = 0;
memcpy(&fTmp4, &ESI_3E0, sizeof(float));
// MOV DWORD PTR SS:[ESP+20],EAX
DWORD ESP_20 = EAX;
// MOV AX,WORD PTR SS:[ESP+1C]
EAX = ESP_1C;
// SHR AX,0F
EAX >>= 0x0F;
// MOV WORD PTR SS:[ESP+2A],AX
DWORD ESP_2A = EAX;
//----
// FDIV QWORD PTR DS:[B9CA10]
fTmp4 /= (double)-10.0;
// CALL sro_clie.0098E260 (float to int)
EAX = (int)fTmp4;
// LEA ECX,DWORD PTR DS:[EDI+EDI*2-195]
ECX = EDI + EDI * 2 - 0x195;
//SHL ECX,6
ECX <<= 0x06;
//SUB ECX,EAX
ECX -= EAX;
// Store the final X position
finalX = ECX;
//----
// FLD DWORD PTR DS:[ESI+3E8]
memcpy(&fTmp4, &ESI_3E8, sizeof(float));
// FDIV QWORD PTR DS:[B9CA10]
fTmp4 /= (double)-10.0;
// CALL sro_clie.0098E260
EAX = (int)fTmp4;
// LEA ECX,DWORD PTR SS:[EBP+EBP*2-114]
ECX = EBP + EBP * 2 - 0x114;
// SHL ECX,6
ECX <<= 0x06;
// SUB ECX,EAX
ECX -= EAX;
// Store the final Y position
finalY = ECX;
}