Index: trunk/src/kernel32/KERNEL32.DEF
===================================================================
--- trunk/src/kernel32/KERNEL32.DEF	(revision 4649)
+++ trunk/src/kernel32/KERNEL32.DEF	(revision 4658)
@@ -1,3 +1,3 @@
-; $Id: KERNEL32.DEF,v 1.93 2000-11-13 06:48:54 phaller Exp $
+; $Id: KERNEL32.DEF,v 1.94 2000-11-21 11:35:07 sandervl Exp $
 
 ;Created by BLAST for IBM's compiler
@@ -1083,7 +1083,6 @@
 
    _GetThreadTEB@0                                                @1234
-   _GetThreadTHDB@0                                               @1235
-   _GetTHDBFromThreadId@4                                         @1255
-   _GetTHDBFromThreadHandle@4                                     @1256
+   _GetTEBFromThreadId@4                                          @1255
+   _GetTEBFromThreadHandle@4                                      @1256
 
 ; HEAP Management (heap.cpp, heapstring.cpp)
Index: trunk/src/kernel32/hmtoken.cpp
===================================================================
--- trunk/src/kernel32/hmtoken.cpp	(revision 4649)
+++ trunk/src/kernel32/hmtoken.cpp	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: hmtoken.cpp,v 1.3 2000-02-16 14:24:00 sandervl Exp $ */
+/* $Id: hmtoken.cpp,v 1.4 2000-11-21 11:35:08 sandervl Exp $ */
 
 /*
@@ -52,11 +52,11 @@
                                           BOOL    OpenAsSelf)
 {
- THDB *thdb = GetTHDBFromThreadHandle(ThreadHandle);
+ TEB *teb = GetTEBFromThreadHandle(ThreadHandle);
 
-  if(thdb == 0) {
+  if(teb == 0) {
 	dprintf(("HMDeviceTokenClass::OpenThreadToken: thread handle %x not found", ThreadHandle));
 	return ERROR_INVALID_PARAMETER;
   }
-  pHMHandleData->dwUserData = (DWORD)&thdb->threadinfo;
+  pHMHandleData->dwUserData = (DWORD)&teb->o.odin.threadinfo;
   pHMHandleData->dwInternalType = HMTYPE_THREADTOKEN;
   return STATUS_SUCCESS;
Index: trunk/src/kernel32/lang.cpp
===================================================================
--- trunk/src/kernel32/lang.cpp	(revision 4649)
+++ trunk/src/kernel32/lang.cpp	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: lang.cpp,v 1.30 2000-11-09 18:18:10 sandervl Exp $ */
+/* $Id: lang.cpp,v 1.31 2000-11-21 11:35:08 sandervl Exp $ */
 /*
  * Win32 language API functions for OS/2
@@ -888,12 +888,12 @@
 LCID WIN32API GetThreadLocale()
 {
- THDB *thdb = GetThreadTHDB();
-
-  if(thdb == NULL) {
-  	dprintf(("KERNEL32: ERROR: GetThreadLocale thdb == NULL!"));
+ TEB *teb = GetThreadTEB();
+
+  if(teb == NULL) {
+  	dprintf(("KERNEL32: ERROR: GetThreadLocale teb == NULL!"));
 	return FALSE;
   }
-  dprintf(("KERNEL32: GetThreadLocale returned %x", thdb->lcid));
-  return(thdb->lcid);
+  dprintf(("KERNEL32: GetThreadLocale returned %x", teb->o.odin.lcid));
+  return(teb->o.odin.lcid);
 }
 //******************************************************************************
@@ -901,12 +901,12 @@
 BOOL WIN32API SetThreadLocale(LCID locale)
 {
- THDB *thdb = GetThreadTHDB();
+ TEB *teb = GetThreadTEB();
  
-  if(thdb == NULL) {
-  	dprintf(("KERNEL32: ERROR SetThreadLocale thdb == NULL!"));
+  if(teb == NULL) {
+  	dprintf(("KERNEL32: ERROR SetThreadLocale teb == NULL!"));
 	return FALSE;
   }
   dprintf(("KERNEL32: SetThreadLocale %x", locale));
-  thdb->lcid = locale;
+  teb->o.odin.lcid = locale;
   return(TRUE);
 }
Index: trunk/src/kernel32/misc.cpp
===================================================================
--- trunk/src/kernel32/misc.cpp	(revision 4649)
+++ trunk/src/kernel32/misc.cpp	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: misc.cpp,v 1.27 2000-10-18 17:09:33 sandervl Exp $ */
+/* $Id: misc.cpp,v 1.28 2000-11-21 11:35:08 sandervl Exp $ */
 
 /*
@@ -289,16 +289,16 @@
   if(fLogging && flog && (dwEnableLogging > 0))
   {
-    THDB *thdb = GetThreadTHDB();
+    TEB *teb = GetThreadTEB();
 
     va_start(argptr, tekst);
-    if(thdb) {
-    thdb->logfile = (DWORD)flog;
+    if(teb) {
+        teb->o.odin.logfile = (DWORD)flog;
         if(sel == 0x150b && !fIsOS2Image) {
-        fprintf(flog, "t%d: (FS=150B) ", thdb->threadId);
-    }
-    else    fprintf(flog, "t%d: ", thdb->threadId);
+        fprintf(flog, "t%d: (FS=150B) ", teb->o.odin.threadId);
+    }
+    else    fprintf(flog, "t%d: ", teb->o.odin.threadId);
     }
     vfprintf(flog, tekst, argptr);
-    if(thdb) thdb->logfile = 0;
+    if(teb) teb->o.odin.logfile = 0;
     va_end(argptr);
 
@@ -342,12 +342,12 @@
   if(fLogging && flog && (dwEnableLogging > 0))
   {
-    THDB *thdb = GetThreadTHDB();
+    TEB *teb = GetThreadTEB();
 
     va_start(argptr, tekst);
-    if(thdb) {
-        thdb->logfile = (DWORD)flog;
+    if(teb) {
+        teb->o.odin.logfile = (DWORD)flog;
     }
     vfprintf(flog, tekst, argptr);
-    if(thdb) thdb->logfile = 0;
+    if(teb) teb->o.odin.logfile = 0;
     va_end(argptr);
   }
@@ -376,12 +376,12 @@
   if(fLogging && logfile)
   {
-    THDB *thdb = GetThreadTHDB();
+    TEB *teb = GetThreadTEB();
 
     va_start(argptr, tekst);
-    if(thdb) {
-        thdb->logfile = (DWORD)flog;
+    if(teb) {
+        teb->o.odin.logfile = (DWORD)flog;
     }
     vfprintf((FILE *)logfile, tekst, argptr);
-    if(thdb) thdb->logfile = 0;
+    if(teb) teb->o.odin.logfile = 0;
     va_end(argptr);
 
@@ -400,13 +400,13 @@
 void LogException(int state)
 {
-  THDB *thdb = GetThreadTHDB();
+  TEB *teb = GetThreadTEB();
   USHORT *lock;
 
-  if(!thdb) return;
-
-  if(thdb->logfile) {
+  if(!teb) return;
+
+  if(teb->o.odin.logfile) {
     if(state == ENTER_EXCEPTION) {
 #if (__IBMCPP__ == 300) || (__IBMC__ == 300)
-        lock = (USHORT *)(thdb->logfile+0x1C);
+        lock = (USHORT *)(teb->o.odin.logfile+0x1C);
 #else
 #error Check the offset of the lock count word in the file stream structure for this compiler revision!!!!!
@@ -416,5 +416,5 @@
     else { //LEAVE_EXCEPTION
 #if (__IBMCPP__ == 300) || (__IBMC__ == 300)
-        lock = (USHORT *)(thdb->logfile+0x1C);
+        lock = (USHORT *)(teb->o.odin.logfile+0x1C);
 #else
 #error Check the offset of the lock count word in the file stream structure for this compiler revision!!!!!
@@ -431,13 +431,13 @@
 void CheckLogException()
 {
-  THDB *thdb = GetThreadTHDB();
+  TEB *teb = GetThreadTEB();
   USHORT *lock;
 
-  if(!thdb) return;
-
-  if(thdb->logfile) {
+  if(!teb) return;
+
+  if(teb->o.odin.logfile) {
     //oops, exception in vfprintf; let's clear the lock count
 #if (__IBMCPP__ == 300) || (__IBMC__ == 300)
-    lock = (USHORT *)(thdb->logfile+0x1C);
+    lock = (USHORT *)(teb->o.odin.logfile+0x1C);
 #else
 #error Check the offset of the lock count word in the file stream structure for this compiler revision!!!!!
Index: trunk/src/kernel32/oslibexcept.cpp
===================================================================
--- trunk/src/kernel32/oslibexcept.cpp	(revision 4649)
+++ trunk/src/kernel32/oslibexcept.cpp	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: oslibexcept.cpp,v 1.4 2000-09-09 08:59:55 sandervl Exp $ */
+/* $Id: oslibexcept.cpp,v 1.5 2000-11-21 11:35:08 sandervl Exp $ */
 /*
  * Exception handler util. procedures
@@ -128,6 +128,5 @@
   }
 
-  TEB  *winteb = GetThreadTEB();
-  THDB *thdb   = (THDB *)(winteb+1);
+  TEB *winteb = GetThreadTEB();
 
   if(pContextRec->ContextFlags & CONTEXT_SEGMENTS) {
@@ -136,5 +135,5 @@
 //   This resets FS to 0x150B - we DON'T want that!!
 //      wincontextrec.SegFs   = pContextRec->ctx_SegFs;
-        wincontextrec.SegFs   = thdb->teb_sel;
+        wincontextrec.SegFs   = winteb->teb_sel;
         wincontextrec.SegEs   = pContextRec->ctx_SegEs;
         wincontextrec.SegDs   = pContextRec->ctx_SegDs;
@@ -153,5 +152,5 @@
   // fuck up the Win32 exception handlers. They could end up using the wrong
   // exception chain if they access FS:[0] directly.
-  DWORD oldsel = SetReturnFS(thdb->teb_sel);
+  DWORD oldsel = SetReturnFS(winteb->teb_sel);
 
   switch(pReportRec->ExceptionNum) {
Index: trunk/src/kernel32/process.cpp
===================================================================
--- trunk/src/kernel32/process.cpp	(revision 4649)
+++ trunk/src/kernel32/process.cpp	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: process.cpp,v 1.7 2000-10-18 17:09:33 sandervl Exp $ */
+/* $Id: process.cpp,v 1.8 2000-11-21 11:35:09 sandervl Exp $ */
 
 /*
@@ -322,5 +322,5 @@
     case GPD_THDB:
         if ( process != PROCESS_Current() ) return 0;
-        return (DWORD)GetThreadTHDB();
+        return (DWORD)GetThreadTEB() + 0x30;
 
     case GPD_PDB:
Index: trunk/src/kernel32/thread.cpp
===================================================================
--- trunk/src/kernel32/thread.cpp	(revision 4649)
+++ trunk/src/kernel32/thread.cpp	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: thread.cpp,v 1.25 2000-04-18 20:06:38 sandervl Exp $ */
+/* $Id: thread.cpp,v 1.26 2000-11-21 11:35:09 sandervl Exp $ */
 
 /*
@@ -48,12 +48,12 @@
 HANDLE WIN32API GetCurrentThread()
 {
- THDB *thdb;
+ TEB *teb;
 
-    thdb = GetThreadTHDB();
-    if(thdb == 0) {
+    teb = GetThreadTEB();
+    if(teb == 0) {
 	SetLastError(ERROR_INVALID_HANDLE); //todo 
 	return 0;
     }
-    return thdb->hThread;
+    return teb->o.odin.hThread;
 }
 //******************************************************************************
@@ -62,11 +62,11 @@
 {
  EXCEPTION_FRAME *exceptFrame;
- THDB            *thdb;
+ TEB             *teb;
 
   dprintf(("ExitThread %x (%x)", GetCurrentThread(), exitcode));
 
-  thdb = GetThreadTHDB();
-  if(thdb != 0) {
-	exceptFrame = (EXCEPTION_FRAME *)thdb->exceptFrame;
+  teb = GetThreadTEB();
+  if(teb != 0) {
+	exceptFrame = (EXCEPTION_FRAME *)teb->o.odin.exceptFrame;
   }
   else  DebugInt3();
@@ -113,17 +113,16 @@
   winteb->flags = me->dwFlags;
 
-  THDB *thdb   = (THDB *)(winteb+1);
-  thdb->entry_point = (void *)winthread;
-  thdb->entry_arg   = (void *)userdata;
-  thdb->hThread     = hThread;
+  winteb->entry_point = (void *)winthread;
+  winteb->entry_arg   = (void *)userdata;
+  winteb->o.odin.hThread = hThread;
 
-  thdb->hab = OSLibWinInitialize();
-  thdb->hmq = OSLibWinQueryMsgQueue(thdb->hab);
-  dprintf(("Win32ThreadProc: hab %x hmq %x", thdb->hab, thdb->hmq));
+  winteb->o.odin.hab = OSLibWinInitialize();
+  winteb->o.odin.hmq = OSLibWinQueryMsgQueue(winteb->o.odin.hab);
+  dprintf(("Win32ThreadProc: hab %x hmq %x", winteb->o.odin.hab, winteb->o.odin.hmq));
 
   //Note: The Win32 exception structure referenced by FS:[0] is the same
   //      in OS/2
   OS2SetExceptionHandler((void *)&exceptFrame);
-  thdb->exceptFrame = (ULONG)&exceptFrame;
+  winteb->o.odin.exceptFrame = (ULONG)&exceptFrame;
 
   SetWin32TIB();
@@ -137,5 +136,5 @@
 
   HMSetThreadTerminated(GetCurrentThread());
-  thdb->exceptFrame = 0;
+  winteb->o.odin.exceptFrame = 0;
   Win32DllBase::detachThreadFromAllDlls();  //send DLL_THREAD_DETACH message to all dlls
   Win32DllBase::tlsDetachThreadFromAllDlls(); //destroy TLS structures of all dlls
Index: trunk/src/kernel32/windllbase.cpp
===================================================================
--- trunk/src/kernel32/windllbase.cpp	(revision 4649)
+++ trunk/src/kernel32/windllbase.cpp	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: windllbase.cpp,v 1.21 2000-10-30 16:38:54 sandervl Exp $ */
+/* $Id: windllbase.cpp,v 1.22 2000-11-21 11:35:09 sandervl Exp $ */
 
 /*
@@ -387,5 +387,5 @@
  WINEXCEPTION_FRAME exceptFrame;
  USHORT sel;
- THDB *thdb;
+ TEB *teb;
  BOOL rc, fSetExceptionHandler;
 
@@ -395,6 +395,6 @@
     fAttachedToProcess = TRUE;
 
-    thdb = GetThreadTHDB();
-    fSetExceptionHandler = (!thdb || thdb->teb_sel != GetFS());
+    teb = GetThreadTEB();
+    fSetExceptionHandler = (!teb || teb->teb_sel != GetFS());
 
     //Note: The Win32 exception structure references by FS:[0] is the same
@@ -440,6 +440,6 @@
     }
     else
-    if(thdb) {
-        if(thdb->teb_sel != GetFS()) {
+    if(teb) {
+        if(teb->teb_sel != GetFS()) {
             dprintf(("Win32DllBase::attachProcess: FS was changed by dll entrypoint!!!!"));
             DebugInt3();
Index: trunk/src/kernel32/wintls.cpp
===================================================================
--- trunk/src/kernel32/wintls.cpp	(revision 4649)
+++ trunk/src/kernel32/wintls.cpp	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: wintls.cpp,v 1.15 2000-10-11 07:22:29 sandervl Exp $ */
+/* $Id: wintls.cpp,v 1.16 2000-11-21 11:35:09 sandervl Exp $ */
 /*
  * Win32 TLS API functions
@@ -140,10 +140,10 @@
 {
  DWORD index = -1;
- THDB *thdb;
+ TEB  *teb;
  PDB  *pdb;
  DWORD mask, tibidx;
  int   i;
 
-  thdb = GetThreadTHDB();
+  teb  = GetThreadTEB();
   pdb  = PROCESS_Current();
 
@@ -167,5 +167,5 @@
   }
   LeaveCriticalSection(&pdb->crit_section);
-  thdb->tls_array[index] = 0;
+  teb->tls_array[index] = 0;
 
   dprintf(("KERNEL32: TlsAlloc returned %d", index));
@@ -176,5 +176,5 @@
 BOOL WIN32API TlsFree(DWORD index)
 {
- THDB  *thdb;
+ TEB   *teb;
  PDB   *pdb;
  int    tlsidx;
@@ -188,6 +188,6 @@
   }
 
-  thdb = GetThreadTHDB();
-  pdb  = PROCESS_Current();
+  teb = GetThreadTEB();
+  pdb = PROCESS_Current();
 
   EnterCriticalSection(&pdb->crit_section);
@@ -200,5 +200,5 @@
         LeaveCriticalSection(&pdb->crit_section);
         pdb->tls_bits[tlsidx] &= ~mask;
-        thdb->tls_array[index] = 0;
+        teb->tls_array[index] = 0;
         SetLastError(ERROR_SUCCESS);
         return TRUE;
@@ -213,5 +213,5 @@
 {
  LPVOID rc;
- THDB  *thdb;
+ TEB   *teb;
 
   if(index >= TLS_MINIMUM_AVAILABLE)
@@ -222,6 +222,6 @@
   SetLastError(ERROR_SUCCESS);
 
-  thdb = GetThreadTHDB();
-  rc = thdb->tls_array[index];
+  teb = GetThreadTEB();
+  rc = teb->tls_array[index];
 
   dprintf2(("KERNEL32: TlsGetValue %d returned %X\n", index, rc));
@@ -232,5 +232,5 @@
 BOOL WIN32API TlsSetValue(DWORD index, LPVOID val)
 {
- THDB *thdb;
+ TEB *teb;
 
   dprintf2(("KERNEL32: TlsSetValue %d %x", index, val));
@@ -242,6 +242,6 @@
   SetLastError(ERROR_SUCCESS);
 
-  thdb = GetThreadTHDB();
-  thdb->tls_array[index] = val;
+  teb = GetThreadTEB();
+  teb->tls_array[index] = val;
   return TRUE;
 }
Index: trunk/src/kernel32/wprocess.cpp
===================================================================
--- trunk/src/kernel32/wprocess.cpp	(revision 4649)
+++ trunk/src/kernel32/wprocess.cpp	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: wprocess.cpp,v 1.107 2000-11-05 13:40:47 sandervl Exp $ */
+/* $Id: wprocess.cpp,v 1.108 2000-11-21 11:35:09 sandervl Exp $ */
 
 /*
@@ -71,5 +71,5 @@
 
 //list of thread database structures
-static THDB     *threadList = 0;
+static TEB      *threadList = 0;
 static VMutex    threadListMutex;
 
@@ -100,51 +100,33 @@
 //******************************************************************************
 //******************************************************************************
-THDB *WIN32API GetThreadTHDB()
-{
- TEB  *winteb;
- THDB *thdb;
-
-    if(TIBFlatPtr == NULL)
-        return 0;
-
-    winteb = (TEB *)*TIBFlatPtr;
-    if(winteb == NULL) {
-        return NULL;
-    }
-    thdb = (THDB *)(winteb+1);
-
-    return thdb;
-}
-//******************************************************************************
-//******************************************************************************
-THDB *WIN32API GetTHDBFromThreadId(ULONG threadId)
-{
- THDB *thdb = threadList;
+TEB *WIN32API GetTEBFromThreadId(ULONG threadId)
+{
+ TEB *teb = threadList;
 
     threadListMutex.enter();
-    while(thdb) {
-        if(thdb->threadId == threadId) {
+    while(teb) {
+        if(teb->o.odin.threadId == threadId) {
             break;
         }
-        thdb = thdb->next;
+        teb = teb->o.odin.next;
     }
     threadListMutex.leave();
-    return thdb;
-}
-//******************************************************************************
-//******************************************************************************
-THDB *WIN32API GetTHDBFromThreadHandle(HANDLE hThread)
-{
- THDB *thdb = threadList;
+    return teb;
+}
+//******************************************************************************
+//******************************************************************************
+TEB *WIN32API GetTEBFromThreadHandle(HANDLE hThread)
+{
+ TEB *teb = threadList;
 
     threadListMutex.enter();
-    while(thdb) {
-        if(thdb->hThread == hThread) {
+    while(teb) {
+        if(teb->o.odin.hThread == hThread) {
             break;
         }
-        thdb = thdb->next;
+        teb = teb->o.odin.next;
     }
     threadListMutex.leave();
-    return thdb;
+    return teb;
 }
 //******************************************************************************
@@ -154,5 +136,4 @@
 {
   TEB   *winteb;
-  THDB  *thdb;
   ULONG  hThreadMain;
   USHORT tibsel;
@@ -170,5 +151,5 @@
         hThreadMain = HMCreateThread(NULL, 0, 0, 0, 0, 0, TRUE);
     }
-    if(OSLibAllocSel(PAGE_SIZE, &tibsel) == FALSE)
+    if(OSLibAllocSel(sizeof(TEB), &tibsel) == FALSE)
     {
         dprintf(("InitializeTIB: selector alloc failed!!"));
@@ -183,6 +164,5 @@
         return NULL;
     }
-    memset(winteb, 0, PAGE_SIZE);
-    thdb       = (THDB *)(winteb+1);
+    memset(winteb, 0, sizeof(TEB));
     *TIBFlatPtr = (DWORD)winteb;
 
@@ -195,39 +175,38 @@
     winteb->flags       = TEBF_WIN32;              /* 1c Flags */
     winteb->queue       = 0;                       /* 28 Message queue */
