From 160977987f8e3922cebcdaaeb36fa69f92dc7587 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 30 Nov 2012 23:00:33 +0000 Subject: inspection: Temporary logo for Windows 8. See the comment from the code: NB about Windows 8: No location we've found so far contains a suitable icon for Win8. In particular, explorer.exe definitely does *not* contain any Windows logo as a resource (I checked). Therefore the "basket icon" that this produces is just a stand-in until we have a better idea for solving this problem. and: https://bugzilla.redhat.com/show_bug.cgi?id=801117 --- src/inspect-icon.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/inspect-icon.c b/src/inspect-icon.c index 4b7f43a2..19f93003 100644 --- a/src/inspect-icon.c +++ b/src/inspect-icon.c @@ -513,6 +513,52 @@ icon_windows_7 (guestfs_h *g, struct inspect_fs *fs, const char *explorer, return NOT_FOUND; } +/* NB about Windows 8: No location we've found so far contains a + * suitable icon for Win8. In particular, explorer.exe definitely + * does *not* contain any Windows logo as a resource (I checked). + * Therefore the "basket icon" that this produces is just a stand-in + * until we have a better idea for solving this problem. + * XXX RHBZ#801117 + */ +static char * +icon_windows_8 (guestfs_h *g, struct inspect_fs *fs, const char *explorer, + size_t *size_r) +{ + char *ret; + char *pngfile = NULL; + struct command *cmd; + int r; + + pngfile = safe_asprintf (g, "%s/windows-8-icon.png", g->tmpdir); + + cmd = guestfs___new_command (g); + guestfs___cmd_add_string_unquoted (cmd, WRESTOOL " -x --type=3 --name=125 --raw "); + guestfs___cmd_add_string_quoted (cmd, explorer); + guestfs___cmd_add_string_unquoted (cmd, " > "); + guestfs___cmd_add_string_quoted (cmd, pngfile); + r = guestfs___cmd_run (cmd); + guestfs___cmd_close (cmd); + if (r == -1) + goto error; + if (!WIFEXITED (r) || WEXITSTATUS (r) != 0) + goto not_found; + + if (read_whole_file (g, pngfile, &ret, size_r) == -1) + goto error; + + free (pngfile); + + return ret; + + error: + free (pngfile); + return NULL; + + not_found: + free (pngfile); + return NOT_FOUND; +} + static char * icon_windows (guestfs_h *g, struct inspect_fs *fs, size_t *size_r) { @@ -529,6 +575,10 @@ icon_windows (guestfs_h *g, struct inspect_fs *fs, size_t *size_r) else if (fs->major_version == 6 && fs->minor_version == 1) fn = icon_windows_7; + /* Windows 8. */ + else if (fs->major_version == 6 && fs->minor_version == 2) + fn = icon_windows_8; + /* Not (yet) a supported version of Windows. */ else return NOT_FOUND; -- cgit