aboutsummaryrefslogtreecommitdiff
path: root/GameInjector/dllmain.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-08-27 04:34:40 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-08-27 04:34:40 +0100
commit83ea828342e59af290857b0854ba768d9412e92c (patch)
tree4f81ef6a5ef6db94448df52425d3fce2a98bd460 /GameInjector/dllmain.cpp
parentf8cdd53561dc5bb37b5387f9ad3b966de8aa2a58 (diff)
downloadNorthstarLauncher-83ea828342e59af290857b0854ba768d9412e92c.tar.gz
NorthstarLauncher-83ea828342e59af290857b0854ba768d9412e92c.zip
fix launcher steam support (hopefully) through disabling steam overlay
Diffstat (limited to 'GameInjector/dllmain.cpp')
-rw-r--r--GameInjector/dllmain.cpp90
1 files changed, 70 insertions, 20 deletions
diff --git a/GameInjector/dllmain.cpp b/GameInjector/dllmain.cpp
index 69ea748a..2ab0415c 100644
--- a/GameInjector/dllmain.cpp
+++ b/GameInjector/dllmain.cpp
@@ -10,6 +10,30 @@
#define DLL_NAME L"Northstar.dll"
+class TempReadWrite
+{
+private:
+ DWORD m_origProtection;
+ void* m_ptr;
+
+public:
+ TempReadWrite(void* ptr)
+ {
+ m_ptr = ptr;
+ MEMORY_BASIC_INFORMATION mbi;
+ VirtualQuery(m_ptr, &mbi, sizeof(mbi));
+ VirtualProtect(mbi.BaseAddress, mbi.RegionSize, PAGE_EXECUTE_READWRITE, &mbi.Protect);
+ m_origProtection = mbi.Protect;
+ }
+
+ ~TempReadWrite()
+ {
+ MEMORY_BASIC_INFORMATION mbi;
+ VirtualQuery(m_ptr, &mbi, sizeof(mbi));
+ VirtualProtect(mbi.BaseAddress, mbi.RegionSize, m_origProtection, &mbi.Protect);
+ }
+};
+
typedef BOOL(WINAPI *CreateProcessWType)(
LPCWSTR lpApplicationName,
LPWSTR lpCommandLine,
@@ -43,18 +67,10 @@ BOOL WINAPI CreateProcessWHook(
bool isTitanfallProcess = false;
// 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;
+ isTitanfallProcess = wcsstr(lpCommandLine, L"Titanfall2\\Titanfall2.exe");
- // steam will start processes suspended
+ // steam will start processes suspended (since we don't actually inject into steam directly this isn't required anymore, but whatever)
bool alreadySuspended = dwCreationFlags & CREATE_SUSPENDED;
// suspend process on creation so we can hook
@@ -73,22 +89,45 @@ BOOL WINAPI CreateProcessWHook(
PROCESS_INFORMATION pi;
memset(&pi, 0, sizeof(pi));
- std::stringstream argStr;
- argStr << lpProcessInformation->dwProcessId;
- argStr << " ";
- argStr << lpProcessInformation->dwThreadId;
-
- 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);
+ // check if we're launching EASteamProxy for steam users, or just launching tf2 directly for origin users
+ // note: atm we fully disable steam integration in origin when we inject, return to this later
+ if (!wcsstr(lpApplicationName, L"Origin\\EASteamProxy.exe"))
+ {
+ std::stringstream argStr;
+ argStr << lpProcessInformation->dwProcessId;
+ argStr << " ";
+ argStr << lpProcessInformation->dwThreadId;
+
+ 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);
+ }
+ else
+ {
+ // for easteamproxy, we have to inject ourself into it
+ // todo: atm we fully disable steam integration in origin when we inject, do this properly later
+ }
// this doesn't seem to work super well
//if (!alreadySuspended)
ResumeThread(lpProcessInformation->hThread);
+ // cleanup
MH_DisableHook(&CreateProcessW);
MH_RemoveHook(&CreateProcessW);
MH_Uninitialize();
+ // allow steam integrations to work again
+ void* ptr = (char*)GetModuleHandleA("OriginClient.dll") + 0x2A83FA;
+ TempReadWrite rw(ptr);
+
+ *((char*)ptr) = 0x0F; // jmp => je
+ *((char*)ptr + 1) = 0x84;
+ *((char*)ptr + 2) = 0xE5;
+ *((char*)ptr + 3) = 0x01;
+ *((char*)ptr + 4) = 0x00;
+ *((char*)ptr + 5) = 0x00;
+
+ // is this undefined behaviour? idk
FreeLibrary(ownHModule);
}
@@ -111,8 +150,8 @@ BOOL APIENTRY DllMain(HMODULE hModule,
break;
}
- AllocConsole();
- freopen("CONOUT$", "w", stdout);
+ //AllocConsole();
+ //freopen("CONOUT$", "w", stdout);
ownHModule = hModule;
char ownDllPath[MAX_PATH];
@@ -127,6 +166,17 @@ BOOL APIENTRY DllMain(HMODULE hModule,
MH_CreateHook(&CreateProcessW, &CreateProcessWHook, reinterpret_cast<LPVOID*>(&CreateProcessWOriginal));
MH_EnableHook(&CreateProcessW);
+ // TEMP: temporarily disable steam stuff because it's a huge pain
+ // change conditional jump to EASteamProxy stuff in launchStep2 to never hit EASteamProxy launch
+ void* ptr = (char*)GetModuleHandleA("OriginClient.dll") + 0x2A83FA;
+ TempReadWrite rw(ptr);
+
+ *((char*)ptr) = 0xE9; // je => jmp
+ *((char*)ptr + 1) = 0xE6;
+ *((char*)ptr + 2) = 0x01;
+ *((char*)ptr + 3) = 0x00;
+ *((char*)ptr + 4) = 0x00;
+
return TRUE;
}