Renamed a few TEB fields to use the "official" names.

This commit is contained in:
Alexandre Julliard 2003-08-27 23:14:29 +00:00
parent fca4a8f877
commit 02f2813968
15 changed files with 75 additions and 67 deletions

View File

@ -461,7 +461,7 @@ HTASK16 TASK_GetTaskFromThread( DWORD thread )
TDB *p = TASK_GetPtr( hFirstTask );
while (p)
{
if (p->teb->tid == thread) return p->hSelf;
if (p->teb->ClientId.UniqueThread == (HANDLE)thread) return p->hSelf;
p = TASK_GetPtr( p->hNext );
}
return 0;
@ -620,7 +620,7 @@ BOOL16 WINAPI WaitEvent16( HTASK16 hTask )
if (pTask->flags & TDBF_WIN32)
{
FIXME("called for Win32 thread (%04lx)!\n", NtCurrentTeb()->tid);
FIXME("called for Win32 thread (%04lx)!\n", GetCurrentThreadId());
return TRUE;
}
@ -659,7 +659,7 @@ void WINAPI PostEvent16( HTASK16 hTask )
if (pTask->flags & TDBF_WIN32)
{
FIXME("called for Win32 thread (%04lx)!\n", pTask->teb->tid );
FIXME("called for Win32 thread (%04lx)!\n", (DWORD)pTask->teb->ClientId.UniqueThread );
return;
}

View File

@ -376,7 +376,7 @@ HANDLE WINAPI K32WOWHandle32( WORD handle, WOW_HANDLE_TYPE type )
return (HANDLE)(ULONG_PTR)handle;
case WOW_TYPE_HTASK:
return (HANDLE)((TDB *)GlobalLock16(handle))->teb->tid;
return ((TDB *)GlobalLock16(handle))->teb->ClientId.UniqueThread;
case WOW_TYPE_FULLHWND:
FIXME( "conversion of full window handles not supported yet\n" );

View File

@ -294,7 +294,7 @@ static int NTDLL_dbg_vlog( unsigned int cls, const char *channel,
if (info->out_pos == info->output || info->out_pos[-1] == '\n')
{
if (TRACE_ON(tid))
ret = wine_dbg_printf( "%04lx:", NtCurrentTeb()->tid );
ret = wine_dbg_printf( "%04lx:", GetCurrentThreadId() );
if (cls < sizeof(classes)/sizeof(classes[0]))
ret += wine_dbg_printf( "%s:%s:%s ", classes[cls], channel + 1, function );
}

View File

@ -516,7 +516,7 @@ static NTSTATUS alloc_thread_tls(void)
memset( data, 0, dir->SizeOfZeroFill );
data += dir->SizeOfZeroFill;
}
NtCurrentTeb()->tls_ptr = pointers;
NtCurrentTeb()->ThreadLocalStoragePointer = pointers;
return STATUS_SUCCESS;
}

View File

@ -298,7 +298,7 @@ void SYSDEPS_ExitThread( int status )
SIGNAL_Block();
size = 0;
NtFreeVirtualMemory( GetCurrentProcess(), &teb->stack_base, &size, MEM_RELEASE | MEM_SYSTEM );
NtFreeVirtualMemory( GetCurrentProcess(), &teb->DeallocationStack, &size, MEM_RELEASE | MEM_SYSTEM );
close( teb->wait_fd[0] );
close( teb->wait_fd[1] );
close( teb->reply_fd );

View File

