From 3349c066554c9fc1f6051f09b44e89c87c80ecf8 Mon Sep 17 00:00:00 2001 From: F1F7Y Date: Wed, 26 Jul 2023 22:47:04 +0200 Subject: [PATCH 1/3] Remove GetCommandLineA hook --- NorthstarDLL/core/hooks.cpp | 61 ------------------------------------- 1 file changed, 61 deletions(-) diff --git a/NorthstarDLL/core/hooks.cpp b/NorthstarDLL/core/hooks.cpp index 4363c0e22..0c5ed5af2 100644 --- a/NorthstarDLL/core/hooks.cpp +++ b/NorthstarDLL/core/hooks.cpp @@ -218,67 +218,6 @@ void MakeHook(LPVOID pTarget, LPVOID pDetour, void* ppOriginal, const char* pFun spdlog::error("MH_CreateHook failed for function {}", pStrippedFuncName); } -AUTOHOOK_ABSOLUTEADDR(_GetCommandLineA, (LPVOID)GetCommandLineA, LPSTR, WINAPI, ()) -{ - static char* cmdlineModified; - static char* cmdlineOrg; - - if (cmdlineOrg == nullptr || cmdlineModified == nullptr) - { - cmdlineOrg = _GetCommandLineA(); - bool isDedi = strstr(cmdlineOrg, "-dedicated"); // well, this one has to be a real argument - bool ignoreStartupArgs = strstr(cmdlineOrg, "-nostartupargs"); - - std::string args; - std::ifstream cmdlineArgFile; - - // it looks like CommandLine() prioritizes parameters apprearing first, so we want the real commandline to take priority - // not to mention that cmdlineOrg starts with the EXE path - args.append(cmdlineOrg); - args.append(" "); - - // append those from the file - - if (!ignoreStartupArgs) - { - - cmdlineArgFile = std::ifstream(!isDedi ? "ns_startup_args.txt" : "ns_startup_args_dedi.txt"); - - if (cmdlineArgFile) - { - std::stringstream argBuffer; - argBuffer << cmdlineArgFile.rdbuf(); - cmdlineArgFile.close(); - - // if some other command line option includes "-northstar" in the future then you have to refactor this check to check with - // both either space after or ending with - if (!isDedi && argBuffer.str().find("-northstar") != std::string::npos) - MessageBoxA( - NULL, - "The \"-northstar\" command line option is NOT supposed to go into ns_startup_args.txt file!\n\nThis option is " - "supposed to go into Origin/Steam game launch options, and then you are supposed to launch the original " - "Titanfall2.exe " - "rather than NorthstarLauncher.exe to make use of it.", - "Northstar Warning", - MB_ICONWARNING); - - args.append(argBuffer.str()); - } - } - - auto len = args.length(); - cmdlineModified = new char[len + 1]; - if (!cmdlineModified) - { - spdlog::error("malloc failed for command line"); - return cmdlineOrg; - } - memcpy(cmdlineModified, args.c_str(), len + 1); - } - - return cmdlineModified; -} - std::vector calledTags; void CallLoadLibraryACallbacks(LPCSTR lpLibFileName, HMODULE moduleAddress) { From a9bf004fde5b9d5afd9bafc99aa43d3dcc5a5c45 Mon Sep 17 00:00:00 2001 From: F1F7Y Date: Wed, 26 Jul 2023 22:50:32 +0200 Subject: [PATCH 2/3] Add warning --- NorthstarLauncher/main.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/NorthstarLauncher/main.cpp b/NorthstarLauncher/main.cpp index dd3b68f5c..c0e8852d7 100644 --- a/NorthstarLauncher/main.cpp +++ b/NorthstarLauncher/main.cpp @@ -388,19 +388,13 @@ int main(int argc, char* argv[]) { PrependPath(); - if (!fs::exists("ns_startup_args.txt")) + if (fs::exists("ns_startup_args.txt")) { - std::ofstream file("ns_startup_args.txt"); - std::string defaultArgs = "-multiple"; - file.write(defaultArgs.c_str(), defaultArgs.length()); - file.close(); + std::cout << "[*] WARNING: 'ns_startup_args.txt' is no longer supported!" << std::endl; } - if (!fs::exists("ns_startup_args_dedi.txt")) + if (fs::exists("ns_startup_args_dedi.txt")) { - std::ofstream file("ns_startup_args_dedi.txt"); - std::string defaultArgs = "+setplaylist private_match"; - file.write(defaultArgs.c_str(), defaultArgs.length()); - file.close(); + std::cout << "[*] WARNING: 'ns_startup_args_dedi.txt' is no longer supported!" << std::endl; } std::cout << "[*] Loading tier0.dll" << std::endl; From 2dc2cfc31692312b4482ee38c4835a3f8e0e5648 Mon Sep 17 00:00:00 2001 From: F1F7Y Date: Wed, 26 Jul 2023 23:14:02 +0200 Subject: [PATCH 3/3] Add note --- NorthstarLauncher/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/NorthstarLauncher/main.cpp b/NorthstarLauncher/main.cpp index c0e8852d7..3dcad3966 100644 --- a/NorthstarLauncher/main.cpp +++ b/NorthstarLauncher/main.cpp @@ -388,6 +388,7 @@ int main(int argc, char* argv[]) { PrependPath(); + // NOTE [Fifty]: Functionality removed in https://github.com/R2Northstar/NorthstarLauncher/pull/517 if (fs::exists("ns_startup_args.txt")) { std::cout << "[*] WARNING: 'ns_startup_args.txt' is no longer supported!" << std::endl;