From b1d20ea747c7c31441fec89a92072370ddb6d8a2 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Wed, 7 Oct 2015 05:16:25 +0200 Subject: [PATCH] ntdll-Status_Mapping: Update patchset and add test for NtWriteFile. --- ...TUS_INVALID_DEVICE_REQUEST-when-tryi.patch | 61 --------------- ...tests-for-calling-NtReadFile-NtWrite.patch | 74 +++++++++++++++++++ ...TUS_INVALID_DEVICE_REQUEST-when-tryi.patch | 39 ++++++++++ patches/patchinstall.sh | 4 +- 4 files changed, 116 insertions(+), 62 deletions(-) delete mode 100644 patches/ntdll-Status_Mapping/0001-ntdll-Return-STATUS_INVALID_DEVICE_REQUEST-when-tryi.patch create mode 100644 patches/ntdll-Status_Mapping/0001-ntdll-tests-Add-tests-for-calling-NtReadFile-NtWrite.patch create mode 100644 patches/ntdll-Status_Mapping/0002-ntdll-Return-STATUS_INVALID_DEVICE_REQUEST-when-tryi.patch 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 deleted file mode 100644 index bbf6fdc5..00000000 --- a/patches/ntdll-Status_Mapping/0001-ntdll-Return-STATUS_INVALID_DEVICE_REQUEST-when-tryi.patch +++ /dev/null @@ -1,61 +0,0 @@ -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/0001-ntdll-tests-Add-tests-for-calling-NtReadFile-NtWrite.patch b/patches/ntdll-Status_Mapping/0001-ntdll-tests-Add-tests-for-calling-NtReadFile-NtWrite.patch new file mode 100644 index 00000000..79b18dcd --- /dev/null +++ b/patches/ntdll-Status_Mapping/0001-ntdll-tests-Add-tests-for-calling-NtReadFile-NtWrite.patch @@ -0,0 +1,74 @@ +From 42d6405bc17730a5e281f7461891acca7803a8cd Mon Sep 17 00:00:00 2001 +From: Sebastian Lackner +Date: Thu, 24 Sep 2015 01:56:24 +0200 +Subject: ntdll/tests: Add tests for calling NtReadFile/NtWriteFile on + directory. + +--- + dlls/ntdll/tests/file.c | 35 +++++++++++++++++++++++++++++++++-- + 1 file changed, 33 insertions(+), 2 deletions(-) + +diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c +index 1afb9c8..b8f1847 100644 +--- a/dlls/ntdll/tests/file.c ++++ b/dlls/ntdll/tests/file.c +@@ -177,6 +177,7 @@ static void create_file_test(void) + static const WCHAR pathInvalidNtW[] = {'\\','\\','?','\\',0}; + static const WCHAR pathInvalidNt2W[] = {'\\','?','?','\\',0}; + static const WCHAR pathInvalidDosW[] = {'\\','D','o','s','D','e','v','i','c','e','s','\\',0}; ++ static const char testdata[] = "Hello World"; + FILE_NETWORK_OPEN_INFORMATION info; + NTSTATUS status; + HANDLE dir, file; +@@ -184,6 +185,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 ); +@@ -195,9 +199,36 @@ static void create_file_test(void) + attr.SecurityQualityOfService = NULL; + + /* try various open modes and options on directories */ +- status = pNtCreateFile( &dir, GENERIC_READ, &attr, &io, NULL, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, +- FILE_OPEN, FILE_DIRECTORY_FILE, NULL, 0 ); ++ status = pNtCreateFile( &dir, GENERIC_READ|GENERIC_WRITE, &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 ); ++ todo_wine ++ 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 ); ++ } ++ ++ U(io).Status = 0xdeadbeef; ++ offset.QuadPart = 0; ++ status = pNtWriteFile( dir, NULL, NULL, NULL, &io, testdata, sizeof(testdata), &offset, NULL); ++ todo_wine ++ ok( status == STATUS_INVALID_DEVICE_REQUEST || status == STATUS_PENDING, "NtWriteFile 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.6.0 + diff --git a/patches/ntdll-Status_Mapping/0002-ntdll-Return-STATUS_INVALID_DEVICE_REQUEST-when-tryi.patch b/patches/ntdll-Status_Mapping/0002-ntdll-Return-STATUS_INVALID_DEVICE_REQUEST-when-tryi.patch new file mode 100644 index 00000000..f310a2ac --- /dev/null +++ b/patches/ntdll-Status_Mapping/0002-ntdll-Return-STATUS_INVALID_DEVICE_REQUEST-when-tryi.patch @@ -0,0 +1,39 @@ +From 3e4e21b4e66f85143a029374c58a66ae54f792e8 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 | 1 - + 2 files changed, 1 insertion(+), 2 deletions(-) + +diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c +index 8f89ba5..67a13b2 100644 +--- a/dlls/ntdll/file.c ++++ b/dlls/ntdll/file.c +@@ -459,7 +459,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 b8f1847..63dd4f9 100644 +--- a/dlls/ntdll/tests/file.c ++++ b/dlls/ntdll/tests/file.c +@@ -206,7 +206,6 @@ static void create_file_test(void) + U(io).Status = 0xdeadbeef; + offset.QuadPart = 0; + status = pNtReadFile( dir, NULL, NULL, NULL, &io, buf, sizeof(buf), &offset, NULL ); +- todo_wine + ok( status == STATUS_INVALID_DEVICE_REQUEST || status == STATUS_PENDING, "NtReadFile error %08x\n", status ); + if (status == STATUS_PENDING) + { +-- +2.6.0 + diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 3362b906..5b418821 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -4240,8 +4240,10 @@ fi # | * 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 + patch_apply ntdll-Status_Mapping/0001-ntdll-tests-Add-tests-for-calling-NtReadFile-NtWrite.patch + patch_apply ntdll-Status_Mapping/0002-ntdll-Return-STATUS_INVALID_DEVICE_REQUEST-when-tryi.patch ( + echo '+ { "Sebastian Lackner", "ntdll/tests: Add tests for calling NtReadFile/NtWriteFile on directory.", 1 },'; echo '+ { "Sebastian Lackner", "ntdll: Return STATUS_INVALID_DEVICE_REQUEST when trying to call NtReadFile on directory.", 1 },'; ) >> "$patchlist" fi