[NTOS:EX]
authorThomas Faber <thomas.faber@reactos.org>
Wed, 25 May 2016 10:27:17 +0000 (10:27 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Wed, 25 May 2016 10:27:17 +0000 (10:27 +0000)
- Use the calling thread instead of the passed-in thread to validate APC status in ExReleaseResourceForThreadLite. The latter can be user-set and might not be a KTHREAD at all.
CORE-11315 #resolve

svn path=/trunk/; revision=71398

reactos/ntoskrnl/ex/resource.c
rostests/kmtests/ntos_ex/ExResource.c

index 362c778..1911ef1 100644 (file)
@@ -1817,7 +1817,7 @@ FASTCALL
 ExReleaseResourceLite(IN PERESOURCE Resource)
 {
     /* Just call the For-Thread function */
 ExReleaseResourceLite(IN PERESOURCE Resource)
 {
     /* Just call the For-Thread function */
-    ExReleaseResourceForThreadLite(Resource, (ERESOURCE_THREAD)PsGetCurrentThread());
+    ExReleaseResourceForThreadLite(Resource, ExGetCurrentResourceThread());
 }
 
 /*++
 }
 
 /*++
@@ -1855,7 +1855,7 @@ ExReleaseResourceForThreadLite(IN PERESOURCE Resource,
 
     /* Sanity checks */
     ExpVerifyResource(Resource);
 
     /* Sanity checks */
     ExpVerifyResource(Resource);
-    ExpCheckForApcsDisabled(LockHandle.OldIrql, Resource, (PKTHREAD)Thread);
+    ExpCheckForApcsDisabled(LockHandle.OldIrql, Resource, KeGetCurrentThread());
 
     /* Check if it's exclusively owned */
     if (IsOwnedExclusive(Resource))
 
     /* Check if it's exclusively owned */
     if (IsOwnedExclusive(Resource))
index c4241aa..74c2dc8 100644 (file)
@@ -504,6 +504,10 @@ TestResourceWithOwner(
     InitThreadDataEx(&ThreadDataOwner, Res, ExAcquireResourceExclusiveLite, TestOwnerRes);
 
     KeEnterCriticalRegion();
     InitThreadDataEx(&ThreadDataOwner, Res, ExAcquireResourceExclusiveLite, TestOwnerRes);
 
     KeEnterCriticalRegion();
+    ok_bool_true(ExAcquireResourceExclusiveLite(Res, FALSE), "ExAcquireResourceExclusiveLite returned");
+    ExSetResourceOwnerPointer(Res, (PVOID)(ULONG_PTR)3);
+    ExReleaseResourceForThreadLite(Res, 3);
+
     ok_bool_true(ExAcquireResourceExclusiveLite(Res, FALSE), "ExAcquireResourceExclusiveLite returned");
     ExSetResourceOwnerPointer(Res, (PVOID)((ULONG_PTR)Res | 3));
     KeLeaveCriticalRegion();
     ok_bool_true(ExAcquireResourceExclusiveLite(Res, FALSE), "ExAcquireResourceExclusiveLite returned");
     ExSetResourceOwnerPointer(Res, (PVOID)((ULONG_PTR)Res | 3));
     KeLeaveCriticalRegion();