Ignore:
Timestamp:
Jun 19, 1999, 7:58:50 PM (26 years ago)
Author:
sandervl
Message:

More TIB changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/wprocess.cpp

    r123 r125  
    1 /* $Id: wprocess.cpp,v 1.9 1999-06-19 13:57:51 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.10 1999-06-19 17:58:33 sandervl Exp $ */
    22
    33/*
     
    3838PDB       ProcessPDB = {0}; 
    3939USHORT    ProcessTIBSel = 0;
    40 USHORT    OS2Selector   = 0;
    41 
    42 //#define WIN32_TIBSEL
     40DWORD    *TIBFlatPtr    = 0;
     41
    4342//******************************************************************************
    4443// Set up the TIB selector and memory for the current thread
     
    5251  USHORT tibsel;
    5352
     53   //Allocate one dword to store the flat address of our TEB
     54   TIBFlatPtr = (DWORD *)OS2AllocThreadLocalMemory(1);
     55   if(TIBFlatPtr == 0) {
     56        dprintf(("InitializeTIB: local thread memory alloc failed!!"));
     57        DebugInt3();
     58        return;
     59   }
    5460   if(OS2AllocSel(PAGE_SIZE, &tibsel) == FALSE)
    5561   {
     
    6672   }
    6773   memset(winteb, 0, PAGE_SIZE);
    68    thdb = (THDB *)(winteb+1);
     74   thdb       = (THDB *)(winteb+1);
     75   TIBFlatPtr = (DWORD)winteb;
    6976
    7077   winteb->except      = (PVOID)-1;               /* 00 Head of exception handling chain */
     
    8390   thdb->exit_code       = 0x103; /* STILL_ACTIVE */
    8491   thdb->teb_sel         = tibsel;
     92   thdb->OrgTIBSel       = GetFS();
    8593
    8694   if(OS2GetPIB(PIB_TASKTYPE) == TASKTYPE_PM)
     
    96104        //TLS in executable always TLS index 0?
    97105        ProcessTIBSel = tibsel;
    98         OS2Selector   = GetFS();        //0x150b
    99106   }
    100107   SetFS(tibsel);
     
    108115void DestroyTIB()
    109116{
     117#ifdef WIN32_TIBSEL
     118 SHORT  orgtibsel;
     119 TEB   *winteb;
     120 THDB  *thdb;
     121
    110122   dprintf(("DestroyTIB: FS = %x", GetFS()));
    111 #ifdef WIN32_TIBSEL
    112    OS2FreeSel(ProcessTIBSel);
     123
     124   winteb = (TEB *)TIBFlatPtr;
     125   if(winteb) {
     126        thdb = (THDB *)(winteb+1);
     127        orgtibsel = thdb->OrgTIBSel;
     128
     129        //Restore our original FS selector
     130        SetFS(orgtibsel);
     131
     132        //And free our own
     133        OS2FreeSel(thdb->teb_sel);
     134   }
     135   else DebugInt3();
     136
    113137   return;
    114138#endif
     
    254278#ifdef WIN32_TIBSEL
    255279  //Restore original OS/2 TIB selector
    256   SetFS(OS2Selector);
     280  DestroyTIB();
    257281#endif
    258282
Note: See TracChangeset for help on using the changeset viewer.