2018-10-29 17:18:13 -07:00
|
|
|
From 89af577ac4db5a48ed30bcf06703a2e7ef05fa7a Mon Sep 17 00:00:00 2001
|
2015-06-06 09:04:37 -07:00
|
|
|
From: Sebastian Lackner <sebastian@fds-team.de>
|
|
|
|
Date: Sat, 6 Jun 2015 07:03:33 +0800
|
2018-10-29 17:18:13 -07:00
|
|
|
Subject: [PATCH] ntdll: Improve stub of NtQueryEaFile.
|
2015-06-06 09:04:37 -07:00
|
|
|
|
|
|
|
Based on a patch by Qian Hong.
|
|
|
|
---
|
|
|
|
dlls/ntdll/file.c | 19 ++++++++---
|
|
|
|
dlls/ntdll/tests/file.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
2 files changed, 98 insertions(+), 4 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
|
2018-10-29 17:18:13 -07:00
|
|
|
index a2cc839..4c7f1b2 100644
|
2015-06-06 09:04:37 -07:00
|
|
|
--- a/dlls/ntdll/file.c
|
|
|
|
+++ b/dlls/ntdll/file.c
|
2018-10-29 17:18:13 -07:00
|
|
|
@@ -3415,14 +3415,25 @@ NTSTATUS WINAPI NtQueryVolumeInformationFile( HANDLE handle, PIO_STATUS_BLOCK io
|
2016-04-29 20:17:53 -07:00
|
|
|
* Success: 0. Atrributes read into buffer
|
2015-06-06 09:04:37 -07:00
|
|
|
* Failure: An NTSTATUS error code describing the error.
|
|
|
|
*/
|
2016-04-29 20:17:53 -07:00
|
|
|
-NTSTATUS WINAPI NtQueryEaFile( HANDLE hFile, PIO_STATUS_BLOCK iosb, PVOID buffer, ULONG length,
|
|
|
|
+NTSTATUS WINAPI NtQueryEaFile( HANDLE handle, PIO_STATUS_BLOCK iosb, PVOID buffer, ULONG length,
|
2015-06-06 09:04:37 -07:00
|
|
|
BOOLEAN single_entry, PVOID ea_list, ULONG ea_list_len,
|
|
|
|
PULONG ea_index, BOOLEAN restart )
|
|
|
|
{
|
|
|
|
- FIXME("(%p,%p,%p,%d,%d,%p,%d,%p,%d) stub\n",
|
|
|
|
- hFile, iosb, buffer, length, single_entry, ea_list,
|
|
|
|
+ int fd, needs_close;
|
|
|
|
+ NTSTATUS status;
|
|
|
|
+
|
|
|
|
+ FIXME("(%p,%p,%p,%d,%d,%p,%d,%p,%d) semi-stub\n",
|
|
|
|
+ handle, iosb, buffer, length, single_entry, ea_list,
|
|
|
|
ea_list_len, ea_index, restart);
|
|
|
|
- return STATUS_ACCESS_DENIED;
|
|
|
|
+
|
|
|
|
+ if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL )) != STATUS_SUCCESS)
|
|
|
|
+ return status;
|
|
|
|
+
|
|
|
|
+ if (buffer && length)
|
2015-06-11 10:19:47 -07:00
|
|
|
+ memset( buffer, 0, length );
|
2015-06-06 09:04:37 -07:00
|
|
|
+
|
|
|
|
+ if (needs_close) close( fd );
|
|
|
|
+ return STATUS_NO_EAS_ON_FILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
|
2018-10-29 17:18:13 -07:00
|
|
|
index 7554187..e9a0d79 100644
|
2015-06-06 09:04:37 -07:00
|
|
|
--- a/dlls/ntdll/tests/file.c
|
|
|
|
+++ b/dlls/ntdll/tests/file.c
|
2018-10-29 17:18:13 -07:00
|
|
|
@@ -84,6 +84,7 @@ static NTSTATUS (WINAPI *pNtQueryDirectoryFile)(HANDLE,HANDLE,PIO_APC_ROUTINE,PV
|
2015-06-06 09:04:37 -07:00
|
|
|
static NTSTATUS (WINAPI *pNtQueryVolumeInformationFile)(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,FS_INFORMATION_CLASS);
|
2015-10-02 08:13:21 -07:00
|
|
|
static NTSTATUS (WINAPI *pNtQueryFullAttributesFile)(const OBJECT_ATTRIBUTES*, FILE_NETWORK_OPEN_INFORMATION*);
|
2017-03-02 20:40:34 -08:00
|
|
|
static NTSTATUS (WINAPI *pNtFlushBuffersFile)(HANDLE, IO_STATUS_BLOCK*);
|
2015-06-06 09:04:37 -07:00
|
|
|
+static NTSTATUS (WINAPI *pNtQueryEaFile)(HANDLE,PIO_STATUS_BLOCK,PVOID,ULONG,BOOLEAN,PVOID,ULONG,PULONG,BOOLEAN);
|
|
|
|
|
2018-10-29 17:18:13 -07:00
|
|
|
static WCHAR fooW[] = {'f','o','o',0};
|
|
|
|
|
|
|
|
@@ -4796,6 +4797,86 @@ static void test_flush_buffers_file(void)
|
2017-03-02 20:40:34 -08:00
|
|
|
DeleteFileA(buffer);
|
2015-06-06 09:04:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
+static void test_query_ea(void)
|
|
|
|
+{
|
|
|
|
+ #define EA_BUFFER_SIZE 4097
|
|
|
|
+ unsigned char data[EA_BUFFER_SIZE + 8];
|
|
|
|
+ unsigned char *buffer = (void *)(((DWORD_PTR)data + 7) & ~7);
|
|
|
|
+ DWORD buffer_len, i;
|
|
|
|
+ IO_STATUS_BLOCK io;
|
|
|
|
+ NTSTATUS status;
|
|
|
|
+ HANDLE handle;
|
|
|
|
+
|
|
|
|
+ if (!(handle = create_temp_file(0))) return;
|
|
|
|
+
|
|
|
|
+ /* test with INVALID_HANDLE_VALUE */
|
|
|
|
+ U(io).Status = 0xdeadbeef;
|
|
|
|
+ io.Information = 0xdeadbeef;
|
|
|
|
+ memset(buffer, 0xcc, EA_BUFFER_SIZE);
|
|
|
|
+ buffer_len = EA_BUFFER_SIZE - 1;
|
|
|
|
+ status = pNtQueryEaFile(INVALID_HANDLE_VALUE, &io, buffer, buffer_len, TRUE, NULL, 0, NULL, FALSE);
|
|
|
|
+ ok(status == STATUS_OBJECT_TYPE_MISMATCH, "expected STATUS_OBJECT_TYPE_MISMATCH, got %x\n", status);
|
|
|
|
+ ok(U(io).Status == 0xdeadbeef, "expected 0xdeadbeef, got %x\n", U(io).Status);
|
|
|
|
+ ok(io.Information == 0xdeadbeef, "expected 0xdeadbeef, got %lu\n", io.Information);
|
|
|
|
+ ok(buffer[0] == 0xcc, "data at position 0 overwritten\n");
|
|
|
|
+
|
|
|
|
+ /* test with 0xdeadbeef */
|
|
|
|
+ U(io).Status = 0xdeadbeef;
|
|
|
|
+ io.Information = 0xdeadbeef;
|
|
|
|
+ memset(buffer, 0xcc, EA_BUFFER_SIZE);
|
|
|
|
+ buffer_len = EA_BUFFER_SIZE - 1;
|
|
|
|
+ status = pNtQueryEaFile((void *)0xdeadbeef, &io, buffer, buffer_len, TRUE, NULL, 0, NULL, FALSE);
|
|
|
|
+ ok(status == STATUS_INVALID_HANDLE, "expected STATUS_INVALID_HANDLE, got %x\n", status);
|
|
|
|
+ ok(U(io).Status == 0xdeadbeef, "expected 0xdeadbeef, got %x\n", U(io).Status);
|
|
|
|
+ ok(io.Information == 0xdeadbeef, "expected 0xdeadbeef, got %lu\n", io.Information);
|
|
|
|
+ ok(buffer[0] == 0xcc, "data at position 0 overwritten\n");
|
|
|
|
+
|
|
|
|
+ /* test without buffer */
|
|
|
|
+ U(io).Status = 0xdeadbeef;
|
|
|
|
+ io.Information = 0xdeadbeef;
|
|
|
|
+ status = pNtQueryEaFile(handle, &io, NULL, 0, TRUE, NULL, 0, NULL, FALSE);
|
|
|
|
+ ok(status == STATUS_NO_EAS_ON_FILE, "expected STATUS_NO_EAS_ON_FILE, got %x\n", status);
|
|
|
|
+ ok(U(io).Status == 0xdeadbeef, "expected 0xdeadbeef, got %x\n", U(io).Status);
|
|
|
|
+ ok(io.Information == 0xdeadbeef, "expected 0xdeadbeef, got %lu\n", io.Information);
|
|
|
|
+
|
|
|
|
+ /* test with zero buffer */
|
|
|
|
+ U(io).Status = 0xdeadbeef;
|
|
|
|
+ io.Information = 0xdeadbeef;
|
|
|
|
+ status = pNtQueryEaFile(handle, &io, buffer, 0, TRUE, NULL, 0, NULL, FALSE);
|
|
|
|
+ ok(status == STATUS_NO_EAS_ON_FILE, "expected STATUS_NO_EAS_ON_FILE, got %x\n", status);
|
|
|
|
+ ok(U(io).Status == 0xdeadbeef, "expected 0xdeadbeef, got %x\n", U(io).Status);
|
|
|
|
+ ok(io.Information == 0xdeadbeef, "expected 0xdeadbeef, got %lu\n", io.Information);
|
|
|
|
+
|
|
|
|
+ /* test with very small buffer */
|
|
|
|
+ U(io).Status = 0xdeadbeef;
|
|
|
|
+ io.Information = 0xdeadbeef;
|
|
|
|
+ memset(buffer, 0xcc, EA_BUFFER_SIZE);
|
|
|
|
+ buffer_len = 4;
|
|
|
|
+ status = pNtQueryEaFile(handle, &io, buffer, buffer_len, TRUE, NULL, 0, NULL, FALSE);
|
|
|
|
+ ok(status == STATUS_NO_EAS_ON_FILE, "expected STATUS_NO_EAS_ON_FILE, got %x\n", status);
|
|
|
|
+ ok(U(io).Status == 0xdeadbeef, "expected 0xdeadbeef, got %x\n", U(io).Status);
|
|
|
|
+ ok(io.Information == 0xdeadbeef, "expected 0xdeadbeef, got %lu\n", io.Information);
|
|
|
|
+ for (i = 0; i < buffer_len && !buffer[i]; i++);
|
|
|
|
+ ok(i == buffer_len, "expected %u bytes filled with 0x00, got %u bytes\n", buffer_len, i);
|
|
|
|
+ ok(buffer[i] == 0xcc, "data at position %u overwritten\n", buffer[i]);
|
|
|
|
+
|
|
|
|
+ /* test with very big buffer */
|
|
|
|
+ U(io).Status = 0xdeadbeef;
|
|
|
|
+ io.Information = 0xdeadbeef;
|
|
|
|
+ memset(buffer, 0xcc, EA_BUFFER_SIZE);
|
2015-06-11 10:19:47 -07:00
|
|
|
+ buffer_len = EA_BUFFER_SIZE - 1;
|
2015-06-06 09:04:37 -07:00
|
|
|
+ status = pNtQueryEaFile(handle, &io, buffer, buffer_len, TRUE, NULL, 0, NULL, FALSE);
|
|
|
|
+ ok(status == STATUS_NO_EAS_ON_FILE, "expected STATUS_NO_EAS_ON_FILE, got %x\n", status);
|
|
|
|
+ ok(U(io).Status == 0xdeadbeef, "expected 0xdeadbeef, got %x\n", U(io).Status);
|
|
|
|
+ ok(io.Information == 0xdeadbeef, "expected 0xdeadbeef, got %lu\n", io.Information);
|
|
|
|
+ for (i = 0; i < buffer_len && !buffer[i]; i++);
|
|
|
|
+ ok(i == buffer_len, "expected %u bytes filled with 0x00, got %u bytes\n", buffer_len, i);
|
|
|
|
+ ok(buffer[i] == 0xcc, "data at position %u overwritten\n", buffer[i]);
|
|
|
|
+
|
|
|
|
+ CloseHandle(handle);
|
|
|
|
+ #undef EA_BUFFER_SIZE
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
START_TEST(file)
|
|
|
|
{
|
|
|
|
HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
|
2018-10-29 17:18:13 -07:00
|
|
|
@@ -4836,6 +4917,7 @@ START_TEST(file)
|
2015-06-06 09:04:37 -07:00
|
|
|
pNtQueryVolumeInformationFile = (void *)GetProcAddress(hntdll, "NtQueryVolumeInformationFile");
|
2015-08-22 01:00:16 -07:00
|
|
|
pNtQueryFullAttributesFile = (void *)GetProcAddress(hntdll, "NtQueryFullAttributesFile");
|
2017-03-02 20:40:34 -08:00
|
|
|
pNtFlushBuffersFile = (void *)GetProcAddress(hntdll, "NtFlushBuffersFile");
|
2015-08-22 01:00:16 -07:00
|
|
|
+ pNtQueryEaFile = (void *)GetProcAddress(hntdll, "NtQueryEaFile");
|
2015-06-06 09:04:37 -07:00
|
|
|
|
|
|
|
test_read_write();
|
|
|
|
test_NtCreateFile();
|
2018-10-29 17:18:13 -07:00
|
|
|
@@ -4865,4 +4947,5 @@ START_TEST(file)
|
2015-06-06 09:04:37 -07:00
|
|
|
test_query_attribute_information_file();
|
2017-02-21 21:50:16 -08:00
|
|
|
test_ioctl();
|
2017-03-02 20:40:34 -08:00
|
|
|
test_flush_buffers_file();
|
2015-06-06 09:04:37 -07:00
|
|
|
+ test_query_ea();
|
|
|
|
}
|
|
|
|
--
|
2018-10-29 17:18:13 -07:00
|
|
|
1.9.1
|
2015-06-06 09:04:37 -07:00
|
|
|
|