Commit defcbc8b authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

kernelbase: Move FlsGetValue() implementation to ntdll.RtlFlsGetValue().

parent e596f404
......@@ -40,6 +40,7 @@ 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 NTSTATUS (WINAPI *pRtlFlsGetValue)(ULONG,void **);
static void *fibers[3];
static BYTE testparam = 185;
static DWORD fls_index_to_set = FLS_OUT_OF_INDEXES;
......@@ -72,6 +73,7 @@ static VOID init_funcs(void)
X(RtlFlsAlloc);
X(RtlFlsFree);
X(RtlFlsSetValue);
X(RtlFlsGetValue);
#undef X
}
......@@ -205,6 +207,16 @@ static void test_FiberLocalStorage(void)
if (pRtlFlsAlloc)
{
if (pRtlFlsGetValue)
{
status = pRtlFlsGetValue(0, NULL);
ok(status == STATUS_INVALID_PARAMETER, "Got unexpected status %#x.\n", status);
}
else
{
win_skip("RtlFlsGetValue is not available.\n");
}
for (i = 0; i < FLS_TEST_INDEX_COUNT; ++i)
{
fls_indices[i] = 0xdeadbeef;
......@@ -225,8 +237,21 @@ static void test_FiberLocalStorage(void)
/* FLS limits are increased since Win10 18312. */
ok(count && (count <= 127 || (count > 4000 && count < 4096)), "Got unexpected count %u.\n", count);
if (0)
{
/* crashes on Windows. */
pRtlFlsGetValue(fls_indices[0], NULL);
}
for (i = 0; i < count; ++i)
{
if (pRtlFlsGetValue)
{
status = pRtlFlsGetValue(fls_indices[i], &val);
ok(!status, "Got unexpected status %#x.\n", status);
ok(val == (void *)(ULONG_PTR)(i + 1), "Got unexpected val %p.\n", val);
}
status = pRtlFlsFree(fls_indices[i]);
ok(!status, "Got unexpected status %#x.\n", status);
}
......@@ -250,6 +275,14 @@ static void test_FiberLocalStorage(void)
ok( val == NULL,
"getting fls index 127 (unallocated) failed with error %u\n", GetLastError() );
if (pRtlFlsGetValue)
{
val = (void *)0xdeadbeef;
status = pRtlFlsGetValue(127, &val);
ok( !status, "Got unexpected status %#x.\n", status );
ok( !val, "Got unexpected val %p.\n", val );
}
ret = pFlsSetValue( 127, (void*) 0x217 );
ok( ret, "setting fls index 127 (unallocated) failed with error %u\n", GetLastError() );
......@@ -259,6 +292,14 @@ static void test_FiberLocalStorage(void)
ok( GetLastError() == ERROR_SUCCESS,
"getting fls index 127 (unallocated) failed with error %u\n", GetLastError() );
if (pRtlFlsGetValue)
{
val = (void *)0xdeadbeef;
status = pRtlFlsGetValue(127, &val);
ok( !status, "Got unexpected status %#x.\n", status );
ok( val == (void*)0x217, "Got unexpected val %p.\n", val );
}
/* FlsFree, FlsGetValue, and FlsSetValue out of bounds should return
* ERROR_INVALID_PARAMETER
*/
......@@ -283,6 +324,14 @@ static void test_FiberLocalStorage(void)
val = pFlsGetValue( 0 );
ok( !val, "fls index 0 set to %p\n", val );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "setting fls index wrong error %u\n", GetLastError() );
if (pRtlFlsGetValue)
{
val = (void *)0xdeadbeef;
status = pRtlFlsGetValue(0, &val);
ok( status == STATUS_INVALID_PARAMETER, "Got unexpected status %#x.\n", status );
ok( val == (void*)0xdeadbeef, "Got unexpected val %p.\n", val );
}
SetLastError( 0xdeadbeef );
ret = pFlsSetValue( 0, (void *)0xdeadbeef );
ok( !ret, "setting fls index 0 succeeded\n" );
......
......@@ -1086,13 +1086,11 @@ BOOL WINAPI DECLSPEC_HOTPATCH FlsFree( DWORD index )
*/
PVOID WINAPI DECLSPEC_HOTPATCH FlsGetValue( DWORD index )
{
if (!index || index >= 8 * sizeof(NtCurrentTeb()->Peb->FlsBitmapBits) || !NtCurrentTeb()->FlsSlots)
{
SetLastError( ERROR_INVALID_PARAMETER );
return NULL;
}
void *data;
if (!set_ntstatus( RtlFlsGetValue( index, &data ))) return NULL;
SetLastError( ERROR_SUCCESS );
return NtCurrentTeb()->FlsSlots[index];
return data;
}
......
......@@ -668,6 +668,7 @@
@ stdcall RtlFirstFreeAce(ptr ptr)
@ stdcall RtlFlsAlloc(ptr ptr)
@ stdcall RtlFlsFree(long)
@ stdcall RtlFlsGetValue(long ptr)
@ stdcall RtlFlsSetValue(long ptr)
@ stub RtlFlushPropertySet
# @ stub RtlFlushSecureMemoryCache
......
......@@ -329,3 +329,17 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH RtlFlsSetValue( ULONG index, void *data )
NtCurrentTeb()->FlsSlots[index] = data;
return STATUS_SUCCESS;
}
/***********************************************************************
* RtlFlsGetValue (NTDLL.@)
*/
NTSTATUS WINAPI DECLSPEC_HOTPATCH RtlFlsGetValue( ULONG index, void **data )
{
if (!index || index >= 8 * sizeof(NtCurrentTeb()->Peb->FlsBitmapBits) || !NtCurrentTeb()->FlsSlots)
return STATUS_INVALID_PARAMETER;
*data = NtCurrentTeb()->FlsSlots[index];
return STATUS_SUCCESS;
}
......@@ -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 RtlFlsGetValue(ULONG,void **);
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*);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment