mirror of
https://github.com/reactos/reactos.git
synced 2024-09-30 22:47:28 +00:00
[IPHLPAPI]
Make GetAdaptersAddresses work, with parameters check. More work is needed : -it returns the loopback, which shouldn't appear with default flags. -the required size is fixed. svn path=/trunk/; revision=66981
This commit is contained in:
parent
0e91e9fc18
commit
e5e4c2bbf0
|
@ -9,7 +9,7 @@
|
||||||
#include "iphlpapi_private.h"
|
#include "iphlpapi_private.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
|
WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
|
||||||
|
#if 1
|
||||||
/* Helper for GetAdaptersAddresses:
|
/* Helper for GetAdaptersAddresses:
|
||||||
* Retrieves the list of network adapters from tcpip.sys */
|
* Retrieves the list of network adapters from tcpip.sys */
|
||||||
static
|
static
|
||||||
|
@ -283,6 +283,8 @@ GetAdaptersAddresses(
|
||||||
ULONG i;
|
ULONG i;
|
||||||
ULONG TotalSize = 0, RemainingSize;
|
ULONG TotalSize = 0, RemainingSize;
|
||||||
BYTE* Ptr = (BYTE*)pAdapterAddresses;
|
BYTE* Ptr = (BYTE*)pAdapterAddresses;
|
||||||
|
DWORD MIN_SIZE = 15 * 1024;
|
||||||
|
PIP_ADAPTER_ADDRESSES PreviousAA = NULL;
|
||||||
|
|
||||||
FIXME("GetAdaptersAddresses - Semi Stub: Family %u, Flags 0x%08x, Reserved %p, pAdapterAddress %p, pOutBufLen %p.\n",
|
FIXME("GetAdaptersAddresses - Semi Stub: Family %u, Flags 0x%08x, Reserved %p, pAdapterAddress %p, pOutBufLen %p.\n",
|
||||||
Family, Flags, Reserved, pAdapterAddresses, pOutBufLen);
|
Family, Flags, Reserved, pAdapterAddresses, pOutBufLen);
|
||||||
|
@ -290,6 +292,14 @@ GetAdaptersAddresses(
|
||||||
if (!pOutBufLen)
|
if (!pOutBufLen)
|
||||||
return ERROR_INVALID_PARAMETER;
|
return ERROR_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
// FIXME: the exact needed size should be computed first, BEFORE doing any write to the output buffer.
|
||||||
|
// As suggested by MSDN, require a 15 KB buffer, which allows to React properly to length checks.
|
||||||
|
if(!Ptr || *pOutBufLen < MIN_SIZE)
|
||||||
|
{
|
||||||
|
*pOutBufLen = MIN_SIZE;
|
||||||
|
return ERROR_BUFFER_OVERFLOW;
|
||||||
|
}
|
||||||
|
|
||||||
switch(Family)
|
switch(Family)
|
||||||
{
|
{
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
|
@ -334,7 +344,7 @@ GetAdaptersAddresses(
|
||||||
/* Let's see if we got any adapter. */
|
/* Let's see if we got any adapter. */
|
||||||
for (i = 0; i < InterfacesCount; i++)
|
for (i = 0; i < InterfacesCount; i++)
|
||||||
{
|
{
|
||||||
PIP_ADAPTER_ADDRESSES CurrentAA = (PIP_ADAPTER_ADDRESSES)Ptr, PreviousAA = NULL;
|
PIP_ADAPTER_ADDRESSES CurrentAA = (PIP_ADAPTER_ADDRESSES)Ptr;
|
||||||
ULONG CurrentAASize = 0;
|
ULONG CurrentAASize = 0;
|
||||||
|
|
||||||
if (InterfacesList[i].tei_entity == IF_ENTITY)
|
if (InterfacesList[i].tei_entity == IF_ENTITY)
|
||||||
|
@ -346,6 +356,10 @@ GetAdaptersAddresses(
|
||||||
/* Remember we got one */
|
/* Remember we got one */
|
||||||
AdaptersCount++;
|
AdaptersCount++;
|
||||||
|
|
||||||
|
/* Set the pointer to this instance in the previous one*/
|
||||||
|
if(PreviousAA)
|
||||||
|
PreviousAA->Next = CurrentAA;
|
||||||
|
|
||||||
/* Of course we need some space for the base structure. */
|
/* Of course we need some space for the base structure. */
|
||||||
CurrentAASize = sizeof(IP_ADAPTER_ADDRESSES);
|
CurrentAASize = sizeof(IP_ADAPTER_ADDRESSES);
|
||||||
|
|
||||||
|
@ -409,7 +423,6 @@ GetAdaptersAddresses(
|
||||||
CurrentAA->Mtu = Entry->if_mtu;
|
CurrentAA->Mtu = Entry->if_mtu;
|
||||||
CurrentAA->IfType = Entry->if_type;
|
CurrentAA->IfType = Entry->if_type;
|
||||||
CurrentAA->OperStatus = Entry->if_operstatus;
|
CurrentAA->OperStatus = Entry->if_operstatus;
|
||||||
CurrentAA->Next = PreviousAA;
|
|
||||||
/* Next items */
|
/* Next items */
|
||||||
Ptr = (BYTE*)(CurrentAA + 1);
|
Ptr = (BYTE*)(CurrentAA + 1);
|
||||||
|
|
||||||
|
@ -628,6 +641,7 @@ Success:
|
||||||
HeapFree(GetProcessHeap(), 0, InterfacesList);
|
HeapFree(GetProcessHeap(), 0, InterfacesList);
|
||||||
NtClose(TcpFile);
|
NtClose(TcpFile);
|
||||||
*pOutBufLen = TotalSize;
|
*pOutBufLen = TotalSize;
|
||||||
|
TRACE("TotalSize: %x\n", *pOutBufLen);
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
|
|
||||||
Error:
|
Error:
|
||||||
|
@ -637,3 +651,4 @@ Error:
|
||||||
NtClose(TcpFile);
|
NtClose(TcpFile);
|
||||||
return RtlNtStatusToDosError(Status);
|
return RtlNtStatusToDosError(Status);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue