- Timestamp:
- Jun 19, 1999, 3:57:51 PM (26 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/except.asm
r100 r123 1 ; $Id: except.asm,v 1. 3 1999-06-10 20:47:58 phallerExp $1 ; $Id: except.asm,v 1.4 1999-06-19 13:57:51 sandervl Exp $ 2 2 3 3 ;/* … … 175 175 SetFS endp 176 176 177 PUBLIC getSS 178 getSS proc near 179 mov ax, ss 180 ret 181 getSS endp 182 177 183 CODE32 ENDS 178 184 -
trunk/src/kernel32/except.h
r99 r123 1 /* $Id: except.h,v 1. 3 1999-06-10 19:11:30 phallerExp $ */1 /* $Id: except.h,v 1.4 1999-06-19 13:57:51 sandervl Exp $ */ 2 2 3 3 /* … … 20 20 ULONG GetDllEntryPoint(); 21 21 22 ULONG getEAX(); 23 ULONG getEBX(); 22 ULONG getEAX(); 23 ULONG getEBX(); 24 USHORT getSS(); 24 25 25 26 #ifdef __cplusplus -
trunk/src/kernel32/initterm.cpp
r120 r123 1 /* $Id: initterm.cpp,v 1. 3 1999-06-19 10:54:41 sandervl Exp $ */1 /* $Id: initterm.cpp,v 1.4 1999-06-19 13:57:51 sandervl Exp $ */ 2 2 3 3 /* … … 33 33 #include <string.h> 34 34 #include <misc.h> 35 #include <wprocess.h> 35 36 36 37 extern "C" { … … 128 129 else flAllocMem = 0; // no high memory support 129 130 131 InitializeTIB(TRUE); 130 132 break; 131 133 case 1 : … … 146 148 dprintf(("kernel32 exit\n")); 147 149 _dump_allocated(10); /*PLF Wed 98-03-18 23:55:07*/ 150 DestroyTIB(); 148 151 _ctordtorTerm(); 149 152 CRT_term(); -
trunk/src/kernel32/os2util.cpp
r120 r123 1 /* $Id: os2util.cpp,v 1. 3 1999-06-19 10:54:42sandervl Exp $ */1 /* $Id: os2util.cpp,v 1.4 1999-06-19 13:57:51 sandervl Exp $ */ 2 2 3 3 /* … … 14 14 #define INCL_BASE 15 15 #define INCL_DOSPROCESS 16 #define INCL_DOSSEL 16 17 #include <os2wrap.h> //Odin32 OS/2 api wrappers 17 18 #include <string.h> … … 207 208 } 208 209 209 210 211 212 210 void OS2Wait(ULONG msec) 213 211 { 214 212 DosSleep(msec); 215 213 } 214 215 //****************************************************************************** 216 //Wrapper for Dos16AllocSeg 217 //****************************************************************************** 218 BOOL OS2AllocSel(ULONG size, USHORT *selector) 219 { 220 return (Dos16AllocSeg(size, selector, SEG_NONSHARED) == 0); 221 } 222 //****************************************************************************** 223 //Wrapper for Dos16FreeSeg 224 //****************************************************************************** 225 BOOL OS2FreeSel(USHORT selector) 226 { 227 return (Dos16FreeSeg(selector) == 0); 228 } 229 //****************************************************************************** 230 //Wrapper for Dos32SelToFlat 231 //****************************************************************************** 232 PVOID OS2SelToFlat(USHORT selector) 233 { 234 return (PVOID)DosSelToFlat(selector << 16); 235 } 236 //****************************************************************************** 237 //Get TIB data 238 //****************************************************************************** 239 ULONG OS2GetTIB(int tiboff) 240 { 241 PTIB ptib; 242 PPIB ppib; 243 APIRET rc; 244 245 rc = DosGetInfoBlocks(&ptib, &ppib); 246 if(rc) { 247 return 0; 248 } 249 switch(tiboff) 250 { 251 case TIB_STACKTOP: 252 return (ULONG)ptib->tib_pstack; 253 case TIB_STACKLOW: 254 return (ULONG)ptib->tib_pstacklimit; 255 default: 256 return 0; 257 } 258 } 259 //****************************************************************************** 260 //Get PIB data 261 //****************************************************************************** 262 ULONG OS2GetPIB(int piboff) 263 { 264 PTIB ptib; 265 PPIB ppib; 266 APIRET rc; 267 268 rc = DosGetInfoBlocks(&ptib, &ppib); 269 if(rc) { 270 return 0; 271 } 272 switch(piboff) 273 { 274 case PIB_TASKHNDL: 275 return ppib->pib_hmte; 276 case PIB_TASKTYPE: 277 if(ppib->pib_ultype == 3) { 278 return TASKTYPE_PM; 279 } 280 else return TASKTYPE_VIO; 281 default: 282 return 0; 283 } 284 } 285 //****************************************************************************** 286 //****************************************************************************** -
trunk/src/kernel32/os2util.h
r99 r123 1 /* $Id: os2util.h,v 1. 3 1999-06-10 19:11:31 phallerExp $ */1 /* $Id: os2util.h,v 1.4 1999-06-19 13:57:51 sandervl Exp $ */ 2 2 3 3 /* … … 41 41 void OS2Wait(ULONG msec); 42 42 43 44 BOOL OS2AllocSel(ULONG size, USHORT *selector); 45 BOOL OS2FreeSel(USHORT selector); 46 PVOID OS2SelToFlat(USHORT selector); 47 48 #define TIB_STACKTOP 0 49 #define TIB_STACKLOW 1 50 51 ULONG OS2GetTIB(int tiboff); 52 53 #define PIB_TASKHNDL 0 54 #define PIB_TASKTYPE 1 55 56 #define TASKTYPE_PM 0 57 #define TASKTYPE_VIO 1 58 59 ULONG OS2GetPIB(int piboff); 60 43 61 #ifdef __cplusplus 44 62 } -
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.