From 26d090e4ae6153d1f7b49f8776c2923345dd810f Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Mon, 27 Sep 2021 00:25:36 +0100 Subject: read cmdline args from file, disable origin on dedi --- LauncherInjector/main.cpp | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'LauncherInjector') diff --git a/LauncherInjector/main.cpp b/LauncherInjector/main.cpp index e392b532..597e72d3 100644 --- a/LauncherInjector/main.cpp +++ b/LauncherInjector/main.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace fs = std::filesystem; @@ -35,7 +36,7 @@ DWORD GetProcessByName(std::wstring processName) #define PROCESS_NAME L"Titanfall2-unpacked.exe" #define DLL_NAME L"Northstar.dll" -int main() { +int main(int argc, char* argv[]) { if (!fs::exists(PROCESS_NAME)) { MessageBoxA(0, "Titanfall2-unpacked.exe not found! Please launch from your titanfall 2 directory and ensure you have Northstar installed correctly!", "", MB_OK); @@ -48,7 +49,12 @@ int main() { return 1; } - if (!GetProcessByName(L"Origin.exe")) + bool isdedi = false; + for (int i = 0; i < argc; i++) + if (!strcmp(argv[i], "-dedicated")) + isdedi = true; + + if (!GetProcessByName(L"Origin.exe") && !isdedi) { // unpacked exe will crash if origin isn't open on launch, so launch it // get origin path from registry, code here is reversed from OriginSDK.dll @@ -78,13 +84,36 @@ int main() { Sleep(200); } + // get cmdline args from file + std::wstring args; + std::ifstream cmdlineArgFile; + + if (!isdedi) + cmdlineArgFile = std::ifstream("ns_startup_args.txt"); + else + cmdlineArgFile = std::ifstream("ns_startup_args_dedi.txt"); + + if (cmdlineArgFile) + { + std::stringstream argBuffer; + argBuffer << cmdlineArgFile.rdbuf(); + cmdlineArgFile.close(); + + std::string str = argBuffer.str(); + args.append(std::wstring(str.begin(), str.end())); + } + + if (isdedi) + // copy -dedicated into args if we have it in commandline args + args.append(L" -dedicated"); + STARTUPINFO startupInfo; PROCESS_INFORMATION processInfo; memset(&startupInfo, 0, sizeof(startupInfo)); memset(&processInfo, 0, sizeof(processInfo)); - CreateProcessW(PROCESS_NAME, (wchar_t*)L" -multiple -novid", NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &startupInfo, &processInfo); + CreateProcessW(PROCESS_NAME, (LPWSTR)args.c_str(), NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &startupInfo, &processInfo); HMODULE hKernel32 = GetModuleHandleW(L"kernel32.dll"); LPTHREAD_START_ROUTINE pLoadLibraryW = (LPTHREAD_START_ROUTINE)GetProcAddress(hKernel32, "LoadLibraryW"); -- cgit v1.2.3