summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
author Ted Green <tedgreen99@protonmail.com>2017-11-24 08:52:16 -0700
committer Ted Green <tedgreen99@protonmail.com>2017-11-24 08:52:16 -0700
commit64705c5ed36225842409760f2e29e60ae90f9430 (patch)
treebfa1e8030fc1a8dd8ed453c7bb0b93e8a4770847 /src/osd
parentb1198c91f9b254efc115a9ae7158aad1fdc6acb3 (diff)
chdman: Patch to allow chdman to access physical drives on Windows 10
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/modules/file/winfile.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/osd/modules/file/winfile.cpp b/src/osd/modules/file/winfile.cpp
index 745b9112b7b..e62382a92ab 100644
--- a/src/osd/modules/file/winfile.cpp
+++ b/src/osd/modules/file/winfile.cpp
@@ -185,6 +185,7 @@ osd_file::error osd_file::open(std::string const &orig_path, uint32_t openflags,
{
disposition = (!is_path_to_physical_drive(path.c_str()) && (openflags & OPEN_FLAG_CREATE)) ? CREATE_ALWAYS : OPEN_EXISTING;
access = (openflags & OPEN_FLAG_READ) ? (GENERIC_READ | GENERIC_WRITE) : GENERIC_WRITE;
+ if (is_path_to_physical_drive(path.c_str())) access |= GENERIC_READ;
sharemode = FILE_SHARE_READ;
}
else if (openflags & OPEN_FLAG_READ)
@@ -230,7 +231,23 @@ osd_file::error osd_file::open(std::string const &orig_path, uint32_t openflags,
// get the file size
DWORD upper, lower;
- lower = GetFileSize(h, &upper);
+ if (is_path_to_physical_drive(path.c_str())) {
+
+ GET_LENGTH_INFORMATION gli;
+ DWORD ret;
+ int getsize = DeviceIoControl(h, IOCTL_DISK_GET_LENGTH_INFO, 0, 0, &gli, sizeof(gli), &ret, 0);
+ if (getsize==0) {
+ upper = 0;
+ lower = INVALID_FILE_SIZE;
+ }
+ else {
+ lower = gli.Length.LowPart;
+ upper = gli.Length.HighPart;
+ }
+ }
+ else {
+ lower = GetFileSize(h, &upper);
+ }
if (INVALID_FILE_SIZE == lower)
{
DWORD const err = GetLastError();