but this is as simple as its gonna get!
Here's an example i whipped together for Minesweeper
Ofcourse within CO theres stuff you can do aswell, once you know a function!
(for example sending magic attacks like stig *hint hint*)
So after trying this out I suggest you to read more about this subject!
(if you're not experienced with function hooks)
And share your sources in this section!
I included everything you need and commented most things out for you.
the attachment below includes:
1) Winject (to inject the dll)
2) Detours folder (lib and header file you need to let your compiler know)
3) the project source folder
4) MineSweeper! (I had to download it because my windows doesnt have that crap)
Heres the main cpp file:
Code:
[COLOR="Green"]/////////////////////////////////////////////////////////
//*****************************************************//
//****Hooking functions and executing them*************//
//****Example for MineSweeper**************************//
//****By fobos*****************************************//
/////////////////////////////////////////////////////////
/*
We need to include some stuff in order to include detours.h
the compiler needs to know where the lib and .h files are.
So first thing you do right now is right click MineSweeperHook
in your solution explorer, click on properties.
click on C/C++ and then add your detours folder you extracted from
the rar file to additional include directories.
Thats not all now click on the Linker tab, and add Detours folder
to Additional library directories.
Thats all to that!
*/ [/COLOR]
[COLOR="Green"]// Includes (duhh)[/COLOR]
#include <windows.h>
#include "detours.h"
#pragma comment(lib, "detours.lib")
DWORD WINAPI MyThread(LPVOID);
DWORD g_threadID;
HMODULE g_hModule;
[COLOR="Green"]//Function prototypes (duhh)[/COLOR]
int (__stdcall* PauseGame)();
int (__stdcall* ResumeGame)();
[COLOR="Green"]//Our pause function, the fun stuff begins :p[/COLOR]
int MyPauseGame()
{
[COLOR="Green"] //Messagebox[/COLOR]
MessageBoxA(NULL, "Press OK and your bitch is on hold. :p", "Call PauseGame", MB_OK);
[COLOR="Green"] //Return the real function[/COLOR]
return PauseGame();
}
[COLOR="Green"]//Our resume function[/COLOR]
int MyResumeGame()
{
[COLOR="Green"]//Messagebox[/COLOR]
MessageBoxA(NULL, "Press OK and your bitch will resume! :p", "Call ResumeGame", MB_OK);
//Return the real function
return ResumeGame();
}
INT APIENTRY DllMain(HMODULE hDLL, DWORD Reason, LPVOID Reserved)
{
switch(Reason)
{
case DLL_PROCESS_ATTACH:
[COLOR="Green"]//On attach set the hooks[/COLOR]
PauseGame = (int (__stdcall*)())DetourFunction((PBYTE)0x0100341C, (PBYTE)MyPauseGame);
ResumeGame = (int (__stdcall*)())DetourFunction((PBYTE)0x0100344C, (PBYTE)MyResumeGame);
g_hModule = hDLL;
DisableThreadLibraryCalls(hDLL);
[COLOR="Green"]//Create a thread [/COLOR]
CreateThread(NULL, NULL, &MyThread, NULL, NULL, &g_threadID);
break;
case DLL_THREAD_ATTACH:
case DLL_PROCESS_DETACH:
[COLOR="Green"]//Remove the hooks cuz we like to clean.. *cough*[/COLOR]
DetourRemove((PBYTE)0x0100341C, (PBYTE)PauseGame);
DetourRemove((PBYTE)0x0100344C, (PBYTE)ResumeGame);
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}
DWORD WINAPI MyThread(LPVOID)
{
while(true)
{
[COLOR="Green"]// Set F10 as our hotkey and wait do something on keypress[/COLOR]
if(GetAsyncKeyState(VK_F10) & 1)
{
[COLOR="Green"] // Execute our function
// You could also call it directly like this:
// PauseGame();[/COLOR]
MyPauseGame();
}
[COLOR="Green"]// Set F11 as our hotkey and wait do something on keypress[/COLOR]
else if(GetAsyncKeyState(VK_F11) & 1)
{
[COLOR="Green"] // Execute our function
// You could also call it directly like this:
// ResumeGame();[/COLOR]
MyResumeGame();
}
[COLOR="Green"]//Set F12 as our hotkey to break and remove the dll from process[/COLOR]
else if(GetAsyncKeyState(VK_F12) & 1)
break;
Sleep(100);
}
FreeLibraryAndExitThread(g_hModule, 0);
return 0;
}
I don't need thank you's or anything, all I want is this section to get more stuff about programming instead of the idiotic questions (No offense..)
(On a side note i gave a minesweeper example instead of a CO example because hell I'm not gonna chew everything for you
So well enjoy!






