Changeset 1325 for trunk/src/kernel32
- Timestamp:
- Oct 17, 1999, 3:49:09 AM (26 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/windllpe2lx.cpp
r1274 r1325 1 /* $Id: windllpe2lx.cpp,v 1. 2 1999-10-14 01:37:55bird Exp $ */1 /* $Id: windllpe2lx.cpp,v 1.3 1999-10-17 01:49:08 bird Exp $ */ 2 2 3 3 /* … … 88 88 89 89 /* Try create pe2lx dll object. */ 90 try 90 pWinMod = new Win32Pe2LxDll(hinstance, (ulPe2LxVersion & 0x80000000UL) == 0x80000000UL); 91 if (pWinMod == NULL) 91 92 { 92 pWinMod = new Win32Pe2LxDll(hinstance, (ulPe2LxVersion & 0x80000000UL) == 0x80000000UL); 93 if (pWinMod == NULL) 94 throw ((ULONG)ERROR_NOT_ENOUGH_MEMORY); 95 96 /* @@@PH 1998/03/17 Console devices initialization */ 97 iConsoleDevicesRegister(); 98 99 /* Add reference and attach dll to process. */ 100 pWinMod->AddRef(); 101 pWinMod->attachProcess(); 93 eprintf(("RegisterPe2LxDll: new returned a NULL-pointer\n")); 94 return 0; 102 95 } 103 catch(ULONG ul)96 if (!pWinMod->init()) 104 97 { 105 eprintf(("RegisterPe2LxD LL: Failed to create module object, ul=%d\n", ul));106 DebugInt3();107 return 0; /* fail dll load */98 eprintf(("RegisterPe2LxDll: init-method failed.\n")); 99 delete pWinMod; 100 return 0; 108 101 } 102 103 /* @@@PH 1998/03/17 Console devices initialization */ 104 iConsoleDevicesRegister(); 105 106 /* Add reference and attach dll to process. */ 107 pWinMod->AddRef(); 108 pWinMod->attachProcess(); 109 109 } 110 110 else … … 112 112 if (pWinMod != NULL && !fFreeLibrary) 113 113 return 0; /* don't unload (OS/2 dll unload bug) - see OS2.bugs in root dir. */ 114 115 #if 0 /* Runtime environment could already be gone, so don't do this */116 dprintf(("KERNEL32: Dll Removed by FreeLibrary or ExitProcess\n"));117 #endif118 114 } 119 115 … … 130 126 * @author Sander van Leeuwen, knut st. osmundsen 131 127 */ 132 Win32Pe2LxDll::Win32Pe2LxDll(HINSTANCE hinstance, BOOL fWin32k) throw(ULONG)128 Win32Pe2LxDll::Win32Pe2LxDll(HINSTANCE hinstance, BOOL fWin32k) 133 129 : Win32ImageBase(hinstance), 134 130 Win32DllBase(hinstance, NULL), … … 136 132 { 137 133 dprintf(("Win32Pe2LxDll::Win32Pe2LxDll %s", szModule)); 138 /* set entry point. */139 dllEntryPoint = (WIN32DLLENTRY)entryPoint;140 134 } 141 135 … … 151 145 } 152 146 147 148 /** 149 * Init object. 150 * Must be called immedeately after objecte construction. 151 * @returns Success indicator. (TRUE == success) 152 * @sketch call init method of the parten class. 153 * set dllEntryPoint 154 * @status completely implemented. 155 * @author knut st. osmundsen 156 */ 157 BOOL Win32Pe2LxDll::init() 158 { 159 if (Win32Pe2LxImage::init()) 160 { 161 /* set entry point. */ 162 dllEntryPoint = (WIN32DLLENTRY)entryPoint; 163 } 164 else 165 return FALSE; 166 return TRUE; 167 } 153 168 154 169 /** -
trunk/src/kernel32/winexepe2lx.cpp
r1274 r1325 1 /* $Id: winexepe2lx.cpp,v 1. 2 1999-10-14 01:37:56bird Exp $ */1 /* $Id: winexepe2lx.cpp,v 1.3 1999-10-17 01:49:09 bird Exp $ */ 2 2 3 3 /* … … 52 52 void WIN32API RegisterPe2LxExe(ULONG ulPe2LxVersion, HINSTANCE hinstance, ULONG ulReserved) 53 53 { 54 Win32Pe2LxExe *pWinPe2LxExe; 55 54 56 /* I/O init. */ 55 57 if (getenv("WIN32_IOPL2")) … … 73 75 74 76 /* Create Pe2Lx Exe object. */ 75 try 77 pWinPe2LxExe = new Win32Pe2LxExe(hinstance, (ulPe2LxVersion & 0x80000000UL) == 0x80000000UL); 78 if (pWinPe2LxExe == NULL) 76 79 { 77 Win32Pe2LxExe *pWinPe2LxExe; 78 pWinPe2LxExe = new Win32Pe2LxExe(hinstance, (ulPe2LxVersion & 0x80000000UL) == 0x80000000UL); 79 if (pWinPe2LxExe == NULL) 80 throw ((ULONG)ERROR_NOT_ENOUGH_MEMORY); 81 82 /* Call start (which calls the entry point). */ 83 /*DebugInt3();*/ 84 pWinPe2LxExe->start(); 85 } 86 catch (ULONG ul) 87 { 88 eprintf(("Win32Pe2LxExe creation failed! ul=%d\n", ul)); 89 DebugInt3(); 80 eprintf(("RegisterPe2LxExe: new returned a NULL-pointer\n")); 90 81 return; 91 82 } 83 if (!pWinPe2LxExe->init()) 84 { 85 eprintf(("RegisterPe2LxExe: init-method failed.\n")); 86 delete pWinPe2LxExe; 87 return; 88 } 89 90 /* Call start (which calls the entry point). */ 91 /*DebugInt3();*/ 92 pWinPe2LxExe->start(); 92 93 } 93 94 … … 102 103 * @remark Win32Pe2LxImage may throw an exception! 103 104 */ 104 Win32Pe2LxExe::Win32Pe2LxExe(HINSTANCE hinstance, BOOL fWin32k) throw(ULONG):105 Win32ImageBase(hinstance),105 Win32Pe2LxExe::Win32Pe2LxExe(HINSTANCE hinstance, BOOL fWin32k) 106 : Win32ImageBase(hinstance), 106 107 Win32ExeBase(hinstance), 107 108 Win32Pe2LxImage(hinstance, fWin32k) 108 109 { 109 fConsoleApp = pNtHdrs->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI;110 111 /* console app? */112 if (fConsoleApp)113 {114 APIRET rc;115 116 dprintf(("Console application!\n"));117 118 rc = iConsoleInit(); /* initialize console subsystem */119 if (rc != NO_ERROR) /* check for errors */120 dprintf(("KERNEL32:Win32Image:Init ConsoleInit failed with %u.\n", rc));121 }122 110 } 123 111 … … 130 118 Win32Pe2LxExe::~Win32Pe2LxExe() 131 119 { 120 132 121 } 122 123 124 /** 125 * Init object. 126 * Must be called immedeately after the object construction. 127 * @returns Success indicator. (TRUE == success) 128 * @sketch 129 * @status completely implemented. 130 * @author knut st. osmundsen 131 */ 132 BOOL Win32Pe2LxExe::init() 133 { 134 if (Win32Pe2LxImage::init()) 135 { 136 fConsoleApp = pNtHdrs->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI; 137 138 /* console app? */ 139 if (fConsoleApp) 140 { 141 APIRET rc; 142 143 dprintf(("Console application!\n")); 144 145 rc = iConsoleInit(); /* initialize console subsystem */ 146 if (rc != NO_ERROR) /* check for errors */ 147 dprintf(("KERNEL32:Win32Image:Init ConsoleInit failed with %u.\n", rc)); 148 } 149 } 150 else 151 return FALSE; 152 return TRUE; 153 } 154 -
trunk/src/kernel32/winimagepe2lx.cpp
r1274 r1325 1 /* $Id: winimagepe2lx.cpp,v 1. 2 1999-10-14 01:37:56bird Exp $ */1 /* $Id: winimagepe2lx.cpp,v 1.3 1999-10-17 01:49:09 bird Exp $ */ 2 2 3 3 /* … … 118 118 * @param fWin32k TRUE: Win32k module. 119 119 * FALSE: Pe2Lx module. 120 * @status partially implemented. 121 * @author knut st. osmundsen, Sander van Leeuwen 122 */ 123 Win32Pe2LxImage::Win32Pe2LxImage(HINSTANCE hinstance, BOOL fWin32k) 124 : Win32ImageBase(hinstance), 125 paSections(NULL), cSections(0), pNtHdrs(NULL), fWin32k(fWin32k) 126 { 127 } 128 129 130 /** 131 * Free memory associated with this object. 132 * @status completely implemented. 133 * @author knut st. osmundsen, Sander van Leeuwen 134 */ 135 Win32Pe2LxImage::~Win32Pe2LxImage() 136 { 137 cleanup(); 138 } 139 140 141 /** 142 * Initiates the object. 143 * Must be called immediately after the object construction. 144 * @returns Success indicator, TRUE == success; FALSE = failure. 120 145 * @sketch Get section placement and sizes for this module. (paSections, cSections) 121 146 * Verify that there is at least one section - the header section. … … 127 152 * Locate the resource directory (if any). (pResDir, pResourceSectionStart) 128 153 * TLS - FIXME! 129 * @status partially implmented. 130 * @author knut st. osmundsen, Sander van Leeuwen 131 */ 132 Win32Pe2LxImage::Win32Pe2LxImage(HINSTANCE hinstance, BOOL fWin32k) throw(ULONG) 133 : Win32ImageBase(hinstance), 134 paSections(NULL), cSections(0), pNtHdrs(NULL), fWin32k(fWin32k) 154 * @status completely implemented. 155 * @author knut st. osmundsen 156 * @remark Object must be destroyed if failure! 157 */ 158 BOOL Win32Pe2LxImage::init() 135 159 { 136 160 APIRET rc; … … 142 166 dprintf(("Win32Pe2LxImage::Win32Pe2LxImage: error - getSection failed with rc=%d\n", 143 167 rc)); 144 Win32Pe2LxImage::~Win32Pe2LxImage(); 145 throw((ULONG)rc); 168 return FALSE; 146 169 } 147 170 … … 150 173 { 151 174 dprintf(("Win32Pe2LxImage::Win32Pe2LxImage: no header section, cSections is 0\n")); 152 Win32Pe2LxImage::~Win32Pe2LxImage(); 153 throw((ULONG)ERROR_BAD_EXE_FORMAT); 175 return FALSE; 154 176 } 155 177 … … 164 186 { 165 187 dprintf(("Win32Pe2LxImage::Win32Pe2LxImage: Not a pe2lx image!(?)\n")); 166 Win32Pe2LxImage::~Win32Pe2LxImage(); 167 throw((ULONG)ERROR_BAD_EXE_FORMAT); 188 return FALSE; 168 189 } 169 190 … … 186 207 { 187 208 dprintf(("Win32Pe2LxImage::Win32Pe2LxImage: Not a pe2lx image!(?)\n")); 188 Win32Pe2LxImage::~Win32Pe2LxImage(); 189 throw((ULONG)ERROR_BAD_EXE_FORMAT); 209 return FALSE; 190 210 } 191 211 … … 195 215 { 196 216 dprintf(("Win32Pe2LxImage::Win32Pe2LxImage: setSectionRVAs failed with rc=%d\n", rc)); 197 Win32Pe2LxImage::~Win32Pe2LxImage(); 198 throw((ULONG)rc); 217 return FALSE; 199 218 } 200 219 … … 208 227 dprintf(("Win32Pe2LxImage::Win32Pe2LxImage: entrypoint is incorrect, AddrOfEP=0x%08x, entryPoint=0x%08x\n", 209 228 pNtHdrs->OptionalHeader.AddressOfEntryPoint, entryPoint)); 210 Win32Pe2LxImage::~Win32Pe2LxImage(); 211 throw((ULONG)ERROR_INVALID_STARTING_CODESEG); 229 return FALSE; 212 230 } 213 231 … … 220 238 } 221 239 222 /* TLS - FIXME! */ 223 } 224 225 226 /** 227 * Free memory associated with this object. 228 * @status completely implemented. 229 * @author knut st. osmundsen, Sander van Leeuwen 230 */ 231 Win32Pe2LxImage::~Win32Pe2LxImage() 232 { 233 cleanup(); 234 } 240 /* TLS - Thread Local Storage */ 241 if (pNtHdrs->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress != 0UL 242 && pNtHdrs->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].Size != 0UL) 243 { 244 PIMAGE_TLS_DIRECTORY pTLSDir; 245 pTLSDir = (PIMAGE_TLS_DIRECTORY)getPointerFromRVA(pNtHdrs->OptionalHeader. 246 DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS]. 247 VirtualAddress); 248 249 if (pTLSDir != NULL) 250 { 251 PVOID pv; 252 pv = getPointerFromRVA(pTLSDir->StartAddressOfRawData); 253 if (pv == NULL) 254 { 255 eprintf(("Win32Pe2LxImage::init: invalid RVA to TLS StartAddressOfRawData - %#8x.\n", 256 pTLSDir->StartAddressOfRawData)); 257 return FALSE; 258 } 259 setTLSAddress(pv); 260 setTLSInitSize(pTLSDir->EndAddressOfRawData - pTLSDir->StartAddressOfRawData); 261 setTLSTotalSize(pTLSDir->EndAddressOfRawData - pTLSDir->StartAddressOfRawData + pTLSDir->SizeOfZeroFill); 262 pv = getPointerFromRVA((ULONG)pTLSDir->AddressOfIndex); 263 if (pv == NULL) 264 { 265 eprintf(("Win32Pe2LxImage::init: invalid RVA to TLS AddressOffIndex - %#8x.\n", 266 pTLSDir->AddressOfIndex)); 267 return FALSE; 268 } 269 setTLSIndexAddr((LPDWORD)pv); 270 pv = getPointerFromRVA((ULONG)pTLSDir->AddressOfCallBacks); 271 if (pv == NULL) 272 { 273 eprintf(("Win32Pe2LxImage::init: invalid RVA to TLS AddressOffIndex - %#8x.\n", 274 pTLSDir->AddressOfIndex)); 275 return FALSE; 276 } 277 setTLSCallBackAddr((PIMAGE_TLS_CALLBACK*)pv); 278 } 279 else 280 { 281 eprintf(("Win32Pe2LxImage::init: invalid RVA to TLS Dir - %#8x. (getPointerFromRVA failed)\n", 282 pNtHdrs->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress)); 283 return FALSE; 284 } 285 } 286 return TRUE; 287 } 288 235 289 236 290
Note:
See TracChangeset
for help on using the changeset viewer.