Changeset 123 for trunk/src/kernel32/wprocess.cpp
- Timestamp:
- Jun 19, 1999, 3:57:51 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/wprocess.cpp
r115 r123 1 /* $Id: wprocess.cpp,v 1.8 1999-06-17 22:06:10 phaller Exp $ */ 2 3 /* 4 * 5 * Project Odin Software License can be found in LICENSE.TXT 6 * 7 */ 1 /* $Id: wprocess.cpp,v 1.9 1999-06-19 13:57:51 sandervl Exp $ */ 2 8 3 /* 9 4 * Win32 process functions 10 5 * 11 6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl) 7 * 8 * 9 * Project Odin Software License can be found in LICENSE.TXT 12 10 * 13 11 */ … … 31 29 #include "versionos2.h" /*PLF Wed 98-03-18 02:36:51*/ 32 30 31 #include <winprocess.h> 32 #include <thread.h> 33 33 34 BOOL fExeStarted = FALSE; 34 35 BOOL fFreeLibrary = FALSE; 35 36 37 //Process database 38 PDB ProcessPDB = {0}; 39 USHORT ProcessTIBSel = 0; 40 USHORT OS2Selector = 0; 41 42 //#define WIN32_TIBSEL 43 //****************************************************************************** 44 // Set up the TIB selector and memory for the current thread 45 //****************************************************************************** 46 void InitializeTIB(BOOL fMainThread) 47 { 48 #ifdef WIN32_TIBSEL 49 TEB *winteb; 50 THDB *thdb; 51 52 USHORT tibsel; 53 54 if(OS2AllocSel(PAGE_SIZE, &tibsel) == FALSE) 55 { 56 dprintf(("InitializeTIB: selector alloc failed!!")); 57 DebugInt3(); 58 return; 59 } 60 winteb = (TEB *)OS2SelToFlat(tibsel); 61 if(winteb == NULL) 62 { 63 dprintf(("InitializeTIB: DosSelToFlat failed!!")); 64 DebugInt3(); 65 return; 66 } 67 memset(winteb, 0, PAGE_SIZE); 68 thdb = (THDB *)(winteb+1); 69 70 winteb->except = (PVOID)-1; /* 00 Head of exception handling chain */ 71 winteb->stack_top = (PVOID)OS2GetTIB(TIB_STACKTOP); /* 04 Top of thread stack */ 72 winteb->stack_low = (PVOID)OS2GetTIB(TIB_STACKLOW); /* 08 Stack low-water mark */ 73 winteb->htask16 = (USHORT)OS2GetPIB(PIB_TASKHNDL); /* 0c Win16 task handle */ 74 winteb->stack_sel = getSS(); /* 0e 16-bit stack selector */ 75 winteb->self = winteb; /* 18 Pointer to this structure */ 76 winteb->flags = TEBF_WIN32; /* 1c Flags */ 77 winteb->queue = 0; /* 28 Message queue */ 78 winteb->tls_ptr = &thdb->tls_array[0]; /* 2c Pointer to TLS array */ 79 winteb->process = &ProcessPDB; /* 30 owning process (used by NT3.51 applets)*/ 80 81 memcpy(&thdb->teb, winteb, sizeof(TEB)); 82 thdb->process = &ProcessPDB; 83 thdb->exit_code = 0x103; /* STILL_ACTIVE */ 84 thdb->teb_sel = tibsel; 85 86 if(OS2GetPIB(PIB_TASKTYPE) == TASKTYPE_PM) 87 { 88 thdb->flags = 0; //todo gui 89 } 90 else thdb->flags = 0; //todo textmode 91 92 if(fMainThread) 93 { 94 //todo initialize PDB during process creation 95 //todo: initialize TLS array if required 96 //TLS in executable always TLS index 0? 97 ProcessTIBSel = tibsel; 98 OS2Selector = GetFS(); //0x150b 99 } 100 SetFS(tibsel); 101 dprintf(("InitializeTIB set up TEB with selector %x", tibsel)); 102 return; 103 #endif 104 } 105 //****************************************************************************** 106 // Destroy the TIB selector and memory for the current thread 107 //****************************************************************************** 108 void DestroyTIB() 109 { 110 dprintf(("DestroyTIB: FS = %x", GetFS())); 111 #ifdef WIN32_TIBSEL 112 OS2FreeSel(ProcessTIBSel); 113 return; 114 #endif 115 } 36 116 /******************************************************************************/ 37 117 //SvL: 4-10-'98: Put in separate procedure, as ICC changes FS:0 when there … … 71 151 HINSTANCE hinstance) 72 152 { 153 #ifdef WIN32_TIBSEL 154 SetFS(ProcessTIBSel); 155 #endif 156 73 157 if(getenv("WIN32_IOPL2")) { 74 158 io_init1(); … … 80 164 RegisterExe(Win32TableId, NameTableId, VersionResId, Pe2lxVersion, hinstance); 81 165 82 //NOTE: Breaks Quake 2 if enabled 83 if(getenv("WIN32_NOEXCEPTION")) { 84 ChangeTIBStack(); //disable exceptions 85 } 166 dprintf(("RegisterResourceUsage: FS = %x", GetFS())); 86 167 } 87 168 //****************************************************************************** … … 171 252 dprintf(("KERNEL32: ExitProcess %d\n", exitcode)); 172 253 254 #ifdef WIN32_TIBSEL 255 //Restore original OS/2 TIB selector 256 SetFS(OS2Selector); 257 #endif 258 173 259 //avoid crashes since win32 & OS/2 exception handler aren't identical 174 260 //(terminate process generates two exceptions) … … 183 269 dprintf(("dll exitlist exception\n")); 184 270 } 271 272 #ifndef WIN32_TIBSEL 185 273 SetExceptionChain((ULONG)-1); 274 #endif 186 275 O32_ExitProcess(exitcode); 187 276 } … … 363 452 364 453 dprintf(("KERNEL32: GetCommandLine %s\n", cmdline)); 454 #ifdef WIN32_TIBSEL 455 dprintf(("KERNEL32: FS = %x\n", GetFS())); 456 #else 365 457 //SvL: Replace original startup code exception handler 366 458 ReplaceExceptionHandler(); 459 #endif 367 460 return(cmdline); 368 461 } … … 374 467 char *asciicmdline = NULL; 375 468 469 #ifdef WIN32_TIBSEL 470 dprintf(("KERNEL32: FS = %x\n", GetFS())); 471 #else 376 472 //SvL: Replace original startup code exception handler 377 473 ReplaceExceptionHandler(); 474 #endif 378 475 379 476 if(UnicodeCmdLine) … … 381 478 382 479 if(WinExe) { 383 asciicmdline = WinExe->getCommandLine();480 asciicmdline = WinExe->getCommandLine(); 384 481 } 385 482 if(asciicmdline == NULL) //not used for converted exes 386 asciicmdline = O32_GetCommandLine();483 asciicmdline = O32_GetCommandLine(); 387 484 388 485 if(asciicmdline) {
Note:
See TracChangeset
for help on using the changeset viewer.