Changeset 5448 for trunk/src


Ignore:
Timestamp:
Apr 3, 2001, 12:51:58 AM (24 years ago)
Author:
sandervl
Message:

check executable type in CreateProcess and use PEC for VIO and PE for GUI apps

Location:
trunk/src/kernel32
Files:
4 edited

Legend:

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

    r4523 r5448  
    1 /* $Id: winimagebase.cpp,v 1.30 2000-10-23 13:42:44 sandervl Exp $ */
     1/* $Id: winimagebase.cpp,v 1.31 2001-04-02 22:51:58 sandervl Exp $ */
    22
    33/*
     
    204204//the Characteristics member of the file header structure)
    205205//******************************************************************************
    206 ULONG Win32ImageBase::isPEImage(char *szFileName, DWORD *Characteristics)
     206ULONG Win32ImageBase::isPEImage(char *szFileName, DWORD *Characteristics, DWORD *subsystem)
    207207{
    208208 char   filename[CCHMAXPATH];
     
    210210 HFILE  dllfile;
    211211 IMAGE_FILE_HEADER     fh;
     212 IMAGE_OPTIONAL_HEADER oh;
    212213 HFILE  win32handle;
    213214 ULONG  ulAction       = 0;      /* Action taken by DosOpen */
     
    262263        return ERROR_INVALID_EXE_SIGNATURE_W;
    263264  }
    264   ULONG hdrsize = pdoshdr->e_lfanew + SIZE_OF_NT_SIGNATURE + sizeof(IMAGE_FILE_HEADER);
     265  ULONG hdrsize = pdoshdr->e_lfanew + SIZE_OF_NT_SIGNATURE + sizeof(IMAGE_FILE_HEADER) + sizeof(IMAGE_OPTIONAL_HEADER);
    265266  free(pdoshdr);
    266267
     
    281282        goto failure;
    282283  }
     284  if(GetPEOptionalHeader (win32file, &oh) == FALSE) {
     285        goto failure;
     286  }
    283287
    284288  if(!(fh.Characteristics & IMAGE_FILE_EXECUTABLE_IMAGE)) {//not valid
     
    294298  if(Characteristics) {
    295299        *Characteristics = fh.Characteristics;
     300  }
     301  if(subsystem) {
     302        *subsystem = oh.Subsystem;
    296303  }
    297304  DosClose(win32handle);
  • trunk/src/kernel32/winimagebase.h

    r4474 r5448  
    1 /* $Id: winimagebase.h,v 1.17 2000-10-10 17:14:07 sandervl Exp $ */
     1/* $Id: winimagebase.h,v 1.18 2001-04-02 22:51:58 sandervl Exp $ */
    22
    33/*
     
    9797//returns ERROR_SUCCESS or error code (Characteristics will contain
    9898//the Characteristics member of the file header structure)
    99 static  ULONG isPEImage(char *szFileName, DWORD *Characteristics = NULL);
     99static  ULONG isPEImage(char *szFileName, DWORD *Characteristics, DWORD *subsystem = NULL);
    100100static  BOOL  findDll(const char *pszFileName, char *pszFullName,
    101101                      int cchFullName, const char *pszAltPath = NULL);
  • trunk/src/kernel32/winimagepeldr.cpp

    r5436 r5448  
    1 /* $Id: winimagepeldr.cpp,v 1.72 2001-04-02 09:52:26 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.73 2001-04-02 22:51:58 sandervl Exp $ */
    22
    33/*
     
    14691469    }
    14701470
    1471     if(isPEImage(modname) != ERROR_SUCCESS_W)
     1471    if(isPEImage(modname, NULL) != ERROR_SUCCESS_W)
    14721472    {//LX image, so let OS/2 do all the work for us
    14731473        APIRET rc;
  • trunk/src/kernel32/wprocess.cpp

    r5354 r5448  
    1 /* $Id: wprocess.cpp,v 1.116 2001-03-22 18:16:41 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.117 2001-04-02 22:51:58 sandervl Exp $ */
    22
    33/*
     
    16511651    }
    16521652
    1653     dprintf(("KERNEL32:  CreateProcess %s\n", cmdline));
     1653    dprintf(("KERNEL32: CreateProcess %s\n", cmdline));
     1654   
     1655    DWORD Characteristics, SubSystem;
     1656    if(Win32ImageBase::isPEImage(exename, &Characteristics, &SubSystem)) {
     1657        dprintf(("CreateProcess: not a PE executable!!"));
     1658        SetLastError(ERROR_BAD_EXE_FORMAT);
     1659        return FALSE;
     1660    }
     1661
     1662    char *lpszPE;
     1663    if(SubSystem == IMAGE_SUBSYSTEM_WINDOWS_CUI) {
     1664         lpszPE = "PEC.EXE";
     1665    }
     1666    else lpszPE = "PE.EXE";
    16541667
    16551668    //SvL: Allright. Before we call O32_CreateProcess, we must take care of
     
    16591672
    16601673        newcmdline = (char *)malloc(strlen(lpCurrentDirectory) + strlen(cmdline) + 32);
    1661         sprintf(newcmdline, "PE.EXE /OPT:[CURDIR=%s] %s", lpCurrentDirectory, cmdline);
     1674        sprintf(newcmdline, "%s /OPT:[CURDIR=%s] %s", lpszPE, lpCurrentDirectory, cmdline);
    16621675        free(cmdline);
    16631676        cmdline = newcmdline;
     
    16671680
    16681681        newcmdline = (char *)malloc(strlen(cmdline) + 16);
    1669         sprintf(newcmdline, "PE.EXE %s", cmdline);
     1682        sprintf(newcmdline, "%s %s", lpszPE, cmdline);
    16701683        free(cmdline);
    16711684        cmdline = newcmdline;
    16721685    }
    1673     rc = O32_CreateProcess("PE.EXE", (LPCSTR)cmdline,lpProcessAttributes,
     1686    rc = O32_CreateProcess(lpszPE, (LPCSTR)cmdline,lpProcessAttributes,
    16741687                         lpThreadAttributes, bInheritHandles, dwCreationFlags,
    16751688                         lpEnvironment, lpCurrentDirectory, lpStartupInfo,
Note: See TracChangeset for help on using the changeset viewer.