[RTL]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 22 Sep 2013 15:14:24 +0000 (15:14 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 22 Sep 2013 15:14:24 +0000 (15:14 +0000)
- Implement and export RtlGetCriticalSectionRecursionCount (introduced in NT 5.2 SP1, see http://www.geoffchappell.com/studies/windows/win32/ntdll/history/names52.htm) which definition comes from http://processhacker.sourceforge.net/doc/ntrtl_8h.html#a26bd65dfad63985a247700c2c2ab9e86.
- Fix the return type of RtlSetCriticalSectionSpinCount.
- Export the already-existing RtlQueryInformationActiveActivationContext API.

RtlQueryInformationActiveActivationContext and RtlGetCriticalSectionRecursionCount are needed by Win2k3 user32.dll and winsrv.dll .

svn path=/trunk/; revision=60302

reactos/dll/ntdll/def/ntdll.spec
reactos/lib/rtl/critical.c

index 9d144c7..32e07c8 100644 (file)
 @ stdcall RtlGetCallersAddress(ptr ptr)
 @ stdcall RtlGetCompressionWorkSpaceSize(long ptr ptr)
 @ stdcall RtlGetControlSecurityDescriptor(ptr ptr ptr)
-;@ stdcall RtlGetCriticalSectionRecursionCount
+@ stdcall RtlGetCriticalSectionRecursionCount(ptr)
 @ stdcall RtlGetCurrentDirectory_U(long ptr)
 @ stdcall RtlGetCurrentPeb()
 @ stdcall RtlGetCurrentProcessorNumber() ; 5.2 SP1 and higher
 @ stdcall RtlQueryHeapInformation(long long ptr long ptr)
 @ stdcall RtlQueryInformationAcl(ptr ptr long long)
 @ stdcall RtlQueryInformationActivationContext(long long ptr long ptr long ptr)
-;@ stdcall RtlQueryInformationActiveActivationContext
+@ stdcall RtlQueryInformationActiveActivationContext(long ptr long ptr)
 ;@ stdcall RtlQueryInterfaceMemoryStream
 ;@ stdcall RtlQueryProcessBackTraceInformation
 @ stdcall RtlQueryProcessDebugInformation(long long ptr)
index 80afe4d..917cbf2 100644 (file)
@@ -299,7 +299,7 @@ RtlpAllocateDebugInfo(VOID)
     }
 
     /* We are out of static buffer, allocate dynamic */
-    return RtlAllocateHeap(NtCurrentPeb()->ProcessHeap,
+    return RtlAllocateHeap(RtlGetProcessHeap(),
                            0,
                            sizeof(RTL_CRITICAL_SECTION_DEBUG));
 }
@@ -436,7 +436,7 @@ RtlDeleteCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
  *     SpinCount is ignored on single-processor systems.
  *
  *--*/
-DWORD
+ULONG
 NTAPI
 RtlSetCriticalSectionSpinCount(PRTL_CRITICAL_SECTION CriticalSection,
                                ULONG SpinCount)
@@ -618,6 +618,45 @@ RtlInitializeCriticalSectionAndSpinCount(PRTL_CRITICAL_SECTION CriticalSection,
     return STATUS_SUCCESS;
 }
 
+/*++
+ * RtlGetCriticalSectionRecursionCount
+ * @implemented NT5.2 SP1
+ *
+ *     Retrieves the recursion count of a given critical section.
+ *
+ * Params:
+ *     CriticalSection - Critical section to retrieve its recursion count.
+ *
+ * Returns:
+ *     The recursion count.
+ *
+ * Remarks:
+ *     We return the recursion count of the critical section if it is owned
+ *     by the current thread, and otherwise we return zero.
+ *
+ *--*/
+LONG
+NTAPI
+RtlGetCriticalSectionRecursionCount(PRTL_CRITICAL_SECTION CriticalSection)
+{
+    if (CriticalSection->OwningThread == NtCurrentTeb()->ClientId.UniqueThread)
+    {
+        /*
+         * The critical section is owned by the current thread,
+         * therefore retrieve its actual recursion count.
+         */
+        return CriticalSection->RecursionCount;
+    }
+    else
+    {
+        /*
+         * It is not owned by the current thread, so
+         * for this thread there is no recursion.
+         */
+        return 0;
+    }
+}
+
 /*++
  * RtlLeaveCriticalSection
  * @implemented NT4