[IDL][NETAPI32][SRVSVC] Hack around another midl/rpcrt4 bug
[reactos.git] / base / services / srvsvc / rpcserver.c
index e47eafb..d1d9f3d 100644 (file)
@@ -348,10 +348,91 @@ __stdcall
 NetrServerGetInfo(
     SRVSVC_HANDLE ServerName,
     DWORD Level,
-    LPSERVER_INFO InfoStruct)
+    LPSERVER_INFO *InfoStruct)
 {
-    UNIMPLEMENTED;
-    return ERROR_CALL_NOT_IMPLEMENTED;
+    WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
+    DWORD dwComputerNameLength, dwSize;
+    PSERVER_INFO pServerInfo = NULL;
+    OSVERSIONINFOW VersionInfo;
+
+    TRACE("NetrServerGetInfo(%p %lu %p)\n",
+          ServerName, Level, InfoStruct);
+
+    dwComputerNameLength = MAX_COMPUTERNAME_LENGTH + 1;
+    GetComputerNameW(szComputerName, &dwComputerNameLength);
+    dwComputerNameLength++; /* include NULL terminator */
+
+    VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo);
+    GetVersionExW(&VersionInfo);
+
+    switch (Level)
+    {
+        case 100:
+            dwSize = sizeof(SERVER_INFO_100) +
+                     dwComputerNameLength * sizeof(WCHAR);
+            pServerInfo = midl_user_allocate(dwSize);
+            if (pServerInfo == NULL)
+                return ERROR_NOT_ENOUGH_MEMORY;
+
+            pServerInfo->ServerInfo100.sv100_platform_id = PLATFORM_ID_NT;
+            pServerInfo->ServerInfo100.sv100_name = (LPWSTR)((ULONG_PTR)pServerInfo + sizeof(SERVER_INFO_100));
+            wcscpy(pServerInfo->ServerInfo100.sv100_name, szComputerName);
+
+            *InfoStruct = pServerInfo;
+            break;
+
+        case 101:
+            dwSize = sizeof(SERVER_INFO_101) +
+                     dwComputerNameLength * sizeof(WCHAR);
+            pServerInfo = midl_user_allocate(dwSize);
+            if (pServerInfo == NULL)
+                return ERROR_NOT_ENOUGH_MEMORY;
+
+            pServerInfo->ServerInfo101.sv101_platform_id = PLATFORM_ID_NT;
+            pServerInfo->ServerInfo101.sv101_name = (LPWSTR)((ULONG_PTR)pServerInfo + sizeof(SERVER_INFO_101));
+            wcscpy(pServerInfo->ServerInfo101.sv101_name, szComputerName);
+
+            pServerInfo->ServerInfo101.sv101_version_major = VersionInfo.dwMajorVersion;
+            pServerInfo->ServerInfo101.sv101_version_minor = VersionInfo.dwMinorVersion;
+            pServerInfo->ServerInfo101.sv101_type = SV_TYPE_NT;  /* FIXME */
+            pServerInfo->ServerInfo101.sv101_comment = NULL; /* FIXME */
+
+            *InfoStruct = pServerInfo;
+            break;
+
+        case 102:
+            dwSize = sizeof(SERVER_INFO_102) +
+                     dwComputerNameLength * sizeof(WCHAR);
+            pServerInfo = midl_user_allocate(dwSize);
+            if (pServerInfo == NULL)
+                return ERROR_NOT_ENOUGH_MEMORY;
+
+            pServerInfo->ServerInfo102.sv102_platform_id = PLATFORM_ID_NT;
+            pServerInfo->ServerInfo102.sv102_name = (LPWSTR)((ULONG_PTR)pServerInfo + sizeof(SERVER_INFO_102));
+            wcscpy(pServerInfo->ServerInfo102.sv102_name, szComputerName);
+
+            pServerInfo->ServerInfo102.sv102_version_major = VersionInfo.dwMajorVersion;
+            pServerInfo->ServerInfo102.sv102_version_minor = VersionInfo.dwMinorVersion;
+            pServerInfo->ServerInfo102.sv102_type = SV_TYPE_NT;
+            pServerInfo->ServerInfo102.sv102_comment = NULL; /* FIXME */
+
+            pServerInfo->ServerInfo102.sv102_users = 0; /* FIXME */
+            pServerInfo->ServerInfo102.sv102_disc = 0; /* FIXME */
+            pServerInfo->ServerInfo102.sv102_hidden = SV_VISIBLE; /* FIXME */
+            pServerInfo->ServerInfo102.sv102_announce = 0; /* FIXME */
+            pServerInfo->ServerInfo102.sv102_anndelta = 0; /* FIXME */
+            pServerInfo->ServerInfo102.sv102_licenses = 0; /* FIXME */
+            pServerInfo->ServerInfo102.sv102_userpath = NULL; /* FIXME */
+
+            *InfoStruct = pServerInfo;
+            break;
+
+        default:
+            FIXME("level %d unimplemented\n", Level);
+            return ERROR_INVALID_LEVEL;
+    }
+
+    return NERR_Success;
 }