Ignore:
Timestamp:
Oct 1, 2000, 2:05:57 PM (25 years ago)
Author:
sandervl
Message:

cmd line fix for pe loader

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/wprocess.cpp

    r4268 r4351  
    1 /* $Id: wprocess.cpp,v 1.96 2000-09-16 00:09:59 bird Exp $ */
     1/* $Id: wprocess.cpp,v 1.97 2000-10-01 12:05:57 sandervl Exp $ */
    22
    33/*
     
    10851085     *
    10861086     */
    1087     if (pszPeExe)
    1088     {
    1089         PSZ     pszArg2;                /* Pointer to into pib_pchcmd to the second argument. */
    1090 
    1091         /** @sketch Method (1):
    1092          * First we'll have to determin the size of the commandline.
    1093          *
    1094          * If the commandline string don't have any arguments we'll fail.
    1095          * Skip argument pointer to the second argument (ie. argv[2]).
    1096          */
    1097         if (pib_pchcmd == NULL                                  /* CPREF states that if may be NULL. */
    1098             || pib_pchcmd[cch = strlen(pib_pchcmd) + 1] == '\0' /* No arguments */
    1099             )
    1100         {
    1101             dprintf(("KERNEL32: InitCommandLine(%p): No arguments!\n", pszPeExe));
    1102             return ERROR_BAD_ARGUMENTS;
    1103         }
    1104 
    1105         psz2 = pib_pchcmd + cch;        /* skip exe name (PE.EXE) */
    1106         while (*psz2 == ' ')
    1107             psz2++;
    1108         fQuotes = *psz2 == '"';
    1109         if (fQuotes)
    1110         {
    1111             psz2++;
    1112             psz = strchr(psz2, '"');
    1113         }
    1114         else
    1115             psz = strchr(psz2, ' ');
    1116         if (psz != NULL)
    1117         {
    1118             psz2 += psz - psz2 + 1;     /* + 1: space or quote. */
    1119             while (*psz2 == ' ')        /* skip blanks after argv[1]. */
    1120                 psz2++;
    1121             pszArg2 = psz2;
    1122         }
    1123         else
    1124             pszArg2 = psz2 += strlen(psz2) + 1; /* no arguments, skip to next string. */
    1125 
    1126         /** @sketch
    1127          * Use passed in executable name.
    1128          * Check if the exe filename needs to be put in quotes.
    1129          * Determin the length of the executable name including quotes and '\0'-terminator.
    1130          * Count the length of the arguments. (We here count's all argument strings.)
    1131          */
    1132         #ifdef DEBUG
    1133         if (pszPeExe[0] == '\0')
    1134         {
    1135             dprintf(("KERNEL32: InitCommandLine(%p): pszPeExe was empty string\n", pszPeExe));
    1136             return ERROR_BAD_ARGUMENTS;
    1137         }
    1138         #endif
    1139 
    1140         fQuotes = strchr(pszPeExe, ' ') != NULL;
    1141         cch = strlen(pszPeExe) + fQuotes*2 + 1;
    1142 
    1143         while (*psz2 != '\0')
    1144         {
    1145             register int cchTmp = strlen(psz2) + 1; /* + 1 is for terminator (psz2) and space (cch). */
    1146             psz2 += cchTmp;
    1147             cch += cchTmp;
    1148         }
    1149 
     1087    if(pszPeExe)
     1088    {
    11501089        /** @sketch
    11511090         * Allocate memory for the commandline.
     
    11541093         *  Add arguments.
    11551094         */
     1095        cch = strlen(pszPeExe)+1;
    11561096        pszCmdLineA = psz = (PSZ)malloc(cch);
    11571097        if (psz == NULL)
     
    11611101        }
    11621102
    1163         if (fQuotes)
    1164             *psz++ = '"';
    1165         strcpy(psz, pszPeExe);
    1166         psz += strlen(psz);
    1167         if (fQuotes)
    1168         {
    1169             *psz++ = '"';
    1170             *psz = '\0';
    1171         }
    1172 
    1173         psz2 = pszArg2;
    1174         while (*psz2 != '\0')
    1175         {
    1176             register int cchTmp = strlen(psz2) + 1; /* + 1 is for terminator (psz). */
    1177             *psz++ = ' ';           /* add space */
    1178             memcpy(psz, psz2, cchTmp);
    1179             psz2 += cchTmp;
    1180             psz += cchTmp - 1;
    1181         }
    11821103        rc = NO_ERROR;
    11831104    }
Note: See TracChangeset for help on using the changeset viewer.