Changeset 9536


Ignore:
Timestamp:
Dec 20, 2002, 12:38:55 PM (22 years ago)
Author:
sandervl
Message:

Error handling changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/peldr/pe.cpp

    r8911 r9536  
    1 /* $Id: pe.cpp,v 1.34 2002-07-23 13:26:10 sandervl Exp $ */
     1/* $Id: pe.cpp,v 1.35 2002-12-20 11:38:55 sandervl Exp $ */
    22
    33/*
     
    3232#include <wprocess.h>
    3333#include <win\peexe.h>
     34#include <odinpe.h>
    3435#include "pe.h"
    3536
    3637char INFO_BANNER[]      = "Usage: PE winexe commandline";
    3738char szErrorTitle[]     = "Odin";
    38 char szLoadErrorMsg[]   = "Can't load executable";
     39char szLoadErrorMsg[]   = "Can't load executable %s";
    3940char szFileNotFound[]   = "File not found.";
    4041char szFileErrorMsg[]   = "File IO error";
    4142char szPEErrorMsg[]     = "Not a valid win32 exe. (perhaps 16 bits windows)";
    42 char szCPUErrorMsg[]    = "Executable doesn't run on x86 machines";
    43 char szExeErrorMsg[]    = "File isn't an executable";
    44 char szInteralErrorMsg[]= "Internal Error";
     43char szCPUErrorMsg[]    = "%s doesn't run on x86 machines";
     44char szExeErrorMsg[]    = "%s isn't an executable";
     45char szInteralErrorMsg[]= "Internal Error while loading %s";
    4546char szNoKernel32Msg[]  = "Can't load/find kernel32.dll (rc=%d, module %s)";
    4647char szDosInfoBlocks[]  = "DosInfoBlocks failed!";
     48char szErrorExports[]   = "Unable to process exports of %s";
     49char szErrorMemory[]    = "Memory allocation failure while loading %s";
     50char szErrorImports[]   = "Failure to load \"%s\" due to bad or missing %s";
     51
    4752char szErrDosStartSession[] = "Failed to start win16 session (rc=%d)";
    4853
     
    6974KRNL32EXCEPTPROC       Krnl32UnsetExceptionHandler = 0;
    7075
    71 //should be the same as in ..\kernel32\winexepeldr.h
    72 typedef BOOL (* WIN32API WIN32CTOR)(char *, char *, char *, ULONG, ULONG, BOOL, BOOL);
    7376
    7477WIN32CTOR   CreateWin32Exe       = 0;
     
    258261        goto fail;
    259262  }
    260   rc = DosQueryProcAddr(hmodKernel32, 0, "_CreateWin32PeLdrExe@28", (PFN *)&CreateWin32Exe);
     263  rc = DosQueryProcAddr(hmodKernel32, 0, "_CreateWin32PeLdrExe@36", (PFN *)&CreateWin32Exe);
    261264
    262265#ifdef COMMAND_LINE_VERSION
     
    265268  fVioConsole = FALSE;
    266269#endif
    267   if(CreateWin32Exe(exeName, win32cmdline, peoptions, reservedMemory, 0, fConsoleApp, fVioConsole) == FALSE) {
     270  rc = CreateWin32Exe(exeName, win32cmdline, peoptions, reservedMemory, 0,
     271                      fConsoleApp, fVioConsole, errorMod, sizeof(errorMod));
     272  if(rc != LDRERROR_SUCCESS)
     273  {
     274        char szErrorMsg[512];
     275
     276        switch(rc) {
     277        case LDRERROR_INVALID_MODULE:
     278            sprintf(szErrorMsg, szLoadErrorMsg, exeName);
     279            break;
     280        case LDRERROR_INVALID_CPU:
     281            sprintf(pszErrorMsg, szCPUErrorMsg, exeName);
     282            break;
     283        case LDRERROR_FILE_SYSTEM:           
     284            sprintf(szErrorMsg, szExeErrorMsg, exeName);
     285            break;
     286        case LDRERROR_MEMORY:
     287            sprintf(szErrorMsg, szErrorMemory, exeName);
     288            break;
     289        case LDRERROR_EXPORTS:
     290            sprintf(szErrorMsg, szErrorExports, exeName);
     291            break;
     292        case LDRERROR_IMPORTS:
     293            sprintf(szErrorMsg, szErrorImports, exeName, errorMod);
     294            break;
     295        case LDRERROR_INVALID_SECTION:
     296        default:
     297            sprintf(szErrorMsg, szInteralErrorMsg, exeName);
     298            break;
     299        }
     300
     301        WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szErrorMsg, szErrorTitle, 0, MB_OK | MB_ERROR | MB_MOVEABLE);
    268302        goto fail;
    269303  }
Note: See TracChangeset for help on using the changeset viewer.