Uploaded image for project: 'Core ReactOS'
  1. Core ReactOS
  2. CORE-19482

Unable to get command line info from PEB

    XMLWordPrintable

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()
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            katayama_hirofumi_mz Katayama Hirofumi MZ
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: