1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| #include <windows.h>
#include "resource.h"
/* Définition des fonctions */
BOOL CALLBACK DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
void check_keys(void);
void InitApp(HWND hDlg,WPARAM wParam, LPARAM lParam);
/* Définition des variables globales */
...
/* Fonction principale */
int WINAPI WinMain(HINSTANCE hInst,
HINSTANCE hPrevInst,
LPSTR lpCmdLine,
int nShowCmd)
{
return DialogBox(hInst, MAKEINTRESOURCE(IDD_MAINDIALOG), NULL, DlgProc);
}
/* Fonction de vérification des touches pressées */
void check_keys()
{
if(GetAsyncKeyState(VK_F8))
WriteProcessMemory(hand, (void*)address, &patch, sizeof(patch), NULL);
}
/* Vérification du lancement du jeu et lancement du timer */
void InitApp(HWND hDlg,WPARAM wParam, LPARAM lParam)
{
HWND hWindow;
DWORD pid;
hWindow = FindWindow(NULL, title);
if(hWindow)
{
GetWindowThreadProcessId(hWindow, &pid);
hand = OpenProcess(PROCESS_ALL_ACCESS,0,pid);
}
else
{
//MessageBox(NULL, "Vous devez lancer le jeu avant le trainer.", "Erreur", MB_OK + MB_ICONWARNING);
}
SetTimer(hDlg, 1, 0, NULL);
}
/* Gestion des messages */
BOOL CALLBACK DlgProc(HWND hWnd,
UINT msg,
WPARAM wParam,
LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
InitApp(hWnd,wParam,lParam);
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_ABOUT:
MessageBox(NULL,about,"About",MB_OK + MB_ICONINFORMATION);
break;
case IDC_QUIT:
EndDialog(hWnd,0);
break;
}
break;
case WM_TIMER:
check_keys();
break;
case WM_CLOSE:
EndDialog(hWnd,0);
break;
}
return FALSE;
} |
Partager