[PATCH 3/5] ntoskrnl/tests: Open the test output file using a hardcoded path.

Zebediah Figura z.figura12 at gmail.com
Sun Apr 4 22:36:47 CDT 2021


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/ntoskrnl.exe/tests/driver.c   |  7 ++++---
 dlls/ntoskrnl.exe/tests/driver.h   |  1 -
 dlls/ntoskrnl.exe/tests/driver4.c  |  7 ++++---
 dlls/ntoskrnl.exe/tests/ntoskrnl.c | 24 ++++++++----------------
 4 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c
index ec2d8d33900..179d2d5e02d 100644
--- a/dlls/ntoskrnl.exe/tests/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.c
@@ -2126,13 +2126,14 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st
         return STATUS_BUFFER_TOO_SMALL;
 
     attr.Length = sizeof(attr);
-    RtlInitUnicodeString(&pathU, test_input->path);
+    RtlInitUnicodeString(&pathU, L"\\??\\C:\\windows\\winetest_ntoskrnl_okfile");
     running_under_wine = test_input->running_under_wine;
     winetest_debug = test_input->winetest_debug;
     winetest_report_success = test_input->winetest_report_success;
     attr.ObjectName = &pathU;
-    attr.Attributes = OBJ_KERNEL_HANDLE; /* needed to be accessible from system threads */
-    ZwOpenFile(&okfile, FILE_APPEND_DATA | SYNCHRONIZE, &attr, &io, 0, FILE_SYNCHRONOUS_IO_NONALERT);
+    attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE; /* needed to be accessible from system threads */
+    ZwOpenFile(&okfile, FILE_APPEND_DATA | SYNCHRONIZE, &attr, &io,
+            FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SYNCHRONOUS_IO_NONALERT);
 
     pExEventObjectType = get_proc_address("ExEventObjectType");
     ok(!!pExEventObjectType, "ExEventObjectType not found\n");
diff --git a/dlls/ntoskrnl.exe/tests/driver.h b/dlls/ntoskrnl.exe/tests/driver.h
index 58a92d4838e..d55dd95cf20 100644
--- a/dlls/ntoskrnl.exe/tests/driver.h
+++ b/dlls/ntoskrnl.exe/tests/driver.h
@@ -46,7 +46,6 @@ struct test_input
     DWORD process_id;
     SIZE_T teststr_offset;
     ULONG64 *modified_value;
-    WCHAR path[1];
 };
 
 static inline char *drv_strrchr( const char *str, char ch )
diff --git a/dlls/ntoskrnl.exe/tests/driver4.c b/dlls/ntoskrnl.exe/tests/driver4.c
index 45ea90260a8..a29ba3b55ab 100644
--- a/dlls/ntoskrnl.exe/tests/driver4.c
+++ b/dlls/ntoskrnl.exe/tests/driver4.c
@@ -487,13 +487,14 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st
         return STATUS_BUFFER_TOO_SMALL;
 
     attr.Length = sizeof(attr);
-    RtlInitUnicodeString(&pathU, test_input->path);
+    RtlInitUnicodeString(&pathU, L"\\??\\C:\\winetest_ntoskrnl_okfile");
     running_under_wine = test_input->running_under_wine;
     winetest_debug = test_input->winetest_debug;
     winetest_report_success = test_input->winetest_report_success;
     attr.ObjectName = &pathU;
-    attr.Attributes = OBJ_KERNEL_HANDLE; /* needed to be accessible from system threads */
-    ZwOpenFile(&okfile, FILE_APPEND_DATA | SYNCHRONIZE, &attr, &io, 0, FILE_SYNCHRONOUS_IO_NONALERT);
+    attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE; /* needed to be accessible from system threads */
+    ZwOpenFile(&okfile, FILE_APPEND_DATA | SYNCHRONIZE, &attr, &io,
+            FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SYNCHRONOUS_IO_NONALERT);
 
     netio_init();
     test_wsk_get_address_info();
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
index 73f96789f06..1987019a6c5 100644
--- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
@@ -367,22 +367,20 @@ static ULONG64 modified_value;
 
 static void main_test(void)
 {
-    WCHAR temppathW[MAX_PATH], pathW[MAX_PATH];
     struct test_input *test_input;
-    DWORD len, written, read;
-    UNICODE_STRING pathU;
+    DWORD written, read;
     LONG new_failures;
     char buffer[512];
     HANDLE okfile;
     BOOL res;
 
     /* Create a temporary file that the driver will write ok/trace output to. */
-    GetTempPathW(MAX_PATH, temppathW);
-    GetTempFileNameW(temppathW, L"dok", 0, pathW);
-    pRtlDosPathNameToNtPathName_U( pathW, &pathU, NULL, NULL );
 
-    len = pathU.Length + sizeof(WCHAR);
-    test_input = heap_alloc( offsetof( struct test_input, path[len / sizeof(WCHAR)]) );
+    okfile = CreateFileA("C:\\windows\\winetest_ntoskrnl_okfile", GENERIC_READ,
+            FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL);
+    ok(okfile != INVALID_HANDLE_VALUE, "failed to create file, error %u\n", GetLastError());
+
+    test_input = heap_alloc( sizeof(*test_input) );
     test_input->running_under_wine = !strcmp(winetest_platform, "wine");
     test_input->winetest_report_success = winetest_report_success;
     test_input->winetest_debug = winetest_debug;
@@ -391,16 +389,11 @@ static void main_test(void)
     test_input->modified_value = &modified_value;
     modified_value = 0;
 
-    memcpy(test_input->path, pathU.Buffer, len);
-    res = DeviceIoControl(device, IOCTL_WINETEST_MAIN_TEST, test_input,
-                          offsetof( struct test_input, path[len / sizeof(WCHAR)]),
+    res = DeviceIoControl(device, IOCTL_WINETEST_MAIN_TEST, test_input, sizeof(*test_input),
                           &new_failures, sizeof(new_failures), &written, NULL);
     ok(res, "DeviceIoControl failed: %u\n", GetLastError());
     ok(written == sizeof(new_failures), "got size %x\n", written);
 
-    okfile = CreateFileW(pathW, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
-    ok(okfile != INVALID_HANDLE_VALUE, "failed to create %s: %u\n", wine_dbgstr_w(pathW), GetLastError());
-
     /* Print the ok/trace output and then add to our failure count. */
     do {
         ReadFile(okfile, buffer, sizeof(buffer), &read, NULL);
@@ -408,10 +401,9 @@ static void main_test(void)
     } while (read == sizeof(buffer));
     winetest_add_failures(new_failures);
 
-    pRtlFreeUnicodeString(&pathU);
     heap_free(test_input);
     CloseHandle(okfile);
-    DeleteFileW(pathW);
+    DeleteFileA("C:\\windows\\winetest_ntoskrnl_okfile");
 }
 
 static void test_basic_ioctl(void)
-- 
2.30.2




More information about the wine-devel mailing list