Alexandre Julliard : kernelbase: Implement DnsHostnameToComputerNameExW().

Alexandre Julliard julliard at winehq.org
Thu Dec 12 16:29:41 CST 2019


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Dec 12 17:48:18 2019 +0100

kernelbase: Implement DnsHostnameToComputerNameExW().

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

---

 dlls/kernelbase/kernelbase.spec |  2 +-
 dlls/kernelbase/registry.c      | 32 ++++++++++++++++++++++++++++++++
 include/winbase.h               |  1 +
 3 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec
index a9ef04aa17..5b3e10f85b 100644
--- a/dlls/kernelbase/kernelbase.spec
+++ b/dlls/kernelbase/kernelbase.spec
@@ -267,7 +267,7 @@
 @ stdcall DisassociateCurrentThreadFromCallback(ptr) ntdll.TpDisassociateCallback
 # @ stub DiscardVirtualMemory
 @ stdcall DisconnectNamedPipe(long)
-# @ stub DnsHostnameToComputerNameExW
+@ stdcall DnsHostnameToComputerNameExW(wstr ptr ptr)
 # @ stub DsBindWithSpnExW
 # @ stub DsCrackNamesW
 # @ stub DsFreeDomainControllerInfoW
diff --git a/dlls/kernelbase/registry.c b/dlls/kernelbase/registry.c
index e482d11cb2..b3297a3ad5 100644
--- a/dlls/kernelbase/registry.c
+++ b/dlls/kernelbase/registry.c
@@ -3046,6 +3046,38 @@ LSTATUS WINAPI RegLoadAppKeyW(const WCHAR *file, HKEY *result, REGSAM sam, DWORD
 }
 
 
+/***********************************************************************
+ * DnsHostnameToComputerNameExW   (kernelbase.@)
+ *
+ * FIXME: how is this different from the non-Ex function?
+ */
+BOOL WINAPI DECLSPEC_HOTPATCH DnsHostnameToComputerNameExW( const WCHAR *hostname, WCHAR *computername,
+                                                            DWORD *size )
+{
+    static const WCHAR allowed[] = L"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&')(-_{}";
+    WCHAR buffer[MAX_COMPUTERNAME_LENGTH + 1];
+    DWORD i, len;
+
+    lstrcpynW( buffer, hostname, MAX_COMPUTERNAME_LENGTH + 1 );
+    len = lstrlenW( buffer );
+    if (*size < len + 1)
+    {
+        *size = len;
+        SetLastError( ERROR_MORE_DATA );
+        return FALSE;
+    }
+    *size = len;
+    if (!computername) return FALSE;
+    for (i = 0; i < len; i++)
+    {
+        if (buffer[i] >= 'a' && buffer[i] <= 'z') computername[i] = buffer[i] + 'A' - 'a';
+        else computername[i] = wcschr( allowed, buffer[i] ) ? buffer[i] : '_';
+    }
+    computername[len] = 0;
+    return TRUE;
+}
+
+
 struct USKEY
 {
     HKEY  HKCUstart; /* Start key in CU hive */
diff --git a/include/winbase.h b/include/winbase.h
index 320e243034..c550ed816d 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -1958,6 +1958,7 @@ WINBASEAPI BOOL        WINAPI DisconnectNamedPipe(HANDLE);
 WINBASEAPI BOOL        WINAPI DnsHostnameToComputerNameA(LPCSTR,LPSTR,LPDWORD);
 WINBASEAPI BOOL        WINAPI DnsHostnameToComputerNameW(LPCWSTR,LPWSTR,LPDWORD);
 #define                       DnsHostnameToComputerName WINELIB_NAME_AW(DnsHostnameToComputerName)
+WINBASEAPI BOOL        WINAPI DnsHostnameToComputerNameExW(LPCWSTR,LPWSTR,LPDWORD);
 WINBASEAPI BOOL        WINAPI DosDateTimeToFileTime(WORD,WORD,LPFILETIME);
 WINBASEAPI BOOL        WINAPI DuplicateHandle(HANDLE,HANDLE,HANDLE,HANDLE*,DWORD,BOOL,DWORD);
 WINADVAPI  BOOL        WINAPI DuplicateToken(HANDLE,SECURITY_IMPERSONATION_LEVEL,PHANDLE);




More information about the wine-cvs mailing list