Richard W.M. Jones
2015-Nov-13 14:23 UTC
[Libguestfs] [PATCH v2] inspection: Fix detection of the kernel version of Windows ≥ 10 (RHBZ#1281578).
This fixes v1 by checking the correct length field. I have tested this against Windows 10 and it works. Rich.
Richard W.M. Jones
2015-Nov-13 14:23 UTC
[Libguestfs] [PATCH] inspection: Fix detection of the kernel version of Windows ≥ 10 (RHBZ#1281578).
See the description in the bug report: https://bugzilla.redhat.com/show_bug.cgi?id=1281578 Thanks: Richard Tollerton for alerting me to this change in the way that Windows version numbers are stored in the Registry starting with Windows ≥ 10. --- src/inspect-fs-windows.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/inspect-fs-windows.c b/src/inspect-fs-windows.c index f8df5e5..e800b1e 100644 --- a/src/inspect-fs-windows.c +++ b/src/inspect-fs-windows.c @@ -20,6 +20,7 @@ #include <stdio.h> #include <stdlib.h> +#include <stdbool.h> #include <unistd.h> #include <string.h> #include <errno.h> @@ -279,6 +280,7 @@ check_windows_software_registry (guestfs_h *g, struct inspect_fs *fs) { "Microsoft", "Windows NT", "CurrentVersion" }; size_t i; CLEANUP_FREE_HIVEX_VALUE_LIST struct guestfs_hivex_value_list *values = NULL; + bool ignore_currentversion = false; if (guestfs_hivex_open (g, software_path, GUESTFS_HIVEX_OPEN_VERBOSE, g->verbose, -1) == -1) @@ -309,7 +311,43 @@ check_windows_software_registry (guestfs_h *g, struct inspect_fs *fs) if (!fs->product_name) goto out; } - else if (STRCASEEQ (key, "CurrentVersion")) { + else if (STRCASEEQ (key, "CurrentMajorVersionNumber")) { + size_t vsize; + int64_t vtype = guestfs_hivex_value_type (g, value); + CLEANUP_FREE char *vbuf = guestfs_hivex_value_value (g, value, &vsize); + + if (vbuf == NULL) + goto out; + if (vtype != 4 || vsize != 4) { + error (g, "hivex: expected CurrentVersion\\%s to be a DWORD field", + "CurrentMajorVersionNumber"); + goto out; + } + + fs->major_version = le32toh (*(int32_t *)vbuf); + + /* Ignore CurrentVersion if we see it after this key. */ + ignore_currentversion = true; + } + else if (STRCASEEQ (key, "CurrentMinorVersionNumber")) { + size_t vsize; + int64_t vtype = guestfs_hivex_value_type (g, value); + CLEANUP_FREE char *vbuf = guestfs_hivex_value_value (g, value, &vsize); + + if (vbuf == NULL) + goto out; + if (vtype != 4 || vsize != 4) { + error (g, "hivex: expected CurrentVersion\\%s to be a DWORD field", + "CurrentMinorVersionNumber"); + goto out; + } + + fs->minor_version = le32toh (*(int32_t *)vbuf); + + /* Ignore CurrentVersion if we see it after this key. */ + ignore_currentversion = true; + } + else if (!ignore_currentversion && STRCASEEQ (key, "CurrentVersion")) { CLEANUP_FREE char *version = guestfs_hivex_value_utf8 (g, value); if (!version) goto out; -- 2.6.2
Seemingly Similar Threads
- [PATCH] inspection: Fix detection of the kernel version of Windows ≥ 10 (RHBZ#1281578).
- [PATCH] inspect: get windows drive letters for GPT disks.
- [PATCHv2] inspect: get windows drive letters for GPT disks.
- [PATCH v12 00/11] Reimplement inspection in the daemon.
- [PATCH v11 00/10] Reimplement inspection in the daemon.