Ignore:
Timestamp:
Feb 7, 2002, 12:19:13 PM (24 years ago)
Author:
sandervl
Message:

Determine if thread callback is inside a PE dll; if true, then force switch to win32 TIB (FS selector)

File:
1 edited

Legend:

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

    r7769 r7828  
    1 /* $Id: thread.cpp,v 1.41 2002-01-13 21:42:43 sandervl Exp $ */
     1/* $Id: thread.cpp,v 1.42 2002-02-07 11:19:13 sandervl Exp $ */
    22
    33/*
     
    279279 EXCEPTION_FRAME exceptFrame;
    280280 Win32Thread     *me = (Win32Thread *)lpData;
    281  ULONG            winthread = (ULONG)me->pCallback;
     281 ULONG            threadCallback = (ULONG)me->pCallback;
    282282 LPVOID           userdata  = me->lpUserData;
    283283 HANDLE           hThread   = me->hThread;
     
    295295  winteb->flags = me->dwFlags;
    296296
    297   winteb->entry_point = (void *)winthread;
     297  winteb->entry_point = (void *)threadCallback;
    298298  winteb->entry_arg   = (void *)userdata;
    299299  winteb->o.odin.hThread = hThread;
     
    308308  winteb->o.odin.exceptFrame = (ULONG)&exceptFrame;
    309309
    310   SetWin32TIB();
     310  //Determine if thread callback is inside a PE dll; if true, then force
     311  //switch to win32 TIB (FS selector)
     312  //(necessary for Opera when loading win32 plugins that create threads)
     313  Win32DllBase *dll;
     314  dll = Win32DllBase::findModuleByAddr(threadCallback);
     315  if(dll && dll->isPEImage()) {
     316       dprintf(("Win32ThreadProc: Force win32 TIB switch"));
     317       SetWin32TIB(TIB_SWITCH_FORCE_WIN32);
     318  }
     319  else SetWin32TIB(TIB_SWITCH_DEFAULT); //executable type determines whether or not FS is changed
    311320
    312321  DWORD dwProcessAffinityMask, dwSystemAffinityMask;
     
    323332  //Set FPU control word to 0x27F (same as in NT)
    324333  CONTROL87(0x27F, 0xFFF);
    325   rc = AsmCallThreadHandler(winthread, userdata);
     334  rc = AsmCallThreadHandler(threadCallback, userdata);
    326335
    327336  if(fExitProcess) {
     
    334343      Win32DllBase::tlsDetachThreadFromAllDlls(); //destroy TLS structures of all dlls
    335344      if(WinExe) WinExe->tlsDetachThread();               //destroy TLS structure of main exe
    336       DestroyTIB();
     345      DestroyTIB();  //destroys TIB and restores FS
    337346      OS2UnsetExceptionHandler((void *)&exceptFrame);
    338347  }
Note: See TracChangeset for help on using the changeset viewer.