// CohEngineInjectee.cpp : Defines the entry point for the DLL application. // #include "stdafx.h" #include "AsmRewrites.h" #include "ModInterface.h" #include "Scar_Internet.h" // comment out to disable scar internet #ifdef _MANAGED #pragma managed(push, off) #endif bool g_bHaxxApplied; bool g_bReLaunch; char g_sConfigName[MAX_PATH + 1]; char g_sEngineFolder[MAX_PATH + 1]; void WritePtr(unsigned char* pDest, char* pStr) { char ** pp = (char **)pDest; *pp = pStr; } void HaxxNotApplied() { HWND hCoH = FindWindow("Plat::Window {DB3DC0D7-BBA3-4d06-BCD8-40CD448B4AE3}", 0); SendMessage(hCoH, WM_CLOSE, 0, 0); g_bReLaunch = true; } extern "C" { /* Function called by injector as a thread. Called after DllMain has finished but before the main thread is resumed. Exported as _Haxx@4 */ DWORD __declspec(dllexport) WINAPI Haxx(LPVOID pIgnored) { unsigned char* pInjectLoc = (unsigned char*) AssemblerUtil::ScanForString("\x74\x11\x68\x96\x00\x00\x00", 7, 0x7D0000); // Allow engine data folder to be loaded by nopping a few bytes pInjectLoc[51] = 0x90; pInjectLoc[52] = 0x90; // .text:007D68F7 jz short loc_7D692B --> nop nop pInjectLoc[62] = 0x90; pInjectLoc[63] = 0x90; // .text:007D6902 jnz short loc_7D692B --> nop nop // Set engine data folder WritePtr(pInjectLoc + 8, g_sEngineFolder); WritePtr(pInjectLoc + 71, g_sEngineFolder); #ifdef _SCAR_INTERNET_H_ Haxx_ApplyScarInternet(); #endif g_bHaxxApplied = true; return 0x1337; } }; BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { if(ul_reason_for_call == DLL_PROCESS_ATTACH) { #ifdef _SCAR_INTERNET_H_ g_hNetConnection = 0; #endif // load our settins char *pTmp; if(GetModuleFileName(hModule, g_sConfigName, MAX_PATH) == 0) return FALSE; pTmp = strstr(g_sConfigName, "Mod.dll"); if(pTmp) *pTmp = 0; strcat(g_sConfigName, ".module"); char sDllName[256]; GetPrivateProfileString("corsix", "DllName", "NoMod", sDllName, 255, g_sConfigName); GetPrivateProfileString("corsix", "Engine", "", g_sEngineFolder, 255, g_sConfigName); // go go go new CModInterface(sDllName); g_bHaxxApplied = false; g_bReLaunch = false; } else if(ul_reason_for_call == DLL_PROCESS_DETACH) { #ifdef _SCAR_INTERNET_H_ if(g_hNetConnection != 0) InternetCloseHandle(g_hNetConnection); #endif delete CModInterface::GetSingleton(); if(g_bReLaunch) { PROCESS_INFORMATION piApp; STARTUPINFO suiStartUp = {0}; suiStartUp.cb = sizeof(STARTUPINFO); char sDllName[MAX_PATH + 1]; GetModuleFileName(hModule, sDllName, MAX_PATH); char *pTmp; pTmp = strstr(sDllName, "Mod.dll"); if(pTmp) *pTmp = 0; strcat(sDllName, "Mod.exe"); BOOL bMadeProcess = CreateProcess(sDllName,GetCommandLine(),NULL,NULL,TRUE,NORMAL_PRIORITY_CLASS,NULL, NULL,&suiStartUp, &piApp); } } return TRUE; } #ifdef _MANAGED #pragma managed(pop) #endif