aboutsummaryrefslogtreecommitdiff
path: root/GameInjector/dllmain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'GameInjector/dllmain.cpp')
-rw-r--r--GameInjector/dllmain.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/GameInjector/dllmain.cpp b/GameInjector/dllmain.cpp
index c18495be..38e262cc 100644
--- a/GameInjector/dllmain.cpp
+++ b/GameInjector/dllmain.cpp
@@ -44,14 +44,21 @@ BOOL WINAPI CreateProcessWHook(
// origin doesn't use lpApplicationName
if (lpApplicationName)
+ {
+ std::wcout << lpApplicationName << std::endl;
isTitanfallProcess = wcsstr(lpApplicationName, L"Titanfall2\\Titanfall2.exe");
+ }
else
+ {
+ std::wcout << lpCommandLine << std::endl;
isTitanfallProcess = wcsstr(lpCommandLine, L"Titanfall2\\Titanfall2.exe");
+ }
- std::wcout << lpCommandLine << std::endl;
+ // steam will start processes suspended
+ bool alreadySuspended = dwCreationFlags & CREATE_SUSPENDED;
// suspend process on creation so we can hook
- if (isTitanfallProcess)
+ if (isTitanfallProcess && !alreadySuspended)
dwCreationFlags |= CREATE_SUSPENDED;
BOOL ret = CreateProcessWOriginal(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
@@ -73,7 +80,9 @@ BOOL WINAPI CreateProcessWHook(
CreateProcessA((tf2DirPath / "InjectionProxy64.exe").string().c_str(), (LPSTR)(argStr.str().c_str()), 0, 0, false, 0, 0, tf2DirPath.string().c_str(), (LPSTARTUPINFOA)&si, &pi);
WaitForSingleObject(pi.hThread, INFINITE);
- ResumeThread(lpProcessInformation->hProcess);
+
+ if (!alreadySuspended)
+ ResumeThread(lpProcessInformation->hThread);
MH_RemoveHook(&CreateProcessW);
FreeLibrary(ownHModule);
@@ -98,6 +107,9 @@ BOOL APIENTRY DllMain(HMODULE hModule,
break;
}
+ //AllocConsole();
+ //freopen("CONOUT$", "w", stdout);
+
ownHModule = hModule;
char ownDllPath[MAX_PATH];
GetModuleFileNameA(hModule, ownDllPath, MAX_PATH);