[SETUP:REACTOS][SYSSETUP] Fix Shift-F10 cmd.exe invocation.

Pressing Shift-F10 to open cmd.exe when the setup program runs from
a different current directory than System32, now works correctly.

Use the 2nd CreateProcessW() `lpCommandLine` parameter, instead of the
1st parameter `lpApplicationName`, so as to use default path search.
The command-line buffer given to the 2nd-parameter can be temporarily
modified by CreateProcessW(), thus use an on-stack buffer.

https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw#parameters
This commit is contained in:
Hermès Bélusca-Maïto 2024-10-30 12:46:17 +01:00
parent d7f1a784a8
commit 3b800165b0
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 7 additions and 7 deletions

View file

@ -2762,7 +2762,6 @@ HotkeyThread(LPVOID Parameter)
DPRINT("HotkeyThread start\n"); DPRINT("HotkeyThread start\n");
hotkey = GlobalAddAtomW(L"Setup Shift+F10 Hotkey"); hotkey = GlobalAddAtomW(L"Setup Shift+F10 Hotkey");
if (!RegisterHotKey(NULL, hotkey, MOD_SHIFT, VK_F10)) if (!RegisterHotKey(NULL, hotkey, MOD_SHIFT, VK_F10))
DPRINT1("RegisterHotKey failed with %lu\n", GetLastError()); DPRINT1("RegisterHotKey failed with %lu\n", GetLastError());
@ -2770,11 +2769,12 @@ HotkeyThread(LPVOID Parameter)
{ {
if (msg.hwnd == NULL && msg.message == WM_HOTKEY && msg.wParam == hotkey) if (msg.hwnd == NULL && msg.message == WM_HOTKEY && msg.wParam == hotkey)
{ {
WCHAR CmdLine[] = L"cmd.exe"; // CreateProcess can modify this buffer.
STARTUPINFOW si = { sizeof(si) }; STARTUPINFOW si = { sizeof(si) };
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
if (CreateProcessW(L"cmd.exe", if (CreateProcessW(NULL,
NULL, CmdLine,
NULL, NULL,
NULL, NULL,
FALSE, FALSE,

View file

@ -1049,19 +1049,19 @@ HotkeyThread(LPVOID Parameter)
DPRINT("HotkeyThread start\n"); DPRINT("HotkeyThread start\n");
hotkey = GlobalAddAtomW(L"Setup Shift+F10 Hotkey"); hotkey = GlobalAddAtomW(L"Setup Shift+F10 Hotkey");
if (!RegisterHotKey(NULL, hotkey, MOD_SHIFT, VK_F10)) if (!RegisterHotKey(NULL, hotkey, MOD_SHIFT, VK_F10))
DPRINT1("RegisterHotKey failed with %lu\n", GetLastError()); DPRINT1("RegisterHotKey failed with %lu\n", GetLastError());
while (GetMessage(&msg, NULL, 0, 0)) while (GetMessageW(&msg, NULL, 0, 0))
{ {
if (msg.hwnd == NULL && msg.message == WM_HOTKEY && msg.wParam == hotkey) if (msg.hwnd == NULL && msg.message == WM_HOTKEY && msg.wParam == hotkey)
{ {
WCHAR CmdLine[] = L"cmd.exe"; // CreateProcess can modify this buffer.
STARTUPINFOW si = { sizeof(si) }; STARTUPINFOW si = { sizeof(si) };
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
if (CreateProcessW(L"cmd.exe", if (CreateProcessW(NULL,
NULL, CmdLine,
NULL, NULL,
NULL, NULL,
FALSE, FALSE,