Changeset 704
- Timestamp:
- Aug 26, 1999, 9:48:14 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/peldr/pe.cpp ¶
r544 r704 1 /* $Id: pe.cpp,v 1. 6 1999-08-18 12:24:32sandervl Exp $ */1 /* $Id: pe.cpp,v 1.7 1999-08-26 07:48:14 sandervl Exp $ */ 2 2 3 3 /* … … 29 29 #include <wprocess.h> 30 30 #include "pe.h" 31 #include "exceptions.h" 32 #include "..\kernel32\exceptutil.h" 31 33 32 34 char INFO_BANNER[] = "Usage: PE winexe commandline"; … … 51 53 ULONG idWindow, 52 54 ULONG flStyle); 55 typedef void (* KRNL32EXCEPTPROC) (void *exceptframe); 53 56 54 57 WININITIALIZEPROC MyWinInitialize = 0; … … 57 60 WINDESTROYMSGQUEUEPROC MyWinDestroyMsgQueue = 0; 58 61 WINMESSAGEBOXPROC MyWinMessageBox = 0; 62 KRNL32EXCEPTPROC Krnl32SetExceptionHandler = 0; 63 KRNL32EXCEPTPROC Krnl32UnsetExceptionHandler = 0; 59 64 60 65 WIN32CTOR CreateWin32Exe = 0; … … 62 67 int main(int argc, char *argv[]) 63 68 { 64 HAB hab ; /* PM anchor block handle */65 HMQ hmq ; /* Message queue handle */69 HAB hab = 0; /* PM anchor block handle */ 70 HMQ hmq = 0; /* Message queue handle */ 66 71 char *szCmdLine; 67 72 char exeName[CCHMAXPATH]; … … 70 75 Win32Exe *WinExe; 71 76 APIRET rc; 72 HMODULE hmodPMWin, hmodKernel32; 77 HMODULE hmodPMWin = 0, hmodKernel32 = 0; 78 WINEXCEPTION_FRAME exceptFrame; 79 ULONG curdisk, curlogdisk, flength = CCHMAXPATH; 73 80 74 81 rc = DosLoadModule(exeName, sizeof(exeName), "PMWIN.DLL", &hmodPMWin); … … 81 88 rc = DosLoadModule(exeName, sizeof(exeName), "KERNEL32.DLL", &hmodKernel32); 82 89 rc = DosQueryProcAddr(hmodKernel32, 0, "CreateWin32Exe", (PFN *)&CreateWin32Exe); 90 rc = DosQueryProcAddr(hmodKernel32, 0, "OS2SetExceptionHandler", (PFN *)&Krnl32SetExceptionHandler); 91 rc = DosQueryProcAddr(hmodKernel32, 0, "OS2UnsetExceptionHandler", (PFN *)&Krnl32UnsetExceptionHandler); 83 92 84 93 if ((hab = MyWinInitialize(0)) == 0L) /* Initialize PM */ 85 return(1);94 goto fail; 86 95 87 96 hmq = MyWinCreateMsgQueue(hab, 0); … … 89 98 if(argc < 2) { 90 99 MyWinMessageBox(HWND_DESKTOP, NULL, INFO_BANNER, szErrorTitle, 0, MB_OK | MB_ERROR | MB_MOVEABLE); 91 return(0);100 goto fail; 92 101 } 93 102 … … 100 109 if(WinExe == NULL) { 101 110 MyWinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szMemErrorMsg, szErrorTitle, 0, MB_OK | MB_ERROR | MB_MOVEABLE); 102 return(1);111 goto fail; 103 112 } 104 113 rc = DosGetInfoBlocks(&ptib, &ppib); … … 106 115 MyWinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szInteralErrorMsg, szErrorTitle, 0, MB_OK | MB_ERROR | MB_MOVEABLE); 107 116 delete WinExe; 108 return(1);117 goto fail; 109 118 } 110 119 szCmdLine = ppib->pib_pchcmd; … … 115 124 while(*szCmdLine == ' ' && *szCmdLine ) //skip spaces 116 125 szCmdLine++; 117 118 ULONG curdisk, curlogdisk, flength = CCHMAXPATH;119 126 120 127 DosQueryCurrentDisk(&curdisk, &curlogdisk); … … 128 135 WinExe->setCommandLine(szCmdLine); 129 136 137 Krnl32SetExceptionHandler(&exceptFrame); 130 138 if(WinExe->init(ReserveMem()) == FALSE) { 131 139 delete WinExe; 132 return(1);140 goto fail; 133 141 } 142 Krnl32UnsetExceptionHandler(&exceptFrame); 134 143 WinExe->start(); 135 144 … … 141 150 DosFreeModule(hmodPMWin); 142 151 DosFreeModule(hmodKernel32); 143 return(0); 152 return 0; 153 154 fail: 155 if(hmq) MyWinDestroyMsgQueue( hmq ); /* Tidy up... */ 156 if(hab) MyWinTerminate( hab ); /* Terminate the application */ 157 158 if(hmodPMWin) DosFreeModule(hmodPMWin); 159 if(hmodKernel32) DosFreeModule(hmodKernel32); 160 return(1); 144 161 } 145 162 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.