From fef6484ec301807c5c34f1baef901dfb62425278 Mon Sep 17 00:00:00 2001 From: Eugene Livis <elivis@basistech.com> Date: Wed, 23 Dec 2015 14:17:25 -0500 Subject: [PATCH] Added support to identify and open VHD images as part of tsk_img_open() --- tsk/auto/auto_db.cpp | 3 +++ tsk/img/img_open.c | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tsk/auto/auto_db.cpp b/tsk/auto/auto_db.cpp index 538395d40..cd38ebff5 100644 --- a/tsk/auto/auto_db.cpp +++ b/tsk/auto/auto_db.cpp @@ -20,6 +20,9 @@ #if HAVE_LIBVMDK #include "tsk/img/vmdk.h" #endif +#if HAVE_LIBVHDI +#include "tsk/img/vhd.h" +#endif #include <string.h> #include <algorithm> diff --git a/tsk/img/img_open.c b/tsk/img/img_open.c index 2594bb72e..090bf883a 100644 --- a/tsk/img/img_open.c +++ b/tsk/img/img_open.c @@ -31,6 +31,9 @@ typedef int bool; #include "vmdk.h" #endif +#if HAVE_LIBVHDI +#include "vhd.h" +#endif /** * \ingroup imglib @@ -117,7 +120,7 @@ tsk_img_open(int num_img, */ if (type == TSK_IMG_TYPE_DETECT) { TSK_IMG_INFO *img_set = NULL; -#if HAVE_LIBAFFLIB || HAVE_LIBEWF || HAVE_LIBVMDK +#if HAVE_LIBAFFLIB || HAVE_LIBEWF || HAVE_LIBVMDK || HAVE_LIBVHDI char *set = NULL; #endif @@ -186,6 +189,26 @@ tsk_img_open(int num_img, } #endif +#if HAVE_LIBVHDI + if ((img_info = vhdi_open(num_img, images, a_ssize)) != NULL) { + if (set == NULL) { + set = "VHD"; + img_set = img_info; + } + else { + img_set->close(img_set); + img_info->close(img_info); + tsk_error_reset(); + tsk_error_set_errno(TSK_ERR_IMG_UNKTYPE); + tsk_error_set_errstr("VHD or %s", set); + return NULL; + } + } + else { + tsk_error_reset(); + } +#endif + // if any of the non-raw formats were detected, then use it. if (img_set != NULL) return img_set; -- GitLab