@ -829,7 +829,7 @@ DWORD VIRTUAL_HandleFault( LPCVOID addr )
{
BYTE vprot = view->prot[((char *)addr - (char *)view->base) >> page_shift];
void *page = (void *)((UINT_PTR)addr & ~page_mask);
char *stack = (char *)NtCurrentTeb()->stack_base + SIGNAL_STACK_SIZE + page_mask + 1;
char *stack = (char *)NtCurrentTeb()->DeallocationStack + SIGNAL_STACK_SIZE + page_mask + 1;
if (vprot & VPROT_GUARD)
{
VIRTUAL_SetProt( view, page, page_mask + 1, vprot & ~VPROT_GUARD );

View File

@ -207,7 +207,7 @@ static APARTMENT* COM_CreateApartment(DWORD model)
apt->next = apts;
apts = apt;
LeaveCriticalSection(&csApartment);
NtCurrentTeb()->ErrorInfo = apt;
NtCurrentTeb()->ReservedForOle = apt;
return apt;
}
@ -379,7 +379,7 @@ HRESULT WINAPI CoInitializeEx(
ERR("(%p, %x) - Bad parameter passed-in %p, must be an old Windows Application\n", lpReserved, (int)dwCoInit, lpReserved);
}
apt = NtCurrentTeb()->ErrorInfo;
apt = NtCurrentTeb()->ReservedForOle;
if (apt && dwCoInit != apt->model) return RPC_E_CHANGED_MODE;
hr = apt ? S_FALSE : S_OK;
@ -404,7 +404,7 @@ HRESULT WINAPI CoInitializeEx(
if (!apt) apt = COM_CreateApartment(dwCoInit);
InterlockedIncrement(&apt->inits);
if (hr == S_OK) NtCurrentTeb()->ErrorInfo = apt;
if (hr == S_OK) NtCurrentTeb()->ReservedForOle = apt;
return hr;
}
@ -423,10 +423,10 @@ void WINAPI CoUninitialize(void)
TRACE("()\n");
apt = NtCurrentTeb()->ErrorInfo;
apt = NtCurrentTeb()->ReservedForOle;
if (!apt) return;
if (InterlockedDecrement(&apt->inits)==0) {
NtCurrentTeb()->ErrorInfo = NULL;
NtCurrentTeb()->ReservedForOle = NULL;
COM_DestroyApartment(apt);
apt = NULL;
}

View File

@ -200,7 +200,7 @@ HRESULT WINAPI __CLSIDFromStringA(LPCSTR idstr, CLSID *id);
static inline APARTMENT* COM_CurrentInfo(void) WINE_UNUSED;
static inline APARTMENT* COM_CurrentInfo(void)
{
APARTMENT* apt = NtCurrentTeb()->ErrorInfo;
APARTMENT* apt = NtCurrentTeb()->ReservedForOle;
return apt;
}
static inline APARTMENT* COM_CurrentApt(void) WINE_UNUSED;

View File

@ -66,11 +66,10 @@ typedef struct _TEB
struct _TEB *self; /* 12- 18 Pointer to this structure */
WORD tibflags; /* 1!n 1c Flags (NT: EnvironmentPointer) */
WORD mutex_count; /* 1-n 1e Win16 mutex count */
DWORD pid; /* !2- 20 Process id (win95: debug context) */
DWORD tid; /* -2- 24 Thread id */
CLIENT_ID ClientId; /* -2- 20 Process and thread id (win95: debug context) */
HQUEUE16 queue; /* 1!- 28 Message queue (NT: DWORD ActiveRpcHandle)*/
WORD pad1; /* --n 2a */
LPVOID *tls_ptr; /* 1-- 2c Pointer to TLS array */
PVOID ThreadLocalStoragePointer; /* 1-- 2c Pointer to TLS array */
PEB *Peb; /* 12- 30 owning process PEB */
DWORD flags; /* 1-n 34 */
DWORD exit_code; /* 1-- 38 Termination status */
@ -130,12 +129,12 @@ typedef struct _TEB
DWORD pad6[624]; /* --n 238 */
UNICODE_STRING StaticUnicodeString; /* -2- bf8 used by advapi32 */
USHORT StaticUnicodeBuffer[261]; /* -2- c00 used by advapi32 */
void *stack_base; /* -2- e0c Base of the stack */
LPVOID tls_array[64]; /* -2- e10 Thread local storage */
PVOID DeallocationStack; /* -2- e0c Base of the stack */
LPVOID TlsSlots[64]; /* -2- e10 Thread local storage */
DWORD pad8[3]; /* --n f10 */
PVOID ReservedForNtRpc; /* -2- f1c used by rpcrt4 */
DWORD pad9[24]; /* --n f20 */
PVOID ErrorInfo; /* -2- f80 used by ole32 (IErrorInfo*) */
PVOID ReservedForOle; /* -2- f80 used by ole32 (IErrorInfo*) */
} TEB;
/* Thread exception flags */

View File

@ -34,15 +34,28 @@ extern "C" {
* TEB data structure
*/
#if 0
typedef struct _TEB {
BYTE Reserved1[1952];
PVOID Reserved2[412];
PVOID TlsSlots[64];
BYTE Reserved3[8];
PVOID Reserved4[26];
PVOID ReservedForOle; /* Windows 2000 only */
PVOID Reserved5[4];
PVOID TlsExpansionSlots;
typedef struct _TEB
{
NT_TIB Tib; /* 000 */
PVOID EnvironmentPointer; /* 01c */
CLIENT_ID ClientId; /* 020 */
PVOID ActiveRpcHandle; /* 028 */
PVOID ThreadLocalStoragePointer; /* 02c */
PPEB Peb; /* 030 */
ULONG LastErrorValue; /* 034 */
BYTE __pad038[140]; /* 038 */
ULONG CurrentLocale; /* 0c4 */
BYTE __pad0c8[1752]; /* 0c8 */
PVOID Reserved2[278]; /* 7a0 */
UNICODE_STRING StaticUnicodeString; /* bf8 used by advapi32 */
WCHAR StaticUnicodeBuffer[261]; /* c00 used by advapi32 */
PVOID DeallocationStack; /* e0c */
PVOID TlsSlots[64]; /* e10 */
BYTE Reserved3[8]; /* f10 */
PVOID Reserved4[26]; /* f18 */
PVOID ReservedForOle; /* f80 Windows 2000 only */
PVOID Reserved5[4]; /* f84 */
PVOID TlsExpansionSlots; /* f94 */
} TEB, *PTEB;
#endif

View File

@ -75,7 +75,7 @@ struct cmsg_fd
};
#endif /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */
static DWORD boot_thread_id;
static HANDLE boot_thread_id;
static sigset_t block_set; /* signals to block during server calls */
static int fd_socket; /* socket to exchange file descriptors with the server */
@ -118,7 +118,7 @@ void server_protocol_error( const char *err, ... )
va_list args;
va_start( args, err );
fprintf( stderr, "wine client error:%lx: ", NtCurrentTeb()->tid );
fprintf( stderr, "wine client error:%lx: ", GetCurrentThreadId() );
vfprintf( stderr, err, args );
va_end( args );
SYSDEPS_AbortThread(1);
@ -130,7 +130,7 @@ void server_protocol_error( const char *err, ... )
*/
void server_protocol_perror( const char *err )
{
fprintf( stderr, "wine client error:%lx: ", NtCurrentTeb()->tid );
fprintf( stderr, "wine client error:%lx: ", GetCurrentThreadId() );
perror( err );
SYSDEPS_AbortThread(1);
}
@ -708,11 +708,11 @@ void CLIENT_InitThread(void)
req->reply_fd = reply_pipe[1];
req->wait_fd = teb->wait_fd[1];
ret = wine_server_call( req );
teb->pid = reply->pid;
teb->tid = reply->tid;
teb->ClientId.UniqueProcess = (HANDLE)reply->pid;
teb->ClientId.UniqueThread = (HANDLE)reply->tid;
version = reply->version;
if (reply->boot) boot_thread_id = teb->tid;
else if (boot_thread_id == teb->tid) boot_thread_id = 0;
if (reply->boot) boot_thread_id = teb->ClientId.UniqueThread;
else if (boot_thread_id == teb->ClientId.UniqueThread) boot_thread_id = 0;
}
SERVER_END_REQ;

