idevicediagnostics: Add ioregentry command to query device IORegistry by entry

Starting with iOS 9.1, querying IORegistry by plane stopped working. This
commit will add a new command that allows querying by entry that will allow
gathering data for devices with newer iOS versions again (including iOS 11).
diff --git a/tools/idevicediagnostics.c b/tools/idevicediagnostics.c
index 2ea986f..66e192f 100644
--- a/tools/idevicediagnostics.c
+++ b/tools/idevicediagnostics.c
@@ -40,7 +40,8 @@
 	CMD_SHUTDOWN,
 	CMD_DIAGNOSTICS,
 	CMD_MOBILEGESTALT,
-	CMD_IOREGISTRY
+	CMD_IOREGISTRY,
+	CMD_IOREGISTRY_ENTRY
 };
 
 static void print_xml(plist_t node)
@@ -156,6 +157,15 @@
 			}
 			continue;
 		}
+		else if (!strcmp(argv[i], "ioregentry")) {
+			cmd = CMD_IOREGISTRY_ENTRY;
+			/* read key */
+			i++;
+			if (argv[i]) {
+				cmd_arg = strdup(argv[i]);
+			}
+			continue;
+		}
 		else {
 			print_usage(argc, argv);
 			return 0;
@@ -232,6 +242,16 @@
 						printf("Unable to query mobilegestalt keys.\n");
 					}
 				break;
+				case CMD_IOREGISTRY_ENTRY:
+					if (diagnostics_relay_query_ioregistry_entry(diagnostics_client, cmd_arg == NULL ? "": cmd_arg, "", &node) == DIAGNOSTICS_RELAY_E_SUCCESS) {
+						if (node) {
+							print_xml(node);
+							result = EXIT_SUCCESS;
+						}
+					} else {
+						printf("Unable to retrieve IORegistry from device.\n");
+					}
+					break;
 				case CMD_IOREGISTRY:
 					if (diagnostics_relay_query_ioregistry_plane(diagnostics_client, cmd_arg == NULL ? "": cmd_arg, &node) == DIAGNOSTICS_RELAY_E_SUCCESS) {
 						if (node) {
@@ -292,6 +312,7 @@
 	printf("  diagnostics [TYPE]\t\tprint diagnostics information from device by TYPE (All, WiFi, GasGauge, NAND)\n");
 	printf("  mobilegestalt KEY [...]\tprint mobilegestalt keys passed as arguments seperated by a space.\n");
 	printf("  ioreg [PLANE]\t\t\tprint IORegistry of device, optionally by PLANE (IODeviceTree, IOPower, IOService) (iOS 5+ only)\n");
+	printf("  ioregentry [KEY]\t\tprint IORegistry entry of device (AppleARMPMUCharger, ASPStorage, ...) (iOS 5+ only)\n");
 	printf("  shutdown\t\t\tshutdown device\n");
 	printf("  restart\t\t\trestart device\n");
 	printf("  sleep\t\t\t\tput device into sleep mode (disconnects from host)\n\n");