diff --git a/2.x/trunk/plugins-extra/AtomTablePlugin/resource.h b/2.x/trunk/plugins-extra/AtomTablePlugin/resource.h index f4c2628e2..69c248153 100644 --- a/2.x/trunk/plugins-extra/AtomTablePlugin/resource.h +++ b/2.x/trunk/plugins-extra/AtomTablePlugin/resource.h @@ -3,10 +3,8 @@ // Used by AtomTablePlugin.rc // #define IDD_ATOMDIALOG 101 -#define IDR_MENU1 111 #define IDR_MAIN_MENU 111 #define IDC_ATOMLIST 1021 -#define ID_ATOMMENU 40004 #define ID_ATOMMENU_REMOVE 40005 // Next default values for new objects diff --git a/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.rc b/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.rc index 207314f02..4f5742235 100644 --- a/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.rc +++ b/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.rc @@ -102,9 +102,7 @@ IDR_MAIN_MENU MENU BEGIN POPUP "DnsEntry" BEGIN - MENUITEM "Remove", ID_DNSENTRY_FLUSH - MENUITEM SEPARATOR - MENUITEM "Properties", ID_DNSENTRY_PROPERTIES, INACTIVE + MENUITEM "Remove", ID_DNSENTRY_FLUSH, INACTIVE END END diff --git a/2.x/trunk/plugins-extra/DnsCachePlugin/main.c b/2.x/trunk/plugins-extra/DnsCachePlugin/main.c index 92244d37a..d90c6d682 100644 --- a/2.x/trunk/plugins-extra/DnsCachePlugin/main.c +++ b/2.x/trunk/plugins-extra/DnsCachePlugin/main.c @@ -19,7 +19,9 @@ * along with Process Hacker. If not, see . */ -#define UPDATE_MENUITEM 1000 +#define UPDATE_MENUITEM 1000 +#define INET_ADDRSTRLEN 22 +#define INET6_ADDRSTRLEN 65 #include "phdk.h" #include "phappresource.h" @@ -180,7 +182,7 @@ static VOID EnumDnsCacheTable( __try { - // Start Winsock (inet_ntoa) + // Start Winsock (required for WSAAddressToString) WSAStartup(WINSOCK_VERSION, &wsaData); if (!DnsGetCacheDataTable_I(&dnsCacheRecordPtr)) @@ -190,14 +192,6 @@ static VOID EnumDnsCacheTable( { PDNS_RECORD dnsQueryResultPtr = NULL; - // Add the item to the listview (it might be nameless)... - INT itemIndex = PhAddListViewItem( - hwndDlg, - MAXINT, - (PWSTR)dnsCacheRecordPtr->Name, - NULL - ); - DNS_STATUS dnsStatus = DnsQuery_I( dnsCacheRecordPtr->Name, dnsCacheRecordPtr->Type, @@ -209,28 +203,50 @@ static VOID EnumDnsCacheTable( if (dnsStatus == ERROR_SUCCESS) { + ULONG dnsRecordCount = 0; PDNS_RECORD dnsRecordPtr = dnsQueryResultPtr; - + while (dnsRecordPtr) { - PPH_STRING ipAddressString = NULL; - PPH_STRING ipTtlString = NULL; + INT itemIndex = 0; + SOCKADDR_IN sockaddr; + TCHAR ipAddrString[INET6_ADDRSTRLEN]; + ULONG ipAddrStringLength = INET6_ADDRSTRLEN; - struct in_addr ipaddr; + // Convert the Internet network address into a string in Internet standard dotted format. + sockaddr.sin_family = AF_INET; + sockaddr.sin_addr.s_addr = dnsRecordPtr->Data.A.IpAddress; + sockaddr.sin_port = 0; - //if (pDnsRecord->wDataLength > DNS_NULL_RECORD_LENGTH(0)) - //convert the Internet network address into a string in Internet standard dotted format. - ipaddr.S_un.S_addr = dnsRecordPtr->Data.A.IpAddress; + // Add the item to the listview (it might be nameless)... + if (dnsRecordCount) + { + itemIndex = PhAddListViewItem(hwndDlg, MAXINT, + PhaFormatString(L"%s [%d]", dnsCacheRecordPtr->Name, dnsRecordCount)->Buffer, + NULL + ); + } + else + { + itemIndex = PhAddListViewItem(hwndDlg, MAXINT, + PhaFormatString(L"%s", dnsCacheRecordPtr->Name)->Buffer, + NULL + ); + } - ipAddressString = PhFormatString(L"%hs", inet_ntoa(ipaddr)); - ipTtlString = PhFormatString(L"%d", dnsRecordPtr->dwTtl); + PhSetListViewSubItem(hwndDlg, itemIndex, 2, PhaFormatString(L"%d", dnsRecordPtr->dwTtl)->Buffer); - PhSetListViewSubItem(hwndDlg, itemIndex, 1, ipAddressString->Buffer); - PhSetListViewSubItem(hwndDlg, itemIndex, 2, ipTtlString->Buffer); - - PhDereferenceObject(ipTtlString); - PhDereferenceObject(ipAddressString); + if (WSAAddressToString((SOCKADDR*)&sockaddr, sizeof(SOCKADDR_IN), NULL, ipAddrString, &ipAddrStringLength) != SOCKET_ERROR) + { + PhSetListViewSubItem(hwndDlg, itemIndex, 1, PhaFormatString(L"%s", ipAddrString)->Buffer); + } + else + { + //inet_ntoa(ipaddr)); + PhSetListViewSubItem(hwndDlg, itemIndex, 1, PhaFormatString(L"Error %d", WSAGetLastError())->Buffer); + } + dnsRecordCount++; dnsRecordPtr = dnsRecordPtr->pNext; }