fix command line arguments for alterware-launcher.exe
This commit is contained in:
parent
cf4ae75cfa
commit
01b8737488
@ -249,7 +249,7 @@ namespace Components
|
|||||||
const std::string command = binary == "iw4x-sp.exe" ? "iw4x-sp" : "iw4x";
|
const std::string command = binary == "iw4x-sp.exe" ? "iw4x-sp" : "iw4x";
|
||||||
|
|
||||||
SetEnvironmentVariableA("MW2_INSTALL", workingDir.data());
|
SetEnvironmentVariableA("MW2_INSTALL", workingDir.data());
|
||||||
Utils::Library::LaunchProcess(binary, std::format("{} --pass \"{}\"", command, GetCommandLineA()), workingDir);
|
Utils::Library::LaunchProcess(Utils::String::Convert(binary), std::format(L"{} --pass \"{}\"", Utils::String::Convert(command), Utils::GetLaunchParameters()), workingDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(naked) void QuickPatch::SND_GetAliasOffset_Stub()
|
__declspec(naked) void QuickPatch::SND_GetAliasOffset_Stub()
|
||||||
|
@ -102,22 +102,22 @@ namespace Utils
|
|||||||
this->module_ = nullptr;
|
this->module_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Library::LaunchProcess(const std::string& process, const std::string& commandLine, const std::string& currentDir)
|
void Library::LaunchProcess(const std::wstring& process, const std::wstring& commandLine, const std::filesystem::path& currentDir)
|
||||||
{
|
{
|
||||||
STARTUPINFOA startupInfo;
|
STARTUPINFOW startup_info;
|
||||||
PROCESS_INFORMATION processInfo;
|
PROCESS_INFORMATION process_info;
|
||||||
|
|
||||||
ZeroMemory(&startupInfo, sizeof(startupInfo));
|
ZeroMemory(&startup_info, sizeof(startup_info));
|
||||||
ZeroMemory(&processInfo, sizeof(processInfo));
|
ZeroMemory(&process_info, sizeof(process_info));
|
||||||
startupInfo.cb = sizeof(startupInfo);
|
startup_info.cb = sizeof(startup_info);
|
||||||
|
|
||||||
CreateProcessA(process.data(), const_cast<char*>(commandLine.data()), nullptr,
|
CreateProcessW(process.data(), const_cast<wchar_t*>(commandLine.data()), nullptr,
|
||||||
nullptr, false, NULL, nullptr, currentDir.data(),
|
nullptr, false, NULL, nullptr, currentDir.wstring().data(),
|
||||||
&startupInfo, &processInfo);
|
&startup_info, &process_info);
|
||||||
|
|
||||||
if (processInfo.hThread && processInfo.hThread != INVALID_HANDLE_VALUE)
|
if (process_info.hThread && process_info.hThread != INVALID_HANDLE_VALUE)
|
||||||
CloseHandle(processInfo.hThread);
|
CloseHandle(process_info.hThread);
|
||||||
if (processInfo.hProcess && processInfo.hProcess != INVALID_HANDLE_VALUE)
|
if (process_info.hProcess && process_info.hProcess != INVALID_HANDLE_VALUE)
|
||||||
CloseHandle(processInfo.hProcess);
|
CloseHandle(process_info.hProcess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ namespace Utils
|
|||||||
return T();
|
return T();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LaunchProcess(const std::string& process, const std::string& commandLine, const std::string& currentDir);
|
static void LaunchProcess(const std::wstring& process, const std::wstring& commandLine, const std::filesystem::path& currentDir);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HMODULE module_;
|
HMODULE module_;
|
||||||
|
@ -163,6 +163,28 @@ namespace Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::wstring GetLaunchParameters()
|
||||||
|
{
|
||||||
|
std::wstring args;
|
||||||
|
|
||||||
|
int numArgs;
|
||||||
|
auto* const argv = CommandLineToArgvW(GetCommandLineW(), &numArgs);
|
||||||
|
|
||||||
|
if (argv)
|
||||||
|
{
|
||||||
|
for (auto i = 1; i < numArgs; ++i)
|
||||||
|
{
|
||||||
|
std::wstring arg(argv[i]);
|
||||||
|
args.append(arg);
|
||||||
|
args.append(L" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalFree(argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
HMODULE GetNTDLL()
|
HMODULE GetNTDLL()
|
||||||
{
|
{
|
||||||
return GetModuleHandleA("ntdll.dll");
|
return GetModuleHandleA("ntdll.dll");
|
||||||
|
@ -24,6 +24,8 @@ namespace Utils
|
|||||||
|
|
||||||
void OpenUrl(const std::string& url);
|
void OpenUrl(const std::string& url);
|
||||||
|
|
||||||
|
std::wstring GetLaunchParameters();
|
||||||
|
|
||||||
bool HasIntersection(unsigned int base1, unsigned int len1, unsigned int base2, unsigned int len2);
|
bool HasIntersection(unsigned int base1, unsigned int len1, unsigned int base2, unsigned int len2);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
Loading…
Reference in New Issue
Block a user