Try3: Open directory for named objects.

Vitaliy Margolen wine-patch at kievinfo.com
Thu Dec 1 11:57:30 CST 2005


This time using InterlockedExchange to make it thread safe.

ChangeLog:
Try3: Open directory for named objects.

 dlls/kernel/kernel_private.h |    3 +++
 dlls/kernel/sync.c           |   26 ++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)
-------------- next part --------------
2b2a424894684ff5f698162c907d657aca5c9adb
diff --git a/dlls/kernel/kernel_private.h b/dlls/kernel/kernel_private.h
index 73c3f22..3ed5f67 100644
--- a/dlls/kernel/kernel_private.h
+++ b/dlls/kernel/kernel_private.h
@@ -146,4 +146,7 @@ extern struct winedos_exports
     void (* BiosTick)(WORD timer);
 } winedos;
 
+/* returns directory handle for named objects */
+extern HANDLE get_BaseNamedObjects_handle(void);
+
 #endif
diff --git a/dlls/kernel/sync.c b/dlls/kernel/sync.c
index 990b3bc..8b96963 100644
--- a/dlls/kernel/sync.c
+++ b/dlls/kernel/sync.c
@@ -52,6 +52,7 @@
 #include "winnls.h"
 #include "winternl.h"
 #include "winioctl.h"
+#include "ddk/wdm.h"
 
 #include "wine/server.h"
 #include "wine/unicode.h"
@@ -68,6 +69,31 @@ inline static int is_version_nt(void)
     return !(GetVersion() & 0x80000000);
 }
 
+/* returns directory handle to \\BaseNamedObjects */
+HANDLE get_BaseNamedObjects_handle(void)
+{
+    static HANDLE handle = NULL;
+    static const WCHAR basenameW[] =
+        {'\\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s',0};
+    UNICODE_STRING str;
+    OBJECT_ATTRIBUTES attr;
+
+    if (!handle)
+    {
+        HANDLE dir;
+
+        RtlInitUnicodeString(&str, basenameW);
+        InitializeObjectAttributes(&attr, &str, 0, 0, NULL);
+        NtOpenDirectoryObject(&dir, DIRECTORY_CREATE_OBJECT|DIRECTORY_TRAVERSE,
+                              &attr);
+        if (InterlockedCompareExchangePointer( (PVOID)&handle, dir, 0 ) != 0)
+        {
+            /* someone beat us here... */
+            CloseHandle( dir );
+        }
+    }
+    return handle;
+}
 
 /***********************************************************************
  *              Sleep  (KERNEL32.@)


More information about the wine-patches mailing list