ExtendedTools: Disable whois for RFC1918 and loopback
@@ -1411,11 +1411,14 @@ VOID ShowFwContextMenu(
{
PPH_EMENU menu;
PPH_EMENU_ITEM item;
+ PPH_EMENU_ITEM pingMenu;
+ PPH_EMENU_ITEM traceMenu;
+ PPH_EMENU_ITEM whoisMenu;
menu = PhCreateEMenu();
- PhInsertEMenuItem(menu, PhCreateEMenuItem(0, FW_ITEM_COMMAND_ID_PING, L"&Ping", NULL, NULL), ULONG_MAX);
- PhInsertEMenuItem(menu, PhCreateEMenuItem(0, FW_ITEM_COMMAND_ID_TRACERT, L"&Traceroute", NULL, NULL), ULONG_MAX);
- PhInsertEMenuItem(menu, PhCreateEMenuItem(0, FW_ITEM_COMMAND_ID_WHOIS, L"&Whois", NULL, NULL), ULONG_MAX);
+ PhInsertEMenuItem(menu, pingMenu = PhCreateEMenuItem(0, FW_ITEM_COMMAND_ID_PING, L"&Ping", NULL, NULL), ULONG_MAX);
+ PhInsertEMenuItem(menu, traceMenu = PhCreateEMenuItem(0, FW_ITEM_COMMAND_ID_TRACERT, L"&Traceroute", NULL, NULL), ULONG_MAX);
+ PhInsertEMenuItem(menu, whoisMenu = PhCreateEMenuItem(0, FW_ITEM_COMMAND_ID_WHOIS, L"&Whois", NULL, NULL), ULONG_MAX);
PhInsertEMenuItem(menu, PhCreateEMenuSeparator(), ULONG_MAX);
PhInsertEMenuItem(menu, PhCreateEMenuItem(0, FW_ITEM_COMMAND_ID_OPENFILELOCATION, L"Open &file location\bEnter", NULL, NULL), ULONG_MAX);
PhInsertEMenuItem(menu, PhCreateEMenuSeparator(), ULONG_MAX);
@@ -1426,6 +1429,42 @@ VOID ShowFwContextMenu(
PhInsertCopyCellEMenuItem(menu, FW_ITEM_COMMAND_ID_COPY, TreeWindowHandle, ContextMenuEvent->Column);
PhSetFlagsEMenuItem(menu, FW_ITEM_COMMAND_ID_OPENFILELOCATION, PH_EMENU_DEFAULT, PH_EMENU_DEFAULT);
+ if (PhIsNullIpAddress(&fwItems[0]->RemoteEndpoint.Address))
+ {
+ PhSetDisabledEMenuItem(pingMenu);
+ PhSetDisabledEMenuItem(traceMenu);
+ PhSetDisabledEMenuItem(whoisMenu);
+ }
+ else if (fwItems[0]->RemoteEndpoint.Address.Type == PH_IPV4_NETWORK_TYPE)
+ {
+ if (
+ IN4_IS_ADDR_UNSPECIFIED(&fwItems[0]->RemoteEndpoint.Address.InAddr) ||
+ IN4_IS_ADDR_LOOPBACK(&fwItems[0]->RemoteEndpoint.Address.InAddr)
+ )
+ {
+ PhSetDisabledEMenuItem(pingMenu);
+ PhSetDisabledEMenuItem(traceMenu);
+ PhSetDisabledEMenuItem(whoisMenu);
+ }
+
+ if (IN4_IS_ADDR_RFC1918(&fwItems[0]->RemoteEndpoint.Address.InAddr))
+ {
+ PhSetDisabledEMenuItem(whoisMenu);
+ }
+ }
+ else if (fwItems[0]->RemoteEndpoint.Address.Type == PH_IPV6_NETWORK_TYPE)
+ {
+ if (
+ IN6_IS_ADDR_UNSPECIFIED(&fwItems[0]->RemoteEndpoint.Address.In6Addr) ||
+ IN6_IS_ADDR_LOOPBACK(&fwItems[0]->RemoteEndpoint.Address.In6Addr)
+ )
+ {
+ PhSetDisabledEMenuItem(pingMenu);
+ PhSetDisabledEMenuItem(traceMenu);
+ PhSetDisabledEMenuItem(whoisMenu);
+ }
+ }
+
if (item = PhShowEMenu(
menu,
PhMainWndHandle,
