From 02b963a7c763581afffae3166d34881949bb25fa Mon Sep 17 00:00:00 2001 From: wj32 Date: Sun, 9 May 2010 11:50:10 +0000 Subject: [PATCH] added check git-svn-id: svn://svn.code.sf.net/p/processhacker/code@3120 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- 2.x/trunk/ProcessHacker/netprv.c | 12 ++++++++++++ 2.x/trunk/phlib/include/phnet.h | 1 + 2 files changed, 13 insertions(+) diff --git a/2.x/trunk/ProcessHacker/netprv.c b/2.x/trunk/ProcessHacker/netprv.c index 917a04fdb..e7f8ba851 100644 --- a/2.x/trunk/ProcessHacker/netprv.c +++ b/2.x/trunk/ProcessHacker/netprv.c @@ -80,6 +80,12 @@ typedef INT (WSAAPI *_GetNameInfoW)( __in INT Flags ); +typedef struct hostent *(WSAAPI *_gethostbyaddr)( + __in_bcount(len) const char *addr, + __in int len, + __in int type + ); + VOID NTAPI PhpNetworkItemDeleteProcedure( __in PVOID Object, __in ULONG Flags @@ -129,6 +135,7 @@ static PH_QUEUED_LOCK PhpResolveCacheHashtableLock = PH_QUEUED_LOCK_INIT; static _GetExtendedTcpTable GetExtendedTcpTable_I; static _GetExtendedUdpTable GetExtendedUdpTable_I; static _GetNameInfoW GetNameInfoW_I; +static _gethostbyaddr gethostbyaddr_I; BOOLEAN PhInitializeNetworkProvider() { @@ -327,6 +334,9 @@ PPH_STRING PhGetHostNameFromAddress( socklen_t length; PPH_STRING hostName; + if (!GetNameInfoW_I) + return NULL; + if (Address->Type == PH_IPV4_NETWORK_TYPE) { ipv4Address.sin_family = AF_INET; @@ -377,6 +387,7 @@ PPH_STRING PhGetHostNameFromAddress( ) != 0) { PhDereferenceObject(hostName); + return NULL; } } @@ -500,6 +511,7 @@ VOID PhNetworkProviderUpdate( GetExtendedUdpTable_I = PhGetProcAddress(L"iphlpapi.dll", "GetExtendedUdpTable"); LoadLibrary(L"ws2_32.dll"); GetNameInfoW_I = PhGetProcAddress(L"ws2_32.dll", "GetNameInfoW"); + gethostbyaddr_I = PhGetProcAddress(L"ws2_32.dll", "gethostbyaddr"); } if (!PhGetNetworkConnections(&connections, &numberOfConnections)) diff --git a/2.x/trunk/phlib/include/phnet.h b/2.x/trunk/phlib/include/phnet.h index 4cc13d410..9d66f1723 100644 --- a/2.x/trunk/phlib/include/phnet.h +++ b/2.x/trunk/phlib/include/phnet.h @@ -23,6 +23,7 @@ typedef struct _PH_IP_ADDRESS ULONG Type; union { + ULONG Address[4]; ULONG Ipv4; struct in_addr InAddr; UCHAR Ipv6[16];