On TlsFree, clear the released TLS index in all threads.
This commit is contained in:
parent
1155531cb3
commit
2eb5d8b9b1
|
@ -163,25 +163,6 @@ NTSTATUS WINAPI NtSetInformationProcess(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Thread
|
|
||||||
*/
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* NtSetInformationThread [NTDLL.@]
|
|
||||||
* ZwSetInformationThread [NTDLL.@]
|
|
||||||
*/
|
|
||||||
NTSTATUS WINAPI NtSetInformationThread(
|
|
||||||
HANDLE ThreadHandle,
|
|
||||||
THREADINFOCLASS ThreadInformationClass,
|
|
||||||
PVOID ThreadInformation,
|
|
||||||
ULONG ThreadInformationLength)
|
|
||||||
{
|
|
||||||
FIXME("(%p,0x%08x,%p,0x%08lx),stub!\n",
|
|
||||||
ThreadHandle, ThreadInformationClass, ThreadInformation, ThreadInformationLength);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Token
|
* Token
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -217,7 +217,7 @@
|
||||||
@ stdcall NtSetInformationKey(long long ptr long)
|
@ stdcall NtSetInformationKey(long long ptr long)
|
||||||
@ stdcall NtSetInformationObject(long long ptr long)
|
@ stdcall NtSetInformationObject(long long ptr long)
|
||||||
@ stdcall NtSetInformationProcess(long long long long)
|
@ stdcall NtSetInformationProcess(long long long long)
|
||||||
@ stdcall NtSetInformationThread(long long long long)
|
@ stdcall NtSetInformationThread(long long ptr long)
|
||||||
@ stub NtSetInformationToken
|
@ stub NtSetInformationToken
|
||||||
@ stdcall NtSetIntervalProfile(long long)
|
@ stdcall NtSetIntervalProfile(long long)
|
||||||
@ stub NtSetIoCompletion
|
@ stub NtSetIoCompletion
|
||||||
|
@ -746,7 +746,7 @@
|
||||||
@ stdcall ZwSetInformationKey(long long ptr long) NtSetInformationKey
|
@ stdcall ZwSetInformationKey(long long ptr long) NtSetInformationKey
|
||||||
@ stdcall ZwSetInformationObject(long long ptr long) NtSetInformationObject
|
@ stdcall ZwSetInformationObject(long long ptr long) NtSetInformationObject
|
||||||
@ stdcall ZwSetInformationProcess(long long long long) NtSetInformationProcess
|
@ stdcall ZwSetInformationProcess(long long long long) NtSetInformationProcess
|
||||||
@ stdcall ZwSetInformationThread(long long long long) NtSetInformationThread
|
@ stdcall ZwSetInformationThread(long long ptr long) NtSetInformationThread
|
||||||
@ stub ZwSetInformationToken
|
@ stub ZwSetInformationToken
|
||||||
@ stdcall ZwSetIntervalProfile(long long) NtSetIntervalProfile
|
@ stdcall ZwSetIntervalProfile(long long) NtSetIntervalProfile
|
||||||
@ stub ZwSetIoCompletion
|
@ stub ZwSetIoCompletion
|
||||||
|
|
|
@ -107,7 +107,13 @@ NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
if (last) exit( exit_code );
|
if (last) exit( exit_code );
|
||||||
else SYSDEPS_ExitThread( exit_code );
|
else
|
||||||
|
{
|
||||||
|
RtlAcquirePebLock();
|
||||||
|
RemoveEntryList( &NtCurrentTeb()->TlsLinks );
|
||||||
|
RtlReleasePebLock();
|
||||||
|
SYSDEPS_ExitThread( exit_code );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -235,3 +241,57 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class,
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* NtSetInformationThread (NTDLL.@)
|
||||||
|
* ZwSetInformationThread (NTDLL.@)
|
||||||
|
*/
|
||||||
|
NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class,
|
||||||
|
LPCVOID data, ULONG length )
|
||||||
|
{
|
||||||
|
switch(class)
|
||||||
|
{
|
||||||
|
case ThreadZeroTlsCell:
|
||||||
|
if (handle == GetCurrentThread())
|
||||||
|
{
|
||||||
|
LIST_ENTRY *entry = &NtCurrentTeb()->TlsLinks;
|
||||||
|
DWORD index;
|
||||||
|
|
||||||
|
if (length != sizeof(DWORD)) return STATUS_INVALID_PARAMETER;
|
||||||
|
index = *(DWORD *)data;
|
||||||
|
if (index >= 64) return STATUS_INVALID_PARAMETER;
|
||||||
|
RtlAcquirePebLock();
|
||||||
|
do
|
||||||
|
{
|
||||||
|
TEB *teb = CONTAINING_RECORD(entry, TEB, TlsLinks);
|
||||||
|
teb->TlsSlots[index] = 0;
|
||||||
|
entry = entry->Flink;
|
||||||
|
} while (entry != &NtCurrentTeb()->TlsLinks);
|
||||||
|
RtlReleasePebLock();
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
FIXME( "ZeroTlsCell not supported on other threads\n" );
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
case ThreadBasicInformation:
|
||||||
|
case ThreadTimes:
|
||||||
|
case ThreadPriority:
|
||||||
|
case ThreadBasePriority:
|
||||||
|
case ThreadAffinityMask:
|
||||||
|
case ThreadImpersonationToken:
|
||||||
|
case ThreadDescriptorTableEntry:
|
||||||
|
case ThreadEnableAlignmentFaultFixup:
|
||||||
|
case ThreadEventPair_Reusable:
|
||||||
|
case ThreadQuerySetWin32StartAddress:
|
||||||
|
case ThreadPerformanceCount:
|
||||||
|
case ThreadAmILastThread:
|
||||||
|
case ThreadIdealProcessor:
|
||||||
|
case ThreadPriorityBoost:
|
||||||
|
case ThreadSetTlsArrayAddress:
|
||||||
|
case ThreadIsIoPending:
|
||||||
|
default:
|
||||||
|
FIXME( "info class %d not supported yet\n", class );
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -128,7 +128,8 @@ typedef struct _TEB
|
||||||
USHORT StaticUnicodeBuffer[261]; /* -2- c00 used by advapi32 */
|
USHORT StaticUnicodeBuffer[261]; /* -2- c00 used by advapi32 */
|
||||||
PVOID DeallocationStack; /* -2- e0c Base of the stack */
|
PVOID DeallocationStack; /* -2- e0c Base of the stack */
|
||||||
LPVOID TlsSlots[64]; /* -2- e10 Thread local storage */
|
LPVOID TlsSlots[64]; /* -2- e10 Thread local storage */
|
||||||
DWORD pad8[3]; /* --n f10 */
|
LIST_ENTRY TlsLinks; /* -2- f10 */
|
||||||
|
DWORD pad8[1]; /* --n f18 */
|
||||||
PVOID ReservedForNtRpc; /* -2- f1c used by rpcrt4 */
|
PVOID ReservedForNtRpc; /* -2- f1c used by rpcrt4 */
|
||||||
DWORD pad9[24]; /* --n f20 */
|
DWORD pad9[24]; /* --n f20 */
|
||||||
PVOID ReservedForOle; /* -2- f80 used by ole32 (IErrorInfo*) */
|
PVOID ReservedForOle; /* -2- f80 used by ole32 (IErrorInfo*) */
|
||||||
|
|
|
@ -171,7 +171,7 @@ typedef struct _TEB
|
||||||
WCHAR StaticUnicodeBuffer[261]; /* c00 used by advapi32 */
|
WCHAR StaticUnicodeBuffer[261]; /* c00 used by advapi32 */
|
||||||
PVOID DeallocationStack; /* e0c */
|
PVOID DeallocationStack; /* e0c */
|
||||||
PVOID TlsSlots[64]; /* e10 */
|
PVOID TlsSlots[64]; /* e10 */
|
||||||
BYTE Reserved3[8]; /* f10 */
|
LIST_ENTRY TlsLinks; /* f10 */
|
||||||
PVOID Reserved4[26]; /* f18 */
|
PVOID Reserved4[26]; /* f18 */
|
||||||
PVOID ReservedForOle; /* f80 Windows 2000 only */
|
PVOID ReservedForOle; /* f80 Windows 2000 only */
|
||||||
PVOID Reserved5[4]; /* f84 */
|
PVOID Reserved5[4]; /* f84 */
|
||||||
|
@ -1019,6 +1019,7 @@ NTSTATUS WINAPI NtSetEvent(HANDLE,PULONG);
|
||||||
NTSTATUS WINAPI NtSetInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,FILE_INFORMATION_CLASS);
|
NTSTATUS WINAPI NtSetInformationFile(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,FILE_INFORMATION_CLASS);
|
||||||
NTSTATUS WINAPI NtSetInformationKey(HKEY,const int,PVOID,ULONG);
|
NTSTATUS WINAPI NtSetInformationKey(HKEY,const int,PVOID,ULONG);
|
||||||
NTSTATUS WINAPI NtSetInformationObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG);
|
NTSTATUS WINAPI NtSetInformationObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG);
|
||||||
|
NTSTATUS WINAPI NtSetInformationThread(HANDLE,THREADINFOCLASS,LPCVOID,ULONG);
|
||||||
NTSTATUS WINAPI NtSetSecurityObject(HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
|
NTSTATUS WINAPI NtSetSecurityObject(HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
|
||||||
NTSTATUS WINAPI NtSetSystemTime(const LARGE_INTEGER*,LARGE_INTEGER*);
|
NTSTATUS WINAPI NtSetSystemTime(const LARGE_INTEGER*,LARGE_INTEGER*);
|
||||||
NTSTATUS WINAPI NtSetTimer(HANDLE, const LARGE_INTEGER*, PTIMERAPCROUTINE, PVOID, BOOLEAN, ULONG, BOOLEAN*);
|
NTSTATUS WINAPI NtSetTimer(HANDLE, const LARGE_INTEGER*, PTIMERAPCROUTINE, PVOID, BOOLEAN, ULONG, BOOLEAN*);
|
||||||
|
|
|
@ -1502,8 +1502,7 @@ BOOL WINAPI TlsFree(
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
*bits &= ~mask;
|
*bits &= ~mask;
|
||||||
NtCurrentTeb()->TlsSlots[index] = 0;
|
NtSetInformationThread( GetCurrentThread(), ThreadZeroTlsCell, &index, sizeof(index) );
|
||||||
/* FIXME: should zero all other thread values */
|
|
||||||
RtlReleasePebLock();
|
RtlReleasePebLock();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ static BOOL THREAD_InitTEB( TEB *teb )
|
||||||
teb->wait_fd[1] = -1;
|
teb->wait_fd[1] = -1;
|
||||||
teb->StaticUnicodeString.MaximumLength = sizeof(teb->StaticUnicodeBuffer);
|
teb->StaticUnicodeString.MaximumLength = sizeof(teb->StaticUnicodeBuffer);
|
||||||
teb->StaticUnicodeString.Buffer = (PWSTR)teb->StaticUnicodeBuffer;
|
teb->StaticUnicodeString.Buffer = (PWSTR)teb->StaticUnicodeBuffer;
|
||||||
|
InitializeListHead(&teb->TlsLinks);
|
||||||
teb->teb_sel = wine_ldt_alloc_fs();
|
teb->teb_sel = wine_ldt_alloc_fs();
|
||||||
return (teb->teb_sel != 0);
|
return (teb->teb_sel != 0);
|
||||||
}
|
}
|
||||||
|
@ -268,12 +269,18 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, SIZE_T stack,
|
||||||
teb->entry_point = start;
|
teb->entry_point = start;
|
||||||
teb->entry_arg = param;
|
teb->entry_arg = param;
|
||||||
teb->htask16 = GetCurrentTask();
|
teb->htask16 = GetCurrentTask();
|
||||||
|
RtlAcquirePebLock();
|
||||||
|
InsertHeadList( &NtCurrentTeb()->TlsLinks, &teb->TlsLinks );
|
||||||
|
RtlReleasePebLock();
|
||||||
|
|
||||||
if (id) *id = tid;
|
if (id) *id = tid;
|
||||||
if (SYSDEPS_SpawnThread( THREAD_Start, teb ) == -1)
|
if (SYSDEPS_SpawnThread( THREAD_Start, teb ) == -1)
|
||||||
{
|
{
|
||||||
CloseHandle( handle );
|
CloseHandle( handle );
|
||||||
close( request_pipe[1] );
|
close( request_pipe[1] );
|
||||||
|
RtlAcquirePebLock();
|
||||||
|
RemoveEntryList( &teb->TlsLinks );
|
||||||
|
RtlReleasePebLock();
|
||||||
THREAD_FreeTEB( teb );
|
THREAD_FreeTEB( teb );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -307,6 +314,9 @@ void WINAPI ExitThread( DWORD code ) /* [in] Exit code for this thread */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LdrShutdownThread();
|
LdrShutdownThread();
|
||||||
|
RtlAcquirePebLock();
|
||||||
|
RemoveEntryList( &NtCurrentTeb()->TlsLinks );
|
||||||
|
RtlReleasePebLock();
|
||||||
SYSDEPS_ExitThread( code );
|
SYSDEPS_ExitThread( code );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue