summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-03-31 15:51:00 +0100
committerRichard W.M. Jones <rjones@redhat.com>2011-03-31 15:51:00 +0100
commit64bc4495031a1942472038db7aee0bf3b746949d (patch)
tree4db1624d9ba18c6c39e43ea2b038d471e0ccbb6d
parentb8e1dee73a1deef1bfd5937e2abfbe9afef7b1ef (diff)
downloadlibguestfs-64bc4495031a1942472038db7aee0bf3b746949d.tar.gz
libguestfs-64bc4495031a1942472038db7aee0bf3b746949d.tar.xz
libguestfs-64bc4495031a1942472038db7aee0bf3b746949d.zip
inspect: Detect 32 bit applications running on WOW64 emulator (RHBZ#692545).
These applications are located along a different Registry path. See http://support.microsoft.com/kb/896459 for all the details. Thanks Jinxin Zheng for finding the bug and the solution.
-rwxr-xr-ximages/guest-aux/windows-softwarebin12288 -> 12288 bytes
-rw-r--r--images/guest-aux/windows-software.reg16
-rw-r--r--inspector/example-windows.xml7
-rw-r--r--src/inspect.c98
4 files changed, 79 insertions, 42 deletions
diff --git a/images/guest-aux/windows-software b/images/guest-aux/windows-software
index e9358860..d936ea88 100755
--- a/images/guest-aux/windows-software
+++ b/images/guest-aux/windows-software
Binary files differ
diff --git a/images/guest-aux/windows-software.reg b/images/guest-aux/windows-software.reg
index e2efda61..2c0f41ce 100644
--- a/images/guest-aux/windows-software.reg
+++ b/images/guest-aux/windows-software.reg
@@ -31,3 +31,19 @@
"DisplayVersion"=str(1):"1.2.5"
"Publisher"=str(1):"Red Hat Inc."
"InstallLocation"=str(1):"C:\\Program Files\\Red Hat\\test3"
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432node]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432node\Microsoft]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432node\Microsoft\Windows]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432node\Microsoft\Windows\CurrentVersion]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432node\Microsoft\Windows\CurrentVersion\Uninstall]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432node\Microsoft\Windows\CurrentVersion\Uninstall\test4]
+"DisplayName"=str(1):"Test4 is not real software"
+"DisplayVersion"=str(1):"1.2.6"
+"Publisher"=str(1):"Red Hat Inc."
+"Comments"=str(1):"WOW6432node is where 32 bit emulated apps are installed on 64 bit Windows"
diff --git a/inspector/example-windows.xml b/inspector/example-windows.xml
index 12c69560..7b3ae743 100644
--- a/inspector/example-windows.xml
+++ b/inspector/example-windows.xml
@@ -40,6 +40,13 @@
<install_path>C:\Program Files\Red Hat\test3</install_path>
<publisher>Red Hat Inc.</publisher>
</application>
+ <application>
+ <name>test4</name>
+ <display_name>Test4 is not real software</display_name>
+ <version>1.2.6</version>
+ <publisher>Red Hat Inc.</publisher>
+ <description>WOW6432node is where 32 bit emulated apps are installed on 64 bit Windows</description>
+ </application>
</applications>
</operatingsystem>
</operatingsystems>
diff --git a/src/inspect.c b/src/inspect.c
index 3a8ede60..238e6e51 100644
--- a/src/inspect.c
+++ b/src/inspect.c
@@ -2460,15 +2460,17 @@ list_applications_deb (guestfs_h *g, struct inspect_fs *fs)
return ret;
}
-/* XXX We already download the SOFTWARE hive when doing general
- * inspection. We could avoid this second download of the same file
- * by caching these entries in the handle.
- */
+static void list_applications_windows_from_path (guestfs_h *g, hive_h *h, struct guestfs_application_list *apps, const char **path, size_t path_len);
+
static struct guestfs_application_list *
list_applications_windows (guestfs_h *g, struct inspect_fs *fs)
{
TMP_TEMPLATE_ON_STACK (software_local);
+ /* XXX We already download the SOFTWARE hive when doing general
+ * inspection. We could avoid this second download of the same file
+ * by caching these entries in the handle.
+ */
size_t len = strlen (fs->windows_systemroot) + 64;
char software[len];
snprintf (software, len, "%s/system32/config/software",
@@ -2481,45 +2483,72 @@ list_applications_windows (guestfs_h *g, struct inspect_fs *fs)
*/
return 0;
- struct guestfs_application_list *apps = NULL, *ret = NULL;
+ struct guestfs_application_list *ret = NULL;
hive_h *h = NULL;
- hive_node_h *children = NULL;
if (download_to_tmp (g, software_path, software_local,
MAX_REGISTRY_SIZE) == -1)
goto out;
+ free (software_path);
+ software_path = NULL;
+
h = hivex_open (software_local, g->verbose ? HIVEX_OPEN_VERBOSE : 0);
if (h == NULL) {
perrorf (g, "hivex_open");
goto out;
}
- hive_node_h node = hivex_root (h);
+ /* Allocate apps list. */
+ ret = safe_malloc (g, sizeof *ret);
+ ret->len = 0;
+ ret->val = NULL;
+
+ /* Ordinary native applications. */
const char *hivepath[] =
{ "Microsoft", "Windows", "CurrentVersion", "Uninstall" };
+ list_applications_windows_from_path (g, h, ret, hivepath,
+ sizeof hivepath / sizeof hivepath[0]);
+
+ /* 32-bit emulated Windows apps running on the WOW64 emulator.
+ * http://support.microsoft.com/kb/896459 (RHBZ#692545).
+ */
+ const char *hivepath2[] =
+ { "WOW6432node", "Microsoft", "Windows", "CurrentVersion", "Uninstall" };
+ list_applications_windows_from_path (g, h, ret, hivepath2,
+ sizeof hivepath2 / sizeof hivepath2[0]);
+
+ out:
+ if (h) hivex_close (h);
+ free (software_path);
+
+ /* Delete the temporary file. */
+ unlink (software_local);
+#undef software_local_len
+
+ return ret;
+}
+
+static void
+list_applications_windows_from_path (guestfs_h *g, hive_h *h,
+ struct guestfs_application_list *apps,
+ const char **path, size_t path_len)
+{
+ hive_node_h *children = NULL;
+ hive_node_h node;
size_t i;
- for (i = 0;
- node != 0 && i < sizeof hivepath / sizeof hivepath[0];
- ++i) {
- node = hivex_node_get_child (h, node, hivepath[i]);
- }
- if (node == 0) {
- perrorf (g, "hivex: cannot locate HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
- goto out;
- }
+ node = hivex_root (h);
- children = hivex_node_children (h, node);
- if (children == NULL) {
- perrorf (g, "hivex_node_children");
- goto out;
- }
+ for (i = 0; node != 0 && i < path_len; ++i)
+ node = hivex_node_get_child (h, node, path[i]);
- /* Allocate 'apps' list. */
- apps = safe_malloc (g, sizeof *apps);
- apps->len = 0;
- apps->val = NULL;
+ if (node == 0)
+ return;
+
+ children = hivex_node_children (h, node);
+ if (children == NULL)
+ return;
/* Consider any child node that has a DisplayName key.
* See also:
@@ -2539,10 +2568,8 @@ list_applications_windows (guestfs_h *g, struct inspect_fs *fs)
* display name is not language-independent, so it cannot be used.
*/
name = hivex_node_name (h, children[i]);
- if (name == NULL) {
- perrorf (g, "hivex_node_get_name");
- goto out;
- }
+ if (name == NULL)
+ continue;
value = hivex_node_get_value (h, children[i], "DisplayName");
if (value) {
@@ -2583,20 +2610,7 @@ list_applications_windows (guestfs_h *g, struct inspect_fs *fs)
free (comments);
}
- ret = apps;
-
- out:
- if (ret == NULL && apps != NULL)
- guestfs_free_application_list (apps);
- if (h) hivex_close (h);
free (children);
- free (software_path);
-
- /* Free up the temporary file. */
- unlink (software_local);
-#undef software_local_len
-
- return ret;
}
static void