static void init() { if(count==0) { CoInitialize(NULL); AfxEnableControlContainer(); { Aregistry *reg=new Aregistry(FLASHOCXKEY, Aregistry::CLASSES_ROOT); bool b=false; char path[1024]; memset(path, 0, sizeof(path)); b=reg->read("", path, sizeof(path)); delete(reg); if(b) hFlashOcx=LoadLibrary(path); else hFlashOcx=LoadLibrary("C:\\WINDOWS\\system32\\Macromed\\Flash\\flash.ocx"); if(hFlashOcx) HookAPICalls(&USER32hook, hFlashOcx, true); } } count++; }
// CBT Hook-style injection. BOOL APIENTRY DllMain( HINSTANCE hModule, DWORD fdwReason, LPVOID lpReserved ) { if (fdwReason == DLL_PROCESS_ATTACH) // When initializing.... { hDLL = hModule; // We don't need thread notifications for what we're doing. Thus, get // rid of them, thereby eliminating some of the overhead of this DLL DisableThreadLibraryCalls(hModule); // Only hook the APIs if this is the right process. GetModuleFileName(GetModuleHandle(NULL), targetExe, sizeof(targetExe)); PathStripPath(targetExe); /*if(std::string(targetExe) == "GitHub.exe") { OutputDebugString("Ignoring process: "); OutputDebugString(targetExe); OutputDebugString("\n"); return TRUE; }*/ GetModuleFileName(GetModuleHandle(NULL), targetPath, sizeof(targetPath)); targetPathString = std::string(targetPath); targetPathString = targetPathString.substr(0, targetPathString.find_last_of("\\/") + 1); OutputDebugString("HIJACKDLL checking process: "); OutputDebugString(targetExe); OutputDebugString("\n"); #ifndef x64 ParsePaths(); #endif ProxyHelper helper = ProxyHelper(); if (helper.HasProfile(targetExe, targetPathString.c_str())) { #ifndef x64 //Need to check that the d3d9.dll is actually in the game folder - If it is, then we don't need to hook API calls //using the methods below as d3d9 will just be loaded by the game's executable if (!fileExists(targetPathString + "D3D9.dll")) { if (HookAPICalls(&D3DHook)) { OutputDebugString("HookAPICalls(D3D): TRUE\n"); } else if(HookAPICalls(&KernelHook)) { OutputDebugString("HookAPICalls(Kernel): TRUE\n"); } else { OutputDebugString("HookAPICalls(Both): FALSE\n"); } SetDllDirectory(dllDir); } else { OutputDebugString(std::string("D3D9.dll found in game directory (" + targetPathString + ") - Bypassing API injection").c_str()); } #endif } else { OutputDebugString((std::string("Game profile not found for: ") + targetExe).c_str()); } } return TRUE; }