[SHELL32_APITEST] ShellExecuteEx: Fix command line checker (#6618)

Follow-up to #6617.
JIRA issue: CORE-19482
Add traces for error checking.
This commit is contained in:
Katayama Hirofumi MZ 2024-03-15 23:46:14 +09:00 committed by GitHub
parent cbad6cef24
commit 4854a1d7b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -111,16 +111,37 @@ getCommandLineFromProcess(HANDLE hProcess)
PEB peb;
PROCESS_BASIC_INFORMATION info;
RTL_USER_PROCESS_PARAMETERS Params;
NTSTATUS Status;
BOOL ret;
Status = NtQueryInformationProcess(hProcess, ProcessBasicInformation, &info, sizeof(info), NULL);
ok_ntstatus(Status, STATUS_SUCCESS);
ret = ReadProcessMemory(hProcess, info.PebBaseAddress, &peb, sizeof(peb), NULL);
if (!ret)
trace("ReadProcessMemory failed (%ld)\n", GetLastError());
NtQueryInformationProcess(hProcess, ProcessBasicInformation, &info, sizeof(info), NULL);
ReadProcessMemory(hProcess, info.PebBaseAddress, &peb, sizeof(peb), NULL);
ReadProcessMemory(hProcess, peb.ProcessParameters, &Params, sizeof(Params), NULL);
if (!ret)
trace("ReadProcessMemory failed (%ld)\n", GetLastError());
LPWSTR cmdline = Params.CommandLine.Buffer;
SIZE_T cchCmdLine = Params.CommandLine.Length;
LPWSTR pszBuffer = (LPWSTR)calloc(cchCmdLine + 1, sizeof(WCHAR));
ReadProcessMemory(hProcess, cmdline, pszBuffer, cchCmdLine, NULL);
pszBuffer[cchCmdLine] = UNICODE_NULL;
if (!cmdline)
trace("!cmdline\n");
SIZE_T cbCmdLine = Params.CommandLine.Length;
if (!cbCmdLine)
trace("!cbCmdLine\n");
LPWSTR pszBuffer = (LPWSTR)calloc(cbCmdLine + sizeof(WCHAR), 1);
if (!pszBuffer)
trace("!pszBuffer\n");
ret = ReadProcessMemory(hProcess, cmdline, pszBuffer, cbCmdLine, NULL);
if (!ret)
trace("ReadProcessMemory failed (%ld)\n", GetLastError());
pszBuffer[cbCmdLine / sizeof(WCHAR)] = UNICODE_NULL;
return pszBuffer; // needs free()
}
@ -366,14 +387,12 @@ static void TEST_End(void)
static void test_properties()
{
WCHAR Buffer[MAX_PATH * 4];
HRESULT hrCoInit = CoInitialize(NULL);
WCHAR Buffer[MAX_PATH * 4];
GetModuleFileNameW(NULL, Buffer, _countof(Buffer));
SHELLEXECUTEINFOW info = { sizeof(info) };
info.cbSize = sizeof(SHELLEXECUTEINFOW);
SHELLEXECUTEINFOW info = { sizeof(info) };
info.fMask = SEE_MASK_INVOKEIDLIST | SEE_MASK_FLAG_NO_UI;
info.lpVerb = L"properties";
info.lpFile = Buffer;