[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 2/2] inspection: Find icon in Windows 7 64 bit guests (RHBZ#1352761).



We have to download the old 32 bit explorer.exe in order to find the
icons as the 64 bit version doesn't contain any icons (where are they?).
Thus prefer the 32 bit (WoW64 subsystem) directory if found.

Fixes commit 7f16c346bbeba2f2fe3c31ccb85158178a284d84.

Thanks: Xiaoyun Hu
---
 src/inspect-icon.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/inspect-icon.c b/src/inspect-icon.c
index 3893fba..0db8147 100644
--- a/src/inspect-icon.c
+++ b/src/inspect-icon.c
@@ -541,7 +541,28 @@ icon_windows_7 (guestfs_h *g, struct inspect_fs *fs, size_t *size_r)
   int r;
   char *ret;
 
-  /* Download %systemroot%\explorer.exe */
+  /* Prefer %systemroot%\SysWOW64\explorer.exe, a PE32 binary that
+   * usually contains the icons on 64 bit guests.
+   */
+  filename = safe_asprintf (g, "%s/syswow64/explorer.exe",
+                            fs->windows_systemroot);
+  filename_case = guestfs_case_sensitive_path (g, filename);
+  if (filename_case == NULL)
+    return NULL;
+
+  guestfs_push_error_handler (g, NULL, NULL);
+  r = guestfs_is_file (g, filename_case);
+  guestfs_pop_error_handler (g);
+  if (r == -1)
+    return NULL;
+  if (r)
+    goto download;
+  free (filename);
+  filename = NULL;
+  free (filename_case);
+  filename_case = NULL;
+
+  /* Otherwise download %systemroot%\explorer.exe */
   filename = safe_asprintf (g, "%s/explorer.exe", fs->windows_systemroot);
   filename_case = guestfs_case_sensitive_path (g, filename);
   if (filename_case == NULL)
@@ -555,6 +576,7 @@ icon_windows_7 (guestfs_h *g, struct inspect_fs *fs, size_t *size_r)
   if (r == 0)
     return NOT_FOUND;
 
+ download:
   filename_downloaded = guestfs_int_download_to_tmp (g, fs, filename_case,
 						     "explorer.exe",
 						     MAX_WINDOWS_EXPLORER_SIZE);
-- 
2.7.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]