Alexandre Julliard : kernel32: Move GetNamedPipeHandleStateW() implementation to kernelbase.

Alexandre Julliard julliard at winehq.org
Thu Apr 16 16:45:12 CDT 2020


Module: wine
Branch: master
Commit: 99027aeaee22b72e5cbd62f83d26f2b2d973dd57
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=99027aeaee22b72e5cbd62f83d26f2b2d973dd57

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Apr 16 15:34:59 2020 +0200

kernel32: Move GetNamedPipeHandleStateW() implementation to kernelbase.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/kernel32.spec     |  4 +--
 dlls/kernel32/sync.c            | 60 -----------------------------------------
 dlls/kernelbase/kernelbase.spec |  2 +-
 dlls/kernelbase/sync.c          | 38 ++++++++++++++++++++++++++
 4 files changed, 41 insertions(+), 63 deletions(-)

diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index a5550dd359..01bfdd37f1 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -731,8 +731,8 @@
 # @ stub GetNamedPipeClientComputerNameW
 @ stdcall GetNamedPipeClientProcessId(long ptr)
 @ stdcall GetNamedPipeClientSessionId(long ptr)
-@ stdcall GetNamedPipeHandleStateA(long ptr ptr ptr ptr str long)
-@ stdcall GetNamedPipeHandleStateW(long ptr ptr ptr ptr wstr long)
+@ stdcall GetNamedPipeHandleStateA(long ptr ptr ptr ptr ptr long)
+@ stdcall -import GetNamedPipeHandleStateW(long ptr ptr ptr ptr ptr long)
 @ stdcall -import GetNamedPipeInfo(long ptr ptr ptr ptr)
 @ stdcall GetNamedPipeServerProcessId(long ptr)
 @ stdcall GetNamedPipeServerSessionId(long ptr)
diff --git a/dlls/kernel32/sync.c b/dlls/kernel32/sync.c
index 48f9fca20a..7a7a37b4a2 100644
--- a/dlls/kernel32/sync.c
+++ b/dlls/kernel32/sync.c
@@ -42,7 +42,6 @@
 #include "ddk/wdm.h"
 
 #include "wine/asm.h"
-#include "wine/library.h"
 #include "wine/unicode.h"
 #include "kernel_private.h"
 
@@ -630,65 +629,6 @@ BOOL WINAPI GetNamedPipeHandleStateA(
     return ret;
 }
 
-/***********************************************************************
- *           GetNamedPipeHandleStateW  (KERNEL32.@)
- */
-BOOL WINAPI GetNamedPipeHandleStateW(
-    HANDLE hNamedPipe, LPDWORD lpState, LPDWORD lpCurInstances,
-    LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout,
-    LPWSTR lpUsername, DWORD nUsernameMaxSize)
-{
-    IO_STATUS_BLOCK iosb;
-    NTSTATUS status;
-
-    FIXME("%p %p %p %p %p %p %d: semi-stub\n", hNamedPipe, lpState, lpCurInstances,
-          lpMaxCollectionCount, lpCollectDataTimeout, lpUsername, nUsernameMaxSize);
-
-    if (lpMaxCollectionCount)
-        *lpMaxCollectionCount = 0;
-
-    if (lpCollectDataTimeout)
-        *lpCollectDataTimeout = 0;
-
-    if (lpUsername && nUsernameMaxSize)
-    {
-        const char *username = wine_get_user_name();
-        int len = MultiByteToWideChar(CP_UNIXCP, 0, username, -1, lpUsername, nUsernameMaxSize);
-        if (!len) *lpUsername = 0;
-    }
-
-    if (lpState)
-    {
-        FILE_PIPE_INFORMATION fpi;
-        status = NtQueryInformationFile(hNamedPipe, &iosb, &fpi, sizeof(fpi),
-                                        FilePipeInformation);
-        if (status)
-        {
-            SetLastError( RtlNtStatusToDosError(status) );
-            return FALSE;
-        }
-
-        *lpState = (fpi.ReadMode ? PIPE_READMODE_MESSAGE : PIPE_READMODE_BYTE) |
-                   (fpi.CompletionMode ? PIPE_NOWAIT : PIPE_WAIT);
-    }
-
-    if (lpCurInstances)
-    {
-        FILE_PIPE_LOCAL_INFORMATION fpli;
-        status = NtQueryInformationFile(hNamedPipe, &iosb, &fpli, sizeof(fpli),
-                                        FilePipeLocalInformation);
-        if (status)
-        {
-            SetLastError( RtlNtStatusToDosError(status) );
-            return FALSE;
-        }
-
-        *lpCurInstances = fpli.CurrentInstances;
-    }
-
-    return TRUE;
-}
-
 /***********************************************************************
  *           CallNamedPipeA  (KERNEL32.@)
  */
diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec
index 9aa0613ea5..631e5c02c7 100644
--- a/dlls/kernelbase/kernelbase.spec
+++ b/dlls/kernelbase/kernelbase.spec
@@ -570,7 +570,7 @@
 @ stub GetNamedLocaleHashNode
 @ stub GetNamedPipeAttribute
 @ stub GetNamedPipeClientComputerNameW
-@ stdcall GetNamedPipeHandleStateW(long ptr ptr ptr ptr wstr long) kernel32.GetNamedPipeHandleStateW
+@ stdcall GetNamedPipeHandleStateW(long ptr ptr ptr ptr ptr long)
 @ stdcall GetNamedPipeInfo(long ptr ptr ptr ptr)
 @ stdcall GetNativeSystemInfo(ptr)
 # @ stub GetNextFgPolicyRefreshInfoInternal
diff --git a/dlls/kernelbase/sync.c b/dlls/kernelbase/sync.c
index 441b47ffb0..c0db4679e9 100644
--- a/dlls/kernelbase/sync.c
+++ b/dlls/kernelbase/sync.c
@@ -1201,6 +1201,44 @@ BOOL WINAPI DECLSPEC_HOTPATCH DisconnectNamedPipe( HANDLE pipe )
 }
 
 
+/***********************************************************************
+ *           GetNamedPipeHandleStateW   (kernelbase.@)
+ */
+BOOL WINAPI DECLSPEC_HOTPATCH GetNamedPipeHandleStateW( HANDLE pipe, DWORD *state, DWORD *instances,
+                                                        DWORD *max_count, DWORD *timeout,
+                                                        WCHAR *user, DWORD size )
+{
+    IO_STATUS_BLOCK io;
+
+    FIXME( "%p %p %p %p %p %p %d: semi-stub\n", pipe, state, instances, max_count, timeout, user, size );
+
+    if (max_count) *max_count = 0;
+    if (timeout) *timeout = 0;
+    if (user && size && !GetEnvironmentVariableW( L"WINEUSERNAME", user, size )) user[0] = 0;
+
+    if (state)
+    {
+        FILE_PIPE_INFORMATION info;
+
+        if (!set_ntstatus( NtQueryInformationFile( pipe, &io, &info, sizeof(info), FilePipeInformation )))
+            return FALSE;
+
+        *state = (info.ReadMode ? PIPE_READMODE_MESSAGE : PIPE_READMODE_BYTE) |
+                 (info.CompletionMode ? PIPE_NOWAIT : PIPE_WAIT);
+    }
+    if (instances)
+    {
+        FILE_PIPE_LOCAL_INFORMATION info;
+
+        if (!set_ntstatus( NtQueryInformationFile( pipe, &io, &info, sizeof(info),
+                                                   FilePipeLocalInformation)))
+            return FALSE;
+        *instances = info.CurrentInstances;
+    }
+    return TRUE;
+}
+
+
 /***********************************************************************
  *           GetNamedPipeInfo   (kernelbase.@)
  */




More information about the wine-cvs mailing list