Pass the HIVEX_OPEN_UNSAFE flag when opening hives for reading. Do NOT pass it when opening hives for writing. This should make inspection and virt-v2v more tolerant about handling Windows Registry corruption, without increasing the risk of causing new corruption in hives. --- lib/inspect-apps.c | 4 +++- lib/inspect-fs-windows.c | 8 ++++++-- v2v/windows.ml | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/inspect-apps.c b/lib/inspect-apps.c index b377f57..0f2b505 100644 --- a/lib/inspect-apps.c +++ b/lib/inspect-apps.c @@ -792,7 +792,9 @@ list_applications_windows (guestfs_h *g, struct inspect_fs *fs) return NULL; if (guestfs_hivex_open (g, software_path, - GUESTFS_HIVEX_OPEN_VERBOSE, g->verbose, -1) == -1) + GUESTFS_HIVEX_OPEN_VERBOSE, g->verbose, + GUESTFS_HIVEX_OPEN_UNSAFE, 1, + -1) == -1) return NULL; /* Allocate apps list. */ diff --git a/lib/inspect-fs-windows.c b/lib/inspect-fs-windows.c index c139051..fc0b42b 100644 --- a/lib/inspect-fs-windows.c +++ b/lib/inspect-fs-windows.c @@ -283,7 +283,9 @@ check_windows_software_registry (guestfs_h *g, struct inspect_fs *fs) bool ignore_currentversion = false; if (guestfs_hivex_open (g, software_path, - GUESTFS_HIVEX_OPEN_VERBOSE, g->verbose, -1) == -1) + GUESTFS_HIVEX_OPEN_VERBOSE, g->verbose, + GUESTFS_HIVEX_OPEN_UNSAFE, 1, + -1) == -1) return -1; node = guestfs_hivex_root (g); @@ -405,7 +407,9 @@ check_windows_system_registry (guestfs_h *g, struct inspect_fs *fs) { NULL /* current control set */, "Services", "Tcpip", "Parameters" }; if (guestfs_hivex_open (g, system_path, - GUESTFS_HIVEX_OPEN_VERBOSE, g->verbose, -1) == -1) + GUESTFS_HIVEX_OPEN_VERBOSE, g->verbose, + GUESTFS_HIVEX_OPEN_UNSAFE, 1, + -1) == -1) goto out; root = guestfs_hivex_root (g); diff --git a/v2v/windows.ml b/v2v/windows.ml index 9e8ef1e..79a14aa 100644 --- a/v2v/windows.ml +++ b/v2v/windows.ml @@ -49,7 +49,8 @@ and (=~) str rex = let with_hive_readonly (g : Guestfs.guestfs) hive_filename f = let verbose = verbose () in - g#hivex_open ~write:false ~verbose (* ~debug:verbose *) hive_filename; + g#hivex_open ~write:false ~unsafe:true ~verbose (* ~debug:verbose *) + hive_filename; protect ~f:( fun () -> let root = g#hivex_root () in -- 2.10.2