Crap, doesnt work for the new 1.0.2 patch.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
void BuildPatchedScript(HWND hDlg)
{
DWORD team_data[16];
char line[0x100];
for (int i=0; i<MaxSlot; i++)
team_data[i] = SendDlgItemMessage(hDlg, CB_TEAM_IDS[i], CB_GETCURSEL, 0, 0);
PatchedScript[0] = 0;
for (int i=0; i<MaxSlot; i++) { // player1 loopfor (int j=0; j<MaxSlot; j++) { // player2 loop if (i != j && team_data[i] == team_data[j]) {
// 0 - c_allianceIdPassive, 1 - c_allianceIdVision wsprintfA(line,
"\t\tPlayerGetAlliance(%d,0,%d);PlayerGetAlliance(%d,0,%d);PlayerGetAlliance(%d,1,%d);PlayerGetAlliance(%d,1,%d);\n",
i+1, j+1, j+1, i+1, i+1, j+1, j+1, i+1);
strcat(PatchedScript, line);
}
}
}
}
for (int i=0; i<MaxSlot; i++) {
EnableWindow(GetDlgItem(hDlg, CB_CTRL_IDS[i]), TRUE);
EnableWindow(GetDlgItem(hDlg, CB_RACE_IDS[i]), TRUE);
SendDlgItemMessage(hDlg, CB_CTRL_IDS[i], CB_SETCURSEL, i == 0 ? 1 : 2, 0);
// Team SlotsSendDlgItemMessage(hDlg, CB_TEAM_IDS[i], CB_RESETCONTENT, 0, 0);
for (int j=0; j<MaxSlot; j++) {
TCHAR teamstr[0x20];
wsprintf(teamstr, _T("Team %d"), j+1);
SendDlgItemMessage(hDlg, CB_TEAM_IDS[i], CB_ADDSTRING, 0, (LPARAM)teamstr);
}
SendDlgItemMessage(hDlg, CB_TEAM_IDS[i], CB_SETCURSEL, i, 0);
EnableWindow(GetDlgItem(hDlg, CB_TEAM_IDS[i]), TRUE);
}
for (int i=MaxSlot; i<6; i++) {
EnableWindow(GetDlgItem(hDlg, CB_CTRL_IDS[i]), FALSE);
EnableWindow(GetDlgItem(hDlg, CB_RACE_IDS[i]), FALSE);
EnableWindow(GetDlgItem(hDlg, CB_TEAM_IDS[i]), FALSE);
}
BYTE PlayerSetAllianceCode[] = {
0x55, 0x8B, 0xEC, 0x56, 0x8B, 0xC1, 0xC1, 0xE2, 0x04, 0x03, 0xD0, 0xBE, 0x01, 0x00, 0x00, 0x00,
0x8A, 0x4D, 0x08, 0xD3, 0xE6, 0x8B, 0x04, 0x95, 0xA0, 0xE8, 0xA9, 0x01, 0x0B, 0xC6, 0x89, 0x04,
0x95, 0xA0, 0xE8, 0xA9, 0x01, 0x5E, 0x5D, 0xC2, 0x04, 0x00};
// alloc memory for my "PlayerSetAlliance" code.LPVOID pCode = VirtualAllocEx(pi.hProcess, (LPVOID)0x60000000, 4096, MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE);
// find "PlayerGetAlliance" wrapper function address in memory.DWORD d = 0;
LPVOID pPGA_Addr = ProcessScanCode((LPBYTE)0x800000, Pattern1, sizeof(Pattern1), pi.hProcess, d, -1);
if (pPGA_Addr == NULL) {
UnmapViewOfFile(pData);
CloseHandle(pData);
ErrorExit(_T("Can not find patch address!"));
}
// find the address of the struct that holds the alliance data.LPVOID pAddr = ProcessScanCode((LPBYTE)0x800000, Pattern2, sizeof(Pattern2), pi.hProcess, d, sizeof(Pattern2) + 3);
if (pAddr == NULL) {
UnmapViewOfFile(pData);
CloseHandle(pData);
ErrorExit(_T("Can not find patch address!"));
}
// and fill in my "PlayerSetAlliance" code.*(DWORD *)(PlayerSetAllianceCode + 24) = d;
*(DWORD *)(PlayerSetAllianceCode + 33) = d;
WriteProcessMemory(pi.hProcess, pCode, PlayerSetAllianceCode, sizeof(PlayerSetAllianceCode), NULL);
// patch code to make the "PlayerGetAlliance" = "PlayerSetAlliance"BYTE call_code[5] = {0xe8, 0, 0, 0, 0};
DWORD patch_addr = ((DWORD)pPGA_Addr + sizeof(Pattern1) + 6);
*(DWORD*)(call_code+1) = (DWORD)pCode - patch_addr - 5;
WriteProcessMemory(pi.hProcess, (LPVOID)patch_addr, call_code, 5, NULL);
ResumeThread(pi.hThread);