-    winteb->tls_ptr     = &thdb->tls_array[0];     /* 2c Pointer to TLS array */
+    winteb->tls_ptr     = &winteb->tls_array[0];   /* 2c Pointer to TLS array */
     winteb->process     = &ProcessPDB;             /* 30 owning process (used by NT3.51 applets)*/
 
-    memcpy(&thdb->teb, winteb, sizeof(TEB));
-    thdb->process         = &ProcessPDB;
-    thdb->exit_code       = 0x103; /* STILL_ACTIVE */
-    thdb->teb_sel         = tibsel;
-    thdb->OrgTIBSel       = GetFS();
-    thdb->pWsockData      = NULL;
-    thdb->threadId        = GetCurrentThreadId();
+    winteb->process         = &ProcessPDB;
+    winteb->exit_code       = 0x103; /* STILL_ACTIVE */
+    winteb->teb_sel         = tibsel;
+    winteb->o.odin.OrgTIBSel       = GetFS();
+    winteb->o.odin.pWsockData      = NULL;
+    winteb->o.odin.threadId        = GetCurrentThreadId();
     if(fMainThread) {
-        thdb->hThread     = hThreadMain;
-    }
-    else thdb->hThread    = GetCurrentThread();
-    thdb->lcid            = GetUserDefaultLCID();
+         winteb->o.odin.hThread     = hThreadMain;
+    }
+    else winteb->o.odin.hThread    = GetCurrentThread();
+    winteb->o.odin.lcid            = GetUserDefaultLCID();
 
     threadListMutex.enter();
