Changeset 4440 for trunk/src


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

console, pe loader + FormatMessage fixes

Location:
trunk/src/kernel32
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/KERNEL32.DEF

    r4363 r4440  
    1 ; $Id: KERNEL32.DEF,v 1.87 2000-10-02 13:05:36 phaller Exp $
     1; $Id: KERNEL32.DEF,v 1.88 2000-10-06 11:04:00 sandervl Exp $
    22
    33;Created by BLAST for IBM's compiler
     
    10331033    _RegisterPe2LxDll@12                                          @1209
    10341034
    1035     _CreateWin32PeLdrExe@12                                       @1236
     1035    _CreateWin32PeLdrExe@16                                       @1236
    10361036
    10371037    _RegisterLxExe@8                                              @1237
  • trunk/src/kernel32/message.cpp

    r3804 r4440  
    1 /* $Id: message.cpp,v 1.11 2000-07-06 21:18:43 sandervl Exp $ */
     1/* $Id: message.cpp,v 1.12 2000-10-06 11:04:01 sandervl Exp $ */
    22
    33/*
     
    174174     INT   bufsize;
    175175
     176//SvL/MN: VACPPWIN uses message ids > 64k!!
     177#ifndef __WIN32OS2__
    176178     dwMessageId &= 0xFFFF;
     179#endif
    177180     bufsize=LoadMessageA((HMODULE)lpSource,dwMessageId,dwLanguageId,NULL,100);
    178181     if (bufsize)
     
    405408      INT   bufsize;
    406409
     410//SvL/MN: VACPPWIN uses message ids > 64k!!
     411#ifndef __WIN32OS2__
    407412      dwMessageId &= 0xFFFF;
     413#endif
    408414      bufsize=LoadMessageA((HMODULE)lpSource,dwMessageId,dwLanguageId,NULL,100);
    409415      if (bufsize)
  • trunk/src/kernel32/pefile.cpp

    r3759 r4440  
    1 /* $Id: pefile.cpp,v 1.9 2000-06-26 13:21:34 sandervl Exp $ */
     1/* $Id: pefile.cpp,v 1.10 2000-10-06 11:04:01 sandervl Exp $ */
    22
    33/*
     
    104104//******************************************************************************
    105105//******************************************************************************
    106 BOOL IsImportSection(LPVOID lpFile, PIMAGE_SECTION_HEADER psh)
     106BOOL IsSectionType(LPVOID lpFile, PIMAGE_SECTION_HEADER psh, DWORD dwIMAGE_DIRECTORY)
    107107{
    108108  PIMAGE_OPTIONAL_HEADER poh = (PIMAGE_OPTIONAL_HEADER)OPTHEADEROFF (lpFile);
     
    110110  DWORD                  ImageDirVA;
    111111
    112     ImageDirVA = poh->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
     112    ImageDirVA = poh->DataDirectory[dwIMAGE_DIRECTORY].VirtualAddress;
    113113
    114114    if(psh->VirtualAddress <= ImageDirVA &&
    115        psh->VirtualAddress + max(psh->Misc.VirtualSize,psh->SizeOfRawData) > ImageDirVA &&
    116        strcmp(psh->Name, ".idata") == 0)
     115       psh->VirtualAddress + max(psh->Misc.VirtualSize,psh->SizeOfRawData) > ImageDirVA)
    117116    {
    118117        return TRUE;
  • trunk/src/kernel32/winexebase.cpp

    r4244 r4440  
    1 /* $Id: winexebase.cpp,v 1.11 2000-09-12 19:01:59 sandervl Exp $ */
     1/* $Id: winexebase.cpp,v 1.12 2000-10-06 11:04:01 sandervl Exp $ */
    22
    33/*
     
    115115  //Set default FPU control word (no exceptions); same as in NT
    116116  _control87(0x27F, 0xFFF);
     117#if 0
    117118  ULONG Size = 16, Attr;
    118119  rc = DosQueryMem((PVOID) (entryPoint), &Size, &Attr);
    119120  dprintf(("Start exe; Attr = %x, rc = %d", Attr, rc));
     121#else
     122  dprintf(("Start exe"));
     123#endif
    120124  rc = ((WIN32EXEENTRY)entryPoint)(NULL);
    121125  RestoreOS2TIB();
  • 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}
  • trunk/src/kernel32/winexepeldr.h

    r3375 r4440  
    1 /* $Id: winexepeldr.h,v 1.2 2000-04-14 22:35:28 sandervl Exp $ */
     1/* $Id: winexepeldr.h,v 1.3 2000-10-06 11:04:02 sandervl Exp $ */
    22
    33/*
     
    1616#include <winimagepeldr.h>
    1717
    18 typedef BOOL (* WIN32API WIN32CTOR)(char *, char *, ULONG);
     18typedef BOOL (* WIN32API WIN32CTOR)(char *, char *, ULONG, BOOL);
    1919
    2020//Class for executables run by the ring 3 PE loader
     
    2222{
    2323public:
    24         Win32PeLdrExe(char *szFileName);
     24        Win32PeLdrExe(char *szFileName, BOOL fConsoleApp);
    2525virtual ~Win32PeLdrExe();
    2626
  • trunk/src/kernel32/winimagebase.cpp

    r4279 r4440  
    1 /* $Id: winimagebase.cpp,v 1.27 2000-09-18 19:26:16 sandervl Exp $ */
     1/* $Id: winimagebase.cpp,v 1.28 2000-10-06 11:04:02 sandervl Exp $ */
    22
    33/*
     
    8585void Win32ImageBase::setFullPath(char *name)
    8686{
    87   dassert(name, ("setFullPath, name == NULL"));
     87  if(fullpath)
     88        free(fullpath);
    8889  fullpath = (char *)malloc(strlen(name)+1);
    89   dassert(fullpath, ("setFullPath, fullpath == NULL"));
    9090  strcpy(fullpath, name);
    9191}
  • trunk/src/kernel32/winimagepeldr.cpp

    r4422 r4440  
    1 /* $Id: winimagepeldr.cpp,v 1.55 2000-10-04 19:36:25 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.56 2000-10-06 11:04:02 sandervl Exp $ */
    22
    33/*
     
    287287   if ((psh = (PIMAGE_SECTION_HEADER)SECTIONHDROFF (win32file)) != NULL) {
    288288    dprintf((LOG, "*************************PE SECTIONS START**************************" ));
    289     for (i=0; i<nSections; i++) {
     289    for (i=0; i<nSections; i++)
     290    {
    290291        dprintf((LOG, "Raw data size:        %x", psh[i].SizeOfRawData ));
    291292        dprintf((LOG, "Virtual Address:      %x", psh[i].VirtualAddress ));
     
    295296        dprintf((LOG, "Pointer to raw data:  %x", psh[i].PointerToRawData ));
    296297        dprintf((LOG, "Section flags:        %x\n\n", psh[i].Characteristics ));
    297         if(strcmp(psh[i].Name, ".reloc") == 0) {
     298
     299        if(IsSectionType(win32file, &psh[i], IMAGE_DIRECTORY_ENTRY_BASERELOC))
     300        {
    298301            dprintf((LOG, ".reloc" ));
    299302            addSection(SECTION_RELOC, psh[i].PointerToRawData,
     
    302305            continue;
    303306        }
    304         if(strcmp(psh[i].Name, ".edata") == 0) {
     307        if(IsSectionType(win32file, &psh[i], IMAGE_DIRECTORY_ENTRY_EXPORT))
     308        {
    305309            dprintf((LOG, ".edata" ));
    306310            addSection(SECTION_EXPORT, psh[i].PointerToRawData,
     
    309313            continue;
    310314        }
    311         if(strcmp(psh[i].Name, ".rsrc") == 0) {
     315        if(IsSectionType(win32file, &psh[i], IMAGE_DIRECTORY_ENTRY_RESOURCE))
     316        {
    312317            dprintf((LOG, ".rsrc" ));
    313318            addSection(SECTION_RESOURCE, psh[i].PointerToRawData,
     
    316321            continue;
    317322        }
    318         if(strcmp(psh[i].Name, ".tls") == 0)
     323        if(IsSectionType(win32file, &psh[i], IMAGE_DIRECTORY_ENTRY_TLS))
    319324        {
    320325                tlsDir = (IMAGE_TLS_DIRECTORY *)ImageDirectoryOffset(win32file, IMAGE_DIRECTORY_ENTRY_TLS);
     
    326331                continue;
    327332        }
    328 
    329         if(strcmp(psh[i].Name, ".debug") == 0) {
     333        if(IsSectionType(win32file, &psh[i], IMAGE_DIRECTORY_ENTRY_DEBUG)) 
     334        {
    330335            dprintf((LOG, ".rdebug" ));
    331336            addSection(SECTION_DEBUG,  psh[i].PointerToRawData,
     
    334339            continue;
    335340        }
    336         if(IsImportSection(win32file, &psh[i]))
     341        if(IsSectionType(win32file, &psh[i], IMAGE_DIRECTORY_ENTRY_IMPORT))
    337342        {
    338           int type = SECTION_IMPORT;
     343            int type = SECTION_IMPORT;
     344
    339345            dprintf((LOG, "Import Data Section" ));
    340346            if(psh[i].Characteristics & IMAGE_SCN_CNT_CODE) {
     
    348354        }
    349355
    350             //KSO Sun 1998-08-09: Borland does not alway set the CODE flag for its "CODE" section
    351         if(  psh[i].Characteristics & IMAGE_SCN_CNT_CODE ||
    352             (psh[i].Characteristics & IMAGE_SCN_MEM_EXECUTE &&
    353                !(psh[i].Characteristics & (IMAGE_SCN_CNT_UNINITIALIZED_DATA | IMAGE_SCN_CNT_INITIALIZED_DATA))) //KSO: make sure its not marked as a datasection
     356        //KSO Sun 1998-08-09: Borland does not alway set the CODE flag for its "CODE" section
     357        if(psh[i].Characteristics & IMAGE_SCN_CNT_CODE ||
     358           (psh[i].Characteristics & IMAGE_SCN_MEM_EXECUTE &&
     359           !(psh[i].Characteristics & (IMAGE_SCN_CNT_UNINITIALIZED_DATA | IMAGE_SCN_CNT_INITIALIZED_DATA))) //KSO: make sure its not marked as a datasection
    354360            )
    355361        {
     
    394400  }
    395401  else {
    396         if(GetSectionHdrByName (win32file, &sh, ".rsrc"))
     402        if(GetSectionHdrByImageDir(win32file, IMAGE_DIRECTORY_ENTRY_RESOURCE, &sh))
    397403        {
    398404            addSection(SECTION_RESOURCE, sh.PointerToRawData,
     
    539545  //PH: get pResRootDir pointer correct first, since processImports may
    540546  //    implicitly call functions depending on it.
    541   if(GetSectionHdrByName (win32file, &sh, ".rsrc")) {
     547  if(GetSectionHdrByImageDir(win32file, IMAGE_DIRECTORY_ENTRY_RESOURCE, &sh)) {
    542548        //get offset in resource object of directory entry
    543549        pResRootDir = (PIMAGE_RESOURCE_DIRECTORY)(sh.VirtualAddress + realBaseAddress);
Note: See TracChangeset for help on using the changeset viewer.