Ignore:
Timestamp:
Oct 6, 2000, 1:04:02 PM (25 years ago)
Author:
sandervl
Message:

console, pe loader + FormatMessage fixes

File:
1 edited

Legend:

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

    r4351 r4440  
    1 /* $Id: winexepeldr.cpp,v 1.11 2000-10-01 12:05:57 sandervl Exp $ */
     1/* $Id: winexepeldr.cpp,v 1.12 2000-10-06 11:04:01 sandervl Exp $ */
    22
    33/*
     
    4747//Called by ring 3 pe loader to create win32 executable
    4848//******************************************************************************
    49 BOOL WIN32API CreateWin32PeLdrExe(char *szFileName, char *szCmdLine, ULONG reservedMem)
     49BOOL WIN32API CreateWin32PeLdrExe(char *szFileName, char *szCmdLine,
     50                                  ULONG reservedMem, BOOL fConsoleApp)
    5051{
    5152 APIRET  rc;
     
    5859  fPeLoader = TRUE;
    5960
    60   WinExe = new Win32PeLdrExe(szFileName);
     61  WinExe = new Win32PeLdrExe(szFileName, fConsoleApp);
    6162
    6263  rc = DosGetInfoBlocks(&ptib, &ppib);
     
    8182
    8283  if(getenv("WIN32_IOPL2")) {
    83     io_init1();
     84        io_init1();
    8485  }
    85 
    86   OS2SetExceptionHandler(&exceptFrame);
    87   if(WinExe->init(reservedMem) == FALSE) {
    88         if(szErrorModule[0] != 0) {
    89           char szErrorMsg[128];
    90 
    91                 sprintf(szErrorMsg, "Can't execute %s due to bad or missing %s", OSLibStripPath(szFileName), szErrorModule);
    92                 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szErrorMsg, szErrorTitle, 0, MB_OK | MB_ERROR | MB_MOVEABLE);
    93         }
    94         delete WinExe;
    95         return FALSE;
    96   }
    97 
    98   OS2UnsetExceptionHandler(&exceptFrame);
    99   if(WinExe->isConsoleApp()) {
     86  //Init console before loading executable as dlls might want to print
     87  //something on the console while being loaded
     88  if(WinExe->isConsoleApp())
     89  {
    10090        dprintf(("Console application!\n"));
    10191
     
    10494                dprintf(("KERNEL32:Win32Image:Init ConsoleInit failed with %u.\n", rc));
    10595  }
     96
     97  OS2SetExceptionHandler(&exceptFrame);
     98  if(WinExe->init(reservedMem) == FALSE)
     99  {
     100        if(szErrorModule[0] != 0) {
     101                char szErrorMsg[128];
     102
     103                sprintf(szErrorMsg, "Can't execute %s due to bad or missing %s", OSLibStripPath(szFileName), szErrorModule);
     104                WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szErrorMsg, szErrorTitle, 0, MB_OK | MB_ERROR | MB_MOVEABLE);
     105        }
     106        delete WinExe;
     107        OS2UnsetExceptionHandler(&exceptFrame);
     108        return FALSE;
     109  }
     110  OS2UnsetExceptionHandler(&exceptFrame);
    106111
    107112  WinExe->start();
     
    113118//******************************************************************************
    114119//******************************************************************************
    115 Win32PeLdrExe::Win32PeLdrExe(char *szFileName) :
     120Win32PeLdrExe::Win32PeLdrExe(char *szFileName, BOOL fConsoleApp) :
    116121                   Win32ImageBase(-1),
    117122                   Win32ExeBase(-1),
     
    119124{
    120125  dprintf(("Win32PeLdrExe ctor: %s", szFileName));
     126  this->fConsoleApp = fConsoleApp;
     127
     128  //SvL: set temporary full path here as console init needs it
     129  setFullPath(szFileName);
    121130}
    122131//******************************************************************************
     
    132141
    133142  rc = Win32PeLdrImage::init(reservedMem);
    134   fConsoleApp = (oh.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI);
    135143  return rc;
    136144}
Note: See TracChangeset for help on using the changeset viewer.