kernel32: Move more thread functions to kernelbase.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0fca739770
commit
f2e7e1658b
|
@ -203,7 +203,7 @@
|
||||||
@ stdcall BuildCommDCBAndTimeoutsA(str ptr ptr)
|
@ stdcall BuildCommDCBAndTimeoutsA(str ptr ptr)
|
||||||
@ stdcall BuildCommDCBAndTimeoutsW(wstr ptr ptr)
|
@ stdcall BuildCommDCBAndTimeoutsW(wstr ptr ptr)
|
||||||
@ stdcall BuildCommDCBW(wstr ptr)
|
@ stdcall BuildCommDCBW(wstr ptr)
|
||||||
@ stdcall CallbackMayRunLong(ptr)
|
@ stdcall -import CallbackMayRunLong(ptr)
|
||||||
@ stdcall CallNamedPipeA(str ptr long ptr long ptr long)
|
@ stdcall CallNamedPipeA(str ptr long ptr long ptr long)
|
||||||
@ stdcall -import CallNamedPipeW(wstr ptr long ptr long ptr long)
|
@ stdcall -import CallNamedPipeW(wstr ptr long ptr long ptr long)
|
||||||
@ stub CancelDeviceWakeupRequest
|
@ stub CancelDeviceWakeupRequest
|
||||||
|
@ -700,7 +700,7 @@
|
||||||
@ stub -i386 GetLSCallbackTemplate
|
@ stub -i386 GetLSCallbackTemplate
|
||||||
@ stdcall GetLargePageMinimum()
|
@ stdcall GetLargePageMinimum()
|
||||||
@ stdcall GetLargestConsoleWindowSize(long)
|
@ stdcall GetLargestConsoleWindowSize(long)
|
||||||
@ stdcall GetLastError() KERNEL32_GetLastError
|
@ stdcall -import GetLastError()
|
||||||
@ stub GetLinguistLangSize
|
@ stub GetLinguistLangSize
|
||||||
@ stdcall GetLocalTime(ptr)
|
@ stdcall GetLocalTime(ptr)
|
||||||
@ stdcall GetLocaleInfoA(long long ptr long)
|
@ stdcall GetLocaleInfoA(long long ptr long)
|
||||||
|
@ -1180,7 +1180,7 @@
|
||||||
@ stdcall QueryUnbiasedInterruptTime(ptr)
|
@ stdcall QueryUnbiasedInterruptTime(ptr)
|
||||||
@ stub QueryWin31IniFilesMappedToRegistry
|
@ stub QueryWin31IniFilesMappedToRegistry
|
||||||
@ stdcall -import QueueUserAPC(ptr long long)
|
@ stdcall -import QueueUserAPC(ptr long long)
|
||||||
@ stdcall QueueUserWorkItem(ptr ptr long)
|
@ stdcall -import QueueUserWorkItem(ptr ptr long)
|
||||||
@ stdcall RaiseException(long long long ptr)
|
@ stdcall RaiseException(long long long ptr)
|
||||||
# @ stub RaiseFailFastException
|
# @ stub RaiseFailFastException
|
||||||
@ stdcall ReadConsoleA(long ptr long ptr ptr)
|
@ stdcall ReadConsoleA(long ptr long ptr ptr)
|
||||||
|
@ -1414,7 +1414,7 @@
|
||||||
@ stdcall SetHandleInformation(long long long)
|
@ stdcall SetHandleInformation(long long long)
|
||||||
@ stdcall SetInformationJobObject(long long ptr long)
|
@ stdcall SetInformationJobObject(long long ptr long)
|
||||||
@ stub SetLastConsoleEventActive
|
@ stub SetLastConsoleEventActive
|
||||||
@ stdcall SetLastError(long) KERNEL32_SetLastError
|
@ stdcall SetLastError(long) RtlSetLastWin32Error
|
||||||
# @ stub SetLocalPrimaryComputerNameA
|
# @ stub SetLocalPrimaryComputerNameA
|
||||||
# @ stub SetLocalPrimaryComputerNameW
|
# @ stub SetLocalPrimaryComputerNameW
|
||||||
@ stdcall SetLocalTime(ptr)
|
@ stdcall SetLocalTime(ptr)
|
||||||
|
@ -1502,12 +1502,12 @@
|
||||||
@ stdcall Thread32First(long ptr)
|
@ stdcall Thread32First(long ptr)
|
||||||
@ stdcall Thread32Next(long ptr)
|
@ stdcall Thread32Next(long ptr)
|
||||||
@ stdcall -i386 -private ThunkConnect32(ptr str str str ptr ptr) krnl386.exe16.ThunkConnect32
|
@ stdcall -i386 -private ThunkConnect32(ptr str str str ptr ptr) krnl386.exe16.ThunkConnect32
|
||||||
@ stdcall TlsAlloc()
|
@ stdcall -import TlsAlloc()
|
||||||
@ stdcall TlsAllocInternal() TlsAlloc
|
@ stdcall -import TlsAllocInternal() TlsAlloc
|
||||||
@ stdcall TlsFree(long)
|
@ stdcall -import TlsFree(long)
|
||||||
@ stdcall TlsFreeInternal(long) TlsFree
|
@ stdcall -import TlsFreeInternal(long) TlsFree
|
||||||
@ stdcall TlsGetValue(long)
|
@ stdcall -import TlsGetValue(long)
|
||||||
@ stdcall TlsSetValue(long ptr)
|
@ stdcall -import TlsSetValue(long ptr)
|
||||||
@ stdcall Toolhelp32ReadProcessMemory(long ptr ptr long ptr)
|
@ stdcall Toolhelp32ReadProcessMemory(long ptr ptr long ptr)
|
||||||
@ stdcall -import TransactNamedPipe(long ptr long ptr long ptr ptr)
|
@ stdcall -import TransactNamedPipe(long ptr long ptr long ptr ptr)
|
||||||
@ stdcall TransmitCommChar(long long)
|
@ stdcall TransmitCommChar(long long)
|
||||||
|
|
|
@ -3229,159 +3229,6 @@ UINT WINAPI GetErrorMode( void )
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* TlsAlloc [KERNEL32.@]
|
|
||||||
*
|
|
||||||
* Allocates a thread local storage index.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: TLS index.
|
|
||||||
* Failure: 0xFFFFFFFF
|
|
||||||
*/
|
|
||||||
DWORD WINAPI TlsAlloc( void )
|
|
||||||
{
|
|
||||||
DWORD index;
|
|
||||||
PEB * const peb = NtCurrentTeb()->Peb;
|
|
||||||
|
|
||||||
RtlAcquirePebLock();
|
|
||||||
index = RtlFindClearBitsAndSet( peb->TlsBitmap, 1, 1 );
|
|
||||||
if (index != ~0U) NtCurrentTeb()->TlsSlots[index] = 0; /* clear the value */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
index = RtlFindClearBitsAndSet( peb->TlsExpansionBitmap, 1, 0 );
|
|
||||||
if (index != ~0U)
|
|
||||||
{
|
|
||||||
if (!NtCurrentTeb()->TlsExpansionSlots &&
|
|
||||||
!(NtCurrentTeb()->TlsExpansionSlots = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
||||||
8 * sizeof(peb->TlsExpansionBitmapBits) * sizeof(void*) )))
|
|
||||||
{
|
|
||||||
RtlClearBits( peb->TlsExpansionBitmap, index, 1 );
|
|
||||||
index = ~0U;
|
|
||||||
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NtCurrentTeb()->TlsExpansionSlots[index] = 0; /* clear the value */
|
|
||||||
index += TLS_MINIMUM_AVAILABLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else SetLastError( ERROR_NO_MORE_ITEMS );
|
|
||||||
}
|
|
||||||
RtlReleasePebLock();
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* TlsFree [KERNEL32.@]
|
|
||||||
*
|
|
||||||
* Releases a thread local storage index, making it available for reuse.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* index [in] TLS index to free.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: TRUE
|
|
||||||
* Failure: FALSE
|
|
||||||
*/
|
|
||||||
BOOL WINAPI TlsFree( DWORD index )
|
|
||||||
{
|
|
||||||
BOOL ret;
|
|
||||||
|
|
||||||
RtlAcquirePebLock();
|
|
||||||
if (index >= TLS_MINIMUM_AVAILABLE)
|
|
||||||
{
|
|
||||||
ret = RtlAreBitsSet( NtCurrentTeb()->Peb->TlsExpansionBitmap, index - TLS_MINIMUM_AVAILABLE, 1 );
|
|
||||||
if (ret) RtlClearBits( NtCurrentTeb()->Peb->TlsExpansionBitmap, index - TLS_MINIMUM_AVAILABLE, 1 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret = RtlAreBitsSet( NtCurrentTeb()->Peb->TlsBitmap, index, 1 );
|
|
||||||
if (ret) RtlClearBits( NtCurrentTeb()->Peb->TlsBitmap, index, 1 );
|
|
||||||
}
|
|
||||||
if (ret) NtSetInformationThread( GetCurrentThread(), ThreadZeroTlsCell, &index, sizeof(index) );
|
|
||||||
else SetLastError( ERROR_INVALID_PARAMETER );
|
|
||||||
RtlReleasePebLock();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* TlsGetValue [KERNEL32.@]
|
|
||||||
*
|
|
||||||
* Gets value in a thread's TLS slot.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* index [in] TLS index to retrieve value for.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: Value stored in calling thread's TLS slot for index.
|
|
||||||
* Failure: 0 and GetLastError() returns NO_ERROR.
|
|
||||||
*/
|
|
||||||
LPVOID WINAPI TlsGetValue( DWORD index )
|
|
||||||
{
|
|
||||||
LPVOID ret;
|
|
||||||
|
|
||||||
if (index < TLS_MINIMUM_AVAILABLE)
|
|
||||||
{
|
|
||||||
ret = NtCurrentTeb()->TlsSlots[index];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
index -= TLS_MINIMUM_AVAILABLE;
|
|
||||||
if (index >= 8 * sizeof(NtCurrentTeb()->Peb->TlsExpansionBitmapBits))
|
|
||||||
{
|
|
||||||
SetLastError( ERROR_INVALID_PARAMETER );
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (!NtCurrentTeb()->TlsExpansionSlots) ret = NULL;
|
|
||||||
else ret = NtCurrentTeb()->TlsExpansionSlots[index];
|
|
||||||
}
|
|
||||||
SetLastError( ERROR_SUCCESS );
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* TlsSetValue [KERNEL32.@]
|
|
||||||
*
|
|
||||||
* Stores a value in the thread's TLS slot.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* index [in] TLS index to set value for.
|
|
||||||
* value [in] Value to be stored.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: TRUE
|
|
||||||
* Failure: FALSE
|
|
||||||
*/
|
|
||||||
BOOL WINAPI TlsSetValue( DWORD index, LPVOID value )
|
|
||||||
{
|
|
||||||
if (index < TLS_MINIMUM_AVAILABLE)
|
|
||||||
{
|
|
||||||
NtCurrentTeb()->TlsSlots[index] = value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
index -= TLS_MINIMUM_AVAILABLE;
|
|
||||||
if (index >= 8 * sizeof(NtCurrentTeb()->Peb->TlsExpansionBitmapBits))
|
|
||||||
{
|
|
||||||
SetLastError( ERROR_INVALID_PARAMETER );
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (!NtCurrentTeb()->TlsExpansionSlots &&
|
|
||||||
!(NtCurrentTeb()->TlsExpansionSlots = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
||||||
8 * sizeof(NtCurrentTeb()->Peb->TlsExpansionBitmapBits) * sizeof(void*) )))
|
|
||||||
{
|
|
||||||
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
NtCurrentTeb()->TlsExpansionSlots[index] = value;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* GetProcessFlags (KERNEL32.@)
|
* GetProcessFlags (KERNEL32.@)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,15 +19,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "wine/port.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ntstatus.h"
|
#include "ntstatus.h"
|
||||||
#define WIN32_NO_STATUS
|
#define WIN32_NO_STATUS
|
||||||
|
@ -35,16 +30,9 @@
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
#include "winerror.h"
|
#include "winerror.h"
|
||||||
#include "winternl.h"
|
#include "winternl.h"
|
||||||
#include "wine/exception.h"
|
|
||||||
#include "wine/library.h"
|
|
||||||
#include "wine/server.h"
|
|
||||||
#include "wine/asm.h"
|
|
||||||
#include "wine/debug.h"
|
|
||||||
|
|
||||||
#include "kernel_private.h"
|
#include "kernel_private.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(thread);
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* FreeLibraryAndExitThread (KERNEL32.@)
|
* FreeLibraryAndExitThread (KERNEL32.@)
|
||||||
|
@ -67,7 +55,6 @@ BOOL WINAPI Wow64SetThreadContext( HANDLE handle, const WOW64_CONTEXT *context)
|
||||||
NTSTATUS status = RtlWow64SetThreadContext( handle, context );
|
NTSTATUS status = RtlWow64SetThreadContext( handle, context );
|
||||||
#else
|
#else
|
||||||
NTSTATUS status = STATUS_NOT_IMPLEMENTED;
|
NTSTATUS status = STATUS_NOT_IMPLEMENTED;
|
||||||
FIXME("not implemented on this platform\n");
|
|
||||||
#endif
|
#endif
|
||||||
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
||||||
return !status;
|
return !status;
|
||||||
|
@ -84,7 +71,6 @@ BOOL WINAPI Wow64GetThreadContext( HANDLE handle, WOW64_CONTEXT *context)
|
||||||
NTSTATUS status = RtlWow64GetThreadContext( handle, context );
|
NTSTATUS status = RtlWow64GetThreadContext( handle, context );
|
||||||
#else
|
#else
|
||||||
NTSTATUS status = STATUS_NOT_IMPLEMENTED;
|
NTSTATUS status = STATUS_NOT_IMPLEMENTED;
|
||||||
FIXME("not implemented on this platform\n");
|
|
||||||
#endif
|
#endif
|
||||||
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
||||||
return !status;
|
return !status;
|
||||||
|
@ -138,21 +124,6 @@ BOOL WINAPI GetThreadSelectorEntry( HANDLE hthread, DWORD sel, LPLDT_ENTRY ldten
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* QueueUserWorkItem (KERNEL32.@)
|
|
||||||
*/
|
|
||||||
BOOL WINAPI QueueUserWorkItem( LPTHREAD_START_ROUTINE Function, PVOID Context, ULONG Flags )
|
|
||||||
{
|
|
||||||
NTSTATUS status;
|
|
||||||
|
|
||||||
TRACE("(%p,%p,0x%08x)\n", Function, Context, Flags);
|
|
||||||
|
|
||||||
status = RtlQueueWorkItem( Function, Context, Flags );
|
|
||||||
|
|
||||||
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
return !status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* GetCurrentThread [KERNEL32.@] Gets pseudohandle for current thread
|
* GetCurrentThread [KERNEL32.@] Gets pseudohandle for current thread
|
||||||
*
|
*
|
||||||
|
@ -164,32 +135,6 @@ HANDLE WINAPI KERNEL32_GetCurrentThread(void)
|
||||||
return (HANDLE)~(ULONG_PTR)1;
|
return (HANDLE)~(ULONG_PTR)1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* SetLastError (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Sets the last-error code.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Nothing.
|
|
||||||
*/
|
|
||||||
void WINAPI KERNEL32_SetLastError( DWORD error ) /* [in] Per-thread error code */
|
|
||||||
{
|
|
||||||
NtCurrentTeb()->LastErrorValue = error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* GetLastError (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Get the last-error code.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* last-error code.
|
|
||||||
*/
|
|
||||||
DWORD WINAPI KERNEL32_GetLastError(void)
|
|
||||||
{
|
|
||||||
return NtCurrentTeb()->LastErrorValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* GetCurrentProcessId (KERNEL32.@)
|
* GetCurrentProcessId (KERNEL32.@)
|
||||||
*
|
*
|
||||||
|
@ -223,22 +168,3 @@ HANDLE WINAPI KERNEL32_GetProcessHeap(void)
|
||||||
{
|
{
|
||||||
return NtCurrentTeb()->Peb->ProcessHeap;
|
return NtCurrentTeb()->Peb->ProcessHeap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* CallbackMayRunLong (KERNEL32.@)
|
|
||||||
*/
|
|
||||||
BOOL WINAPI CallbackMayRunLong( TP_CALLBACK_INSTANCE *instance )
|
|
||||||
{
|
|
||||||
NTSTATUS status;
|
|
||||||
|
|
||||||
TRACE( "%p\n", instance );
|
|
||||||
|
|
||||||
status = TpCallbackMayRunLong( instance );
|
|
||||||
if (status)
|
|
||||||
{
|
|
||||||
SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
|
@ -101,7 +101,7 @@
|
||||||
@ stub BemFreeReference
|
@ stub BemFreeReference
|
||||||
# @ stub CLOSE_LOCAL_HANDLE_INTERNAL
|
# @ stub CLOSE_LOCAL_HANDLE_INTERNAL
|
||||||
@ stdcall CallNamedPipeW(wstr ptr long ptr long ptr long)
|
@ stdcall CallNamedPipeW(wstr ptr long ptr long ptr long)
|
||||||
@ stdcall CallbackMayRunLong(ptr) kernel32.CallbackMayRunLong
|
@ stdcall CallbackMayRunLong(ptr)
|
||||||
@ stdcall CancelIo(long) kernel32.CancelIo
|
@ stdcall CancelIo(long) kernel32.CancelIo
|
||||||
@ stdcall CancelIoEx(long ptr) kernel32.CancelIoEx
|
@ stdcall CancelIoEx(long ptr) kernel32.CancelIoEx
|
||||||
@ stdcall CancelSynchronousIo(long) kernel32.CancelSynchronousIo
|
@ stdcall CancelSynchronousIo(long) kernel32.CancelSynchronousIo
|
||||||
|
@ -538,7 +538,7 @@
|
||||||
@ stdcall GetKernelObjectSecurity(long long ptr long ptr)
|
@ stdcall GetKernelObjectSecurity(long long ptr long ptr)
|
||||||
@ stdcall GetLargePageMinimum() kernel32.GetLargePageMinimum
|
@ stdcall GetLargePageMinimum() kernel32.GetLargePageMinimum
|
||||||
@ stdcall GetLargestConsoleWindowSize(long) kernel32.GetLargestConsoleWindowSize
|
@ stdcall GetLargestConsoleWindowSize(long) kernel32.GetLargestConsoleWindowSize
|
||||||
@ stdcall GetLastError() kernel32.GetLastError
|
@ stdcall GetLastError() kernelbase_GetLastError
|
||||||
@ stdcall GetLengthSid(ptr)
|
@ stdcall GetLengthSid(ptr)
|
||||||
@ stdcall GetLocalTime(ptr) kernel32.GetLocalTime
|
@ stdcall GetLocalTime(ptr) kernel32.GetLocalTime
|
||||||
@ stdcall GetLocaleInfoA(long long ptr long) kernel32.GetLocaleInfoA
|
@ stdcall GetLocaleInfoA(long long ptr long) kernel32.GetLocaleInfoA
|
||||||
|
@ -1221,7 +1221,7 @@
|
||||||
# @ stub QueryWorkingSet
|
# @ stub QueryWorkingSet
|
||||||
# @ stub QueryWorkingSetEx
|
# @ stub QueryWorkingSetEx
|
||||||
@ stdcall QueueUserAPC(ptr long long)
|
@ stdcall QueueUserAPC(ptr long long)
|
||||||
@ stdcall QueueUserWorkItem(ptr ptr long) kernel32.QueueUserWorkItem
|
@ stdcall QueueUserWorkItem(ptr ptr long)
|
||||||
# @ stub QuirkGetData
|
# @ stub QuirkGetData
|
||||||
# @ stub QuirkGetData2
|
# @ stub QuirkGetData2
|
||||||
@ stdcall QuirkIsEnabled(ptr)
|
@ stdcall QuirkIsEnabled(ptr)
|
||||||
|
@ -1597,10 +1597,10 @@
|
||||||
@ stdcall TerminateProcess(long long) kernel32.TerminateProcess
|
@ stdcall TerminateProcess(long long) kernel32.TerminateProcess
|
||||||
# @ stub TerminateProcessOnMemoryExhaustion
|
# @ stub TerminateProcessOnMemoryExhaustion
|
||||||
@ stdcall TerminateThread(long long)
|
@ stdcall TerminateThread(long long)
|
||||||
@ stdcall TlsAlloc() kernel32.TlsAlloc
|
@ stdcall TlsAlloc()
|
||||||
@ stdcall TlsFree(long) kernel32.TlsFree
|
@ stdcall TlsFree(long)
|
||||||
@ stdcall TlsGetValue(long) kernel32.TlsGetValue
|
@ stdcall TlsGetValue(long)
|
||||||
@ stdcall TlsSetValue(long ptr) kernel32.TlsSetValue
|
@ stdcall TlsSetValue(long ptr)
|
||||||
@ stdcall TraceEvent(int64 ptr) ntdll.EtwLogTraceEvent
|
@ stdcall TraceEvent(int64 ptr) ntdll.EtwLogTraceEvent
|
||||||
@ varargs TraceMessage(int64 long ptr long) ntdll.EtwTraceMessage
|
@ varargs TraceMessage(int64 long ptr long) ntdll.EtwTraceMessage
|
||||||
@ stdcall TraceMessageVa(int64 long ptr long ptr) ntdll.EtwTraceMessageVa
|
@ stdcall TraceMessageVa(int64 long ptr long ptr) ntdll.EtwTraceMessageVa
|
||||||
|
|
|
@ -171,6 +171,15 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetExitCodeThread( HANDLE thread, LPDWORD exit_cod
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* GetLastError (kernelbase.@)
|
||||||
|
*/
|
||||||
|
DWORD WINAPI kernelbase_GetLastError(void)
|
||||||
|
{
|
||||||
|
return NtCurrentTeb()->LastErrorValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* GetProcessIdOfThread (kernelbase.@)
|
* GetProcessIdOfThread (kernelbase.@)
|
||||||
*/
|
*/
|
||||||
|
@ -497,6 +506,117 @@ BOOL WINAPI DECLSPEC_HOTPATCH TerminateThread( HANDLE handle, DWORD exit_code )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* TlsAlloc (kernelbase.@)
|
||||||
|
*/
|
||||||
|
DWORD WINAPI DECLSPEC_HOTPATCH TlsAlloc(void)
|
||||||
|
{
|
||||||
|
DWORD index;
|
||||||
|
PEB * const peb = NtCurrentTeb()->Peb;
|
||||||
|
|
||||||
|
RtlAcquirePebLock();
|
||||||
|
index = RtlFindClearBitsAndSet( peb->TlsBitmap, 1, 1 );
|
||||||
|
if (index != ~0U) NtCurrentTeb()->TlsSlots[index] = 0; /* clear the value */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
index = RtlFindClearBitsAndSet( peb->TlsExpansionBitmap, 1, 0 );
|
||||||
|
if (index != ~0U)
|
||||||
|
{
|
||||||
|
if (!NtCurrentTeb()->TlsExpansionSlots &&
|
||||||
|
!(NtCurrentTeb()->TlsExpansionSlots = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||||
|
8 * sizeof(peb->TlsExpansionBitmapBits) * sizeof(void*) )))
|
||||||
|
{
|
||||||
|
RtlClearBits( peb->TlsExpansionBitmap, index, 1 );
|
||||||
|
index = ~0U;
|
||||||
|
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NtCurrentTeb()->TlsExpansionSlots[index] = 0; /* clear the value */
|
||||||
|
index += TLS_MINIMUM_AVAILABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else SetLastError( ERROR_NO_MORE_ITEMS );
|
||||||
|
}
|
||||||
|
RtlReleasePebLock();
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* TlsFree (kernelbase.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI DECLSPEC_HOTPATCH TlsFree( DWORD index )
|
||||||
|
{
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
RtlAcquirePebLock();
|
||||||
|
if (index >= TLS_MINIMUM_AVAILABLE)
|
||||||
|
{
|
||||||
|
ret = RtlAreBitsSet( NtCurrentTeb()->Peb->TlsExpansionBitmap, index - TLS_MINIMUM_AVAILABLE, 1 );
|
||||||
|
if (ret) RtlClearBits( NtCurrentTeb()->Peb->TlsExpansionBitmap, index - TLS_MINIMUM_AVAILABLE, 1 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = RtlAreBitsSet( NtCurrentTeb()->Peb->TlsBitmap, index, 1 );
|
||||||
|
if (ret) RtlClearBits( NtCurrentTeb()->Peb->TlsBitmap, index, 1 );
|
||||||
|
}
|
||||||
|
if (ret) NtSetInformationThread( GetCurrentThread(), ThreadZeroTlsCell, &index, sizeof(index) );
|
||||||
|
else SetLastError( ERROR_INVALID_PARAMETER );
|
||||||
|
RtlReleasePebLock();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* TlsGetValue (kernelbase.@)
|
||||||
|
*/
|
||||||
|
LPVOID WINAPI DECLSPEC_HOTPATCH TlsGetValue( DWORD index )
|
||||||
|
{
|
||||||
|
SetLastError( ERROR_SUCCESS );
|
||||||
|
if (index < TLS_MINIMUM_AVAILABLE) return NtCurrentTeb()->TlsSlots[index];
|
||||||
|
|
||||||
|
index -= TLS_MINIMUM_AVAILABLE;
|
||||||
|
if (index >= 8 * sizeof(NtCurrentTeb()->Peb->TlsExpansionBitmapBits))
|
||||||
|
{
|
||||||
|
SetLastError( ERROR_INVALID_PARAMETER );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (!NtCurrentTeb()->TlsExpansionSlots) return NULL;
|
||||||
|
return NtCurrentTeb()->TlsExpansionSlots[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* TlsSetValue (kernelbase.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI DECLSPEC_HOTPATCH TlsSetValue( DWORD index, LPVOID value )
|
||||||
|
{
|
||||||
|
if (index < TLS_MINIMUM_AVAILABLE)
|
||||||
|
{
|
||||||
|
NtCurrentTeb()->TlsSlots[index] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
index -= TLS_MINIMUM_AVAILABLE;
|
||||||
|
if (index >= 8 * sizeof(NtCurrentTeb()->Peb->TlsExpansionBitmapBits))
|
||||||
|
{
|
||||||
|
SetLastError( ERROR_INVALID_PARAMETER );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!NtCurrentTeb()->TlsExpansionSlots &&
|
||||||
|
!(NtCurrentTeb()->TlsExpansionSlots = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||||
|
8 * sizeof(NtCurrentTeb()->Peb->TlsExpansionBitmapBits) * sizeof(void*) )))
|
||||||
|
{
|
||||||
|
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
NtCurrentTeb()->TlsExpansionSlots[index] = value;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Fibers
|
* Fibers
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
@ -917,6 +1037,15 @@ BOOL WINAPI DECLSPEC_HOTPATCH FlsSetValue( DWORD index, PVOID data )
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* CallbackMayRunLong (kernelbase.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI DECLSPEC_HOTPATCH CallbackMayRunLong( TP_CALLBACK_INSTANCE *instance )
|
||||||
|
{
|
||||||
|
return set_ntstatus( TpCallbackMayRunLong( instance ));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* CreateThreadpool (kernelbase.@)
|
* CreateThreadpool (kernelbase.@)
|
||||||
*/
|
*/
|
||||||
|
@ -999,3 +1128,12 @@ BOOL WINAPI DECLSPEC_HOTPATCH TrySubmitThreadpoolCallback( PTP_SIMPLE_CALLBACK c
|
||||||
{
|
{
|
||||||
return set_ntstatus( TpSimpleTryPost( callback, userdata, environment ));
|
return set_ntstatus( TpSimpleTryPost( callback, userdata, environment ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* QueueUserWorkItem (kernelbase.@)
|
||||||
|
*/
|
||||||
|
BOOL WINAPI DECLSPEC_HOTPATCH QueueUserWorkItem( LPTHREAD_START_ROUTINE func, PVOID context, ULONG flags )
|
||||||
|
{
|
||||||
|
return set_ntstatus( RtlQueueWorkItem( func, context, flags ));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue