From 24752c3f60a299e5a7380b67737174c3bfb91f9c Mon Sep 17 00:00:00 2001 From: Brian Carrier <carrier@sleuthkit.org> Date: Mon, 27 Oct 2008 15:06:00 +0000 Subject: [PATCH] Added SHARE_READ to CreateFile open --- tsk3/img/raw.c | 19 +++++++++++++++---- tsk3/img/split.c | 4 ++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tsk3/img/raw.c b/tsk3/img/raw.c index 521874c4b..3912f8bfa 100644 --- a/tsk3/img/raw.c +++ b/tsk3/img/raw.c @@ -208,16 +208,27 @@ raw_open(const TSK_TCHAR * image) if (tsk_verbose) tsk_fprintf(stderr, "raw_open: Trying Windows device with share_write mode\n"); + raw_info->fd = CreateFile(image, GENERIC_READ, - FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); + FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); } if (raw_info->fd == INVALID_HANDLE_VALUE) { tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OPEN; - snprintf(tsk_errstr, TSK_ERRSTR_L, - "raw_open file: %" PRIttocTSK " msg: %d", image, - (int)GetLastError()); + if (GetLastError() == ERROR_ACCESS_DENIED) { + snprintf(tsk_errstr, TSK_ERRSTR_L, + "raw_open file: %" PRIttocTSK " msg: Access Denied", image); + } + if (GetLastError() == ERROR_SHARING_VIOLATION) { + snprintf(tsk_errstr, TSK_ERRSTR_L, + "raw_open file: %" PRIttocTSK " msg: Sharing Violation", image); + } + else { + snprintf(tsk_errstr, TSK_ERRSTR_L, + "raw_open file: %" PRIttocTSK " msg: %d", image, + (int)GetLastError()); + } return NULL; } } diff --git a/tsk3/img/split.c b/tsk3/img/split.c index 5b001e660..a8d5410b6 100644 --- a/tsk3/img/split.c +++ b/tsk3/img/split.c @@ -64,8 +64,8 @@ split_read_segment(IMG_SPLIT_INFO * split_info, int idx, char *buf, tsk_error_reset(); tsk_errno = TSK_ERR_IMG_OPEN; snprintf(tsk_errstr, TSK_ERRSTR_L, - "split_read file: %" PRIttocTSK " msg: %s", - split_info->images[idx], strerror(errno)); + "split_read file: %" PRIttocTSK " msg: %d", + split_info->images[idx], (int)GetLastError()); return -1; } #else -- GitLab