diff --git a/reactos/dll/ntdll/def/ntdll.spec b/reactos/dll/ntdll/def/ntdll.spec index 9d144c743e3..32e07c84f5c 100644 --- a/reactos/dll/ntdll/def/ntdll.spec +++ b/reactos/dll/ntdll/def/ntdll.spec @@ -614,7 +614,7 @@ @ 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 @@ -780,7 +780,7 @@ @ 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) diff --git a/reactos/lib/rtl/critical.c b/reactos/lib/rtl/critical.c index 80afe4de445..917cbf2dda9 100644 --- a/reactos/lib/rtl/critical.c +++ b/reactos/lib/rtl/critical.c @@ -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