Ignore:
Timestamp:
Oct 6, 2000, 5:16:07 PM (25 years ago)
Author:
sandervl
Message:

changes for setting current dir of new process

File:
1 edited

Legend:

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

    r4422 r4445  
    1 /* $Id: wprocess.cpp,v 1.101 2000-10-04 19:36:26 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.102 2000-10-06 15:16:07 sandervl Exp $ */
    22
    33/*
     
    15631563            }
    15641564            cmdline = (char *)malloc(strlen(lpApplicationName)+strlen(lpCommandLine) + 16);
    1565             sprintf(cmdline, "PE.EXE %s %s", lpApplicationName, lpCommandLine);
     1565            sprintf(cmdline, "%s %s", lpApplicationName, lpCommandLine);
    15661566         }
    15671567         else {
    15681568            cmdline = (char *)malloc(strlen(lpApplicationName) + 16);
    1569             sprintf(cmdline, "PE.EXE %s", lpApplicationName);
     1569            sprintf(cmdline, "%s", lpApplicationName);
    15701570        }
    15711571    }
    15721572    else {
    15731573        cmdline = (char *)malloc(strlen(lpCommandLine) + 16);
    1574         sprintf(cmdline, "PE.EXE %s", lpCommandLine);
     1574        sprintf(cmdline, "%s", lpCommandLine);
    15751575    }
    15761576    char szAppName[255];
    15771577    char *exename = szAppName;
    1578     strncpy(szAppName, &cmdline[7], sizeof(szAppName)); //skip pe.exe
     1578    strncpy(szAppName, cmdline, sizeof(szAppName));
    15791579    szAppName[254] = 0;
    15801580    if(*exename == '"') {
     
    16001600    }   
    16011601    dprintf(("KERNEL32:  CreateProcess %s\n", cmdline));
     1602
     1603    //SvL: Allright. Before we call O32_CreateProcess, we must take care of
     1604    //     lpCurrentDirectory ourselves. (Open32 ignores it!)
     1605    if(lpCurrentDirectory) {
     1606        char *newcmdline;
     1607
     1608        newcmdline = (char *)malloc(strlen(lpCurrentDirectory) + strlen(cmdline) + 32);
     1609        sprintf(newcmdline, "PE.EXE /OPT:[CURDIR=%s] %s", lpCurrentDirectory, cmdline);
     1610        free(cmdline);
     1611        cmdline = newcmdline;
     1612    }
     1613    else {
     1614        char *newcmdline;
     1615
     1616        newcmdline = (char *)malloc(strlen(cmdline) + 16);
     1617        sprintf(newcmdline, "PE.EXE %s", cmdline);
     1618        free(cmdline);
     1619        cmdline = newcmdline;
     1620    }
    16021621    rc = O32_CreateProcess("PE.EXE", (LPCSTR)cmdline,lpProcessAttributes,
    16031622                         lpThreadAttributes, bInheritHandles, dwCreationFlags,
    16041623                         lpEnvironment, lpCurrentDirectory, lpStartupInfo,
    16051624                         lpProcessInfo);
    1606     if(rc == TRUE) {
     1625    if(rc == TRUE)
     1626    {
    16071627      if (dwCreationFlags & DEBUG_PROCESS && pThreadDB != NULL)
    16081628      {
Note: See TracChangeset for help on using the changeset viewer.