#include <Windows.h>
#include "Game.h"
#include <detours.h>
#define MakeThread(x) CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)x, NULL, NULL, NULL)
void HookGame()
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)LoopThroughIngamePlayers_Org, LoopThroughInGamePlayers_Hook);
DetourAttach(&(PVOID&)NameRenderer_Org, NameRenderer_Hook);
DetourTransactionCommit();
}
void UnHookGame()
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(&(PVOID&)LoopThroughIngamePlayers_Org, LoopThroughInGamePlayers_Hook);
DetourDetach(&(PVOID&)NameRenderer_Org, NameRenderer_Hook);
DetourTransactionCommit();
}
void Initialize();
void Stop();
namespace Globals
{
HMODULE hDll;
BOOL IsExiting;
}
namespace Threads
{
HANDLE hMainLoop;
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
Globals::IsExiting = FALSE;
Globals::hDll = hinstDLL;
MakeThread(Initialize);
break;
case DLL_PROCESS_DETACH:
Stop();
break;
}
return TRUE;
}
void Initialize()
{
Beep(2500, 500);
InitializeGame();
HookGame();
}
void Stop()
{
Globals::IsExiting = TRUE;
UnHookGame();
Beep(500, 500);
}
1>------ Build started: Project: AoS, Configuration: Debug Win32 ------ 1>dllmain.obj : error LNK2019: unresolved external symbol _DetourTransactionCommit@0 referenced in function "void __cdecl HookGame(void)" (?HookGame@@YAXXZ) 1>dllmain.obj : error LNK2019: unresolved external symbol _DetourAttach@8 referenced in function "void __cdecl HookGame(void)" (?HookGame@@YAXXZ) 1>dllmain.obj : error LNK2019: unresolved external symbol _DetourUpdateThread@4 referenced in function "void __cdecl HookGame(void)" (?HookGame@@YAXXZ) 1>dllmain.obj : error LNK2019: unresolved external symbol _DetourTransactionBegin@0 referenced in function "void __cdecl HookGame(void)" (?HookGame@@YAXXZ) 1>dllmain.obj : error LNK2019: unresolved external symbol _DetourDetach@8 referenced in function "void __cdecl UnHookGame(void)" (?UnHookGame@@YAXXZ) 1>C:\Documents and Settings\Owner\My Documents\Visual Studio 2010\Projects\AoS\Debug\AoS.dll : fatal error LNK1120: 5 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
#pragma comment(lib,"C:\path\detours.lib");