Beispiel #1
0
BOOL WINAPI DllMain(HMODULE hDll, DWORD dwReason, PVOID pvReserved) {	
	if(dwReason == DLL_PROCESS_ATTACH) {
		OutputDebugString("GeDoSaTo: startup");
		DisableThreadLibraryCalls(hDll);
	}
	if(dwReason == DLL_PROCESS_DETACH) {
		OutputDebugString(format("GeDoSaTo: Exiting from %s", getExeFileName()).c_str());
		if(g_active) {
			OutputDebugString("GeDoSaTo: was active");
			Settings::get().shutdown();
			endDetour();
			SDLOG(-1, "===== end =\n");
			fclose(g_oFile);
		}
	}
    return true;
}
Beispiel #2
0
BOOL WINAPI DllMain(HMODULE hDll, DWORD dwReason, PVOID pvReserved) {	
	if(dwReason == DLL_PROCESS_ATTACH) {
		OutputDebugString("GeDoSaTo: startup");

		// read install location from registry
		getInstallDirectory();
		OutputDebugString("GeDoSaTo: Got install dir");

		// don't attach to processes on the blacklist / not on the whitelist
		if(getUseBlacklist() ? onList(getExeFileName(), "blacklist.txt") : !onList(getExeFileName(), "whitelist.txt")) {
			OutputDebugString("GeDoSaTo: blacklisted / not whitelisted");
			if(getExeFileName() == "GeDoSaToTool") return true;
			return true;
		}
		g_active = true;
		OutputDebugString("GeDoSaTo: Active");
		
		// initialize log
		string logFn = format("logs\\%s_%s.log", getExeFileName().c_str(), getTimeString().c_str());
		std::replace(logFn.begin(), logFn.end(), ':', '-');
		std::replace(logFn.begin(), logFn.end(), ' ', '_');
		logFn = getInstalledFileName(logFn);
		fopen_s(&g_oFile, logFn.c_str(), "w");
		if(!g_oFile) OutputDebugString(format("GeDoSaTo: Error opening log fn %s", logFn.c_str()).c_str());
		else OutputDebugString(format("GeDoSaTo: Opening log fn %s, handle: %p", logFn.c_str(), g_oFile).c_str());
		OutputDebugString("GeDoSaTo: Log file initialized, let that take over");

		// startup
		sdlogtime(-1);
		SDLOG(-1, "===== start "INTERCEPTOR_NAME" %s = fn: %s\n", GeDoSaToVersion(), getExeFileName().c_str());
		SDLOG(-1, "===== installation directory: %s\n", getInstallDirectory().c_str());

		// load settings
		Settings::get().load();
		Settings::get().report();
		 
		KeyActions::get().load();
		KeyActions::get().report();

		if(!Settings::get().getPreventSteamOverlay() && Settings::get().getLoadSteamOverlayEarly()) {
			SDLOG(2, "Attempting to pre-load Steam overlay dll.\n");
			LoadLibrary("gameoverlayrenderer.dll");
		}

		if(Settings::get().getLoadD3DEarly()) {
			SDLOG(2, "Early d3d loading.\n");
			auto dllname = getSystemDllName("d3d9.dll");
			LoadLibrary(dllname.c_str());
		}

		// detour
		startDetour();
		return true;
	}
	if(dwReason == DLL_PROCESS_DETACH && g_active) {
		Settings::get().shutdown();
		endDetour();
		SDLOG(-1, "===== end =\n");
		fclose(g_oFile);
	}
    return false;
}