https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0e3a043526b1f34061e6168c5807769eeeeb4b53

commit 0e3a043526b1f34061e6168c5807769eeeeb4b53
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Thu Aug 23 21:30:56 2018 +0200
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Sat Apr 27 18:41:50 2019 +0200

    [KERNEL32] Add an (incomplete) pre-implementation for 
SetThreadStackGuarantee(). (#803)
    
    This should remove some of the "SetThreadStackGuarantee(): stub" messages 
in some simple cases.
---
 dll/win32/kernel32/client/thread.c | 39 ++++++++++++++++++++++++++++++++------
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/dll/win32/kernel32/client/thread.c 
b/dll/win32/kernel32/client/thread.c
index 2ff0102483..1a593ba2dd 100644
--- a/dll/win32/kernel32/client/thread.c
+++ b/dll/win32/kernel32/client/thread.c
@@ -5,7 +5,6 @@
  * PURPOSE:         Thread functions
  * PROGRAMMERS:     Alex Ionescu ([email protected])
  *                  Ariadne ([email protected])
- *
  */
 
 /* INCLUDES 
*******************************************************************/
@@ -950,16 +949,44 @@ QueueUserAPC(IN PAPCFUNC pfnAPC,
 }
 
 /*
- * @implemented
+ * @unimplemented
  */
 BOOL
 WINAPI
 SetThreadStackGuarantee(IN OUT PULONG StackSizeInBytes)
 {
-    static int once;
-    if (once++ == 0)
-         DPRINT1("SetThreadStackGuarantee(%p): stub\n", StackSizeInBytes);
-    return TRUE;
+    PTEB Teb = NtCurrentTeb();
+    ULONG GuaranteedStackBytes;
+    ULONG AllocationSize;
+
+    if (!StackSizeInBytes)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
+    AllocationSize = *StackSizeInBytes;
+
+    /* Retrieve the current stack size */
+    GuaranteedStackBytes = Teb->GuaranteedStackBytes;
+
+    /* Return the size of the previous stack */
+    *StackSizeInBytes = GuaranteedStackBytes;
+
+    /*
+     * If the new stack size is either zero or is less than the current size,
+     * the previous stack size is returned and we return success.
+     */
+    if ((AllocationSize == 0) || (AllocationSize < GuaranteedStackBytes))
+    {
+        return TRUE;
+    }
+
+    // FIXME: Unimplemented!
+    UNIMPLEMENTED_ONCE;
+
+    // return TRUE;
+    return FALSE;
 }
 
 /*

Reply via email to