View File

@ -144,7 +144,7 @@ LPVOID WINAPI ConvertThreadToFiberEx( LPVOID param, DWORD flags )
fiber->except = NtCurrentTeb()->except;
fiber->stack_top = NtCurrentTeb()->stack_top;
fiber->stack_low = NtCurrentTeb()->stack_low;
fiber->stack_base = NtCurrentTeb()->stack_base;
fiber->stack_base = NtCurrentTeb()->DeallocationStack;
fiber->start = NULL;
fiber->flags = flags;
NtCurrentTeb()->fiber = fiber;
@ -183,11 +183,11 @@ void WINAPI SwitchToFiber( LPVOID fiber )
/* FIXME: should save floating point context if requested in fiber->flags */
if (!setjmp( current_fiber->jmpbuf ))
{
NtCurrentTeb()->fiber = new_fiber;
NtCurrentTeb()->except = new_fiber->except;
NtCurrentTeb()->stack_top = new_fiber->stack_top;
NtCurrentTeb()->stack_low = new_fiber->stack_low;
NtCurrentTeb()->stack_base = new_fiber->stack_base;
NtCurrentTeb()->fiber = new_fiber;
NtCurrentTeb()->except = new_fiber->except;
NtCurrentTeb()->stack_top = new_fiber->stack_top;
NtCurrentTeb()->stack_low = new_fiber->stack_low;
NtCurrentTeb()->DeallocationStack = new_fiber->stack_base;
if (new_fiber->start) /* first time */
SYSDEPS_SwitchToThreadStack( start_fiber, new_fiber );
else

View File

@ -1475,7 +1475,7 @@ DWORD WINAPI TlsAlloc( void )
for (i = 0, mask = 1; i < 32; i++, mask <<= 1) if (!(*bits & mask)) break;
*bits |= mask;
RtlReleasePebLock();
NtCurrentTeb()->tls_array[ret+i] = 0; /* clear the value */
NtCurrentTeb()->TlsSlots[ret+i] = 0; /* clear the value */
return ret + i;
}
@ -1508,7 +1508,7 @@ BOOL WINAPI TlsFree(
return FALSE;
}
*bits &= ~mask;
NtCurrentTeb()->tls_array[index] = 0;
NtCurrentTeb()->TlsSlots[index] = 0;
/* FIXME: should zero all other thread values */
RtlReleasePebLock();
return TRUE;
@ -1531,7 +1531,7 @@ LPVOID WINAPI TlsGetValue(
return NULL;
}
SetLastError( ERROR_SUCCESS );
return NtCurrentTeb()->tls_array[index];
return NtCurrentTeb()->TlsSlots[index];
}
@ -1551,6 +1551,6 @@ BOOL WINAPI TlsSetValue(
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
NtCurrentTeb()->tls_array[index] = value;
NtCurrentTeb()->TlsSlots[index] = value;
return TRUE;
}

View File