-    THDB *thdblast        = threadList;
-    if(!thdblast) {
-        threadList = thdb;
+    TEB *teblast        = threadList;
+    if(!teblast) {
+        threadList = winteb;
     }
     else {
-        while(thdblast->next) {
-            thdblast = thdblast->next;
-        }
-        thdblast->next   = thdb;
-    }
-    thdb->next            = NULL;
+        while(teblast->o.odin.next) {
+            teblast = teblast->o.odin.next;
+        }
+        teblast->o.odin.next = winteb;
+    }
+    winteb->o.odin.next        = NULL;
     threadListMutex.leave();
 
     if(OSLibGetPIB(PIB_TASKTYPE) == TASKTYPE_PM)
     {
-        thdb->flags      = 0;  //todo gui
-    }
-    else thdb->flags      = 0;  //todo textmode
+         winteb->flags      = 0;  //todo gui
+    }
+    else winteb->flags      = 0;  //todo textmode
 
     //Initialize thread security objects (TODO: Not complete)
@@ -240,13 +219,13 @@
     }
     SID_IDENTIFIER_AUTHORITY sidIdAuth = {0};
-    thdb->threadinfo.dwType = SECTYPE_PROCESS | SECTYPE_INITIALIZED;
-    RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &thdb->threadinfo.SidUser.User.Sid);
-    thdb->threadinfo.SidUser.User.Attributes = 0; //?????????
-
-    thdb->threadinfo.pTokenGroups = (TOKEN_GROUPS*)malloc(sizeof(TOKEN_GROUPS));
-    thdb->threadinfo.pTokenGroups->GroupCount = 1;
-    RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &thdb->threadinfo.PrimaryGroup.PrimaryGroup);
-    thdb->threadinfo.pTokenGroups->Groups[0].Sid = thdb->threadinfo.PrimaryGroup.PrimaryGroup;
-    thdb->threadinfo.pTokenGroups->Groups[0].Attributes = 0; //????
+    winteb->o.odin.threadinfo.dwType = SECTYPE_PROCESS | SECTYPE_INITIALIZED;
+    RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &winteb->o.odin.threadinfo.SidUser.User.Sid);
+    winteb->o.odin.threadinfo.SidUser.User.Attributes = 0; //?????????
+
+    winteb->o.odin.threadinfo.pTokenGroups = (TOKEN_GROUPS*)malloc(sizeof(TOKEN_GROUPS));
+    winteb->o.odin.threadinfo.pTokenGroups->GroupCount = 1;
+    RtlAllocateAndInitializeSid(&sidIdAuth, 1, 0, 0, 0, 0, 0, 0, 0, 0, &winteb->o.odin.threadinfo.PrimaryGroup.PrimaryGroup);
+    winteb->o.odin.threadinfo.pTokenGroups->Groups[0].Sid = winteb->o.odin.threadinfo.PrimaryGroup.PrimaryGroup;
+    winteb->o.odin.threadinfo.pTokenGroups->Groups[0].Attributes = 0; //????
 //        pPrivilegeSet   = NULL;
 //        pTokenPrivileges= NULL;
