mlitn
19th October 2004, 09:47
In Loaderdlg.cpp, replace DLLNAME.dll with the desired dll name.
It's ok for me to make public releases with this (unless someone has objections.)
Evilhack part:
Hookworks.cpp:
Replace everything below
Quote:
//*************************** D3D8.dll HOOKS
with:
Quote:
//*************************** D3D8.dll HOOKS
DWORD WINAPI MyDirect3DCreate8(UINT SDKVersion)
{
_asm mov ppDirect3DInterface, ebx;
ppDirect3DInterface += 0x46A4;
MyDirect3DCreate8_t OldFn = (MyDirect3DCreate8_t)D3DHook.Functions[0].OrigFn;
//Set pointer to original device
pD3D8 = (IDirect3D8*)OldFn(SDKVersion);
pMyD3D8 = &MyD3D8;
//Set Keyboard Hooks
hMessageHook = SetWindowsHookEx(WH_GETMESSAGE, MessageProc, NULL, GetCurrentThreadId());
//Unhook core.dll and d3ddrv.dll
UnHookAPICalls(&LoadLibraryHook, GetModuleHandle("Core.dll"));
UnHookAPICalls(&D3DHook, hD3DDrvDll);
//Return pointer to wrapper
return (DWORD)pMyD3D8;
}
//*************************** DINPUT.dll HOOKS
HRESULT WINAPI MyDirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID* ppvOut, LPUNKNOWN punkOuter)
{
ppDirectInputInterface = (DWORD)ppvOut;
MyDirectInput8Create_t OldFn = (MyDirectInput8Create_t)DirectInput8Hook.Functions[0].OrigFn;
HRESULT Result = OldFn(hinst, dwVersion, riidltf, (LPVOID*)&pDInput8, punkOuter);
pMyDInput8 = &MyDInput8;
*ppvOut = pMyDInput8;
//Unhook WinDrv.dll
UnHookAPICalls(&DirectInput8Hook, hWinDrvDll);
return Result;
}
//*************************** KERNEL32.dll HOOKS
DWORD WINAPI MyLoadLibraryW(wchar_t *lpFileName)
{
MyLoadLibraryW_t OldFn = (MyLoadLibraryW_t)LoadLibraryHook.Functions[0].OrigFn;
#ifdef TESTMODE
fwprintf(GameInfo.m_pLogFile, _TEXT("LoadLibraryW: %s\n"), lpFileName);
#endif
DWORD Result = OldFn(lpFileName);
if (wcsstr(lpFileName, _TEXT("D3DDrv")) != 0)
{
HookAPICalls(&D3DHook, (HMODULE)Result);
hD3DDrvDll = (HMODULE)Result;
}
if (wcsstr(lpFileName, _TEXT("WinDrv")) != 0)
{
HookAPICalls(&DirectInput8Hook, (HMODULE)Result);
hWinDrvDll = (HMODULE)Result;
}
return Result;
}
Evilhack.cpp:
Replace everything above:
Quote:
bool CheckForAutoFire()
with:
Quote:
#include "evilhack.h"
#include <winable.h> //for SendInput
#ifdef TESTMODE
#include "mdump.h"
#endif
extern IDirect3DDevice8 *pD3DDevice8; //Original Device pointer
extern NewIDirect3DDevice8 *pMyD3DDevice8; //Wrapped Device pointer
extern IDirect3D8 *pD3D8; //Original Device pointer
extern NewIDirect3D8 *pMyD3D8; //Wrapped Device pointer
extern NewIDirect3D8 MyD3D8;
extern NewIDirectInput8 MyDInput8;
extern IDirectInput8 *pDInput8; //Original Device pointer
externvoid HookDDrawCreate();
externvoid UnHookDDrawCreate();
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
#ifdef TESTMODE
MessageBox(NULL, "Evilhack has been loaded. You can now attach debugger and then press ok to continue", "info", MB_OK | MB_TOPMOST);
GameInfo.m_pLogFile = fopen("c:\\log.txt", "w");
#endif
//Fixing a bug in loading evilhack.dll path for TESTMODE
#ifdef TESTMODE
staticchar DllPath[MAX_PATH];
FullDllPath = DllPath;
GetModuleFileName((HMODULE)hModule, FullDllPath, MAX_PATH);
#else
FullDllPath = (char*)hModule;
#endif
if (HookAPICalls(&LoadLibraryHook, GetModuleHandle("core.dll")) != true)
MessageBox(NULL, "error attaching evilhack", "error", MB_OK);
//Get Handle to original dll. Its important not to call LoadLibrary here so that the reference counter doesnt get incremented
hOriginalDll = GetModuleHandle("d3d8.dll");
pDirect3DCreate8 = (pDirect3DCreate8_t)GetProcAddress(hOriginalDll, "Direct3DCreate8");
GameInfo.m_Settings.ReadSettings(FullDllPath);
GameInfo.m_Settings.ConvertColors();
GameInfo.m_Settings.ReadIniFiles();
GameInfo.m_LogoStartTime = GetTickCount();
CheckSanity();
}
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
#ifdef TESTMODE
if (GameInfo.m_pLogFile != NULL)
fclose(GameInfo.m_pLogFile);
#endif
if (hMessageHook != NULL)
UnhookWindowsHookEx(hMessageHook);
break;
}
return TRUE;
}
r
Evilconfig part:
Loaderdlg.cpp:
Search for:
Quote:
char StartGameCommand[2048];
add:
Quote:
char EvilhackDll[2048];
Search for:
Quote:
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
ZeroMemory(&pi, sizeof(pi));
si.cb = sizeof(si);
if (CreateProcess(NULL, StartGameCommand, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
NULL;
#ifndef _DEBUG //keep evilconfig loaded for debug purposes
PostMessage(WM_QUIT, 0, 0);
#endif
}
else
MessageBox("Error creating process", "error", MB_OK);
Replace with:
Quote:
strcpy(EvilhackDll, theApp.m_Settings.m_PathToEvilhack);
strcat(EvilhackDll, "DLLNAME.dll");
if (SpawnProcess(StartGameCommand, EvilhackDll))
PostMessage(WM_QUIT, 0, 0);
else
MessageBox("Error creating process", "error", MB_OK);
Search for:
Quote:
#ifdef _DEBUG
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, CurrentEntry.th32ProcessID);
SuspendThread(hProcess);
if (hProcess == NULL)
MessageBox("Couldnt open process", "error", MB_OK);
//Need full path here, just "evilhack.dll" won't do
if (!DetourContinueProcessWithDllA(hProcess, theApp.GetFullDllName()))
MessageBox("Couldnt inject dll", "error", MB_OK);
ResumeThread(hProcess);
CloseHandle(hProcess);
#else
dllinject(CurrentEntry.th32ProcessID, theApp.GetFullDllName());
#endif
CloseHandle(hSnapshot); //Move this here from inside the old CDC 1.5.1 multipass counter
PassCount += 1;
if (PassCount > 1)
{
KillTimer(0);
PostMessage(WM_QUIT, 0, 0);
}
return;
}
}
if (hSnapshot != NULL)
CloseHandle(hSnapshot);
}
CPropertyPage::OnTimer(nIDEvent);
}
Replace with:
Quote:
finish:
#ifdef _DEBUG
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, CurrentEntry.th32ProcessID);
SuspendThread(hProcess);
if (hProcess == NULL)
MessageBox("Couldnt open process", "error", MB_OK);
//Need full path here, just "evilhack.dll" won't do
if (!DetourContinueProcessWithDllA(hProcess, theApp.GetFullDllName()))
MessageBox("Couldnt inject dll", "error", MB_OK);
ResumeThread(hProcess);
CloseHandle(hProcess);
#else
dllinject(CurrentEntry.th32ProcessID, theApp.GetFullDllName());
#endif
CloseHandle(hSnapshot); //Move this here from inside the old CDC 1.5.1 multipass counter
PassCount += 1;
if (PassCount > 1)
{
KillTimer(0);
PostMessage(WM_QUIT, 0, 0);
}
return;
}
}
if (hSnapshot != NULL)
CloseHandle(hSnapshot);
}
CPropertyPage::OnTimer(nIDEvent);
}
It's ok for me to make public releases with this (unless someone has objections.)
Evilhack part:
Hookworks.cpp:
Replace everything below
Quote:
//*************************** D3D8.dll HOOKS
with:
Quote:
//*************************** D3D8.dll HOOKS
DWORD WINAPI MyDirect3DCreate8(UINT SDKVersion)
{
_asm mov ppDirect3DInterface, ebx;
ppDirect3DInterface += 0x46A4;
MyDirect3DCreate8_t OldFn = (MyDirect3DCreate8_t)D3DHook.Functions[0].OrigFn;
//Set pointer to original device
pD3D8 = (IDirect3D8*)OldFn(SDKVersion);
pMyD3D8 = &MyD3D8;
//Set Keyboard Hooks
hMessageHook = SetWindowsHookEx(WH_GETMESSAGE, MessageProc, NULL, GetCurrentThreadId());
//Unhook core.dll and d3ddrv.dll
UnHookAPICalls(&LoadLibraryHook, GetModuleHandle("Core.dll"));
UnHookAPICalls(&D3DHook, hD3DDrvDll);
//Return pointer to wrapper
return (DWORD)pMyD3D8;
}
//*************************** DINPUT.dll HOOKS
HRESULT WINAPI MyDirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID* ppvOut, LPUNKNOWN punkOuter)
{
ppDirectInputInterface = (DWORD)ppvOut;
MyDirectInput8Create_t OldFn = (MyDirectInput8Create_t)DirectInput8Hook.Functions[0].OrigFn;
HRESULT Result = OldFn(hinst, dwVersion, riidltf, (LPVOID*)&pDInput8, punkOuter);
pMyDInput8 = &MyDInput8;
*ppvOut = pMyDInput8;
//Unhook WinDrv.dll
UnHookAPICalls(&DirectInput8Hook, hWinDrvDll);
return Result;
}
//*************************** KERNEL32.dll HOOKS
DWORD WINAPI MyLoadLibraryW(wchar_t *lpFileName)
{
MyLoadLibraryW_t OldFn = (MyLoadLibraryW_t)LoadLibraryHook.Functions[0].OrigFn;
#ifdef TESTMODE
fwprintf(GameInfo.m_pLogFile, _TEXT("LoadLibraryW: %s\n"), lpFileName);
#endif
DWORD Result = OldFn(lpFileName);
if (wcsstr(lpFileName, _TEXT("D3DDrv")) != 0)
{
HookAPICalls(&D3DHook, (HMODULE)Result);
hD3DDrvDll = (HMODULE)Result;
}
if (wcsstr(lpFileName, _TEXT("WinDrv")) != 0)
{
HookAPICalls(&DirectInput8Hook, (HMODULE)Result);
hWinDrvDll = (HMODULE)Result;
}
return Result;
}
Evilhack.cpp:
Replace everything above:
Quote:
bool CheckForAutoFire()
with:
Quote:
#include "evilhack.h"
#include <winable.h> //for SendInput
#ifdef TESTMODE
#include "mdump.h"
#endif
extern IDirect3DDevice8 *pD3DDevice8; //Original Device pointer
extern NewIDirect3DDevice8 *pMyD3DDevice8; //Wrapped Device pointer
extern IDirect3D8 *pD3D8; //Original Device pointer
extern NewIDirect3D8 *pMyD3D8; //Wrapped Device pointer
extern NewIDirect3D8 MyD3D8;
extern NewIDirectInput8 MyDInput8;
extern IDirectInput8 *pDInput8; //Original Device pointer
externvoid HookDDrawCreate();
externvoid UnHookDDrawCreate();
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
#ifdef TESTMODE
MessageBox(NULL, "Evilhack has been loaded. You can now attach debugger and then press ok to continue", "info", MB_OK | MB_TOPMOST);
GameInfo.m_pLogFile = fopen("c:\\log.txt", "w");
#endif
//Fixing a bug in loading evilhack.dll path for TESTMODE
#ifdef TESTMODE
staticchar DllPath[MAX_PATH];
FullDllPath = DllPath;
GetModuleFileName((HMODULE)hModule, FullDllPath, MAX_PATH);
#else
FullDllPath = (char*)hModule;
#endif
if (HookAPICalls(&LoadLibraryHook, GetModuleHandle("core.dll")) != true)
MessageBox(NULL, "error attaching evilhack", "error", MB_OK);
//Get Handle to original dll. Its important not to call LoadLibrary here so that the reference counter doesnt get incremented
hOriginalDll = GetModuleHandle("d3d8.dll");
pDirect3DCreate8 = (pDirect3DCreate8_t)GetProcAddress(hOriginalDll, "Direct3DCreate8");
GameInfo.m_Settings.ReadSettings(FullDllPath);
GameInfo.m_Settings.ConvertColors();
GameInfo.m_Settings.ReadIniFiles();
GameInfo.m_LogoStartTime = GetTickCount();
CheckSanity();
}
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
#ifdef TESTMODE
if (GameInfo.m_pLogFile != NULL)
fclose(GameInfo.m_pLogFile);
#endif
if (hMessageHook != NULL)
UnhookWindowsHookEx(hMessageHook);
break;
}
return TRUE;
}
r
Evilconfig part:
Loaderdlg.cpp:
Search for:
Quote:
char StartGameCommand[2048];
add:
Quote:
char EvilhackDll[2048];
Search for:
Quote:
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
ZeroMemory(&pi, sizeof(pi));
si.cb = sizeof(si);
if (CreateProcess(NULL, StartGameCommand, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
NULL;
#ifndef _DEBUG //keep evilconfig loaded for debug purposes
PostMessage(WM_QUIT, 0, 0);
#endif
}
else
MessageBox("Error creating process", "error", MB_OK);
Replace with:
Quote:
strcpy(EvilhackDll, theApp.m_Settings.m_PathToEvilhack);
strcat(EvilhackDll, "DLLNAME.dll");
if (SpawnProcess(StartGameCommand, EvilhackDll))
PostMessage(WM_QUIT, 0, 0);
else
MessageBox("Error creating process", "error", MB_OK);
Search for:
Quote:
#ifdef _DEBUG
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, CurrentEntry.th32ProcessID);
SuspendThread(hProcess);
if (hProcess == NULL)
MessageBox("Couldnt open process", "error", MB_OK);
//Need full path here, just "evilhack.dll" won't do
if (!DetourContinueProcessWithDllA(hProcess, theApp.GetFullDllName()))
MessageBox("Couldnt inject dll", "error", MB_OK);
ResumeThread(hProcess);
CloseHandle(hProcess);
#else
dllinject(CurrentEntry.th32ProcessID, theApp.GetFullDllName());
#endif
CloseHandle(hSnapshot); //Move this here from inside the old CDC 1.5.1 multipass counter
PassCount += 1;
if (PassCount > 1)
{
KillTimer(0);
PostMessage(WM_QUIT, 0, 0);
}
return;
}
}
if (hSnapshot != NULL)
CloseHandle(hSnapshot);
}
CPropertyPage::OnTimer(nIDEvent);
}
Replace with:
Quote:
finish:
#ifdef _DEBUG
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, CurrentEntry.th32ProcessID);
SuspendThread(hProcess);
if (hProcess == NULL)
MessageBox("Couldnt open process", "error", MB_OK);
//Need full path here, just "evilhack.dll" won't do
if (!DetourContinueProcessWithDllA(hProcess, theApp.GetFullDllName()))
MessageBox("Couldnt inject dll", "error", MB_OK);
ResumeThread(hProcess);
CloseHandle(hProcess);
#else
dllinject(CurrentEntry.th32ProcessID, theApp.GetFullDllName());
#endif
CloseHandle(hSnapshot); //Move this here from inside the old CDC 1.5.1 multipass counter
PassCount += 1;
if (PassCount > 1)
{
KillTimer(0);
PostMessage(WM_QUIT, 0, 0);
}
return;
}
}
if (hSnapshot != NULL)
CloseHandle(hSnapshot);
}
CPropertyPage::OnTimer(nIDEvent);
}