From dce4f492bd2f3f71ff49ea3ea1de70e1c61db0cf Mon Sep 17 00:00:00 2001 From: wj32 Date: Mon, 10 May 2010 23:12:10 +0000 Subject: [PATCH] address resolving is still broken git-svn-id: svn://svn.code.sf.net/p/processhacker/code@3129 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- 2.x/trunk/ProcessHacker/netprv.c | 20 +++++++++++++++++++- 2.x/trunk/phlib/include/phnet.h | 1 - 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/2.x/trunk/ProcessHacker/netprv.c b/2.x/trunk/ProcessHacker/netprv.c index e7f8ba851..0917e7d69 100644 --- a/2.x/trunk/ProcessHacker/netprv.c +++ b/2.x/trunk/ProcessHacker/netprv.c @@ -70,6 +70,13 @@ typedef DWORD (WINAPI *_GetExtendedUdpTable)( __in ULONG Reserved ); +typedef int (WSAAPI *_WSAStartup)( + __in WORD wVersionRequested, + __out LPWSADATA lpWSAData + ); + +typedef int (WSAAPI *_WSAGetLastError)(); + typedef INT (WSAAPI *_GetNameInfoW)( __in_bcount(SockaddrLength) const SOCKADDR *pSockaddr, __in socklen_t SockaddrLength, @@ -132,8 +139,11 @@ PH_MUTEX PhNetworkItemQueryQueueLock; static PPH_HASHTABLE PhpResolveCacheHashtable; static PH_QUEUED_LOCK PhpResolveCacheHashtableLock = PH_QUEUED_LOCK_INIT; +static BOOLEAN NetworkImportDone = FALSE; static _GetExtendedTcpTable GetExtendedTcpTable_I; static _GetExtendedUdpTable GetExtendedUdpTable_I; +static _WSAStartup WSAStartup_I; +static _WSAGetLastError WSAGetLastError_I; static _GetNameInfoW GetNameInfoW_I; static _gethostbyaddr gethostbyaddr_I; @@ -435,6 +445,10 @@ NTSTATUS PhpNetworkItemQueryWorker( PhReleaseQueuedLockExclusiveFast(&PhpResolveCacheHashtableLock); } + else + { + dwlprintf(L"resolve failed, error %u", WSAGetLastError_I()); + } } else { @@ -504,14 +518,18 @@ VOID PhNetworkProviderUpdate( ULONG numberOfConnections; ULONG i; - if (!GetExtendedTcpTable_I || !GetExtendedUdpTable_I || !GetNameInfoW_I) + if (!NetworkImportDone) { LoadLibrary(L"iphlpapi.dll"); GetExtendedTcpTable_I = PhGetProcAddress(L"iphlpapi.dll", "GetExtendedTcpTable"); GetExtendedUdpTable_I = PhGetProcAddress(L"iphlpapi.dll", "GetExtendedUdpTable"); LoadLibrary(L"ws2_32.dll"); + WSAStartup_I = PhGetProcAddress(L"ws2_32.dll", "WSAStartup"); + WSAGetLastError_I = PhGetProcAddress(L"ws2_32.dll", "WSAGetLastError"); GetNameInfoW_I = PhGetProcAddress(L"ws2_32.dll", "GetNameInfoW"); gethostbyaddr_I = PhGetProcAddress(L"ws2_32.dll", "gethostbyaddr"); + + NetworkImportDone = TRUE; } if (!PhGetNetworkConnections(&connections, &numberOfConnections)) diff --git a/2.x/trunk/phlib/include/phnet.h b/2.x/trunk/phlib/include/phnet.h index 9d66f1723..4cc13d410 100644 --- a/2.x/trunk/phlib/include/phnet.h +++ b/2.x/trunk/phlib/include/phnet.h @@ -23,7 +23,6 @@ typedef struct _PH_IP_ADDRESS ULONG Type; union { - ULONG Address[4]; ULONG Ipv4; struct in_addr InAddr; UCHAR Ipv6[16];