peview: Add workaround for 'access flags are incompatible' error dialog when viewing some binary types
@@ -162,13 +162,27 @@ INT WINAPI wWinMain(
else
{
NTSTATUS status;
+ HANDLE fileHandle;
+ status = PhCreateFileWin32(
+ &fileHandle,
+ PvFileName->Buffer,
+ FILE_READ_ATTRIBUTES | FILE_READ_DATA | SYNCHRONIZE,
+ FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ FILE_OPEN,
+ FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT
+ );
+
+ if (NT_SUCCESS(status))
+ {
status = PhLoadMappedImageEx(
PvFileName->Buffer,
- NULL,
+ fileHandle,
TRUE,
&PvMappedImage
);
+ NtClose(fileHandle);
if (NT_SUCCESS(status))
{
@@ -188,7 +202,9 @@ INT WINAPI wWinMain(
if (NT_SUCCESS(status))
PhUnloadMappedImage(&PvMappedImage);
- else
+ }
+
+ if (!NT_SUCCESS(status))
PhShowStatus(NULL, L"Unable to load the file.", status, 0);
}
