main.cpp :
Code:
#include <windows.h> //#include <WinBase.h> #include <cstdio> #include <tlhelp32.h> #include <stdio.h> #include <string.h> #include <psapi.h> #include <time.h> #define PREMUTO -32767 #define N_Cheats 8 // If change /* --------------------------------------------------------------------------------- */ int _WinAPI_PlaySound(void* Bsound, DWORD flag){ HINSTANCE hDll = LoadLibrary("winmm.dll"); FARPROC PID = GetProcAddress(HMODULE (hDll),"PlaySoundW"); typedef int (__stdcall * pICFUNC)(void *, void *, DWORD); pICFUNC PlaySound; PlaySound = pICFUNC(PID); int Val = PlaySound(Bsound, GetModuleHandle(NULL), flag); FreeLibrary(hDll); return Val; } int Call_DLL_EmptyWorkingSet_Function(void) { HINSTANCE hGetProcIDDLL = LoadLibrary("psapi.dll"); FARPROC lpfnGetProcessID = GetProcAddress(HMODULE (hGetProcIDDLL),"EmptyWorkingSet"); typedef int (__stdcall * pICFUNC)(long); pICFUNC MyFunction; MyFunction = pICFUNC(lpfnGetProcessID); int intMyReturnVal = MyFunction(-1); FreeLibrary(hGetProcIDDLL); return intMyReturnVal; } /* --------------------------------------------------------------------------------- */ void MsgBox(char *t,char *m,int n) { MessageBox(0, m, t, n); } /* --------------------------------------------------------------------------------- */ typedef struct Cheat { char NameCheat[200]; char CodeCave[1024]; char Modulename[100]; char Andress[1024]; char Value[100]; int Noffset; char Offset[101][50]; char Onop[101][3]; char Snop[101][3]; int AoBscanner; int AoBscanner_Adrss; int BaseAndress; int Freeze; int Gamecode; int CheatActive; } t_Cheat; /* --------------------------------------------------------------------------------- */ DWORD GetModuleBase_or_Size(DWORD dwProcessId, char * ModuleName, int X); DWORD AoBscanner(HANDLE hProcess, int BaseAndress, Cheat * ZD, int P); void drawButton(DRAWITEMSTRUCT *dis, HWND hwnd); void CenterWindow(HWND hwndChild); void Game_Box_Update(HWND hwnd, HWND hwndChild, Cheat * ZD, int i); void Inizialized_Struct(Cheat * ZD); BOOL GemeIsRun(char * Wind_or_exe_file); void WriteMemory_Pointer_ON_OFF(Cheat * ZD, int i); void GameCode_ON_OFF(Cheat * ZD, int i, int SET); // set ON/OFF Cheat ! void Work_Cheats_Engine(HWND hwnd, Cheat * ZD,char * Wind_or_exe_file); void Set_State_Cheat(Cheat * ZD, int i, int k); void CodeCave(Cheat * ZD, int i, int SET); /* Declare Windows procedure */ LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); /* --------------------------------------------------------------------------------- */ t_Cheat ZC[N_Cheats]; char Wind_or_exe_file[]="Plants vs. Zombies"; // If change UINT TimmerID = 0; bool Auto_Trainer_Closed = false; DWORD MEM_ALLOC_END[10]; DWORD My_Process_ID; /* --------------------------------------------------------------------------------- */ /* Make the class name into a global variable */ char szClassName[] = "Trainer_By_ZeroClock"; // non change HWND hwndstatic[5], hwndBut[2]; int F11_cheatactive = 0, Trainer_Is_off = 0; /* --------------------------------------------------------------------------------- */ int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { Inizialized_Struct(ZC); HWND hwnd; /* This is the handle for our window */ MSG messages; /* Here messages to the application are saved */ ZeroMemory(&messages,sizeof(MSG)); WNDCLASSEX wincl; /* Data structure for the windowclass */ ZeroMemory(&wincl,sizeof(WNDCLASSEX)); /* The Window structure */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX); /* Use default icon and mouse-pointer */ wincl.hIcon = LoadIcon(NULL, 0); wincl.hIconSm = LoadIcon(NULL, 0); wincl.hCursor = LoadCursor(NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use Windows's default color as the background of the window */ wincl.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); /* Register the window class, and if it fails quit the program */ if (!RegisterClassEx (&wincl)) return 0; /* The class is registered, let's create the program*/ hwnd = CreateWindowEx(WS_EX_TOPMOST | WS_EX_APPWINDOW, /* Extended possibilites for variation */ szClassName, /* Classname */ "", /* Title Text */ WS_SYSMENU|WS_MINIMIZEBOX, //WS_EX_WINDOWEDGE, /* default window */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */ 350, /* The programs width */ 310, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); /* Make the window visible on the screen */ ShowWindow(hwnd, nFunsterStil); CenterWindow(hwnd); //SetWindowLong(hwnd, GWL_EXSTYLE,GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_WINDOWEDGE); //EnableWindow(hwnd,false); /* Run the message loop. It will run until GetMessage() returns 0 */ while (GetMessage (&messages, NULL, 0, 0)) { /* Translate virtual-key messages into character messages */ TranslateMessage(&messages); /* Send message to WindowProcedure */ DispatchMessage(&messages); } /* The program return-value is 0 - The value that PostQuitMessage() gave */ return messages.wParam; } /* This function is called by the Windows function DispatchMessage() */ LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) /* handle the messages */ { case WM_CREATE: hwndstatic[0] = CreateWindow("static","", WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_NOHIDESEL|ES_LEFT, 5, 5, 335, 210, hwnd, (HMENU)(501), (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); hwndstatic[3] = CreateWindow("static","\n\nThis program was created with :\n\n" // If Canged "\n Author: By ZeroClock \n", WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_NOHIDESEL|ES_CENTER, 5, 5, 335, 210, hwnd, (HMENU)(504), (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); ShowWindow(hwndstatic[3], SW_HIDE); hwndstatic[4] = CreateWindow("static","\n\n< Cheats Created By >\n\n" // If Canged "Autor: ???? \n\n" "Email: ???? \n\n" "Trainer Version: ?.?.?.?", WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_NOHIDESEL|ES_CENTER, 5, 5, 335, 210, hwnd, (HMENU)(505), (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); ShowWindow(hwndstatic[4], SW_HIDE); Game_Box_Update(hwnd, hwndstatic[0], ZC, N_Cheats); hwndstatic[1] = CreateWindow("static","Game Is Not Running !", WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_NOHIDESEL|ES_CENTER, 5, 225, 332, 20, hwnd, (HMENU)(502), (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); hwndstatic[2] = CreateWindow("static","Game Is Running !", WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_NOHIDESEL|ES_CENTER, 5, 225, 332, 20, hwnd, (HMENU)(503), (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); ShowWindow(hwndstatic[2], SW_HIDE); hwndBut[0] = CreateWindow("Button","About !", WS_CHILD|WS_VISIBLE|BN_PAINT|BS_OWNERDRAW|WS_BORDER|BS_PUSHBUTTON|BS_FLAT|BS_TEXT, 5, 250, 165, 25,hwnd, (HMENU) 101, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); hwndBut[1] = CreateWindow("Button","Info !", WS_CHILD|WS_VISIBLE|BN_PAINT|BS_OWNERDRAW|WS_BORDER|BS_PUSHBUTTON|BS_FLAT|BS_TEXT, 172, 250, 165, 25,hwnd, (HMENU) 102, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL); TimmerID = SetTimer(hwnd, 210, 1 *10 , NULL); break; case WM_TIMER: Work_Cheats_Engine(hwnd, ZC, Wind_or_exe_file); break; case WM_DRAWITEM: { DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT*)lParam; switch(dis->CtlID) { case 101: drawButton(dis, hwndBut[0]); break; case 102: drawButton(dis, hwndBut[1]); break; } return TRUE; } break; case WM_COMMAND: switch(LOWORD(wParam)) { case 101: if(ShowWindow(hwndstatic[3], SW_SHOW) == 0) { ShowWindow(hwndstatic[0], SW_HIDE); ShowWindow(hwndstatic[4], SW_HIDE); SetWindowText(hwndBut[0],"<-- Return"); EnableWindow(hwndBut[1],FALSE); } else { EnableWindow(hwndBut[1],TRUE); SetWindowText(hwndBut[0],"About !"); ShowWindow(hwndstatic[0], SW_SHOW); ShowWindow(hwndstatic[3], SW_HIDE); ShowWindow(hwndstatic[4], SW_HIDE); } break; case 102: if(ShowWindow(hwndstatic[4], SW_SHOW) == 0) { ShowWindow(hwndstatic[0], SW_HIDE); ShowWindow(hwndstatic[3], SW_HIDE); SetWindowText(hwndBut[1],"<-- Return"); EnableWindow(hwndBut[0],FALSE); } else { EnableWindow(hwndBut[0],TRUE); SetWindowText(hwndBut[1],"Info !"); ShowWindow(hwndstatic[0], SW_SHOW); ShowWindow(hwndstatic[3], SW_HIDE); ShowWindow(hwndstatic[4], SW_HIDE); } break; } break; case WM_CTLCOLORSTATIC: for(int i=0; i<5; i++) { if((HWND)lParam == hwndstatic[i]) { SetBkColor((HDC)wParam,(LPARAM) RGB(0,0,0)); SetTextColor((HDC)wParam,(LPARAM) RGB(0,255,255)); // Celeste Text Color return (LRESULT)GetStockObject(BLACK_BRUSH); } if(i==0) { i=2; } } if((HWND)lParam == hwndstatic[1]) { SetBkColor((HDC)wParam,(LPARAM) RGB(0,0,0)); SetTextColor((HDC)wParam,(LPARAM) RGB(255,0,0)); // Red Text Color return (LRESULT)GetStockObject(BLACK_BRUSH); } if((HWND)lParam == hwndstatic[2]) { SetBkColor((HDC)wParam,(LPARAM) RGB(0,0,0)); SetTextColor((HDC)wParam,(LPARAM) RGB(0,255,0)); // Green Text Color return (LRESULT)GetStockObject(BLACK_BRUSH); } break; case WM_DESTROY: PostQuitMessage (0); /* send a WM_QUIT to the message queue */ break; default: /* for messages that we don't deal with */ return DefWindowProc(hwnd, message, wParam, lParam); } return 0; } /* --------------------------------------------------------------------------------- */ void drawButton(DRAWITEMSTRUCT *dis, HWND hwnd) { RECT rc; GetClientRect(hwnd, &rc); SetBkMode(dis->hDC, TRANSPARENT); FillRect(dis->hDC, &rc, (HBRUSH) GetStockObject(BLACK_BRUSH)); char buf[255]; GetWindowText(hwnd, buf, 255); SetTextColor(dis->hDC, RGB(0,255,255)); DrawText(dis->hDC, buf, strlen(buf), &rc, DT_CENTER|DT_VCENTER|DT_SINGLELINE); } /* --------------------------------------------------------------------------------- */ void CenterWindow(HWND hwndChild) { RECT rChild, rWorkArea; int wChild, hChild; int xNew, yNew; BOOL bResult; // Get the Height and Width of the child window GetWindowRect (hwndChild, &rChild); wChild = rChild.right - rChild.left; hChild = rChild.bottom - rChild.top; // Get the limits of the 'workarea' bResult = SystemParametersInfo( SPI_GETWORKAREA, // system parameter to query or set sizeof(RECT), &rWorkArea, 0); if (!bResult) { rWorkArea.left = rWorkArea.top = 0; rWorkArea.right = GetSystemMetrics(SM_CXSCREEN); rWorkArea.bottom = GetSystemMetrics(SM_CYSCREEN); } // Calculate new X position, then adjust for workarea xNew = (rWorkArea.right /2) - wChild/2; // Calculate new Y position, then adjust for workarea yNew = (rWorkArea.bottom/2) - hChild/2; // Set it, and return SetWindowPos(hwndChild, NULL, xNew, yNew, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } /* --------------------------------------------------------------------------------- */ void Game_Box_Update(HWND hwnds, HWND hwndChild, Cheat * ZD, int i) { char XX[2048] = ""; char str[10] = ""; strcat(XX,"Plants vs. Zombies - Trainer+"); // If Canged itoa(i, str, 10); strcat(XX,str); strcat(XX,"\n\n"); if(hwnds != (HWND) -1) { SetWindowText(hwnds,XX); } for(int j=0; j<i; j++) { itoa((j+1), str, 10); strcat(XX,"F"); strcat(XX,str); strcat(XX," = "); strcat(XX,ZD[j].NameCheat); strcat(XX," [ "); if(ZD[j].CheatActive == 0) { strcat(XX,"OFF"); } else { strcat(XX,"ON"); } strcat(XX," ]\n"); } // end F1 To F10 strcat(XX,"F11 = Set All Cheats - { ON / OFF }"); strcat(XX," - [ "); if(F11_cheatactive == 0) { strcat(XX,"OFF"); } else { strcat(XX,"ON"); } strcat(XX," ]\n"); SetWindowText(hwndChild,XX); } /* --------------------------------------------------------------------------------- */ void Inizialized_Struct(Cheat * ZD) { // If change // auto it used for(int i=0;i<10;i++){ //for(int i=0;i<10;i++){ strcpy(ZD[0].NameCheat,"Cards Unlocked"); strcpy(ZD[0].Modulename,""); // PlantsVsZombies.exe strcpy(ZD[0].Value,""); strcpy(ZD[0].Andress,"8B47243B"); // 91E4F ZD[0].Noffset = 3; strcpy(ZD[0].Offset[0],""); strcpy(ZD[0].Onop[0],"8B"); strcpy(ZD[0].Onop[1],"47"); strcpy(ZD[0].Onop[2],"24"); strcpy(ZD[0].Snop[0],""); ZD[0].AoBscanner_Adrss = 0; ZD[0].AoBscanner = 1; ZD[0].BaseAndress = 1; ZD[0].Freeze = 0; ZD[0].Gamecode = 1; ZD[0].CheatActive = 0; // False strcpy(ZD[1].NameCheat,"Freeze Sun To 9999"); strcpy(ZD[1].Modulename,"PlantsVsZombies.exe"); strcpy(ZD[1].Value,"9999"); //strcpy(ZD[1].Andress,"00329728"); strcpy(ZD[1].Andress,"1E846"); strcpy(ZD[1].CodeCave,"C7877855000006270000"); ZD[1].Noffset = 6; strcpy(ZD[1].Offset[0],""); strcpy(ZD[1].Onop[0],"89"); strcpy(ZD[1].Onop[1],"B7"); strcpy(ZD[1].Onop[2],"78"); strcpy(ZD[1].Onop[3],"55"); strcpy(ZD[1].Onop[4],"00"); strcpy(ZD[1].Onop[5],"00"); strcpy(ZD[1].Snop[0],""); ZD[0].AoBscanner_Adrss = 0; ZD[1].AoBscanner = 1; ZD[1].BaseAndress = 1; ZD[1].Freeze = 0; ZD[1].Gamecode = 1; ZD[1].CheatActive = 0; // False strcpy(ZD[2].NameCheat,"Not Decrease Money"); strcpy(ZD[2].Modulename,""); strcpy(ZD[2].Value,""); strcpy(ZD[2].Andress,"976AC"); ZD[2].Noffset = 1; strcpy(ZD[2].Offset[0],""); strcpy(ZD[2].Onop[0],"50"); strcpy(ZD[2].Snop[0],""); ZD[2].BaseAndress = 1; ZD[2].Freeze = 0; ZD[2].Gamecode = 1; ZD[2].CheatActive = 0; // False strcpy(ZD[3].NameCheat,"Not Decrease Fertilizer tree of wisdom"); strcpy(ZD[3].Modulename,""); strcpy(ZD[3].Value,""); strcpy(ZD[3].Andress,"3018D"); ZD[3].Noffset = 6; strcpy(ZD[3].Offset[0],""); strcpy(ZD[3].Onop[0],"FF"); strcpy(ZD[3].Onop[1],"88"); strcpy(ZD[3].Onop[2],"58"); strcpy(ZD[3].Onop[3],"02"); strcpy(ZD[3].Onop[4],"00"); strcpy(ZD[3].Onop[5],"00"); strcpy(ZD[3].Snop[0],""); ZD[3].BaseAndress = 1; ZD[3].Freeze = 0; ZD[3].Gamecode = 1; ZD[3].CheatActive = 0; // False strcpy(ZD[4].NameCheat,"Not Decrease Chocolate"); strcpy(ZD[4].Modulename,"PlantsVsZombies.exe"); strcpy(ZD[4].Value,""); strcpy(ZD[4].Andress,"1295C7"); ZD[4].Noffset = 6; strcpy(ZD[4].Offset[0],""); strcpy(ZD[4].Onop[0],"FF"); strcpy(ZD[4].Onop[1],"88"); strcpy(ZD[4].Onop[2],"50"); strcpy(ZD[4].Onop[3],"02"); strcpy(ZD[4].Onop[4],"00"); strcpy(ZD[4].Onop[5],"00"); strcpy(ZD[4].Snop[0],""); ZD[4].BaseAndress = 1; ZD[4].Freeze = 0; ZD[4].Gamecode = 1; ZD[4].CheatActive = 0; // False strcpy(ZD[5].NameCheat,"Not Decrease Fertilizer"); strcpy(ZD[5].Modulename,""); strcpy(ZD[5].Value,""); strcpy(ZD[5].Andress,"12992B"); ZD[5].Noffset = 6; strcpy(ZD[5].Offset[0],""); strcpy(ZD[5].Onop[0],"FF"); strcpy(ZD[5].Onop[1],"88"); strcpy(ZD[5].Onop[2],"20"); strcpy(ZD[5].Onop[3],"02"); strcpy(ZD[5].Onop[4],"00"); strcpy(ZD[5].Onop[5],"00"); strcpy(ZD[5].Snop[0],""); ZD[5].BaseAndress = 1; ZD[5].Freeze = 0; ZD[5].Gamecode = 1; ZD[5].CheatActive = 0; // False strcpy(ZD[6].NameCheat,"Not Decrease Spray"); strcpy(ZD[6].Modulename,""); strcpy(ZD[6].Value,""); strcpy(ZD[6].Andress,"129A23"); ZD[6].Noffset = 6; strcpy(ZD[6].Offset[0],""); strcpy(ZD[6].Onop[0],"FF"); strcpy(ZD[6].Onop[1],"88"); strcpy(ZD[6].Onop[2],"24"); strcpy(ZD[6].Onop[3],"02"); strcpy(ZD[6].Onop[4],"00"); strcpy(ZD[6].Onop[5],"00"); strcpy(ZD[6].Snop[0],""); ZD[6].BaseAndress = 1; ZD[6].Freeze = 0; ZD[6].Gamecode = 1; ZD[6].CheatActive = 0; // False strcpy(ZD[7].NameCheat,"Not Plant's Damage !"); strcpy(ZD[7].Modulename,""); strcpy(ZD[7].Value,""); strcpy(ZD[7].Andress,"140680"); ZD[7].Noffset = 4; strcpy(ZD[7].Offset[0],""); strcpy(ZD[7].Onop[0],"83"); strcpy(ZD[7].Onop[1],"46"); strcpy(ZD[7].Onop[2],"40"); strcpy(ZD[7].Onop[3],"FC"); strcpy(ZD[7].Snop[0],""); ZD[7].BaseAndress = 1; ZD[7].Freeze = 0; ZD[7].Gamecode = 1; ZD[7].CheatActive = 0; // False //} if(true == true) { UINT X_X = WinExec("PlantsVsZombies.exe", SW_SHOW); // Game AutoRun if(X_X == 0) { MsgBox("Error...","The system is out of memory or resources.",16+4096); } if(X_X == ERROR_FILE_NOT_FOUND) { MsgBox("Error...","The specified FILE was not found.\n\nFILE: PlantsVsZombies.exe",16+4096); } else { Auto_Trainer_Closed = true; // End If change } } } /* --------------------------------------------------------------------------------- */ void Work_Cheats_Engine(HWND hwnd, Cheat * ZD,char * Wind_or_exe_file) { Call_DLL_EmptyWorkingSet_Function(); if(GemeIsRun(Wind_or_exe_file) == true) { if(Trainer_Is_off == 0) { ShowWindow(hwndstatic[1], SW_HIDE); // Game Is Not Running ! ShowWindow(hwndstatic[2], SW_SHOW); // Game Is Running ! Trainer_Is_off = 1; } // auto code press key ... for(int i=0; i<N_Cheats; i++) { if((ZD[i].CheatActive != 0)&&(ZD[i].Gamecode == 0)&&(ZD[i].Freeze != 0)) { WriteMemory_Pointer_ON_OFF(ZD, i); // On Freeze } } //Logga i tasti F1 a F11 if(GetAsyncKeyState(VK_F1)==PREMUTO) { Set_State_Cheat(ZD,0,-1); } if(GetAsyncKeyState(VK_F2)==PREMUTO) { Set_State_Cheat(ZD,1,-1); } if(GetAsyncKeyState(VK_F3)==PREMUTO) { Set_State_Cheat(ZD,2,-1); } if(GetAsyncKeyState(VK_F4)==PREMUTO) { Set_State_Cheat(ZD,3,-1); } if(GetAsyncKeyState(VK_F5)==PREMUTO) { Set_State_Cheat(ZD,4,-1); } if(GetAsyncKeyState(VK_F6)==PREMUTO) { Set_State_Cheat(ZD,5,-1); } if(GetAsyncKeyState(VK_F7)==PREMUTO) { Set_State_Cheat(ZD,6,-1); } if(GetAsyncKeyState(VK_F8)==PREMUTO) { Set_State_Cheat(ZD,7,-1); } if(GetAsyncKeyState(VK_F9)==PREMUTO) { Set_State_Cheat(ZD,8,-1); } if(GetAsyncKeyState(VK_F10)==PREMUTO) { Set_State_Cheat(ZD,9,-1); } if(GetAsyncKeyState(VK_F11)==PREMUTO) { if(F11_cheatactive == 0) { F11_cheatactive = 1; } else { F11_cheatactive = 0; } for(int i=0; i<N_Cheats; i++) { Set_State_Cheat(ZD,i,F11_cheatactive); } } } else { if(Trainer_Is_off == 1) { for(int i=0; i<N_Cheats; i++) { F11_cheatactive = 0; Set_State_Cheat(ZD,i,F11_cheatactive); } Trainer_Is_off = 0; ShowWindow(hwndstatic[2], SW_HIDE); // Game Is Running ! ShowWindow(hwndstatic[1], SW_SHOW); // Game Is Not Running ! if(Auto_Trainer_Closed == true) { SendMessage(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0); // if canged } } } } /* --------------------------------------------------------------------------------- */ void Set_State_Cheat(Cheat * ZD, int i, int k) { if(k == 1) { ZD[i].CheatActive = 0; _WinAPI_PlaySound(MAKEINTRESOURCE(300), 0x00040005); } if(k == 0) { ZD[i].CheatActive = 1; } if(ZD[i].CheatActive == 0) { ZD[i].CheatActive = 1; if(ZD[i].Gamecode != 0) { GameCode_ON_OFF(ZD, i, 0); // On } else { WriteMemory_Pointer_ON_OFF(ZD, i); // On } } else { ZD[i].CheatActive = 0; if(ZD[i].Gamecode != 0) { GameCode_ON_OFF(ZD, i, 1); // Off } } Game_Box_Update((HWND) -1, hwndstatic[0], ZC, N_Cheats); } /* --------------------------------------------------------------------------------- */ /* void wait(int seconds){ Sleep(seconds * 10); }*/ /* Returns a pointer to a PROCESSENTRY32 structure given the process name */ PROCESSENTRY32 *GetProcessInfo(char *szExeFile) { PROCESSENTRY32 *pe32 = new PROCESSENTRY32 [sizeof(PROCESSENTRY32)]; HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if(hSnapshot == INVALID_HANDLE_VALUE) CloseHandle(hSnapshot); delete [] pe32; pe32 = NULL; if(!Process32First(hSnapshot, pe32)) { CloseHandle(hSnapshot); delete [] pe32; pe32 = NULL; printf("2"); return NULL; } while(Process32Next(hSnapshot, pe32)) { if(strcmp(szExeFile, pe32->szExeFile) == 0) { CloseHandle(hSnapshot); printf("3"); return pe32; } } delete [] pe32; pe32 = NULL; printf("4"); return NULL; } DWORD GetModuleBase_or_Size(DWORD dwProcessId, char * ModuleName, int X){ MODULEENTRY32 lpModuleEntry; // ={0} HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessId); // TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32 if(!hSnapShot) { CloseHandle(hSnapShot); return 0; } lpModuleEntry.dwSize = sizeof(MODULEENTRY32); BOOL bModule = Module32First(hSnapShot, &lpModuleEntry); while(bModule) { if(lpModuleEntry.th32ProcessID == dwProcessId) { if(stricmp(ModuleName,"") != 0) { if(stricmp(lpModuleEntry.szModule,ModuleName) == 0) { CloseHandle(hSnapShot); if(X == 0){ return (DWORD)lpModuleEntry.modBaseAddr; }else{ return (DWORD)lpModuleEntry.modBaseSize; } } } if(stricmp(ModuleName,"") == 0) { CloseHandle(hSnapShot); if(X == 0){ return (DWORD)lpModuleEntry.modBaseAddr; }else{ return (DWORD)lpModuleEntry.modBaseSize; } } } bModule = Module32Next(hSnapShot, &lpModuleEntry); } CloseHandle(hSnapShot); return 0; } HANDLE xopenx(char *tit, int * BaseAndress, char * ModuleNames) { HWND hwnd = 0; DWORD proc_id = 0; hwnd = FindWindow(0, tit); if(hwnd) { GetWindowThreadProcessId(hwnd, &proc_id); } else { PROCESSENTRY32 *PE32 = GetProcessInfo(tit); if(PE32 != NULL) { proc_id = PE32->th32ProcessID; } } if(!proc_id) { return NULL; } HANDLE hProcess; hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proc_id); if(!hProcess) { CloseHandle(hProcess); return NULL; } else { *BaseAndress = GetModuleBase_or_Size(proc_id, ModuleNames, 0); // Return BaseAndress From ID Process Or Modules My_Process_ID = proc_id; return hProcess; } } BOOL GemeIsRun(char * Wind_or_exe_file) { int BaseAndress = 0; HANDLE hProcess = xopenx(Wind_or_exe_file,&BaseAndress,""); if(!hProcess) { CloseHandle(hProcess); return FALSE; } else { CloseHandle(hProcess); return TRUE; } } void WriteMemory_Pointer_ON_OFF(Cheat * ZD, int i) { char msg[200]; int BaseAndress,Andress; HANDLE hProcess = xopenx(Wind_or_exe_file,&BaseAndress,ZD[i].Modulename); strcpy(msg, ZD[i].Andress); sscanf(msg,"%x", &Andress); if(ZD[i].BaseAndress == 0) { BaseAndress=Andress; } if(ZD[i].BaseAndress == 1) { BaseAndress+=Andress; } int Value=atoi(ZD[i].Value),Va; DWORD BAndr=BaseAndress; for(int I=0; I<(ZD[i].Noffset); I++) { ReadProcessMemory(hProcess, (LPVOID) BAndr, (LPVOID) &BAndr, sizeof(DWORD), NULL); strcpy(msg, ZD[i].Offset[I]); sscanf(msg,"%x", &Va); BAndr+=Va; } WriteProcessMemory(hProcess, (LPVOID) BAndr, &Value, sizeof(Value), NULL); } void GameCode_ON_OFF(Cheat * ZD, int i, int SET) { char msg[200]; int BaseAndress,Andress,B,BAndr; HANDLE hProcess = xopenx(Wind_or_exe_file,&BaseAndress,ZD[i].Modulename); if(ZD[i].AoBscanner == 1 && ZD[i].AoBscanner_Adrss == 0){ BAndr = AoBscanner(hProcess, BaseAndress, ZD, i); ZD[i].AoBscanner_Adrss = BAndr; printf("Anddress: %.8x \n\n", BAndr); system("pause"); } /* strcpy(msg, ZD[i].Andress); sscanf(msg,"%x", &Andress); if(ZD[i].BaseAndress == 0) { BaseAndress=Andress; } if(ZD[i].BaseAndress == 1) { BaseAndress+=Andress; } BAndr = BaseAndress; //CodeCave(ZD, i, SET); */ BYTE Nop[(ZD[i].Noffset)]; for(int I=0;I<(ZD[i].Noffset);I++){ if(SET == 1){ strcpy(msg, ZD[i].Onop[I]); sscanf(msg,"%x", &B); Nop[I]=B;} if(SET == 0){Nop[I] = 0x90;} } WriteProcessMemory(hProcess, (LPVOID) BAndr, &Nop, sizeof(Nop), NULL); CloseHandle(hProcess); } DWORD AoBscanner(HANDLE hProcess, int BaseAndress, Cheat * ZD, int P){ char msg[1024]; int Andress; strcpy(msg, ZD[P].Andress); sscanf(msg,"%x", &Andress); DWORD B; int lx = strlen(ZD[P].Andress); BYTE Nop[(lx/2)]; char MsgX[3]; int ix=0; for(int I=0; I<(lx/2); I++){ strncpy(MsgX,(msg+ix),2); sscanf(MsgX,"%x", &B); Nop[I]=B; ix+=2; } // -----------------------------------------------------------------------------> int Size_Step = 9216, k = 0, a = 0; BYTE* memdump = (BYTE*) calloc(Size_Step, sizeof(BYTE)); DWORD i, IAddr = 0x00000000, searchsize = 0x7FFFFFFF; //if(ZD[P].BaseAndress != 0){ IAddr = (DWORD)(BaseAndress); } //if(stricmp(ZD[P].Modulename,"") != 0){ searchsize = GetModuleBase_or_Size(My_Process_ID, ZD[P].Modulename,1); } for(i = IAddr; i < searchsize; i+=(DWORD)(Size_Step)){ ReadProcessMemory(hProcess, (LPVOID) i, memdump, (Size_Step), NULL); for(k = 0; k < Size_Step; k++){ if(memdump[k] == Nop[a]){ //printf("Addr: %.8X | Byte: %.2X | AoB: %.2X - %d\n\n", (i+(DWORD)k), memdump[k], Nop[a], (lx/2)); if(a == (lx/2) -1){ return (i + (DWORD)k - ((lx/2) -1)); } a++; }else{ a = 0; }}} return 0; } void CodeCave(Cheat * ZD, int i, int SET) { char msg[1024]; int Andress, BaseAndress, Size_CodeCave_JMP = (strlen(ZD[i].CodeCave)/2); DWORD Mem_Alloc, CodeJmp, B; HANDLE hProcess = xopenx(Wind_or_exe_file,&BaseAndress,ZD[i].Modulename); strcpy(msg, ZD[i].Andress); sscanf(msg,"%x", &Andress); if(ZD[i].BaseAndress == 0) { BaseAndress=Andress; } if(ZD[i].BaseAndress == 1) { BaseAndress+=Andress; } DWORD BAndr = BaseAndress; if( SET == 0 ) { if(ZD[i].AoBscanner == 1 && ZD[i].AoBscanner_Adrss == 0){ BAndr = AoBscanner(hProcess, BaseAndress, ZD, i); ZD[i].AoBscanner_Adrss = BAndr; } if(ZD[i].AoBscanner == 1 && ZD[i].AoBscanner_Adrss != 0){ BAndr = ZD[i].AoBscanner_Adrss; } Mem_Alloc = (DWORD) VirtualAllocEx(hProcess, NULL, (Size_CodeCave_JMP+10), 0x1000, 0x40); /* salto di andata */ CodeJmp = ( Mem_Alloc - BAndr - (DWORD)(5)); wsprintf(msg, "%.8x", CodeJmp); strcat(msg,"E9"); int lx = strlen(msg); //printf("Adr:%.8x Mall:%.8x\n%s - %d\nJMP:%d\n\n", BAndr, Mem_Alloc, msg, lx, Size_CodeCave_JMP); BYTE Nop[(ZD[i].Noffset)]; int lz = (lx/2); char MsgX[3]; int ix=2; for(int I=0; I<(ZD[i].Noffset); I++) { strncpy(MsgX,((msg+lx))-(ix),2); sscanf(MsgX,"%x", &B); //printf("%d - %s\n", I, MsgX); //system("pause"); if( I < lz ) { Nop[I]=B; } else { Nop[I] = 0x90; } ix+=2; } /* for(int I=0; I<(ZD[i].Noffset); I++){ printf("%d - %x\n", I, Nop[I]); } printf("\n\n"); system("pause"); */ WriteProcessMemory(hProcess, (LPVOID) BAndr, &Nop, sizeof(Nop), NULL); /* Scrivi CodeCave */ BYTE Ncc[Size_CodeCave_JMP]; strcpy(msg, ZD[i].CodeCave); lx = strlen(msg); //printf("= %s\n", msg); ix=0; for(int I=0; I<(Size_CodeCave_JMP); I++) { strncpy(MsgX,(msg+ix),2); sscanf(MsgX,"%x", &B); //printf("1:: %d - %s\n", I, MsgX); Ncc[I]=B; ix+=2; } /* for(int I=0; I<(Size_CodeCave_JMP); I++){ printf("%d - %.2x :", I, Ncc[I]); } printf("\n\n"); system("pause"); */ WriteProcessMemory(hProcess, (LPVOID) (Mem_Alloc), &Ncc, sizeof(Ncc), NULL); /* salto di ritorno */ CodeJmp = BAndr - Mem_Alloc - ((Size_CodeCave_JMP)-1); wsprintf(msg, "%.8x", CodeJmp); strcat(msg,"E9"); lx = strlen(msg); //printf("Adr:%.8x\n%s - %d\n\n", (Mem_Alloc+(Size_CodeCave_JMP)), msg, lx); //system("pause"); BYTE Nope[lx+1]; lz = (lx/2); ix=2; for(int I=0; I<(lz); I++) { strncpy(MsgX,((msg+lx)+sizeof(4))-(ix+sizeof(4)),2); sscanf(MsgX,"%x", &B); //printf("%d - %s\n", I, MsgX); Nope[I]=B; ix+=2; } WriteProcessMemory(hProcess, (LPVOID) (Mem_Alloc+(Size_CodeCave_JMP)), &Nope, sizeof(Nope), NULL); //system("pause"); MEM_ALLOC_END[i] = (Mem_Alloc+(Size_CodeCave_JMP)+10); } else { BYTE Nopr[(ZD[i].Noffset)]; for(int I=0; I<(ZD[i].Noffset); I++) { strcpy(msg, ZD[i].Onop[I]); sscanf(msg,"%x", &B); Nopr[I]=B; } WriteProcessMemory(hProcess, (LPVOID) BAndr, &Nopr, sizeof(Nopr), NULL); VirtualFreeEx(hProcess, (void*)MEM_ALLOC_END[i], 0, 0x4000); } }
Code:
/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */ /* DO NOT EDIT! */ A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "Trainer.ico" IDR_Sound1 300 "Activated.wav" IDR_Sound2 301 "Disactived.wav"