Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
Description
Related to https://github.com/reactos/reactos/pull/6617 .
shell32_apitest ShellExecuteEx testcase is failing to get command line info from PEB.
Here is the code:
#include <pstypes.h>
|
#include <psfuncs.h>
|
|
static LPWSTR
|
getCommandLineFromProcess(HANDLE hProcess)
|
{
|
PEB peb;
|
PROCESS_BASIC_INFORMATION info;
|
RTL_USER_PROCESS_PARAMETERS Params;
|
|
NtQueryInformationProcess(hProcess, ProcessBasicInformation, &info, sizeof(info), NULL);
|
ReadProcessMemory(hProcess, info.PebBaseAddress, &peb, sizeof(peb), NULL);
|
ReadProcessMemory(hProcess, peb.ProcessParameters, &Params, sizeof(Params), NULL);
|
|
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;
|
|
return pszBuffer; // needs free()
|
}
|