Changeset 57920 in vbox for trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp
- Timestamp:
- Sep 28, 2015 2:16:53 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp
r57358 r57920 962 962 } 963 963 964 INTERFACE_INFO InterfaceList[20] = {0}; 965 unsigned long nBytesReturned = 0; 966 if (WSAIoctl(sd, 967 SIO_GET_INTERFACE_LIST, 968 0, 969 0, 970 &InterfaceList, 971 sizeof(InterfaceList), 972 &nBytesReturned, 973 0, 974 0) == SOCKET_ERROR) 964 INTERFACE_INFO aInterfaces[20] = {0}; 965 DWORD cbReturned = 0; 966 # ifdef TARGET_NT4 967 /* Workaround for uninitialized variable used in memcpy in GetTcpipInterfaceList 968 (NT4SP1 at least). It seems to be happy enough with garbages, no failure 969 returns so far, so we just need to prevent it from crashing by filling the 970 stack with valid pointer values prior to the API call. */ 971 _asm 972 { 973 mov edx, edi 974 lea eax, aInterfaces 975 mov [esp - 0x1000], eax 976 mov [esp - 0x2000], eax 977 mov ecx, 0x2000/4 - 1 978 cld 979 lea edi, [esp - 0x2000] 980 rep stosd 981 mov edi, edx 982 } 983 # endif 984 if ( WSAIoctl(sd, 985 SIO_GET_INTERFACE_LIST, 986 NULL, /* pvInBuffer */ 987 0, /* cbInBuffer */ 988 &aInterfaces[0], /* pvOutBuffer */ 989 sizeof(aInterfaces), /* cbOutBuffer */ 990 &cbReturned, 991 NULL, /* pOverlapped */ 992 NULL) /* pCompletionRoutine */ 993 == SOCKET_ERROR) 975 994 { 976 995 VBoxServiceError("VMInfo/Network: Failed to WSAIoctl() on socket: Error: %d\n", WSAGetLastError()); … … 979 998 return RTErrConvertFromWin32(WSAGetLastError()); 980 999 } 981 int cIfacesSystem = nBytesReturned / sizeof(INTERFACE_INFO);1000 int cIfacesSystem = cbReturned / sizeof(INTERFACE_INFO); 982 1001 983 1002 /** @todo Use GetAdaptersInfo() and GetAdapterAddresses (IPv4 + IPv6) for more information. */ … … 986 1005 sockaddr_in *pAddress; 987 1006 u_long nFlags = 0; 988 if ( InterfaceList[i].iiFlags & IFF_LOOPBACK) /* Skip loopback device. */1007 if (aInterfaces[i].iiFlags & IFF_LOOPBACK) /* Skip loopback device. */ 989 1008 continue; 990 nFlags = InterfaceList[i].iiFlags;991 pAddress = (sockaddr_in *)&( InterfaceList[i].iiAddress);1009 nFlags = aInterfaces[i].iiFlags; 1010 pAddress = (sockaddr_in *)&(aInterfaces[i].iiAddress); 992 1011 Assert(pAddress); 993 1012 char szIp[32]; … … 996 1015 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", szIp); 997 1016 998 pAddress = (sockaddr_in *) & ( InterfaceList[i].iiBroadcastAddress);1017 pAddress = (sockaddr_in *) & (aInterfaces[i].iiBroadcastAddress); 999 1018 RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%RU32/V4/Broadcast", cIfsReported); 1000 1019 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", inet_ntoa(pAddress->sin_addr)); 1001 1020 1002 pAddress = (sockaddr_in *)&( InterfaceList[i].iiNetmask);1021 pAddress = (sockaddr_in *)&(aInterfaces[i].iiNetmask); 1003 1022 RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%RU32/V4/Netmask", cIfsReported); 1004 1023 VBoxServicePropCacheUpdate(&g_VMInfoPropCache, szPropPath, "%s", inet_ntoa(pAddress->sin_addr));
Note:
See TracChangeset
for help on using the changeset viewer.