| 12
 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
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 
 | #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);
HWND AppWnd;
 
 
/* Définition des variables globales */
HANDLE hand		= NULL;
char *title		= "Command and Conquer Generals";
char *about		= "Command and Conquer Generals 1.0 Trainer\n" \
				"Version 1.0\n" \
				"by Sephi\n" \
				"sephi@countercheat.net\n\n" \
				"Enjoy!";
 
DWORD address	= 0x73E326;
unsigned char patch[1]	= {0xFF};
 
 
/* Fonction principale */
int WINAPI WinMain(HINSTANCE hInst,
				   HINSTANCE hPrevInst,
				   LPSTR lpCmdLine,
				   int nShowCmd)
{
	HICON hIcon1,hIcon2;
	MSG msg;
	int Ret;
 
	AppWnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_MAINDIALOG), NULL, DlgProc);
 
	hIcon1 = LoadIcon(hInst,MAKEINTRESOURCE(IDI_MAINICON)); 
	hIcon2 = LoadIcon(hInst,MAKEINTRESOURCE(IDI_MAINICON)); 
 
	SendMessage(AppWnd,WM_SETICON,(WPARAM)ICON_SMALL,(LPARAM)hIcon1); 
	SendMessage(AppWnd,WM_SETICON,(WPARAM)ICON_BIG,(LPARAM)hIcon2);
 
	ShowWindow(AppWnd,nShowCmd);
 
    // Boucle principale des messages:
	while( (Ret = GetMessage(&msg,NULL,0,0)) != 0)
	{ 
		if (Ret == -1) exit(0); // Grosse erreur style Fatal error
	    else
	    {
			TranslateMessage(&msg); 
			DispatchMessage(&msg); 
		}
	}
	return msg.wParam;
}
 
/* 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,wParam);
					PostQuitMessage(0);
					break;
			}
			break;
 
		case WM_TIMER:
			check_keys();
			break;
 
		case WM_QUIT:
		case WM_CLOSE:
			EndDialog(hWnd,wParam);
			PostQuitMessage(0);
			break;
 
	}
	return FALSE;
} |