I noticed a problem with severe impact on our application, which is coming from GetAdaptersAddresses API (also applies to GetAdaptersInfo).
The problem is that a Win32 application calling this API receives correct results except servers where our process is set up to process a lot of data.
At some point, GetAdaptersAddresses/GetAdaptersInfo which previously reported good results, starts returning zero adapeters. As soon as I replaced GetAdaptersInfo call with a newer GetAdaptersAddresses I started seeing 998 ERROR_NOACCESS error code.
As a clue, it is taking place around going over 2GB on Private Bytes and Virtual Size. Our application is 32-bit marked as aware of large addresses, so it can receive 3 or 4GB of virtual address space depending on OS and configuration.
Note that when I turned off some activity on the same process to make it free some memory, and retried GetAdaptersAddresses - I could again obtain the list of adapters. It took place without restarting a process. At the same time other processes receive adapter list without problems.
I thought it might be a bug in Windows component which is failing to see valid memory pointer in higher 2GB address space.
I am providing code snippet below to indicate API usage:
ULONG nAdapterAddressesSize = 16 << 10; // 16K
static const DWORD g_nFlags = GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_INCLUDE_GATEWAYS | GAA_FLAG_INCLUDE_ALL_INTERFACES;
HRESULT nResult = HRESULT_FROM_WIN32(GetAdaptersAddresses(AF_INET, g_nFlags, NULL, pAdaptersAddresses, &nAdapterAddressesSize));
// *** Here we go with ERROR_NOACCESS ***
if(nResult == HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW))
nAdapterAddressesSize += 4 << 10; // 4K
nResult = HRESULT_FROM_WIN32(GetAdaptersAddresses(AF_INET, g_nFlags, NULL, pAdaptersAddresses, &nAdapterAddressesSize));