Skip to content

Commit

Permalink
fix MsRdpEx_LaunchProcess when launch path has spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
awakecoding committed Nov 28, 2023
1 parent 2840924 commit ca0393b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions dll/RdpProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class CMsRdpExProcess : public IMsRdpExProcess
{
HRESULT hr = S_OK;
uint32_t appPathId = 0;
char szCommandLine[2048];
char* lpCommandLine = NULL;
STARTUPINFOA* startupInfo;
PROCESS_INFORMATION* processInfo;
const char* axNameEnv = NULL;
Expand Down Expand Up @@ -279,15 +279,14 @@ class CMsRdpExProcess : public IMsRdpExProcess
lpApplicationName = MsRdpEx_GetPath(appPathId);
}

ZeroMemory(szCommandLine, sizeof(szCommandLine));
char quotedAppFilePath[MSRDPEX_MAX_PATH];
sprintf_s(quotedAppFilePath, MSRDPEX_MAX_PATH - 1, "\"%s\"", lpApplicationName);

for (int i = 1; i < argc; i++)
{
strncat(szCommandLine, argv[i], sizeof(szCommandLine) - 1);
strncat(szCommandLine, " ", sizeof(szCommandLine) - 1);
}
char* argv0 = argv[0];
argv[0] = (char*) quotedAppFilePath;
lpCommandLine = MsRdpEx_StringJoin(argv, argc, ' ');
argv[0] = argv0;

char* lpCommandLine = szCommandLine;
DWORD dwCreationFlags = CREATE_DEFAULT_ERROR_MODE | CREATE_SUSPENDED;
const char* lpDllName = MsRdpEx_GetPath(MSRDPEX_LIBRARY_PATH);

Expand All @@ -306,6 +305,8 @@ class CMsRdpExProcess : public IMsRdpExProcess
NULL /* pfCreateProcessW */
);

free(lpCommandLine);

if (!fSuccess) {
hr = E_FAIL;
goto exit;
Expand Down

0 comments on commit ca0393b

Please sign in to comment.