mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
[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:
parent
cbad6cef24
commit
4854a1d7b6
1 changed files with 29 additions and 10 deletions
|
@ -111,16 +111,37 @@ getCommandLineFromProcess(HANDLE hProcess)
|
||||||
PEB peb;
|
PEB peb;
|
||||||
PROCESS_BASIC_INFORMATION info;
|
PROCESS_BASIC_INFORMATION info;
|
||||||
RTL_USER_PROCESS_PARAMETERS Params;
|
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);
|
ReadProcessMemory(hProcess, peb.ProcessParameters, &Params, sizeof(Params), NULL);
|
||||||
|
if (!ret)
|
||||||
|
trace("ReadProcessMemory failed (%ld)\n", GetLastError());
|
||||||
|
|
||||||
LPWSTR cmdline = Params.CommandLine.Buffer;
|
LPWSTR cmdline = Params.CommandLine.Buffer;
|
||||||
SIZE_T cchCmdLine = Params.CommandLine.Length;
|
if (!cmdline)
|
||||||
LPWSTR pszBuffer = (LPWSTR)calloc(cchCmdLine + 1, sizeof(WCHAR));
|
trace("!cmdline\n");
|
||||||
ReadProcessMemory(hProcess, cmdline, pszBuffer, cchCmdLine, NULL);
|
|
||||||
pszBuffer[cchCmdLine] = UNICODE_NULL;
|
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()
|
return pszBuffer; // needs free()
|
||||||
}
|
}
|
||||||
|
@ -366,14 +387,12 @@ static void TEST_End(void)
|
||||||
|
|
||||||
static void test_properties()
|
static void test_properties()
|
||||||
{
|
{
|
||||||
WCHAR Buffer[MAX_PATH * 4];
|
|
||||||
|
|
||||||
HRESULT hrCoInit = CoInitialize(NULL);
|
HRESULT hrCoInit = CoInitialize(NULL);
|
||||||
|
|
||||||
|
WCHAR Buffer[MAX_PATH * 4];
|
||||||
GetModuleFileNameW(NULL, Buffer, _countof(Buffer));
|
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.fMask = SEE_MASK_INVOKEIDLIST | SEE_MASK_FLAG_NO_UI;
|
||||||
info.lpVerb = L"properties";
|
info.lpVerb = L"properties";
|
||||||
info.lpFile = Buffer;
|
info.lpFile = Buffer;
|
||||||
|
|
Loading…
Reference in a new issue