[NETAPI32]
authorEric Kohl <eric.kohl@reactos.org>
Sun, 2 Jul 2017 18:29:38 +0000 (18:29 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 2 Jul 2017 18:29:38 +0000 (18:29 +0000)
- Add DsAddressToSiteNamesA stub.
- Implement DsAddressToSiteNamesW.

[SDK/INCLUDE]
Add DsAddressToSiteNamesA/W and DsAddressToSiteNamesExA/W prototypes to dsgetdc.h.

svn path=/trunk/; revision=75268

reactos/dll/win32/netapi32/netapi32.spec
reactos/dll/win32/netapi32/netlogon.c
reactos/sdk/include/psdk/dsgetdc.h

index 3f2e108..d15fb14 100644 (file)
@@ -1,8 +1,8 @@
 @ stub CredpValidateTargetName
 @ stub CredpValidateTargetName
-@ stub DsAddressToSiteNamesA
+@ stdcall DsAddressToSiteNamesA(str long ptr str)
 @ stub DsAddressToSiteNamesExA
 @ stub DsAddressToSiteNamesExW
 @ stub DsAddressToSiteNamesExA
 @ stub DsAddressToSiteNamesExW
-@ stub DsAddressToSiteNamesW
+@ stdcall DsAddressToSiteNamesW(wstr long ptr wstr)
 @ stub DsDeregisterDnsHostRecordsA
 @ stub DsDeregisterDnsHostRecordsW
 8 stdcall DsEnumerateDomainTrustsA(wstr long ptr ptr)
 @ stub DsDeregisterDnsHostRecordsA
 @ stub DsDeregisterDnsHostRecordsW
 8 stdcall DsEnumerateDomainTrustsA(wstr long ptr ptr)
index d68f8ed..f74372d 100644 (file)
@@ -9,6 +9,7 @@
 /* INCLUDES ******************************************************************/
 
 #include "netapi32.h"
 /* INCLUDES ******************************************************************/
 
 #include "netapi32.h"
+#include <winsock2.h>
 #include <rpc.h>
 #include <dsrole.h>
 #include <dsgetdc.h>
 #include <rpc.h>
 #include <dsrole.h>
 #include <dsgetdc.h>
@@ -73,6 +74,92 @@ LOGONSRV_HANDLE_unbind(LOGONSRV_HANDLE pszSystemName,
 }
 
 
 }
 
 
+DWORD
+WINAPI
+DsAddressToSiteNamesA(
+    _In_opt_ LPCSTR ComputerName,
+    _In_ DWORD EntryCount,
+    _In_ PSOCKET_ADDRESS SocketAddresses,
+    _Out_ LPSTR **SiteNames)
+{
+    FIXME("DsAddressToSiteNamesA(%s, %lu, %p, %p)\n",
+          debugstr_a(ComputerName), EntryCount, SocketAddresses, SiteNames);
+    return ERROR_NO_LOGON_SERVERS;
+}
+
+
+DWORD
+WINAPI
+DsAddressToSiteNamesW(
+    _In_opt_ LPCWSTR ComputerName,
+    _In_ DWORD EntryCount,
+    _In_ PSOCKET_ADDRESS SocketAddresses,
+    _Out_ LPWSTR **SiteNames)
+{
+    PNL_SITE_NAME_ARRAY SiteNameArray = NULL;
+    PWSTR *SiteNamesBuffer = NULL, Ptr;
+    ULONG BufferSize, i;
+    NET_API_STATUS status;
+
+    TRACE("DsAddressToSiteNamesW(%s, %lu, %p, %p)\n",
+          debugstr_w(ComputerName), EntryCount, SocketAddresses, SiteNames);
+
+    if (EntryCount == 0)
+        return ERROR_INVALID_PARAMETER;
+
+    *SiteNames = NULL;
+
+    RpcTryExcept
+    {
+        status = DsrAddressToSiteNamesW((PWSTR)ComputerName,
+                                        EntryCount,
+                                        (PNL_SOCKET_ADDRESS)SocketAddresses,
+                                        &SiteNameArray);
+        if (status == NERR_Success)
+        {
+            if (SiteNameArray->EntryCount == 0)
+            {
+                status = ERROR_INVALID_PARAMETER;
+            }
+            else
+            {
+                BufferSize = SiteNameArray->EntryCount * sizeof(PWSTR);
+                for (i = 0; i < SiteNameArray->EntryCount; i++)
+                    BufferSize += SiteNameArray->SiteNames[i].Length + sizeof(WCHAR);
+
+                status = NetApiBufferAllocate(BufferSize, (PVOID*)&SiteNamesBuffer);
+                if (status == NERR_Success)
+                {
+                    ZeroMemory(SiteNamesBuffer, BufferSize);
+
+                    Ptr = (PWSTR)((ULONG_PTR)SiteNamesBuffer + SiteNameArray->EntryCount * sizeof(PWSTR));
+                    for (i = 0; i < SiteNameArray->EntryCount; i++)
+                    {
+                        SiteNamesBuffer[i] = Ptr;
+                        CopyMemory(Ptr,
+                                   SiteNameArray->SiteNames[i].Buffer,
+                                   SiteNameArray->SiteNames[i].Length);
+
+                        Ptr = (PWSTR)((ULONG_PTR)Ptr + SiteNameArray->SiteNames[i].Length + sizeof(WCHAR));
+                    }
+
+                    *SiteNames = SiteNamesBuffer;
+                }
+            }
+
+            MIDL_user_free(SiteNameArray);
+        }
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
 DWORD
 WINAPI
 DsEnumerateDomainTrustsA(
 DWORD
 WINAPI
 DsEnumerateDomainTrustsA(
index 496b471..9b4719a 100644 (file)
@@ -62,6 +62,36 @@ typedef struct _DS_DOMAIN_TRUSTSW
        GUID DomainGuid;
 } DS_DOMAIN_TRUSTSW, *PDS_DOMAIN_TRUSTSW;
 
        GUID DomainGuid;
 } DS_DOMAIN_TRUSTSW, *PDS_DOMAIN_TRUSTSW;
 
+DWORD WINAPI
+DsAddressToSiteNamesA(
+       LPCSTR ComputerName,
+       DWORD EntryCount,
+       PSOCKET_ADDRESS SocketAddresses,
+       LPSTR **SiteNames);
+
+DWORD WINAPI
+DsAddressToSiteNamesW(
+       LPCWSTR ComputerName,
+       DWORD EntryCount,
+       PSOCKET_ADDRESS SocketAddresses,
+       LPWSTR **SiteNames);
+
+DWORD WINAPI
+DsAddressToSiteNamesExA(
+       LPCSTR ComputerName,
+       DWORD EntryCount,
+       PSOCKET_ADDRESS SocketAddresses,
+       LPSTR **SiteNames,
+       LPSTR **SubnetNames);
+
+DWORD WINAPI
+DsAddressToSiteNamesExW(
+       LPCWSTR ComputerName,
+       DWORD EntryCount,
+       PSOCKET_ADDRESS SocketAddresses,
+       LPWSTR **SiteNames,
+       LPWSTR **SubnetNames);
+
 DWORD WINAPI
 DsEnumerateDomainTrustsA(
        LPSTR ServerName,
 DWORD WINAPI
 DsEnumerateDomainTrustsA(
        LPSTR ServerName,
@@ -97,11 +127,15 @@ DsGetDcNameW(
 #ifdef UNICODE
 typedef DOMAIN_CONTROLLER_INFOW DOMAIN_CONTROLLER_INFO, *PDOMAIN_CONTROLLER_INFO;
 typedef DS_DOMAIN_TRUSTSW DS_DOMAIN_TRUSTS, *PDS_DOMAIN_TRUSTS;
 #ifdef UNICODE
 typedef DOMAIN_CONTROLLER_INFOW DOMAIN_CONTROLLER_INFO, *PDOMAIN_CONTROLLER_INFO;
 typedef DS_DOMAIN_TRUSTSW DS_DOMAIN_TRUSTS, *PDS_DOMAIN_TRUSTS;
+#define DsAddressToSiteNames DsAddressToSiteNamesW
+#define DsAddressToSiteNamesEx DsAddressToSiteNamesExW
 #define DsEnumerateDomainTrusts DsEnumerateDomainTrustsW
 #define DsGetDcName DsGetDcNameW
 #else
 typedef DOMAIN_CONTROLLER_INFOA DOMAIN_CONTROLLER_INFO, *PDOMAIN_CONTROLLER_INFO;
 typedef DS_DOMAIN_TRUSTSA DS_DOMAIN_TRUSTS, *PDS_DOMAIN_TRUSTS;
 #define DsEnumerateDomainTrusts DsEnumerateDomainTrustsW
 #define DsGetDcName DsGetDcNameW
 #else
 typedef DOMAIN_CONTROLLER_INFOA DOMAIN_CONTROLLER_INFO, *PDOMAIN_CONTROLLER_INFO;
 typedef DS_DOMAIN_TRUSTSA DS_DOMAIN_TRUSTS, *PDS_DOMAIN_TRUSTS;
+#define DsAddressToSiteNames DsAddressToSiteNamesA
+#define DsAddressToSiteNamesEx DsAddressToSiteNamesExA
 #define DsEnumerateDomainTrusts DsEnumerateDomainTrustsA
 #define DsGetDcName DsGetDcNameA
 #endif
 #define DsEnumerateDomainTrusts DsEnumerateDomainTrustsA
 #define DsGetDcName DsGetDcNameA
 #endif