diff --git a/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec b/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec index 563bd79b67d..708a8eff091 100644 --- a/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec +++ b/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec @@ -15,7 +15,7 @@ @ stdcall GetCurrentProcessorNumberEx(ptr) kernel32.GetCurrentProcessorNumberEx @ stdcall -norelay GetCurrentThread() kernel32.GetCurrentThread @ stdcall -norelay GetCurrentThreadId() kernel32.GetCurrentThreadId -@ stub GetCurrentThreadStackLimits +@ stdcall GetCurrentThreadStackLimits(ptr ptr) kernel32.GetCurrentThreadStackLimits @ stdcall GetExitCodeProcess(long ptr) kernel32.GetExitCodeProcess @ stdcall GetExitCodeThread(long ptr) kernel32.GetExitCodeThread @ stdcall GetPriorityClass(long) kernel32.GetPriorityClass diff --git a/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec b/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec index 85830a11fc3..a29ef435662 100644 --- a/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec +++ b/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec @@ -15,7 +15,7 @@ @ stdcall GetCurrentProcessorNumberEx(ptr) kernel32.GetCurrentProcessorNumberEx @ stdcall -norelay GetCurrentThread() kernel32.GetCurrentThread @ stdcall -norelay GetCurrentThreadId() kernel32.GetCurrentThreadId -@ stub GetCurrentThreadStackLimits +@ stdcall GetCurrentThreadStackLimits(ptr ptr) kernel32.GetCurrentThreadStackLimits @ stdcall GetExitCodeProcess(long ptr) kernel32.GetExitCodeProcess @ stdcall GetExitCodeThread(long ptr) kernel32.GetExitCodeThread @ stdcall GetPriorityClass(long) kernel32.GetPriorityClass diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index 85fce3725aa..ae7bc886c51 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -635,6 +635,7 @@ @ stdcall GetCurrentProcessorNumberEx(ptr) ntdll.RtlGetCurrentProcessorNumberEx @ stdcall -norelay GetCurrentThread() @ stdcall -norelay GetCurrentThreadId() +@ stdcall GetCurrentThreadStackLimits(ptr ptr) @ stdcall -arch=x86_64 GetCurrentUmsThread() @ stdcall GetDateFormatA(long long ptr str ptr long) @ stdcall GetDateFormatEx(wstr long ptr wstr ptr long wstr) diff --git a/dlls/kernel32/tests/thread.c b/dlls/kernel32/tests/thread.c index b69d2eb371f..f27bbdf2b51 100644 --- a/dlls/kernel32/tests/thread.c +++ b/dlls/kernel32/tests/thread.c @@ -76,6 +76,7 @@ #define ARCH "none" #endif +static void (WINAPI *pGetCurrentThreadStackLimits)(PULONG_PTR,PULONG_PTR); static BOOL (WINAPI *pGetThreadPriorityBoost)(HANDLE,PBOOL); static HANDLE (WINAPI *pOpenThread)(DWORD,BOOL,DWORD); static BOOL (WINAPI *pQueueUserWorkItem)(LPTHREAD_START_ROUTINE,PVOID,ULONG); @@ -992,6 +993,29 @@ static VOID test_thread_processor(void) win_skip("Get/SetThreadGroupAffinity not available\n"); } +static VOID test_GetCurrentThreadStackLimits(void) +{ + ULONG_PTR low = 0, high = 0; + + if (!pGetCurrentThreadStackLimits) + { + win_skip("GetCurrentThreadStackLimits not available.\n"); + return; + } + + if (0) + { + /* crashes on native */ + pGetCurrentThreadStackLimits(NULL, NULL); + pGetCurrentThreadStackLimits(NULL, &high); + pGetCurrentThreadStackLimits(&low, NULL); + } + + pGetCurrentThreadStackLimits(&low, &high); + ok(low == (ULONG_PTR)NtCurrentTeb()->DeallocationStack, "exptected %p, got %lx\n", NtCurrentTeb()->DeallocationStack, low); + ok(high == (ULONG_PTR)NtCurrentTeb()->Tib.StackBase, "exptected %p, got %lx\n", NtCurrentTeb()->Tib.StackBase, high); +} + static VOID test_GetThreadExitCode(void) { DWORD exitCode, threadid; @@ -1999,6 +2023,7 @@ static void init_funcs(void) so that the compile passes */ #define X(f) p##f = (void*)GetProcAddress(hKernel32, #f) + X(GetCurrentThreadStackLimits); X(GetThreadPriorityBoost); X(OpenThread); X(QueueUserWorkItem); @@ -2084,6 +2109,7 @@ START_TEST(thread) test_TerminateThread(); test_CreateThread_stack(); test_thread_priority(); + test_GetCurrentThreadStackLimits(); test_GetThreadTimes(); test_thread_processor(); test_GetThreadExitCode(); diff --git a/dlls/kernel32/thread.c b/dlls/kernel32/thread.c index e6b99aed62c..ac5d46546a1 100644 --- a/dlls/kernel32/thread.c +++ b/dlls/kernel32/thread.c @@ -701,6 +701,15 @@ HANDLE WINAPI GetCurrentThread(void) return (HANDLE)~(ULONG_PTR)1; } +/*********************************************************************** + * GetCurrentThreadStackLimits (KERNEL32.@) + */ +void WINAPI GetCurrentThreadStackLimits(ULONG_PTR *low, ULONG_PTR *high) +{ + *low = (ULONG_PTR)NtCurrentTeb()->DeallocationStack; + *high = (ULONG_PTR)NtCurrentTeb()->Tib.StackBase; +} + #ifdef __i386__ diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec index d1bff9fec5c..45b375ce2f4 100644 --- a/dlls/kernelbase/kernelbase.spec +++ b/dlls/kernelbase/kernelbase.spec @@ -471,7 +471,7 @@ # @ stub GetCurrentTargetPlatformContext @ stdcall -norelay GetCurrentThread() kernel32.GetCurrentThread @ stdcall -norelay GetCurrentThreadId() kernel32.GetCurrentThreadId -# @ stub GetCurrentThreadStackLimits +@ stdcall GetCurrentThreadStackLimits(ptr ptr) kernel32.GetCurrentThreadStackLimits @ stdcall GetDateFormatA(long long ptr str ptr long) kernel32.GetDateFormatA @ stdcall GetDateFormatEx(wstr long ptr wstr ptr long wstr) kernel32.GetDateFormatEx @ stdcall GetDateFormatW(long long ptr wstr ptr long) kernel32.GetDateFormatW