https://git.reactos.org/?p=reactos.git;a=commitdiff;h=12bdbe5710f617a50c5a9…
commit 12bdbe5710f617a50c5a9f65b0ff9fcf0243a8a1
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sun May 6 16:49:24 2018 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sun May 6 16:49:24 2018 +0200
[IDL][NETAPI32][SRVSVC] Hack around another midl/rpcrt4 bug
NETAPI32: Get rid of the old WINE NetServerGetInfo and replace it by a proper call to
NetrServerGetInfo.
SRVSVC: Implement parts of NetrServerGetInfo.
srvsvc.idl: Hack around a bug in midl or rpcrt4. They are not able to handle a pointer
to a union of pointers to structs. A pointer to a union of structs works a advertised.
---
base/services/srvsvc/rpcserver.c | 87 ++++++++++++++++++++++++++++++++++++--
dll/win32/netapi32/netapi32.c | 63 ---------------------------
dll/win32/netapi32/srvsvc.c | 4 +-
sdk/include/reactos/idl/srvsvc.idl | 59 +++++++++++++++++++++++++-
4 files changed, 143 insertions(+), 70 deletions(-)
diff --git a/base/services/srvsvc/rpcserver.c b/base/services/srvsvc/rpcserver.c
index e47eafb2c0..d1d9f3dc3d 100644
--- a/base/services/srvsvc/rpcserver.c
+++ b/base/services/srvsvc/rpcserver.c
@@ -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;
}
diff --git a/dll/win32/netapi32/netapi32.c b/dll/win32/netapi32/netapi32.c
index a2ffcefd52..5775aa46bd 100644
--- a/dll/win32/netapi32/netapi32.c
+++ b/dll/win32/netapi32/netapi32.c
@@ -18,8 +18,6 @@
#include "netapi32.h"
-#include <lmserver.h>
-
WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
@@ -40,64 +38,3 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID
lpvReserved)
return TRUE;
}
-
-/************************************************************
- * NetServerGetInfo (NETAPI32.@)
- */
-NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE* bufptr)
-{
- NET_API_STATUS ret;
-
- TRACE("%s %d %p\n", debugstr_w( servername ), level, bufptr );
- if (servername)
- {
- if (!NETAPI_IsLocalComputer(servername))
- {
- FIXME("remote computers not supported\n");
- return ERROR_INVALID_LEVEL;
- }
- }
- if (!bufptr) return ERROR_INVALID_PARAMETER;
-
- switch (level)
- {
- case 100:
- case 101:
- {
- DWORD computerNameLen, size;
- WCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
-
- computerNameLen = MAX_COMPUTERNAME_LENGTH + 1;
- GetComputerNameW(computerName, &computerNameLen);
- computerNameLen++; /* include NULL terminator */
-
- size = sizeof(SERVER_INFO_101) + computerNameLen * sizeof(WCHAR);
- ret = NetApiBufferAllocate(size, (LPVOID *)bufptr);
- if (ret == NERR_Success)
- {
- /* INFO_100 structure is a subset of INFO_101 */
- PSERVER_INFO_101 info = (PSERVER_INFO_101)*bufptr;
- OSVERSIONINFOW verInfo;
-
- info->sv101_platform_id = PLATFORM_ID_NT;
- info->sv101_name = (LMSTR)(*bufptr + sizeof(SERVER_INFO_101));
- memcpy(info->sv101_name, computerName,
- computerNameLen * sizeof(WCHAR));
- verInfo.dwOSVersionInfoSize = sizeof(verInfo);
- GetVersionExW(&verInfo);
- info->sv101_version_major = verInfo.dwMajorVersion;
- info->sv101_version_minor = verInfo.dwMinorVersion;
- /* Use generic type as no wine equivalent of DC / Server */
- info->sv101_type = SV_TYPE_NT;
- info->sv101_comment = NULL;
- }
- break;
- }
-
- default:
- FIXME("level %d unimplemented\n", level);
- ret = ERROR_INVALID_LEVEL;
- }
- return ret;
-}
-
diff --git a/dll/win32/netapi32/srvsvc.c b/dll/win32/netapi32/srvsvc.c
index 139bcfc6f7..7103e4aa58 100644
--- a/dll/win32/netapi32/srvsvc.c
+++ b/dll/win32/netapi32/srvsvc.c
@@ -364,7 +364,6 @@ NetServerDiskEnum(
}
-#if 0
NET_API_STATUS
WINAPI
NetServerGetInfo(
@@ -383,7 +382,7 @@ NetServerGetInfo(
{
status = NetrServerGetInfo(servername,
level,
- (LPSERVER_INFO)bufptr);
+ (LPSERVER_INFO *)bufptr);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
@@ -393,7 +392,6 @@ NetServerGetInfo(
return status;
}
-#endif
NET_API_STATUS
diff --git a/sdk/include/reactos/idl/srvsvc.idl b/sdk/include/reactos/idl/srvsvc.idl
index f8d1d6c54b..eea19b18ea 100644
--- a/sdk/include/reactos/idl/srvsvc.idl
+++ b/sdk/include/reactos/idl/srvsvc.idl
@@ -734,6 +734,7 @@ typedef struct _SERVER_INFO_1556
} SERVER_INFO_1556, *PSERVER_INFO_1556, *LPSERVER_INFO_1556;
cpp_quote("#endif")
+/*
typedef [switch_type(unsigned long)] union _SERVER_INFO
{
[case(100)] LPSERVER_INFO_100 ServerInfo100;
@@ -788,6 +789,61 @@ typedef [switch_type(unsigned long)] union _SERVER_INFO
[case(1555)] LPSERVER_INFO_1555 ServerInfo1555;
[case(1556)] LPSERVER_INFO_1556 ServerInfo1556;
} SERVER_INFO, *PSERVER_INFO, *LPSERVER_INFO;
+*/
+typedef [switch_type(unsigned long)] union _SERVER_INFO
+{
+ [case(100)] SERVER_INFO_100 ServerInfo100;
+ [case(101)] SERVER_INFO_101 ServerInfo101;
+ [case(102)] SERVER_INFO_102 ServerInfo102;
+ [case(103)] SERVER_INFO_103 ServerInfo103;
+ [case(502)] SERVER_INFO_502 ServerInfo502;
+ [case(503)] SERVER_INFO_503 ServerInfo503;
+ [case(599)] SERVER_INFO_599 ServerInfo599;
+ [case(1005)] SERVER_INFO_1005 ServerInfo1005;
+ [case(1107)] SERVER_INFO_1107 ServerInfo1107;
+ [case(1010)] SERVER_INFO_1010 ServerInfo1010;
+ [case(1016)] SERVER_INFO_1016 ServerInfo1016;
+ [case(1017)] SERVER_INFO_1017 ServerInfo1017;
+ [case(1018)] SERVER_INFO_1018 ServerInfo1018;
+ [case(1501)] SERVER_INFO_1501 ServerInfo1501;
+ [case(1502)] SERVER_INFO_1502 ServerInfo1502;
+ [case(1503)] SERVER_INFO_1503 ServerInfo1503;
+ [case(1506)] SERVER_INFO_1506 ServerInfo1506;
+ [case(1510)] SERVER_INFO_1510 ServerInfo1510;
+ [case(1511)] SERVER_INFO_1511 ServerInfo1511;
+ [case(1512)] SERVER_INFO_1512 ServerInfo1512;
+ [case(1513)] SERVER_INFO_1513 ServerInfo1513;
+ [case(1514)] SERVER_INFO_1514 ServerInfo1514;
+ [case(1515)] SERVER_INFO_1515 ServerInfo1515;
+ [case(1516)] SERVER_INFO_1516 ServerInfo1516;
+ [case(1518)] SERVER_INFO_1518 ServerInfo1518;
+ [case(1523)] SERVER_INFO_1523 ServerInfo1523;
+ [case(1528)] SERVER_INFO_1528 ServerInfo1528;
+ [case(1529)] SERVER_INFO_1529 ServerInfo1529;
+ [case(1530)] SERVER_INFO_1530 ServerInfo1530;
+ [case(1533)] SERVER_INFO_1533 ServerInfo1533;
+ [case(1534)] SERVER_INFO_1534 ServerInfo1534;
+ [case(1535)] SERVER_INFO_1535 ServerInfo1535;
+ [case(1536)] SERVER_INFO_1536 ServerInfo1536;
+ [case(1538)] SERVER_INFO_1538 ServerInfo1538;
+ [case(1539)] SERVER_INFO_1539 ServerInfo1539;
+ [case(1540)] SERVER_INFO_1540 ServerInfo1540;
+ [case(1541)] SERVER_INFO_1541 ServerInfo1541;
+ [case(1542)] SERVER_INFO_1542 ServerInfo1542;
+ [case(1543)] SERVER_INFO_1543 ServerInfo1543;
+ [case(1544)] SERVER_INFO_1544 ServerInfo1544;
+ [case(1545)] SERVER_INFO_1545 ServerInfo1545;
+ [case(1546)] SERVER_INFO_1546 ServerInfo1546;
+ [case(1547)] SERVER_INFO_1547 ServerInfo1547;
+ [case(1548)] SERVER_INFO_1548 ServerInfo1548;
+ [case(1549)] SERVER_INFO_1549 ServerInfo1549;
+ [case(1550)] SERVER_INFO_1550 ServerInfo1550;
+ [case(1552)] SERVER_INFO_1552 ServerInfo1552;
+ [case(1553)] SERVER_INFO_1553 ServerInfo1553;
+ [case(1554)] SERVER_INFO_1554 ServerInfo1554;
+ [case(1555)] SERVER_INFO_1555 ServerInfo1555;
+ [case(1556)] SERVER_INFO_1556 ServerInfo1556;
+} SERVER_INFO, *PSERVER_INFO, *LPSERVER_INFO;
typedef struct _DISK_INFO
{
@@ -1162,7 +1218,8 @@ interface srvsvc
NetrServerGetInfo(
[in, string, unique] SRVSVC_HANDLE ServerName,
[in] DWORD Level,
- [out, switch_is(Level)] LPSERVER_INFO InfoStruct);
+ [out, switch_is(Level)] LPSERVER_INFO *InfoStruct);
+// [out, switch_is(Level)] LPSERVER_INFO InfoStruct);
NET_API_STATUS
__stdcall