@ -91,9 +91,8 @@ VOID WINAPI _EnterSysLevel(SYSLEVEL *lock)
TEB *teb = NtCurrentTeb();
int i;
TRACE("(%p, level %d): thread %lx (fs %04x, pid %ld) count before %ld\n",
lock, lock->level, teb->tid, teb->teb_sel, (long) getpid(),
teb->sys_count[lock->level] );
TRACE("(%p, level %d): thread %lx count before %ld\n",
lock, lock->level, GetCurrentThreadId(), teb->sys_count[lock->level] );
for ( i = 3; i > lock->level; i-- )
if ( teb->sys_count[i] > 0 )
@ -107,9 +106,8 @@ VOID WINAPI _EnterSysLevel(SYSLEVEL *lock)
teb->sys_count[lock->level]++;
teb->sys_mutex[lock->level] = lock;
TRACE("(%p, level %d): thread %lx (fs %04x, pid %ld) count after %ld\n",
lock, lock->level, teb->tid, teb->teb_sel, (long) getpid(),
teb->sys_count[lock->level] );
TRACE("(%p, level %d): thread %lx count after %ld\n",
lock, lock->level, GetCurrentThreadId(), teb->sys_count[lock->level] );
if (lock == &Win16Mutex)
SYSLEVEL_Win16CurrentTeb = wine_get_fs();
@ -123,9 +121,8 @@ VOID WINAPI _LeaveSysLevel(SYSLEVEL *lock)
{
TEB *teb = NtCurrentTeb();
TRACE("(%p, level %d): thread %lx (fs %04x, pid %ld) count before %ld\n",
lock, lock->level, teb->tid, teb->teb_sel, (long) getpid(),
teb->sys_count[lock->level] );
TRACE("(%p, level %d): thread %lx count before %ld\n",
lock, lock->level, GetCurrentThreadId(), teb->sys_count[lock->level] );
if ( teb->sys_count[lock->level] <= 0 || teb->sys_mutex[lock->level] != lock )
{
@ -141,9 +138,8 @@ VOID WINAPI _LeaveSysLevel(SYSLEVEL *lock)
RtlLeaveCriticalSection( &lock->crst );
TRACE("(%p, level %d): thread %lx (fs %04x, pid %ld) count after %ld\n",
lock, lock->level, teb->tid, teb->teb_sel, (long) getpid(),
teb->sys_count[lock->level] );
TRACE("(%p, level %d): thread %lx count after %ld\n",
lock, lock->level, GetCurrentThreadId(), teb->sys_count[lock->level] );
}
/************************************************************************

View File

@ -85,7 +85,7 @@ static void THREAD_FreeTEB( TEB *teb )
TRACE("(%p) called\n", teb );
/* Free the associated memory */
wine_ldt_free_fs( teb->teb_sel );
VirtualFree( teb->stack_base, 0, MEM_RELEASE );
VirtualFree( teb->DeallocationStack, 0, MEM_RELEASE );
}
@ -111,7 +111,7 @@ TEB *THREAD_InitStack( TEB *teb, DWORD stack_size )
if (teb)
stack_size = 1024 * 1024; /* no parent */
else
stack_size = ((char *)NtCurrentTeb()->stack_top - (char *)NtCurrentTeb()->stack_base
stack_size = ((char *)NtCurrentTeb()->stack_top - (char *)NtCurrentTeb()->DeallocationStack
- SIGNAL_STACK_SIZE - 3 * page_size);
}
@ -146,10 +146,10 @@ TEB *THREAD_InitStack( TEB *teb, DWORD stack_size )
}
}
teb->stack_low = base;
teb->stack_base = base;
teb->signal_stack = (char *)base + page_size;
teb->stack_top = (char *)base + 3 * page_size + SIGNAL_STACK_SIZE + stack_size;
teb->stack_low = base;
teb->DeallocationStack = base;
teb->signal_stack = (char *)base + page_size;
teb->stack_top = (char *)base + 3 * page_size + SIGNAL_STACK_SIZE + stack_size;
/* Setup guard pages */
@ -262,7 +262,7 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, SIZE_T stack,
}
teb->Peb = NtCurrentTeb()->Peb;
teb->tid = tid;
teb->ClientId.UniqueThread = (HANDLE)tid;
teb->request_fd = request_pipe[1];
teb->entry_point = start;
teb->entry_arg = param;
@ -472,7 +472,7 @@ DWORD WINAPI GetLastError(void)
*/
DWORD WINAPI GetCurrentProcessId(void)
{
return (DWORD)NtCurrentTeb()->pid;
return (DWORD)NtCurrentTeb()->ClientId.UniqueProcess;
}
/***********************************************************************
@ -483,7 +483,7 @@ DWORD WINAPI GetCurrentProcessId(void)
*/
DWORD WINAPI GetCurrentThreadId(void)
{
return NtCurrentTeb()->tid;
return (DWORD)NtCurrentTeb()->ClientId.UniqueThread;
}
#endif /* __i386__ */