@@ -254,5 +233,5 @@
 //        DefaultDACL     = {0};
 //        TokenSource     = {0};
-    thdb->threadinfo.TokenType = TokenPrimary;
+    winteb->o.odin.threadinfo.TokenType = TokenPrimary;
 
     if(fMainThread)
@@ -293,5 +272,4 @@
  SHORT  orgtibsel;
  TEB   *winteb;
- THDB  *thdb;
 
     dprintf(("DestroyTIB: FS     = %x", GetFS()));
@@ -300,23 +278,24 @@
     winteb = (TEB *)*TIBFlatPtr;
     if(winteb) {
-        thdb = (THDB *)(winteb+1);
-        orgtibsel = thdb->OrgTIBSel;
+        orgtibsel = winteb->o.odin.OrgTIBSel;
+
+        dprintf(("DestroyTIB: OSLibFreeSel %x", winteb->teb_sel));
 
         threadListMutex.enter();
-        THDB *curthdb        = threadList;
-        if(curthdb == thdb) {
-            threadList = thdb->next;
+        TEB *curteb        = threadList;
+        if(curteb == winteb) {
+            threadList = winteb->o.odin.next;
         }
         else {
-            while(curthdb->next != thdb) {
-                curthdb = curthdb->next;
-                if(curthdb == NULL) {
-                    dprintf(("DestroyTIB: couldn't find thdb %x", thdb));
+            while(curteb->o.odin.next != winteb) {
+                curteb = curteb->o.odin.next;
+                if(curteb == NULL) {
+                    dprintf(("DestroyTIB: couldn't find teb %x", winteb));
                     DebugInt3();
                     break;
                 }
             }
-            if(curthdb) {
-                curthdb->next = thdb->next;
+            if(curteb) {
+                curteb->o.odin.next = winteb->o.odin.next;
             }
         }
@@ -327,5 +306,5 @@
 
         //And free our own
-        OSLibFreeSel(thdb->teb_sel);
+        OSLibFreeSel(winteb->teb_sel);
 
         *TIBFlatPtr = 0;
@@ -348,5 +327,4 @@
  SHORT  orgtibsel;
  TEB   *winteb;
- THDB  *thdb;
 
    //If we're running an Odin32 OS/2 application (not converted!), then we
@@ -358,6 +336,5 @@
     winteb = (TEB *)*TIBFlatPtr;
     if(winteb) {
-        thdb = (THDB *)(winteb+1);
-        orgtibsel = thdb->OrgTIBSel;
+        orgtibsel = winteb->o.odin.OrgTIBSel;
 
         //Restore our original FS selector
@@ -371,5 +348,4 @@
  SHORT  win32tibsel;
  TEB   *winteb;
- THDB  *thdb;
 
     //If we're running an Odin32 OS/2 application (not converted!), then we
@@ -381,6 +357,5 @@
     winteb = (TEB *)*TIBFlatPtr;
     if(winteb) {
-        thdb = (THDB *)(winteb+1);
-        win32tibsel = thdb->teb_sel;
+        win32tibsel = winteb->teb_sel;
 
         //Restore our win32 FS selector
@@ -395,6 +370,5 @@
             return GetFS();
         }
-        thdb = (THDB *)(winteb+1);
-        win32tibsel = thdb->teb_sel;
+        win32tibsel = winteb->teb_sel;
 
         //Restore our win32 FS selector
@@ -1538,5 +1512,5 @@
                             LPPROCESS_INFORMATION lpProcessInfo )
 {
- THDB *pThreadDB = (THDB*)GetThreadTHDB();
+ TEB *pThreadDB = (TEB*)GetThreadTEB();
  char *cmdline = NULL;
  BOOL  rc;
@@ -1557,5 +1531,5 @@
       if (dwCreationFlags & DEBUG_PROCESS && pThreadDB != NULL)
       {
-        if(pThreadDB->pidDebuggee != 0)
+        if(pThreadDB->o.odin.pidDebuggee != 0)
         {
           // TODO: handle this
@@ -1564,9 +1538,9 @@
         else
         {
-          pThreadDB->pidDebuggee = lpProcessInfo->dwProcessId;
-          OSLibStartDebugger((ULONG*)&pThreadDB->pidDebuggee);
+          pThreadDB->o.odin.pidDebuggee = lpProcessInfo->dwProcessId;
+          OSLibStartDebugger((ULONG*)&pThreadDB->o.odin.pidDebuggee);
         }
       }
-      else pThreadDB->pidDebuggee = 0;
+      else pThreadDB->o.odin.pidDebuggee = 0;
 
       return(TRUE);
@@ -1648,5 +1622,5 @@
       if (dwCreationFlags & DEBUG_PROCESS && pThreadDB != NULL)
       {
-        if(pThreadDB->pidDebuggee != 0)
+        if(pThreadDB->o.odin.pidDebuggee != 0)
         {
           // TODO: handle this
@@ -1655,10 +1629,10 @@
         else
         {
-          pThreadDB->pidDebuggee = lpProcessInfo->dwProcessId;
-          OSLibStartDebugger((ULONG*)&pThreadDB->pidDebuggee);
+          pThreadDB->o.odin.pidDebuggee = lpProcessInfo->dwProcessId;
+          OSLibStartDebugger((ULONG*)&pThreadDB->o.odin.pidDebuggee);
         }
       }
       else
-        pThreadDB->pidDebuggee = 0;
+        pThreadDB->o.odin.pidDebuggee = 0;
     }
     if(cmdline)
Index: trunk/src/user32/HOOK.CPP
===================================================================
--- trunk/src/user32/HOOK.CPP	(revision 4649)
+++ trunk/src/user32/HOOK.CPP	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: HOOK.CPP,v 1.15 2000-10-05 13:47:06 sandervl Exp $ */
+/* $Id: HOOK.CPP,v 1.16 2000-11-21 11:36:07 sandervl Exp $ */
 
 /*
@@ -240,9 +240,9 @@
   MESSAGEQUEUE *queue;
   HANDLE hook = 0;
-  THDB *thdb;
-
-    thdb = GetTHDBFromThreadId(threadId);
-    if(thdb) {
-        hook = thdb->hooks[id - WH_MINHOOK];
+  TEB *teb;
+
+    teb = GetTEBFromThreadId(threadId);
+    if(teb) {
+        hook = teb->o.odin.hooks[id - WH_MINHOOK];
     }
     if (!hook) hook = HOOK_systemHooks[id - WH_MINHOOK];
@@ -261,5 +261,5 @@
 {
   HOOKDATA *data;
-  THDB     *thdb;
+  TEB      *teb;
 
     if ((id < WH_MINHOOK) || (id > WH_MAXHOOK) || !proc )
@@ -301,12 +301,12 @@
     if(dwThreadId)
     {
-        thdb = GetTHDBFromThreadId(dwThreadId);
-        if(!thdb) {
+        teb = GetTEBFromThreadId(dwThreadId);
+        if(!teb) {
                 dprintf(("HOOK_SetHook: can't find thread database for thread %x", dwThreadId));
                 return 0;
         }
         threadHookMutex.enter();
-        data->next = thdb->hooks[id - WH_MINHOOK];
-        thdb->hooks[id - WH_MINHOOK] = (DWORD)data;
+        data->next = teb->o.odin.hooks[id - WH_MINHOOK];
+        teb->o.odin.hooks[id - WH_MINHOOK] = (DWORD)data;
         threadHookMutex.leave();
     }
@@ -331,5 +331,5 @@
 {
   HOOKDATA **prevHook;
-  THDB     *thdb;
+  TEB       *teb;
 
     dprintf(("Removing hook %08x\n", data));
@@ -351,11 +351,11 @@
     if (data->ownerThread)
     {
-        thdb = GetTHDBFromThreadId(data->ownerThread);
-        if(!thdb) {
+        teb = GetTEBFromThreadId(data->ownerThread);
+        if(!teb) {
                 dprintf(("HOOK_RemoveHook: can't find thread database for thread %x", data->ownerThread));
                 return FALSE;
         }
         threadHookMutex.enter();
-        prevHook = (HOOKDATA **)&thdb->hooks[data->id - WH_MINHOOK];
+        prevHook = (HOOKDATA **)&teb->o.odin.hooks[data->id - WH_MINHOOK];
     }
     else {
Index: trunk/src/user32/oslibmsg.cpp
===================================================================
--- trunk/src/user32/oslibmsg.cpp	(revision 4649)
+++ trunk/src/user32/oslibmsg.cpp	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: oslibmsg.cpp,v 1.33 2000-05-12 18:09:40 sandervl Exp $ */
+/* $Id: oslibmsg.cpp,v 1.34 2000-11-21 11:36:08 sandervl Exp $ */
 /*
  * Window message translation functions for OS/2
@@ -78,9 +78,7 @@
    WM_CHAR,          WINWM_KEYLAST,
 
-   WM_COMMAND,       WINWM_COMMAND,
-   WM_SYSCOMMAND,    WINWM_SYSCOMMAND,
    //
    WM_TIMER,         WINWM_TIMER,
-   WM_INITMENU,      WINWM_INITMENU,
+
    //
    WM_MOUSEMOVE,     WINWM_MOUSEMOVE,
@@ -99,6 +97,4 @@
 #define MAX_MSGTRANSTAB (sizeof(MsgTransTab)/sizeof(MsgTransTab[0]))
 
-LRESULT WIN32API SendMessageA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-
 //******************************************************************************
 //******************************************************************************
@@ -134,5 +130,6 @@
     }
 
-    return 0;
+    //not found, probaby WIN32APP_POSTMSG
+    return WIN32APP_POSTMSG;
 }
 //******************************************************************************
@@ -149,10 +146,10 @@
 LONG OSLibWinDispatchMsg(MSG *msg, BOOL isUnicode)
 {
- THDB *thdb;
+ TEB  *teb;
  QMSG  os2msg;
  LONG  rc;
 
-  thdb = GetThreadTHDB();
-  if(thdb == NULL) {
+  teb = GetThreadTEB();
+  if(teb == NULL) {
         DebugInt3();
         return FALSE;
@@ -162,17 +159,17 @@
   //  WinToOS2MsgTranslate(msg, &qmsg, isUnicode);
 
-  if(!memcmp(msg, &thdb->winmsg, sizeof(MSG)) || msg->hwnd == 0) {
-        memcpy(&os2msg, &thdb->os2msg, sizeof(QMSG));
-        thdb->os2msg.time = -1;
-        thdb->winmsg.time = -1;
+  if(!memcmp(msg, &teb->o.odin.winmsg, sizeof(MSG)) || msg->hwnd == 0) {
+        memcpy(&os2msg, &teb->o.odin.os2msg, sizeof(QMSG));
+        teb->o.odin.os2msg.time = -1;
+        teb->o.odin.winmsg.time = -1;
         if(msg->hwnd) {
-            	thdb->nrOfMsgs = 1;
-            	thdb->msgstate++; //odd -> next call to our PM window handler should dispatch the translated msg
-            	memcpy(&thdb->msg, msg, sizeof(MSG));
+            	teb->o.odin.nrOfMsgs = 1;
+            	teb->o.odin.msgstate++; //odd -> next call to our PM window handler should dispatch the translated msg
+            	memcpy(&teb->o.odin.msg, msg, sizeof(MSG));
         }
         if(os2msg.hwnd || os2msg.msg == WM_QUIT) {
-		memset(&thdb->os2msg, 0, sizeof(thdb->os2msg));
-		memset(&thdb->winmsg, 0, sizeof(thdb->winmsg));
-            	return (LONG)WinDispatchMsg(thdb->hab, &os2msg);
+		memset(&teb->o.odin.os2msg, 0, sizeof(teb->o.odin.os2msg));
+		memset(&teb->o.odin.winmsg, 0, sizeof(teb->o.odin.winmsg));
+            	return (LONG)WinDispatchMsg(teb->o.odin.hab, &os2msg);
         }
         //SvL: Don't dispatch messages sent by PostThreadMessage (correct??)
@@ -192,7 +189,8 @@
 {
  BOOL rc, eaten;
- THDB *thdb;
+ TEB  *teb;
  QMSG  os2msg;
  HWND  hwndOS2 = 0;
+ ULONG filtermin, filtermax;
 
   if(hwnd) {
@@ -206,23 +204,23 @@
   }
 
-  thdb = GetThreadTHDB();
-  if(thdb == NULL) {
+  teb = GetThreadTEB();
+  if(teb == NULL) {
         DebugInt3();
 	return TRUE;
   }
 
-  if(thdb->fTranslated && (!hwnd || hwnd == thdb->msgWCHAR.hwnd)) {
+  if(teb->o.odin.fTranslated && (!hwnd || hwnd == teb->o.odin.msgWCHAR.hwnd)) {
         if(uMsgFilterMin) {
-            if(thdb->msgWCHAR.message < uMsgFilterMin)
+            if(teb->o.odin.msgWCHAR.message < uMsgFilterMin)
                 goto continuegetmsg;
         }
         if(uMsgFilterMax) {
-            if(thdb->msgWCHAR.message > uMsgFilterMax)
+            if(teb->o.odin.msgWCHAR.message > uMsgFilterMax)
                 goto continuegetmsg;
         }
-        thdb->fTranslated = FALSE;
-        memcpy(pMsg, &thdb->msgWCHAR, sizeof(MSG));
-        thdb->os2msg.msg  = 0;
-        thdb->os2msg.hwnd = 0;
+        teb->o.odin.fTranslated = FALSE;
+        memcpy(pMsg, &teb->o.odin.msgWCHAR, sizeof(MSG));
+        teb->o.odin.os2msg.msg  = 0;
+        teb->o.odin.os2msg.hwnd = 0;
         return (pMsg->message != WINWM_QUIT);
   }
@@ -230,7 +228,14 @@
 continuegetmsg:
   if(hwnd) {
+    	filtermin = TranslateWinMsg(uMsgFilterMin, TRUE);
+	filtermax = TranslateWinMsg(uMsgFilterMax, FALSE);
+	if(filtermin > filtermax) {
+		ULONG tmp = filtermin;
+		filtermin = filtermax;
+		filtermax = filtermin;
+	}
         do {
-            WinWaitMsg(thdb->hab, TranslateWinMsg(uMsgFilterMin, TRUE), TranslateWinMsg(uMsgFilterMax, FALSE));
-            rc = OSLibWinPeekMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, PM_REMOVE_W, isUnicode);
+            	WinWaitMsg(teb->o.odin.hab, filtermin, filtermax);
+            	rc = OSLibWinPeekMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, PM_REMOVE_W, isUnicode);
         }
         while(rc == FALSE);
@@ -240,15 +245,22 @@
   else
   {
-    do {
-        eaten = FALSE;
-        rc = WinGetMsg(thdb->hab, &os2msg, TranslateWinMsg(uMsgFilterMin, TRUE), TranslateWinMsg(uMsgFilterMax, FALSE), 0);
-        if (os2msg.msg == WM_TIMER)
-            eaten = TIMER_HandleTimer(&os2msg);
-    } while (eaten);
-  }
-
-  OS2ToWinMsgTranslate((PVOID)thdb, &os2msg, pMsg, isUnicode, MSG_REMOVE);
-  memcpy(&thdb->os2msg, &os2msg, sizeof(QMSG));
-  memcpy(&thdb->winmsg, pMsg, sizeof(MSG));
+    	filtermin = TranslateWinMsg(uMsgFilterMin, TRUE);
+	filtermax = TranslateWinMsg(uMsgFilterMax, FALSE);
+	if(filtermin > filtermax) {
+		ULONG tmp = filtermin;
+		filtermin = filtermax;
+		filtermax = filtermin;
+	}
+    	do {
+        	eaten = FALSE;
+	        rc = WinGetMsg(teb->o.odin.hab, &os2msg, filtermin, filtermax, 0);
+	        if (os2msg.msg == WM_TIMER)
+	            eaten = TIMER_HandleTimer(&os2msg);
+	} while (eaten);
+  }
+
+  OS2ToWinMsgTranslate((PVOID)teb, &os2msg, pMsg, isUnicode, MSG_REMOVE);
+  memcpy(&teb->o.odin.os2msg, &os2msg, sizeof(QMSG));
+  memcpy(&teb->o.odin.winmsg, pMsg, sizeof(MSG));
 
   if(pMsg->message <= WINWM_KEYLAST && pMsg->message >= WINWM_KEYDOWN)
@@ -275,5 +287,5 @@
 {
  BOOL  rc, eaten;
- THDB *thdb;
+ TEB  *teb;
  QMSG  os2msg;
  HWND  hwndOS2 = 0;
@@ -288,26 +300,26 @@
   }
 
-  thdb = GetThreadTHDB();
-  if(thdb == NULL) {
+  teb = GetThreadTEB();
+  if(teb == NULL) {
         DebugInt3();
         return FALSE;
   }
 
-  if(thdb->fTranslated && (!hwnd || hwnd == thdb->msgWCHAR.hwnd)) {
+  if(teb->o.odin.fTranslated && (!hwnd || hwnd == teb->o.odin.msgWCHAR.hwnd)) {
         if(uMsgFilterMin) {
-            if(thdb->msgWCHAR.message < uMsgFilterMin)
+            if(teb->o.odin.msgWCHAR.message < uMsgFilterMin)
                 goto continuepeekmsg;
         }
         if(uMsgFilterMax) {
-            if(thdb->msgWCHAR.message > uMsgFilterMax)
+            if(teb->o.odin.msgWCHAR.message > uMsgFilterMax)
                 goto continuepeekmsg;
         }
 
         if(fRemove & PM_REMOVE_W) {
-            thdb->fTranslated = FALSE;
-            thdb->os2msg.msg  = 0;
-            thdb->os2msg.hwnd = 0;
-        }
-        memcpy(pMsg, &thdb->msgWCHAR, sizeof(MSG));
+            teb->o.odin.fTranslated = FALSE;
+            teb->o.odin.os2msg.msg  = 0;
+            teb->o.odin.os2msg.hwnd = 0;
+        }
+        memcpy(pMsg, &teb->o.odin.msgWCHAR, sizeof(MSG));
         return TRUE;
   }
@@ -316,5 +328,5 @@
   do {
         eaten = FALSE;
-        rc = WinPeekMsg(thdb->hab, &os2msg, hwndOS2, TranslateWinMsg(uMsgFilterMin, TRUE),
+        rc = WinPeekMsg(teb->o.odin.hab, &os2msg, hwndOS2, TranslateWinMsg(uMsgFilterMin, TRUE),
                         TranslateWinMsg(uMsgFilterMax, FALSE), (fRemove & PM_REMOVE_W) ? PM_REMOVE : PM_NOREMOVE);
 
@@ -329,9 +341,9 @@
   }
 
-  OS2ToWinMsgTranslate((PVOID)thdb, &os2msg, pMsg, isUnicode, (fRemove & PM_REMOVE_W) ? MSG_REMOVE : MSG_NOREMOVE);
+  OS2ToWinMsgTranslate((PVOID)teb, &os2msg, pMsg, isUnicode, (fRemove & PM_REMOVE_W) ? MSG_REMOVE : MSG_NOREMOVE);
   //TODO: This is not safe! There's no guarantee this message will be dispatched and it might overwrite a previous message
   if(fRemove & PM_REMOVE_W) {
-  	memcpy(&thdb->os2msg, &os2msg, sizeof(QMSG));
-  	memcpy(&thdb->winmsg, pMsg, sizeof(MSG));
+  	memcpy(&teb->o.odin.os2msg, &os2msg, sizeof(QMSG));
+  	memcpy(&teb->o.odin.winmsg, pMsg, sizeof(MSG));
   }
 
@@ -460,8 +472,8 @@
 BOOL OSLibPostThreadMessage(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
 {
-// THDB *thdb = GetTHDBFromThreadId(threadid);
+// TEB *teb = GetTEBFromThreadId(threadid);
  POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
 
-//    if(thdb == NULL) {
+//    if(teb == NULL) {
 //        dprintf(("OSLibPostThreadMessage: thread %x not found!", threadid));
 //        return FALSE;
Index: trunk/src/user32/oslibmsgtranslate.cpp
===================================================================
--- trunk/src/user32/oslibmsgtranslate.cpp	(revision 4649)
+++ trunk/src/user32/oslibmsgtranslate.cpp	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: oslibmsgtranslate.cpp,v 1.38 2000-11-15 20:30:46 sandervl Exp $ */
+/* $Id: oslibmsgtranslate.cpp,v 1.39 2000-11-21 11:36:08 sandervl Exp $ */
 /*
  * Window message translation functions for OS/2
@@ -132,10 +132,10 @@
 //******************************************************************************
 //******************************************************************************
-BOOL OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fMsgRemoved)
+BOOL OS2ToWinMsgTranslate(void *pTeb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fMsgRemoved)
 {
   Win32BaseWindow *win32wnd = 0;
   OSLIBPOINT       point, ClientPoint;
   POSTMSG_PACKET  *packet;
-  THDB            *thdb = (THDB *)pThdb;
+  TEB             *teb = (TEB *)pTeb;
   BOOL             fWasDisabled = FALSE;
   int i;
@@ -176,10 +176,10 @@
     case WM_CREATE:
     {
-        if(thdb->newWindow == 0) {
+        if(teb->o.odin.newWindow == 0) {
             DebugInt3();
             goto dummymessage;
         }
 
-        win32wnd = (Win32BaseWindow *)thdb->newWindow;
+        win32wnd = (Win32BaseWindow *)teb->o.odin.newWindow;
 
         winMsg->message = WINWM_CREATE;
@@ -233,10 +233,10 @@
         }
         if(win32wnd->getParent()) {
-   	      OSLibMapSWPtoWINDOWPOS(pswp, &thdb->wp, &swpOld, win32wnd->getParent()->getWindowHeight(), 
+   	      OSLibMapSWPtoWINDOWPOS(pswp, &teb->o.odin.wp, &swpOld, win32wnd->getParent()->getWindowHeight(), 
                                      win32wnd->getParent()->getClientRectPtr()->left,
                                      win32wnd->getParent()->getClientRectPtr()->top,
                                      win32wnd->getOS2WindowHandle());
         } 
-        else  OSLibMapSWPtoWINDOWPOS(pswp, &thdb->wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, win32wnd->getOS2WindowHandle());
+        else  OSLibMapSWPtoWINDOWPOS(pswp, &teb->o.odin.wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, win32wnd->getOS2WindowHandle());
 
         if (!win32wnd->CanReceiveSizeMsgs())    goto dummymessage;
@@ -246,15 +246,15 @@
 /////                win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
 
-                thdb->wp.hwnd = win32wnd->getWindowHandle();
+                teb->o.odin.wp.hwnd = win32wnd->getWindowHandle();
                 if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
                 {
                         Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
                         if(wndAfter)
-                  	      thdb->wp.hwndInsertAfter = wndAfter->getWindowHandle();
-			else  thdb->wp.hwndInsertAfter = HWND_TOP_W;
+                  	      teb->o.odin.wp.hwndInsertAfter = wndAfter->getWindowHandle();
+			else  teb->o.odin.wp.hwndInsertAfter = HWND_TOP_W;
                 }
         }
         winMsg->message = WINWM_WINDOWPOSCHANGED;
-        winMsg->lParam  = (LPARAM)&thdb->wp;
+        winMsg->lParam  = (LPARAM)&teb->o.odin.wp;
         break;
     }
@@ -496,5 +496,5 @@
         char c;
 
-        thdb->fTranslated = FALSE;
+        teb->o.odin.fTranslated = FALSE;
         repeatCount = CHAR3FROMMP(os2Msg->mp1);
         scanCode = CHAR4FROMMP(os2Msg->mp1);
@@ -694,4 +694,8 @@
     case WM_RENDERALLFMTS:
         winMsg->message = WINWM_RENDERALLFORMATS;
+        break;
+
+    case WM_DESTROYCLIPBOARD:
+        winMsg->message = WINWM_DESTROYCLIPBOARD;
         break;
 
@@ -733,19 +737,19 @@
 BOOL OSLibWinTranslateMessage(MSG *msg)
 {
- THDB *thdb;
-
-    thdb = GetThreadTHDB();
-    if(!thdb) {
+ TEB *teb;
+
+    teb = GetThreadTEB();
+    if(!teb) {
         return FALSE;
     }
     //NOTE: These actually need to be posted so that the next message retrieved by GetMessage contains
     //      the newly generated WM_CHAR message.
-    if(!thdb->fTranslated && thdb->os2msg.msg == WM_CHAR && !((SHORT1FROMMP(thdb->os2msg.mp1) & KC_KEYUP) == KC_KEYUP))
+    if(!teb->o.odin.fTranslated && teb->o.odin.os2msg.msg == WM_CHAR && !((SHORT1FROMMP(teb->o.odin.os2msg.mp1) & KC_KEYUP) == KC_KEYUP))
     {//TranslatedMessage was called before DispatchMessage, so queue WM_CHAR message
-            ULONG fl = SHORT1FROMMP(thdb->os2msg.mp1);
+            ULONG fl = SHORT1FROMMP(teb->o.odin.os2msg.mp1);
             MSG extramsg;
 
             memcpy(&extramsg, msg, sizeof(MSG));
-            extramsg.wParam = SHORT1FROMMP(thdb->os2msg.mp2);
+            extramsg.wParam = SHORT1FROMMP(teb->o.odin.os2msg.mp2);
             extramsg.lParam = 0;
 
@@ -757,5 +761,5 @@
                 if(msg->wParam)
                         extramsg.wParam = msg->wParam;
-                else    extramsg.wParam = SHORT2FROMMP(thdb->os2msg.mp2);
+                else    extramsg.wParam = SHORT2FROMMP(teb->o.odin.os2msg.mp2);
             }
 
@@ -778,6 +782,6 @@
                 extramsg.lParam |= (1<<31);
 
-            thdb->fTranslated = TRUE;
-            memcpy(&thdb->msgWCHAR, &extramsg, sizeof(MSG));
+            teb->o.odin.fTranslated = TRUE;
+            memcpy(&teb->o.odin.msgWCHAR, &extramsg, sizeof(MSG));
             return TRUE;
     }
Index: trunk/src/user32/oslibutil.cpp
===================================================================
--- trunk/src/user32/oslibutil.cpp	(revision 4649)
+++ trunk/src/user32/oslibutil.cpp	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: oslibutil.cpp,v 1.5 2000-02-16 14:34:28 sandervl Exp $ */
+/* $Id: oslibutil.cpp,v 1.6 2000-11-21 11:36:08 sandervl Exp $ */
 /*
  * Window API utility functions for OS/2
@@ -22,13 +22,13 @@
 HAB GetThreadHAB()
 {
- THDB *thdb;
+ TEB *teb;
 
-  thdb = GetThreadTHDB();
-  if(thdb)
+  teb = GetThreadTEB();
+  if(teb)
   {
-        return (HAB)thdb->hab;
+        return (HAB)teb->o.odin.hab;
   }
 
-  dprintf(("GetThreadHAB: thdb == NULL!!"));
+  dprintf(("GetThreadHAB: teb == NULL!!"));
   return 0;
 }
@@ -37,12 +37,12 @@
 void SetThreadHAB(HAB hab)
 {
- THDB *thdb;
+ TEB *teb;
 
-  thdb = GetThreadTHDB();
-  if(thdb)
+  teb = GetThreadTEB();
+  if(teb)
   {
-        thdb->hab = (ULONG)hab;
+        teb->o.odin.hab = (ULONG)hab;
   }
-  else  dprintf(("SetThreadHAB: thdb == NULL!!"));
+  else  dprintf(("SetThreadHAB: teb == NULL!!"));
 }
 //******************************************************************************
@@ -50,13 +50,13 @@
 HMQ GetThreadMessageQueue()
 {
- THDB *thdb;
+ TEB *teb;
 
-  thdb = GetThreadTHDB();
-  if(thdb)
+  teb = GetThreadTEB();
+  if(teb)
   {
-        return (HMQ)thdb->hmq;
+        return (HMQ)teb->o.odin.hmq;
   }
 
-  dprintf(("GetThreadMessageQueue: thdb == NULL!!"));
+  dprintf(("GetThreadMessageQueue: teb == NULL!!"));
   return 0;
 }
@@ -65,12 +65,12 @@
 void SetThreadMessageQueue(HMQ hmq)
 {
- THDB *thdb;
+ TEB *teb;
 
-  thdb = GetThreadTHDB();
-  if(thdb)
+  teb = GetThreadTEB();
+  if(teb)
   {
-        thdb->hmq = (ULONG)hmq;
+        teb->o.odin.hmq = (ULONG)hmq;
   }
-  else  dprintf(("SetThreadMessageQueue: thdb == NULL!!"));
+  else  dprintf(("SetThreadMessageQueue: teb == NULL!!"));
 }
 //******************************************************************************
@@ -78,13 +78,13 @@
 DWORD GetThreadMessageExtraInfo()
 {
- THDB *thdb;
+ TEB *teb;
 
-  thdb = GetThreadTHDB();
-  if(thdb)
+  teb = GetThreadTEB();
+  if(teb)
   {
-        return thdb->lParam;
+        return teb->o.odin.lParam;
   }
 
-  dprintf(("GetThreadMessageExtraInfo: thdb == NULL!!"));
+  dprintf(("GetThreadMessageExtraInfo: teb == NULL!!"));
   return 0;
 }
@@ -93,12 +93,12 @@
 DWORD SetThreadMessageExtraInfo(DWORD lParam)
 {
- THDB *thdb;
+ TEB *teb;
 
-  thdb = GetThreadTHDB();
-  if(thdb)
+  teb = GetThreadTEB();
+  if(teb)
   {
-        thdb->lParam = lParam;
+        teb->o.odin.lParam = lParam;
   }
-  else  dprintf(("SetThreadMessageExtraInfo: thdb == NULL!!"));
+  else  dprintf(("SetThreadMessageExtraInfo: teb == NULL!!"));
   return 0;
 }
Index: trunk/src/user32/pmframe.cpp
===================================================================
--- trunk/src/user32/pmframe.cpp	(revision 4649)
+++ trunk/src/user32/pmframe.cpp	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: pmframe.cpp,v 1.55 2000-05-24 19:30:05 sandervl Exp $ */
+/* $Id: pmframe.cpp,v 1.56 2000-11-21 11:36:08 sandervl Exp $ */
 /*
  * Win32 Frame Managment Code for OS/2
@@ -68,13 +68,13 @@
  PFNWP            OldFrameProc;
  MRESULT          rc;
- THDB            *thdb;
+ TEB             *teb;
  MSG             *pWinMsg,winMsg;
 
   SetWin32TIB();
 
-  thdb = GetThreadTHDB();
+  teb = GetThreadTEB();
   win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
 
-  if (!thdb || (win32wnd == NULL) || !win32wnd->getOldFrameProc())
+  if (!teb || (win32wnd == NULL) || !win32wnd->getOldFrameProc())
   {
     dprintf(("Invalid win32wnd pointer for frame %x!!", hwnd));
@@ -82,5 +82,5 @@
   }
 
-  if((thdb->msgstate & 1) == 0)
+  if((teb->o.odin.msgstate & 1) == 0)
   {//message that was sent directly to our window proc handler; translate it here
         QMSG qmsg;
@@ -90,9 +90,9 @@
         qmsg.mp1  = mp1;
         qmsg.mp2  = mp2;
-        qmsg.time = WinQueryMsgTime(thdb->hab);
-        WinQueryMsgPos(thdb->hab, &qmsg.ptl);
+        qmsg.time = WinQueryMsgTime(teb->o.odin.hab);
+        WinQueryMsgPos(teb->o.odin.hab, &qmsg.ptl);
         qmsg.reserved = 0;
 
-        if(OS2ToWinMsgTranslate((PVOID)thdb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
+        if(OS2ToWinMsgTranslate((PVOID)teb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
         {//message was not translated
             memset(&winMsg, 0, sizeof(MSG));
@@ -101,6 +101,6 @@
   }
   else {
-        pWinMsg = &thdb->msg;
-        thdb->msgstate++;
+        pWinMsg = &teb->o.odin.msg;
+        teb->o.odin.msgstate++;
   }
 
@@ -357,5 +357,5 @@
           //TODO: Get rid of SWP_SHOW; needed for winhlp32 button bar for now
           swpClient.fl = (pswp->fl & ~SWP_ZORDER) | SWP_MOVE | SWP_SHOW;
-          WinSetMultWindowPos(thdb->hab, &swpClient, 1);
+          WinSetMultWindowPos(teb->o.odin.hab, &swpClient, 1);
 
           //update child positions: rectWindow is in window coordinates
Index: trunk/src/user32/pmwindow.cpp
===================================================================
--- trunk/src/user32/pmwindow.cpp	(revision 4649)
+++ trunk/src/user32/pmwindow.cpp	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: pmwindow.cpp,v 1.107 2000-11-15 20:30:46 sandervl Exp $ */
+/* $Id: pmwindow.cpp,v 1.108 2000-11-21 11:36:09 sandervl Exp $ */
 /*
  * Win32 Window Managment Code for OS/2
@@ -144,5 +144,5 @@
  OSLIBPOINT       point, ClientPoint;
  Win32BaseWindow *win32wnd;
- THDB            *thdb;
+ TEB             *teb;
  APIRET           rc = 0;
  MSG              winMsg, *pWinMsg;
@@ -151,13 +151,13 @@
   SetWin32TIB();
 
-  thdb = GetThreadTHDB();
+  teb = GetThreadTEB();
   win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
 
-  if(!thdb || (msg != WM_CREATE && win32wnd == NULL)) {
+  if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
         dprintf(("Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
         goto RunDefWndProc;
   }
 
-  if((thdb->msgstate & 1) == 0)
+  if((teb->o.odin.msgstate & 1) == 0)
   {//message that was sent directly to our window proc handler; translate it here
         QMSG qmsg;
@@ -167,9 +167,9 @@
         qmsg.mp1  = mp1;
         qmsg.mp2  = mp2;
-        qmsg.time = WinQueryMsgTime(thdb->hab);
-        WinQueryMsgPos(thdb->hab, &qmsg.ptl);
+        qmsg.time = WinQueryMsgTime(teb->o.odin.hab);
+        WinQueryMsgPos(teb->o.odin.hab, &qmsg.ptl);
         qmsg.reserved = 0;
 
-        if(OS2ToWinMsgTranslate((PVOID)thdb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
+        if(OS2ToWinMsgTranslate((PVOID)teb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
         {//message was not translated
             memset(&winMsg, 0, sizeof(MSG));
@@ -178,6 +178,6 @@
   }
   else {
-        pWinMsg = &thdb->msg;
-        thdb->msgstate++;
+        pWinMsg = &teb->o.odin.msg;
+        teb->o.odin.msgstate++;
   }
 
@@ -197,11 +197,11 @@
     case WM_CREATE:
     {
-        if(thdb->newWindow == 0)
+        if(teb->o.odin.newWindow == 0)
             goto createfail;
 
         //Processing is done in after WinCreateWindow returns
         dprintf(("OS2: WM_CREATE %x", hwnd));
-        win32wnd = (Win32BaseWindow *)thdb->newWindow;
-        thdb->newWindow = 0;
+        win32wnd = (Win32BaseWindow *)teb->o.odin.newWindow;
+        teb->o.odin.newWindow = 0;
         if(win32wnd->MsgCreate(hwnd) == FALSE)
         {
@@ -794,4 +794,5 @@
     case WM_RENDERFMT:
     case WM_RENDERALLFMTS:
+    case WM_DESTROYCLIPBOARD:
         win32wnd->DispatchMsgA(pWinMsg);
         break;
Index: trunk/src/user32/win32wbase.cpp
===================================================================
--- trunk/src/user32/win32wbase.cpp	(revision 4649)
+++ trunk/src/user32/win32wbase.cpp	(revision 4658)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.223 2000-11-19 11:52:40 sandervl Exp $ */
+/* $Id: win32wbase.cpp,v 1.224 2000-11-21 11:36:09 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -496,13 +496,13 @@
 
   //Store our window object pointer in thread local memory, so PMWINDOW.CPP can retrieve it
-  THDB *thdb = GetThreadTHDB();
-
-  if(thdb == NULL) {
-        dprintf(("Window creation failed - thdb == NULL")); //this is VERY bad
+  TEB *teb = GetThreadTEB();
+
+  if(teb == NULL) {
+        dprintf(("Window creation failed - teb == NULL")); //this is VERY bad
         ExitProcess(666);
         return FALSE;
   }
 
-  thdb->newWindow = (ULONG)this;
+  teb->o.odin.newWindow = (ULONG)this;
 
   DWORD dwOSWinStyle;
