mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
Plugins-extra: *tidyup; Fixed EnumDnsCacheTable;
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@5333 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user