[ros-diffs] 01/01: [IDL][NETAPI32][SRVSVC] Hack around another midl/rpcrt4 bug
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=12bdbe5710f617a50c5a9f65b0ff9fcf0243a8a1 commit 12bdbe5710f617a50c5a9f65b0ff9fcf0243a8a1 Author: Eric KohlAuthorDate: Sun May 6 16:49:24 2018 +0200 Commit: Eric Kohl 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++; /* include NULL terminator */ + +VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo); +GetVersionExW(); + +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: +
[ros-diffs] 01/01: [IPHLPAPI_APITEST] Avoid crash on ROS and failure on Windows. CORE-14411
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=93edd2a1855be5c3fde4dc2a985a3bbd6ce6a56c commit 93edd2a1855be5c3fde4dc2a985a3bbd6ce6a56c Author: Thomas FaberAuthorDate: Sun May 6 08:24:26 2018 +0200 Commit: Thomas Faber CommitDate: Sun May 6 08:36:19 2018 +0200 [IPHLPAPI_APITEST] Avoid crash on ROS and failure on Windows. CORE-14411 - Make the reply buffer for IcmpSendEcho large enough to hold the reply, even when testing a smaller size. This avoids a buffer overflow with ROS's broken implementation. - Avoid unnecessary initialization. - Fix IcmpSendEcho return value check to succeed on Win2003. - Don't free a string literal in the GetInterfaceName test. --- modules/rostests/apitests/iphlpapi/GetInterfaceName.c | 1 - modules/rostests/apitests/iphlpapi/icmp.c | 12 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/rostests/apitests/iphlpapi/GetInterfaceName.c b/modules/rostests/apitests/iphlpapi/GetInterfaceName.c index f6e3321cee..76078cc39f 100644 --- a/modules/rostests/apitests/iphlpapi/GetInterfaceName.c +++ b/modules/rostests/apitests/iphlpapi/GetInterfaceName.c @@ -361,7 +361,6 @@ test_GetInterfaceName(VOID) } ApiReturn = RtlGUIDFromString(, ); -RtlFreeUnicodeString(); if (ApiReturn != 0) { skip("RtlGUIDFromString failed. Can't proceed\n"); diff --git a/modules/rostests/apitests/iphlpapi/icmp.c b/modules/rostests/apitests/iphlpapi/icmp.c index 0d853ffa57..c635c225b3 100644 --- a/modules/rostests/apitests/iphlpapi/icmp.c +++ b/modules/rostests/apitests/iphlpapi/icmp.c @@ -90,7 +90,7 @@ test_IcmpSendEcho(void) unsigned long ipaddr = INADDR_NONE; DWORD bRet = 0, error = 0; char SendData[32] = "Data Buffer"; -PVOID ReplyBuffer = NULL; +PVOID ReplyBuffer; DWORD ReplySize = 0; SetLastError(0xDEADBEEF); @@ -102,27 +102,27 @@ test_IcmpSendEcho(void) } ipaddr = 0x08080808; // 8.8.8.8 +ReplyBuffer = malloc(sizeof(ICMP_ECHO_REPLY) + sizeof(SendData)); ReplySize = sizeof(ICMP_ECHO_REPLY); -ReplyBuffer = malloc(ReplySize); SetLastError(0xDEADBEEF); bRet = IcmpSendEcho(hIcmp, ipaddr, SendData, sizeof(SendData), NULL, ReplyBuffer, ReplySize, 5000); ok(!bRet, "IcmpSendEcho succeeded unexpectedly\n"); error = GetLastError(); -ok(error == IP_GENERAL_FAILURE, "IcmpSendEcho returned unexpected error: %lu\n", error); -free(ReplyBuffer); +ok(error == IP_BUF_TOO_SMALL /* Win2003 */ || + error == IP_GENERAL_FAILURE /* Win10 */, + "IcmpSendEcho returned unexpected error: %lu\n", error); ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData); -ReplyBuffer = malloc(ReplySize); SetLastError(0xDEADBEEF); bRet = IcmpSendEcho(hIcmp, ipaddr, SendData, sizeof(SendData), NULL, ReplyBuffer, ReplySize, 5000); ok(bRet, "IcmpSendEcho failed unexpectedly: %lu\n", GetLastError()); -free(ReplyBuffer); +free(ReplyBuffer); IcmpCloseHandle(hIcmp); }