Paul Gofman : kernelbase: Move FlsSetValue() implementation to ntdll.RtlFlsSetValue().
Alexandre Julliard
julliard at winehq.org
Thu Oct 1 15:50:29 CDT 2020
Module: wine
Branch: master
Commit: e596f4047ba5cc08a8324756f04851e09e8f629b
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e596f4047ba5cc08a8324756f04851e09e8f629b
Author: Paul Gofman <pgofman at codeweavers.com>
Date: Tue Sep 29 23:15:31 2020 +0300
kernelbase: Move FlsSetValue() implementation to ntdll.RtlFlsSetValue().
Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/tests/fiber.c | 14 ++++++++++++++
dlls/kernelbase/thread.c | 15 +--------------
dlls/ntdll/ntdll.spec | 1 +
dlls/ntdll/thread.c | 18 ++++++++++++++++++
include/winternl.h | 1 +
5 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/dlls/kernel32/tests/fiber.c b/dlls/kernel32/tests/fiber.c
index 0304dcfcde..4ffbe8916d 100644
--- a/dlls/kernel32/tests/fiber.c
+++ b/dlls/kernel32/tests/fiber.c
@@ -39,6 +39,7 @@ static PVOID (WINAPI *pFlsGetValue)(DWORD);
static BOOL (WINAPI *pFlsSetValue)(DWORD,PVOID);
static NTSTATUS (WINAPI *pRtlFlsAlloc)(PFLS_CALLBACK_FUNCTION,DWORD*);
static NTSTATUS (WINAPI *pRtlFlsFree)(ULONG);
+static NTSTATUS (WINAPI *pRtlFlsSetValue)(ULONG,void *);
static void *fibers[3];
static BYTE testparam = 185;
static DWORD fls_index_to_set = FLS_OUT_OF_INDEXES;
@@ -70,6 +71,7 @@ static VOID init_funcs(void)
#define X(f) p##f = (void*)GetProcAddress(hntdll, #f);
X(RtlFlsAlloc);
X(RtlFlsFree);
+ X(RtlFlsSetValue);
#undef X
}
@@ -213,6 +215,11 @@ static void test_FiberLocalStorage(void)
ok(fls_indices[i] == 0xdeadbeef, "Got unexpected index %#x.\n", fls_indices[i]);
break;
}
+ if (pRtlFlsSetValue)
+ {
+ status = pRtlFlsSetValue(fls_indices[i], (void *)(ULONG_PTR)(i + 1));
+ ok(!status, "Got unexpected status %#x.\n", status);
+ }
}
count = i;
/* FLS limits are increased since Win10 18312. */
@@ -280,6 +287,11 @@ static void test_FiberLocalStorage(void)
ret = pFlsSetValue( 0, (void *)0xdeadbeef );
ok( !ret, "setting fls index 0 succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "setting fls index wrong error %u\n", GetLastError() );
+ if (pRtlFlsSetValue)
+ {
+ status = pRtlFlsSetValue( 0, (void *)0xdeadbeef );
+ ok( status == STATUS_INVALID_PARAMETER, "Got unexpected status %#x.\n", status );
+ }
SetLastError( 0xdeadbeef );
val = pFlsGetValue( 0 );
ok( !val, "fls index 0 wrong value %p\n", val );
@@ -291,8 +303,10 @@ static void test_FiberLocalStorage(void)
ok( fls != 0, "fls index 0 allocated\n" );
val = pFlsGetValue( fls );
ok( !val, "fls index %u wrong value %p\n", fls, val );
+ SetLastError( 0xdeadbeef );
ret = pFlsSetValue( fls, (void *)0xdeadbeef );
ok( ret, "setting fls index %u failed\n", fls );
+ ok( GetLastError() == 0xdeadbeef, "setting fls index wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
val = pFlsGetValue( fls );
ok( val == (void *)0xdeadbeef, "fls index %u wrong value %p\n", fls, val );
diff --git a/dlls/kernelbase/thread.c b/dlls/kernelbase/thread.c
index bce77787ef..0aacff4008 100644
--- a/dlls/kernelbase/thread.c
+++ b/dlls/kernelbase/thread.c
@@ -1101,20 +1101,7 @@ PVOID WINAPI DECLSPEC_HOTPATCH FlsGetValue( DWORD index )
*/
BOOL WINAPI DECLSPEC_HOTPATCH FlsSetValue( DWORD index, PVOID data )
{
- if (!index || index >= 8 * sizeof(NtCurrentTeb()->Peb->FlsBitmapBits))
- {
- SetLastError( ERROR_INVALID_PARAMETER );
- return FALSE;
- }
- if (!NtCurrentTeb()->FlsSlots &&
- !(NtCurrentTeb()->FlsSlots = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
- 8 * sizeof(NtCurrentTeb()->Peb->FlsBitmapBits) * sizeof(void*) )))
- {
- SetLastError( ERROR_NOT_ENOUGH_MEMORY );
- return FALSE;
- }
- NtCurrentTeb()->FlsSlots[index] = data;
- return TRUE;
+ return set_ntstatus( RtlFlsSetValue( index, data ));
}
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 5cf7e31b01..87ac9c6cb2 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -668,6 +668,7 @@
@ stdcall RtlFirstFreeAce(ptr ptr)
@ stdcall RtlFlsAlloc(ptr ptr)
@ stdcall RtlFlsFree(long)
+@ stdcall RtlFlsSetValue(long ptr)
@ stub RtlFlushPropertySet
# @ stub RtlFlushSecureMemoryCache
@ stdcall RtlFormatCurrentUserKeyPath(ptr)
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index bbec1f9872..15bfe4c304 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -311,3 +311,21 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH RtlFlsFree( ULONG index )
RtlReleasePebLock();
return status;
}
+
+
+/***********************************************************************
+ * RtlFlsSetValue (NTDLL.@)
+ */
+NTSTATUS WINAPI DECLSPEC_HOTPATCH RtlFlsSetValue( ULONG index, void *data )
+{
+ if (!index || index >= 8 * sizeof(NtCurrentTeb()->Peb->FlsBitmapBits))
+ return STATUS_INVALID_PARAMETER;
+
+ if (!NtCurrentTeb()->FlsSlots &&
+ !(NtCurrentTeb()->FlsSlots = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY,
+ 8 * sizeof(NtCurrentTeb()->Peb->FlsBitmapBits) * sizeof(void*) )))
+ return STATUS_NO_MEMORY;
+
+ NtCurrentTeb()->FlsSlots[index] = data;
+ return STATUS_SUCCESS;
+}
diff --git a/include/winternl.h b/include/winternl.h
index 117d34bbfd..2e490dcfef 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -3373,6 +3373,7 @@ NTSYSAPI ULONG WINAPI RtlFindSetRuns(PCRTL_BITMAP,PRTL_BITMAP_RUN,ULONG,BOOL
NTSYSAPI BOOLEAN WINAPI RtlFirstFreeAce(PACL,PACE_HEADER *);
NTSYSAPI NTSTATUS WINAPI RtlFlsAlloc(PFLS_CALLBACK_FUNCTION,ULONG *);
NTSYSAPI NTSTATUS WINAPI RtlFlsFree(ULONG);
+NTSYSAPI NTSTATUS WINAPI RtlFlsSetValue(ULONG,void *);
NTSYSAPI NTSTATUS WINAPI RtlFormatCurrentUserKeyPath(PUNICODE_STRING);
NTSYSAPI NTSTATUS WINAPI RtlFormatMessage(LPCWSTR,ULONG,BOOLEAN,BOOLEAN,BOOLEAN,__ms_va_list *,LPWSTR,ULONG,ULONG*);
NTSYSAPI NTSTATUS WINAPI RtlFormatMessageEx(LPCWSTR,ULONG,BOOLEAN,BOOLEAN,BOOLEAN,__ms_va_list *,LPWSTR,ULONG,ULONG*,ULONG);
More information about the wine-cvs
mailing list