View Single Post
  #9 (permalink)  
Join Date: 29 Mar 2007
Location: AgeRage.net Cosmos
Posts: 14
beer__'s Avatar
Old 07-02-2008, 19:35
beer__ beer__ is offline
Recruited Rager
AoC Maphack

AoC maphack in C++
Do not use it on igz, this one will get you banned.
I am not gonna translate it to English so try to use altavista (Dutch to English, if you think my notes can be useful).


Code:
main.cpp

#include <windows.h>					//windows.h includen, het bestand dat dit mogelijk maakt, de <> eromheen geven aan dat het gewoon ergens in je WINDOWS map staat..
#include <stdio.h>
#include <string.h>
#include "Process.h"

#define ID_TIMER                1					// ID voor de timer
#define TIMER_INTERRUPT         600					// timer msg interval-tijd in msec
///////////////
// Addresses //
///////////////

//Adressen
#define AOC_MINI_MAPHACK_NOPE				0x4336E6
#define AOC_MINI_MAPHACK_JMP				0x4336E8
#define AOC_MAPHACK							0x586252
// WAARDES VOOR ADRESSEN
//Maphack aan
BYTE NOPNOP[2] = {144,144};											//Maphack en nope van overbodige instructie.
BYTE SPRING[12] = {233 , 237, 255, 255, 255, 255};					//Jump back naar adres voor minimaphack
//Maphach uit
BYTE FIXNOP1[2] = {133,216};
BYTE FIXSPRING[6] = {15, 132, 164, 1, 0, 0};
BYTE FIXNOP2[2] = {117, 6};



HINSTANCE hInstance;								// Komt van cw.hInstance bij de configuratie van de window?
CProcess gameProcess;
/* Naam voor de windowtekst */
char wndText[30];
BYTE poke;

const char g_szClassName[] = "myWindowClass";		//Naam van eigen window.

// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)					// Zeggen voor welk window het geld
{
   switch(msg)
   {
      case WM_CREATE:

      hwndLives = CreateWindow("Button", "Map-Hack-On", WS_CHILD|WS_VISIBLE, 20,10,			/* Button */
      100,20,hwnd,(HMENU)1,hInstance,NULL);

      hwndAbout = CreateWindow("Button", "About", WS_CHILD|WS_VISIBLE, 140,70,				/* Button */
      100,20,hwnd,(HMENU)2,hInstance,NULL);
      
	  hwndBy = CreateWindow("Static", "By. Aedan", WS_CHILD|WS_TABSTOP|WS_VISIBLE, 20,70,	/* Button */
      100,20,hwnd,NULL,hInstance,NULL);
      break;
    //case	WM_TIMER:												// Als de timer gestart wordt
	//		WriteMem(hwnd, opt);									/*Maak dan van BYTE opt in WriteMem de waarde 0*/
	//		opt = 0;
    //break;
      case  WM_COMMAND:												// Als er iets geselecteerd wordt in een menu
	  WriteMem(hwnd, opt);	  
	  case  BN_CLICKED:												// Als er iets aangeklikt wordt
	  WriteMem(hwnd, opt);	  
	  switch(LOWORD(wParam))
	  {
    //----       
			case 1:													// Als de knop freeze lifes bediend wordt
            GetWindowText(hwndLives, wndText, 30);					/* Laad de momentele windowstekst */
            if(strcmp("Map-Hack-On",wndText) == 0)					/* Als die tekst [Map-Hack-On] is verander die naar Map-Hack-Off */
			{
				SetWindowText(hwndLives, "Map-Hack-Off");
				poke = 1;											/* Verander poke in 0 */
            }

            else if(strcmp("Map-Hack-Off", wndText) == 0)			/*  Het omgekeerde van hierboven */
			{
				SetWindowText(hwndLives, "Map-Hack-On");
                poke = 0;											/*  Verander poke in 1 */
            }
            break;
	//----
			case 2:													
			MessageBox(hwnd,
				"This is a trainer, made by Aedan for the game:\n"
				"\"Age of Empires 2 The Conquerors\"\n\n" 

				"Quote: "
				"Hacking is more than just a crime. It's a survival trait.\n\n"
				
				,"Untitled - Notepad", MB_OK);
			break;

            default: { break;}
      }
      break;														// van WM_COMMAND
      break;														// van BN_CLICKED
      case WM_CLOSE: // 
      DestroyWindow(hwnd);
      break;
	  case WM_DESTROY:
      PostQuitMessage(0);
      break;
	  default:
      return DefWindowProc(hwnd, msg, wParam, lParam);
   }
   return 0;
}
#define OBTE() \
	asm_ {mov	eax,fs: [00000018]};\
	asm_ {mov	eax, [eax+0x30]};\
	asm_ {cmp	byte ptr [eax+0x2], 0};\
	asm_ {je		RunProgram};\

//1------------------------------------------------------------------------------------------------------------------------
																	//Hier ga ik het window definieren
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASSEX wc;													/* Data-structuur voor de windowclass */
    HWND hwnd;														/* De handle voor mijn window */	
    MSG Msg;														/* Berichten naar de applicaties worden hier bewaard */

																	//Stap 1a: Structuur van het window
	wc.hInstance     = hInstance;									
    wc.cbSize        = sizeof(WNDCLASSEX);							/* size of structuir */
    wc.lpszClassName = g_szClassName;								/* Naam om de class mee te definieren */
	wc.style         = CS_DBLCLKS;									/* Onderschep dubbel-klikken */ 
    wc.lpfnWndProc   = WndProc;										/* Dit is de pointer naar de windows procedure voor deze window class */

																	//Stap 1b: Gebruik standaard icoon en muis-aanwijzer
	wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);				/* NULL, IDI_APPLICATION = kan ook // Grooter icoon als de gebruiker Alt+Tab drukt */
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+22);					/* Gebruik de standaard windows background kleur */
    wc.lpszMenuName  = NULL;										/* Geen menu */
    wc.cbClsExtra    = 0;											/* Geen extra bytes na de window class */
    wc.cbWndExtra    = 0;											/* Structure or the window instance */
    wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);				/* NULL, IDI_APPLICATION = kan ook // Smal icoontje in de bovenhoek */

	if(!RegisterClassEx(&wc))										// Registreer de window class en als die faalt stop dan het programma
    {
        MessageBox(NULL, "Window Registration Failed!", "Error!",
            MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }

														// Stap 2: Hier ga ik het windows scherm uitvoeren
    hwnd = CreateWindowEx(
        WS_EX_CLIENTEDGE,
        g_szClassName,									/* Class-naam */ 
        "Untitled - Notepad",							/* Titel natuurlijk */
        WS_OVERLAPPED|WS_SYSMENU|WS_CAPTION,			/* WS_OVERLAPPEDWINDOW = zou een standaard window zijn */ 
        CW_USEDEFAULT,									/* Windows bepaald the positie */ 
		CW_USEDEFAULT,									/* waar het scherm verschijnt */
		270,											/* Breedte in pixels */
		150,											/* Hoogte in pixels */
        NULL,											/* The window is a child-window to desktop */
		NULL,											/* Geen menu */
		hInstance,										/* Programma Instance handler */
		NULL											/* Geen window data */
		);

    if(hwnd == NULL)									//Creeer het window en indien dit faalt: stop dan het programma.
    {
        MessageBox(NULL, "Window Creation Failed!", "Error!",
        MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }

	else SetTimer(hwnd, ID_TIMER, TIMER_INTERRUPT, NULL);	//Definieer mijn timer

    
	ShowWindow(hwnd, nCmdShow);								// Maak het window zichtbaar op het scherm 
    UpdateWindow(hwnd);
															// Stap 3: Message Loop
    while(GetMessage(&Msg, NULL, 0, 0) > 0)
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }
    return Msg.wParam;
}

//2------------------------------------------------------------------------------------------------------------------------    



void WriteMem(HWND hwnd, BYTE opt)									// De opt is 1 als ...
{
    bool bOk = gameProcess.IsRunning();								/* Komt van class */

	if (!bOk) 
	bOk = gameProcess.FindProcess("Age of Empires II Expansion");	/* Komt van class */

    if (bOk) 
	{
        if (poke == 0) 
		{
			gameProcess.Write2Bytes(AOC_MINI_MAPHACK_NOPE, NOPNOP);
			gameProcess.Write6Bytes(AOC_MINI_MAPHACK_JMP, SPRING);
			gameProcess.Write2Bytes(AOC_MAPHACK, NOPNOP);
        }

        if (poke == 1) 
		{
			gameProcess.Write2Bytes(AOC_MINI_MAPHACK_NOPE, FIXNOP1);
			gameProcess.Write6Bytes(AOC_MINI_MAPHACK_JMP, FIXSPRING);
			gameProcess.Write2Bytes(AOC_MAPHACK, FIXNOP2);	
		}
	}
}
Code:
void WriteMem(HWND hwnd, BYTE opt);						// Hier gaan we mijn hwnd van game en mijn BYTE opt bemachtigen. Die in main word opgeroepen.
BYTE opt;
static HWND hwndPoints, hwndBy, hwndLives, hwndAbout;


class CProcess 
{
public:
    CProcess();
    virtual ~CProcess();

    bool IsRunning();													/* proces al gevonden? */
    bool FindProcess(char *p_WindowTitle);								/* zoek proces */
    
	BYTE ReadByte(DWORD p_Address);										/* 1 byte lezen van memory */
    WORD ReadWord(DWORD p_Address);
    DWORD ReadDword(DWORD p_Address);
    
	bool WriteByte(DWORD p_Address, BYTE p_Value);						/* 1 byte naar memory */
    bool Write2Bytes(DWORD p_Address, BYTE *array);
    bool Write6Bytes(DWORD p_Address, BYTE *array);
	
	bool IsKeyPressed(int p_iKey);
	bool IsSpyRunning(char *p_WindowTitle);								
	HANDLE m_hProcess;
    

private:
    HANDLE OpenProcess(char *p_ClassName, char *p_WindowTitle);
    bool m_bGameRunning;
};

CProcess::CProcess()													// We gaan hier zeggen dat we geen handle hebben en dat het process niet loopt
{
   m_hProcess = NULL;
   m_bGameRunning = false;												/* Game is niet opgestart */
}
CProcess::~CProcess() 
{}

bool CProcess::IsRunning()
{
    return m_bGameRunning;
}

HANDLE CProcess::OpenProcess(char *p_ClassName, char *p_WindowTitle)	// Te vinden in private 
{
    HWND hWindow;																										
    DWORD pid;															
    
    hWindow = FindWindow(p_ClassName, p_WindowTitle);					/* Vind window met deze class-naam en window-titel */
    if (hWindow)														/* Als window gevonden is */
	{
        GetWindowThreadProcessId(hWindow, &pid);						/* Get process ID */
        return ::OpenProcess(PROCESS_ALL_ACCESS, false, pid);			/* Stuur dit terug naar de class */
    }
    return NULL;
}

bool CProcess::FindProcess(char *p_WindowTitle)						// We gaan zoeken naar het process
{
    if (m_hProcess == NULL)											/* Als m_hProcess == 0 wat we geporgrammeerd hebben dan gaan we verder */
	{
        m_hProcess = this->OpenProcess(NULL, p_WindowTitle);		/* De handle m_hProcess krijgt dit window */
        if (m_hProcess)
        m_bGameRunning = true;
        return m_bGameRunning;										/* Geef de waarde 1 terug aan de bool m_bGameRunning */
	}
    else															
	return false;													
}



bool CProcess::Write2Bytes(DWORD p_Address, BYTE *array)				// 2 BYTES schrijven
{
    DWORD bytes;

    if (m_bGameRunning)
    return (WriteProcessMemory(m_hProcess, (void*)p_Address, array, 2, 0) != 0);
    return false;
}


bool CProcess::Write6Bytes(DWORD p_Address, BYTE *array)				// 6 BYTES schrijven
{
    DWORD bytes;

    if (m_bGameRunning)
    return (WriteProcessMemory(m_hProcess, (void*)p_Address, array, 6, 0) != 0);
    return false;
}

BYTE CProcess::ReadByte(DWORD p_Address)							// 1 Byte lezen
{
    DWORD bytes;
    BYTE tmpValue;

    if (m_bGameRunning) 
	{
		 if (ReadProcessMemory(m_hProcess, (void*)p_Address,(void *)&tmpValue, 1, 0) == 0)
		 return 0;
		 else 
		 return tmpValue;
    }
    return 0;
}

WORD CProcess::ReadWord(DWORD p_Address)							// 1 Woord lezen
{
    DWORD bytes;
    WORD tmpValue;

    if (m_bGameRunning) 
	{
		if (ReadProcessMemory(m_hProcess, (void*)p_Address,(void *)&tmpValue, 2, 0) == 0)
		return 0;
		else
		return tmpValue;
    }
    return 0;
}

DWORD CProcess::ReadDword(DWORD p_Address)							// Dubbel woord lezen
{
    DWORD bytes;
    DWORD tmpValue;

    if (m_bGameRunning) 
	{
		if (ReadProcessMemory(m_hProcess, (void*)p_Address,(void *)&tmpValue, 4, 0) == 0)
		return 0;
		else
		return tmpValue;
    }
    return 0;
}

bool CProcess::IsKeyPressed(int iKey)
{
    return ((GetAsyncKeyState(iKey) & 1) == 1);
}
cheating is lame

Last edited by beer__; 07-02-2008 at 19:46..
Reply With Quote
 
Page generated in 0.11406 seconds with 10 queries