From ff9f5115fbe7baba26574e937a2f08526869a7a0 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sun, 13 Sep 2015 17:18:35 +0200 Subject: [PATCH] Added patch to return STATUS_INVALID_DEVICE_REQUEST when trying to call NtReadFile on directory. --- README.md | 5 ++ debian/changelog | 2 + ...TUS_INVALID_DEVICE_REQUEST-when-tryi.patch | 61 +++++++++++++++++++ patches/ntdll-Status_Mapping/definition | 1 + patches/patchinstall.sh | 18 +++++- 5 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 patches/ntdll-Status_Mapping/0001-ntdll-Return-STATUS_INVALID_DEVICE_REQUEST-when-tryi.patch create mode 100644 patches/ntdll-Status_Mapping/definition diff --git a/README.md b/README.md index 0dd30e71..7896e4a1 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,11 @@ Wine. All those differences are also documented on the Included bug fixes and improvements ----------------------------------- +**Bug fixes and features included in the next upcoming release [1]:** + +* Return STATUS_INVALID_DEVICE_REQUEST when trying to call NtReadFile on directory + + **Bug fixes and features in Wine Staging 1.7.51 [260]:** *Note: The following list only contains features and bug fixes which are not diff --git a/debian/changelog b/debian/changelog index 312ae55e..cd527e89 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,6 @@ wine-staging (1.7.52) UNRELEASED; urgency=low + * Added patch to return STATUS_INVALID_DEVICE_REQUEST when trying to call + NtReadFile on directory. * Removed patch to fix possible memory leak in netprofm init_networks (fixed upstream). * Removed patch for stub of dwmapi.DwmUpdateThumbnailProperties (accepted diff --git a/patches/ntdll-Status_Mapping/0001-ntdll-Return-STATUS_INVALID_DEVICE_REQUEST-when-tryi.patch b/patches/ntdll-Status_Mapping/0001-ntdll-Return-STATUS_INVALID_DEVICE_REQUEST-when-tryi.patch new file mode 100644 index 00000000..bbf6fdc5 --- /dev/null +++ b/patches/ntdll-Status_Mapping/0001-ntdll-Return-STATUS_INVALID_DEVICE_REQUEST-when-tryi.patch @@ -0,0 +1,61 @@ +From db6ccdc010d7542492e12a456ae716def47f6309 Mon Sep 17 00:00:00 2001 +From: Sebastian Lackner +Date: Sun, 13 Sep 2015 17:16:07 +0200 +Subject: ntdll: Return STATUS_INVALID_DEVICE_REQUEST when trying to call + NtReadFile on directory. + +--- + dlls/ntdll/file.c | 2 +- + dlls/ntdll/tests/file.c | 16 ++++++++++++++++ + 2 files changed, 17 insertions(+), 1 deletion(-) + +diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c +index 61db8f6..2312a51 100644 +--- a/dlls/ntdll/file.c ++++ b/dlls/ntdll/file.c +@@ -458,7 +458,7 @@ NTSTATUS FILE_GetNtStatus(void) + case EACCES: return STATUS_ACCESS_DENIED; + case ENOTDIR: return STATUS_OBJECT_PATH_NOT_FOUND; + case ENOENT: return STATUS_OBJECT_NAME_NOT_FOUND; +- case EISDIR: return STATUS_FILE_IS_A_DIRECTORY; ++ case EISDIR: return STATUS_INVALID_DEVICE_REQUEST; + case EMFILE: + case ENFILE: return STATUS_TOO_MANY_OPENED_FILES; + case EINVAL: return STATUS_INVALID_PARAMETER; +diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c +index d68be15..d192afb 100644 +--- a/dlls/ntdll/tests/file.c ++++ b/dlls/ntdll/tests/file.c +@@ -179,6 +179,9 @@ static void create_file_test(void) + OBJECT_ATTRIBUTES attr; + IO_STATUS_BLOCK io; + UNICODE_STRING nameW; ++ LARGE_INTEGER offset; ++ char buf[32]; ++ DWORD ret; + + GetCurrentDirectoryW( MAX_PATH, path ); + pRtlDosPathNameToNtPathName_U( path, &nameW, NULL, NULL ); +@@ -193,6 +196,19 @@ static void create_file_test(void) + status = pNtCreateFile( &dir, GENERIC_READ, &attr, &io, NULL, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, + FILE_OPEN, FILE_DIRECTORY_FILE, NULL, 0 ); + ok( !status, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status ); ++ ++ U(io).Status = 0xdeadbeef; ++ offset.QuadPart = 0; ++ status = pNtReadFile( dir, NULL, NULL, NULL, &io, buf, sizeof(buf), &offset, NULL ); ++ ok( status == STATUS_INVALID_DEVICE_REQUEST || status == STATUS_PENDING, "NtReadFile error %08x\n", status ); ++ if (status == STATUS_PENDING) ++ { ++ ret = WaitForSingleObject( dir, 1000 ); ++ ok( ret == WAIT_OBJECT_0, "WaitForSingleObject error %u\n", ret ); ++ ok( U(io).Status == STATUS_INVALID_DEVICE_REQUEST, ++ "expected STATUS_INVALID_DEVICE_REQUEST, got %08x\n", U(io).Status ); ++ } ++ + CloseHandle( dir ); + + status = pNtCreateFile( &dir, GENERIC_READ, &attr, &io, NULL, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, +-- +2.5.1 + diff --git a/patches/ntdll-Status_Mapping/definition b/patches/ntdll-Status_Mapping/definition new file mode 100644 index 00000000..4eead9e0 --- /dev/null +++ b/patches/ntdll-Status_Mapping/definition @@ -0,0 +1 @@ +Fixes: Return STATUS_INVALID_DEVICE_REQUEST when trying to call NtReadFile on directory diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 4a2251a5..1a97093b 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -52,7 +52,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "efb1cf0299c23385f934fa9b3abc920bfca46611" + echo "a7e294c064ac443a4351d1cbe84e7f52e0775d6f" } # Show version information @@ -200,6 +200,7 @@ patch_enable_all () enable_ntdll_Pipe_SpecialCharacters="$1" enable_ntdll_RtlIpStringToAddress="$1" enable_ntdll_Stack_Fault="$1" + enable_ntdll_Status_Mapping="$1" enable_ntdll_SystemRoot_Symlink="$1" enable_ntdll_ThreadTime="$1" enable_ntdll_Threading="$1" @@ -693,6 +694,9 @@ patch_enable () ntdll-Stack_Fault) enable_ntdll_Stack_Fault="$2" ;; + ntdll-Status_Mapping) + enable_ntdll_Status_Mapping="$2" + ;; ntdll-SystemRoot_Symlink) enable_ntdll_SystemRoot_Symlink="$2" ;; @@ -4154,6 +4158,18 @@ if test "$enable_ntdll_Stack_Fault" -eq 1; then ) >> "$patchlist" fi +# Patchset ntdll-Status_Mapping +# | +# | Modified files: +# | * dlls/ntdll/file.c, dlls/ntdll/tests/file.c +# | +if test "$enable_ntdll_Status_Mapping" -eq 1; then + patch_apply ntdll-Status_Mapping/0001-ntdll-Return-STATUS_INVALID_DEVICE_REQUEST-when-tryi.patch + ( + echo '+ { "Sebastian Lackner", "ntdll: Return STATUS_INVALID_DEVICE_REQUEST when trying to call NtReadFile on directory.", 1 },'; + ) >> "$patchlist" +fi + # Patchset ntdll-SystemRoot_Symlink # | # | This patchset has the following (direct or indirect) dependencies: