[ros-diffs] [mjmartin] 44318: [ntdll] - Implement LdrLockLoaderLock and LdrUnlockLoaderLock.

mjmartin at svn.reactos.org mjmartin at svn.reactos.org
Sun Nov 29 11:53:39 CET 2009


Author: mjmartin
Date: Sun Nov 29 11:53:39 2009
New Revision: 44318

URL: http://svn.reactos.org/svn/reactos?rev=44318&view=rev
Log:
[ntdll]
- Implement LdrLockLoaderLock and LdrUnlockLoaderLock.

Modified:
    trunk/reactos/dll/ntdll/ldr/utils.c

Modified: trunk/reactos/dll/ntdll/ldr/utils.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/utils.c?rev=44318&r1=44317&r2=44318&view=diff
==============================================================================
--- trunk/reactos/dll/ntdll/ldr/utils.c [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/ldr/utils.c [iso-8859-1] Sun Nov 29 11:53:39 2009
@@ -3382,8 +3382,55 @@
                   OUT PULONG Disposition OPTIONAL,
                   OUT PULONG Cookie OPTIONAL)
 {
-    UNIMPLEMENTED;
-    return STATUS_NOT_IMPLEMENTED;
+    NTSTATUS Status;
+    BOOLEAN Ret;
+    BOOLEAN CookieSet = FALSE;
+
+    if ((Flags != 0x01) && (Flags != 0x02))
+        return STATUS_INVALID_PARAMETER_1;
+
+    if (!Cookie) return STATUS_INVALID_PARAMETER_3;
+
+    /* Set some defaults for failure while verifying params */
+    _SEH2_TRY
+    {
+        *Cookie = 0;
+        CookieSet = TRUE;
+        if (Disposition) *Disposition = 0;
+    }
+    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+    {
+        if (CookieSet)
+            Status = STATUS_INVALID_PARAMETER_3;
+        else
+            Status =  STATUS_INVALID_PARAMETER_2;
+    }
+    _SEH2_END;
+
+    if (Flags == 0x01)
+    {
+        DPRINT1("Warning: Reporting errors with exception not supported yet!\n");
+        RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock);
+        Status = STATUS_SUCCESS;
+
+    }
+    else
+    {
+        if (!Disposition) return STATUS_INVALID_PARAMETER_2;
+
+        Ret = RtlTryEnterCriticalSection(NtCurrentPeb()->LoaderLock);
+
+        if (Ret)
+            *Disposition = 0x01;
+        else
+            *Disposition = 0x02;
+
+        Status = STATUS_SUCCESS;
+    }
+
+    /* FIXME: Cookie is based on part of the thread id */
+    *Cookie = (ULONG)NtCurrentTeb()->RealClientId.UniqueThread;
+    return Status;
 }
 
 NTSTATUS
@@ -3391,8 +3438,15 @@
 LdrUnlockLoaderLock(IN ULONG Flags,
                     IN ULONG Cookie OPTIONAL)
 {
-    UNIMPLEMENTED;
-    return STATUS_NOT_IMPLEMENTED;
+    if (Flags != 0x01)
+        return STATUS_INVALID_PARAMETER_1;
+
+    if (Cookie != (ULONG)NtCurrentTeb()->RealClientId.UniqueThread)
+        return STATUS_INVALID_PARAMETER_2;
+
+    RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock);
+
+    return STATUS_SUCCESS;
 }
 
 BOOLEAN




More information about the Ros-diffs mailing list