ntoskrnl-DriverTest: Merge tests with appropriate patches in ntoskrnl-Stubs and winedevice-Default_Drivers.

This commit is contained in:
Zebediah Figura 2018-05-02 18:37:53 -05:00
parent 27c94566e3
commit 797372c132
9 changed files with 289 additions and 476 deletions

View File

@ -1,115 +0,0 @@
From 823f783bfa8b733abed5ec67d3119c2bbccf3d14 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 10 Jun 2017 15:45:03 +0200
Subject: ntoskrnl.exe/tests: Add tests for NtBuildNumber.
---
dlls/ntoskrnl.exe/tests/driver.sys/driver.c | 34 +++++++++++++++++++++++++++++
dlls/ntoskrnl.exe/tests/driver.sys/driver.h | 1 +
dlls/ntoskrnl.exe/tests/ntoskrnl.c | 7 ++++++
3 files changed, 42 insertions(+)
diff --git a/dlls/ntoskrnl.exe/tests/driver.sys/driver.c b/dlls/ntoskrnl.exe/tests/driver.sys/driver.c
index 78fb55a961c..28fbaf1747f 100644
--- a/dlls/ntoskrnl.exe/tests/driver.sys/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.sys/driver.c
@@ -35,11 +35,29 @@
#include "test.h"
#include "driver.h"
+extern PVOID WINAPI MmGetSystemRoutineAddress(PUNICODE_STRING);
+
const WCHAR driver_device[] = {'\\','D','e','v','i','c','e',
'\\','W','i','n','e','T','e','s','t','D','r','i','v','e','r',0};
const WCHAR driver_link[] = {'\\','D','o','s','D','e','v','i','c','e','s',
'\\','W','i','n','e','T','e','s','t','D','r','i','v','e','r',0};
+static void *get_system_routine(const char *name)
+{
+ UNICODE_STRING name_u;
+ ANSI_STRING name_a;
+ NTSTATUS status;
+ void *ret;
+
+ RtlInitAnsiString(&name_a, name);
+ status = RtlAnsiStringToUnicodeString(&name_u, &name_a, TRUE);
+ if (status) return NULL;
+
+ ret = MmGetSystemRoutineAddress(&name_u);
+ RtlFreeUnicodeString(&name_u);
+ return ret;
+}
+
/* In each kernel testcase the following variables are available:
*
* device - DEVICE_OBJECT used for ioctl
@@ -62,6 +80,21 @@ KERNEL_TESTCASE(PsGetCurrentThread)
return STATUS_SUCCESS;
}
+KERNEL_TESTCASE(NtBuildNumber)
+{
+ USHORT *pNtBuildNumber;
+ ULONG build;
+
+ if (!(pNtBuildNumber = get_system_routine("NtBuildNumber")))
+ {
+ win_skip("Could not get pointer to NtBuildNumber\n");
+ return STATUS_SUCCESS;
+ }
+
+ PsGetVersion(NULL, NULL, &build, NULL);
+ ok(*pNtBuildNumber == build, "Expected build number %u, got %u\n", build, *pNtBuildNumber);
+ return STATUS_SUCCESS;
+}
static NTSTATUS WINAPI driver_Create(DEVICE_OBJECT *device, IRP *irp)
{
@@ -100,6 +133,7 @@ static NTSTATUS WINAPI driver_IoControl(DEVICE_OBJECT *device, IRP *irp)
{
DECLARE_TEST(PsGetCurrentProcessId);
DECLARE_TEST(PsGetCurrentThread);
+ DECLARE_TEST(NtBuildNumber);
default:
break;
diff --git a/dlls/ntoskrnl.exe/tests/driver.sys/driver.h b/dlls/ntoskrnl.exe/tests/driver.sys/driver.h
index 1af2dcec249..c3440cb65c2 100644
--- a/dlls/ntoskrnl.exe/tests/driver.sys/driver.h
+++ b/dlls/ntoskrnl.exe/tests/driver.sys/driver.h
@@ -24,6 +24,7 @@
#define WINE_IOCTL_PsGetCurrentProcessId WINE_TEST_IOCTL(0)
#define WINE_IOCTL_PsGetCurrentThread WINE_TEST_IOCTL(1)
+#define WINE_IOCTL_NtBuildNumber WINE_TEST_IOCTL(2)
struct test_PsGetCurrentProcessId
{
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
index 6f020101b4c..c9799ec5a3c 100644
--- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
@@ -202,6 +202,12 @@ static void test_PsGetCurrentThread(void)
wine_run_kernel_test(device_path, WINE_IOCTL_PsGetCurrentThread, NULL);
}
+static void test_NtBuildNumber(void)
+{
+ trace("Running tests for NtBuildNumber\n");
+ wine_run_kernel_test(device_path, WINE_IOCTL_NtBuildNumber, NULL);
+}
+
START_TEST(ntoskrnl)
{
char filename[MAX_PATH];
@@ -215,6 +221,7 @@ START_TEST(ntoskrnl)
test_PsGetCurrentProcessId();
test_PsGetCurrentThread();
+ test_NtBuildNumber();
unload_driver(service, filename);
}
--
2.13.1

View File

@ -1,137 +0,0 @@
From 0ab2d5154c93ef99861a19381037728a034f9afa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Tue, 6 Jun 2017 23:45:07 +0200
Subject: ntoskrnl.exe/tests: Add tests for ExInitializeNPagedLookasideList.
---
dlls/ntoskrnl.exe/tests/driver.sys/driver.c | 39 ++++++++++++++++++++++++++---
dlls/ntoskrnl.exe/tests/driver.sys/driver.h | 7 +++---
dlls/ntoskrnl.exe/tests/ntoskrnl.c | 7 ++++++
3 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/dlls/ntoskrnl.exe/tests/driver.sys/driver.c b/dlls/ntoskrnl.exe/tests/driver.sys/driver.c
index 28fbaf1747f..39c2fb2aa50 100644
--- a/dlls/ntoskrnl.exe/tests/driver.sys/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.sys/driver.c
@@ -22,6 +22,9 @@
#include <stdarg.h>
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
@@ -96,9 +99,38 @@ KERNEL_TESTCASE(NtBuildNumber)
return STATUS_SUCCESS;
}
+KERNEL_TESTCASE(ExInitializeNPagedLookasideList)
+{
+ NPAGED_LOOKASIDE_LIST list;
+ ULONG tag = 0x454e4957; /* WINE */
+
+ ExInitializeNPagedLookasideList(&list, NULL, NULL, POOL_NX_ALLOCATION, LOOKASIDE_MINIMUM_BLOCK_SIZE, tag, 0);
+ ok(list.L.Depth == 4, "Expected 4 got %u\n", list.L.Depth);
+ ok(list.L.MaximumDepth == 256, "Expected 256 got %u\n", list.L.MaximumDepth);
+ ok(list.L.TotalAllocates == 0, "Expected 0 got %u\n", list.L.TotalAllocates);
+ ok(list.L.u2.AllocateMisses == 0, "Expected 0 got %u\n", list.L.u2.AllocateMisses);
+ ok(list.L.TotalFrees == 0, "Expected 0 got %u\n", list.L.TotalFrees);
+ ok(list.L.u3.FreeMisses == 0, "Expected 0 got %u\n", list.L.u3.FreeMisses);
+ ok(list.L.Type == (NonPagedPool|POOL_NX_ALLOCATION),
+ "Expected NonPagedPool|POOL_NX_ALLOCATION got %u\n", list.L.Type);
+ ok(list.L.Tag == tag, "Expected %x got %x\n", tag, list.L.Tag);
+ ok(list.L.Size == LOOKASIDE_MINIMUM_BLOCK_SIZE,
+ "Expected %u got %u\n", LOOKASIDE_MINIMUM_BLOCK_SIZE, list.L.Size);
+ ok(list.L.LastTotalAllocates == 0,"Expected 0 got %u\n", list.L.LastTotalAllocates);
+ ok(list.L.u6.LastAllocateMisses == 0,"Expected 0 got %u\n", list.L.u6.LastAllocateMisses);
+ ExDeleteNPagedLookasideList(&list);
+
+ list.L.Depth = 0;
+ ExInitializeNPagedLookasideList(&list, NULL, NULL, 0, LOOKASIDE_MINIMUM_BLOCK_SIZE, tag, 20);
+ ok(list.L.Depth == 4, "Expected 4 got %u\n", list.L.Depth);
+ ExDeleteNPagedLookasideList(&list);
+
+ return STATUS_SUCCESS;
+}
+
static NTSTATUS WINAPI driver_Create(DEVICE_OBJECT *device, IRP *irp)
{
- irp->IoStatus.Status = STATUS_SUCCESS;
+ irp->IoStatus.u.Status = STATUS_SUCCESS;
IoCompleteRequest(irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
@@ -134,6 +166,7 @@ static NTSTATUS WINAPI driver_IoControl(DEVICE_OBJECT *device, IRP *irp)
DECLARE_TEST(PsGetCurrentProcessId);
DECLARE_TEST(PsGetCurrentThread);
DECLARE_TEST(NtBuildNumber);
+ DECLARE_TEST(ExInitializeNPagedLookasideList);
default:
break;
@@ -145,7 +178,7 @@ static NTSTATUS WINAPI driver_IoControl(DEVICE_OBJECT *device, IRP *irp)
if (status == STATUS_SUCCESS) information = sizeof(*state);
done:
- irp->IoStatus.Status = status;
+ irp->IoStatus.u.Status = status;
irp->IoStatus.Information = information;
IoCompleteRequest(irp, IO_NO_INCREMENT);
return status;
@@ -153,7 +186,7 @@ done:
static NTSTATUS WINAPI driver_Close(DEVICE_OBJECT *device, IRP *irp)
{
- irp->IoStatus.Status = STATUS_SUCCESS;
+ irp->IoStatus.u.Status = STATUS_SUCCESS;
IoCompleteRequest(irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
diff --git a/dlls/ntoskrnl.exe/tests/driver.sys/driver.h b/dlls/ntoskrnl.exe/tests/driver.sys/driver.h
index c3440cb65c2..b5b3ef4e027 100644
--- a/dlls/ntoskrnl.exe/tests/driver.sys/driver.h
+++ b/dlls/ntoskrnl.exe/tests/driver.sys/driver.h
@@ -22,9 +22,10 @@
#include "test.h"
-#define WINE_IOCTL_PsGetCurrentProcessId WINE_TEST_IOCTL(0)
-#define WINE_IOCTL_PsGetCurrentThread WINE_TEST_IOCTL(1)
-#define WINE_IOCTL_NtBuildNumber WINE_TEST_IOCTL(2)
+#define WINE_IOCTL_PsGetCurrentProcessId WINE_TEST_IOCTL(0)
+#define WINE_IOCTL_PsGetCurrentThread WINE_TEST_IOCTL(1)
+#define WINE_IOCTL_NtBuildNumber WINE_TEST_IOCTL(2)
+#define WINE_IOCTL_ExInitializeNPagedLookasideList WINE_TEST_IOCTL(3)
struct test_PsGetCurrentProcessId
{
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
index c9799ec5a3c..40e62053150 100644
--- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
@@ -208,6 +208,12 @@ static void test_NtBuildNumber(void)
wine_run_kernel_test(device_path, WINE_IOCTL_NtBuildNumber, NULL);
}
+static void test_ExInitializeNPagedLookasideList(void)
+{
+ trace("Running tests for ExInitializeNPagedLookasideList\n");
+ wine_run_kernel_test(device_path, WINE_IOCTL_ExInitializeNPagedLookasideList, NULL);
+}
+
START_TEST(ntoskrnl)
{
char filename[MAX_PATH];
@@ -222,6 +228,7 @@ START_TEST(ntoskrnl)
test_PsGetCurrentProcessId();
test_PsGetCurrentThread();
test_NtBuildNumber();
+ test_ExInitializeNPagedLookasideList();
unload_driver(service, filename);
}
--
2.13.1

View File

@ -1,194 +0,0 @@
From 276f9cb5ec799bb0919d8ae06609260daddc52cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 8 Jun 2017 23:54:59 +0200
Subject: ntoskrnl.exe/tests: Check ldr module order and some common kernel
drivers.
---
dlls/ntoskrnl.exe/tests/driver.sys/driver.c | 60 +++++++++++++++++++++++++++++
dlls/ntoskrnl.exe/tests/driver.sys/driver.h | 1 +
dlls/ntoskrnl.exe/tests/driver.sys/util.h | 18 +++++++++
dlls/ntoskrnl.exe/tests/ntoskrnl.c | 7 ++++
include/ddk/ntddk.h | 1 +
5 files changed, 87 insertions(+)
diff --git a/dlls/ntoskrnl.exe/tests/driver.sys/driver.c b/dlls/ntoskrnl.exe/tests/driver.sys/driver.c
index 39c2fb2aa50..c512f3c3f31 100644
--- a/dlls/ntoskrnl.exe/tests/driver.sys/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.sys/driver.c
@@ -31,6 +31,7 @@
#include "winbase.h"
#include "winternl.h"
#include "winioctl.h"
+#include "ddk/ntddk.h"
#include "ddk/wdm.h"
#define WINE_KERNEL
@@ -45,6 +46,8 @@ const WCHAR driver_device[] = {'\\','D','e','v','i','c','e',
const WCHAR driver_link[] = {'\\','D','o','s','D','e','v','i','c','e','s',
'\\','W','i','n','e','T','e','s','t','D','r','i','v','e','r',0};
+static LDR_MODULE *ldr_module;
+
static void *get_system_routine(const char *name)
{
UNICODE_STRING name_u;
@@ -128,6 +131,60 @@ KERNEL_TESTCASE(ExInitializeNPagedLookasideList)
return STATUS_SUCCESS;
}
+static BOOL equal_string(ANSI_STRING *str1, const char *str2)
+{
+ if (str1->Length != kernel_strlen(str2)) return FALSE;
+ return !kernel_strncmp(str1->Buffer, str2, str1->Length);
+}
+
+KERNEL_TESTCASE(LdrModules)
+{
+ BOOL win32k = FALSE, dxgkrnl = FALSE, dxgmms1 = FALSE;
+ LIST_ENTRY *start, *entry;
+ ANSI_STRING name_a;
+ LDR_MODULE *mod;
+ NTSTATUS status;
+
+ /* Try to find start of the InLoadOrderModuleList list */
+ for (start = ldr_module->InLoadOrderModuleList.Flink; ; start = start->Flink)
+ {
+ mod = CONTAINING_RECORD(start, LDR_MODULE, InLoadOrderModuleList);
+
+ if (!MmIsAddressValid(&mod->BaseAddress) || !mod->BaseAddress) break;
+ if (!MmIsAddressValid(&mod->LoadCount) || !mod->LoadCount) break;
+ if (!MmIsAddressValid(&mod->SizeOfImage) || !mod->SizeOfImage) break;
+ if (!MmIsAddressValid(&mod->EntryPoint) || mod->EntryPoint < mod->BaseAddress ||
+ (DWORD_PTR)mod->EntryPoint > (DWORD_PTR)mod->BaseAddress + mod->SizeOfImage) break;
+ }
+
+ for (entry = start->Flink; entry != start; entry = entry->Flink)
+ {
+ mod = CONTAINING_RECORD(entry, LDR_MODULE, InLoadOrderModuleList);
+
+ status = RtlUnicodeStringToAnsiString(&name_a, &mod->BaseDllName, TRUE);
+ ok(!status, "RtlUnicodeStringToAnsiString failed with %08x\n", status);
+ if (status) continue;
+
+ if (entry == start->Flink)
+ {
+ ok(equal_string(&name_a, "ntoskrnl.exe"),
+ "Expected ntoskrnl.exe, got %.*s\n", name_a.Length, name_a.Buffer);
+ }
+
+ if (equal_string(&name_a, "win32k.sys")) win32k = TRUE;
+ if (equal_string(&name_a, "dxgkrnl.sys")) dxgkrnl = TRUE;
+ if (equal_string(&name_a, "dxgmms1.sys")) dxgmms1 = TRUE;
+
+ RtlFreeAnsiString(&name_a);
+ }
+
+ ok(win32k, "Failed to find win32k.sys\n");
+ ok(dxgkrnl, "Failed to find dxgkrnl.sys\n");
+ ok(dxgmms1, "Failed to find dxgmms1.sys\n");
+
+ return STATUS_SUCCESS;
+}
+
static NTSTATUS WINAPI driver_Create(DEVICE_OBJECT *device, IRP *irp)
{
irp->IoStatus.u.Status = STATUS_SUCCESS;
@@ -167,6 +224,7 @@ static NTSTATUS WINAPI driver_IoControl(DEVICE_OBJECT *device, IRP *irp)
DECLARE_TEST(PsGetCurrentThread);
DECLARE_TEST(NtBuildNumber);
DECLARE_TEST(ExInitializeNPagedLookasideList);
+ DECLARE_TEST(LdrModules);
default:
break;
@@ -211,6 +269,8 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry)
DbgPrint("loading driver\n");
+ ldr_module = (LDR_MODULE*)driver->DriverSection;
+
/* Allow unloading of the driver */
driver->DriverUnload = driver_Unload;
diff --git a/dlls/ntoskrnl.exe/tests/driver.sys/driver.h b/dlls/ntoskrnl.exe/tests/driver.sys/driver.h
index b5b3ef4e027..7442aa55286 100644
--- a/dlls/ntoskrnl.exe/tests/driver.sys/driver.h
+++ b/dlls/ntoskrnl.exe/tests/driver.sys/driver.h
@@ -26,6 +26,7 @@
#define WINE_IOCTL_PsGetCurrentThread WINE_TEST_IOCTL(1)
#define WINE_IOCTL_NtBuildNumber WINE_TEST_IOCTL(2)
#define WINE_IOCTL_ExInitializeNPagedLookasideList WINE_TEST_IOCTL(3)
+#define WINE_IOCTL_LdrModules WINE_TEST_IOCTL(4)
struct test_PsGetCurrentProcessId
{
diff --git a/dlls/ntoskrnl.exe/tests/driver.sys/util.h b/dlls/ntoskrnl.exe/tests/driver.sys/util.h
index 881a4a2952f..07c04da40fe 100644
--- a/dlls/ntoskrnl.exe/tests/driver.sys/util.h
+++ b/dlls/ntoskrnl.exe/tests/driver.sys/util.h
@@ -31,6 +31,24 @@ static inline const char* kernel_strrchr(const char *str, int character)
return ret;
}
+static inline size_t kernel_strlen(const char *str)
+{
+ const char *ptr = str;
+ while (*ptr) ptr++;
+ return ptr - str;
+}
+
+static inline int kernel_strncmp(const char *str1, const char *str2, size_t len)
+{
+ if (!len) return 0;
+ while (--len && *str1 && *str1 == *str2)
+ {
+ str1++;
+ str2++;
+ }
+ return *str1 - *str2;
+}
+
static inline void* kernel_memcpy(void *destination, const void *source, size_t num)
{
const char *src = source;
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
index 40e62053150..abd62520b95 100644
--- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
@@ -214,6 +214,12 @@ static void test_ExInitializeNPagedLookasideList(void)
wine_run_kernel_test(device_path, WINE_IOCTL_ExInitializeNPagedLookasideList, NULL);
}
+static void test_LdrModules(void)
+{
+ trace("Running tests for LdrModules\n");
+ wine_run_kernel_test(device_path, WINE_IOCTL_LdrModules, NULL);
+}
+
START_TEST(ntoskrnl)
{
char filename[MAX_PATH];
@@ -229,6 +235,7 @@ START_TEST(ntoskrnl)
test_PsGetCurrentThread();
test_NtBuildNumber();
test_ExInitializeNPagedLookasideList();
+ test_LdrModules();
unload_driver(service, filename);
}
diff --git a/include/ddk/ntddk.h b/include/ddk/ntddk.h
index 6aae257770d..7a565aae105 100644
--- a/include/ddk/ntddk.h
+++ b/include/ddk/ntddk.h
@@ -196,6 +196,7 @@ NTSTATUS WINAPI IoQueryDeviceDescription(PINTERFACE_TYPE,PULONG,PCONFIGURATION_
PCONFIGURATION_TYPE,PULONG,PIO_QUERY_DEVICE_ROUTINE,PVOID);
void WINAPI IoRegisterDriverReinitialization(PDRIVER_OBJECT,PDRIVER_REINITIALIZE,PVOID);
NTSTATUS WINAPI IoRegisterShutdownNotification(PDEVICE_OBJECT);
+BOOLEAN WINAPI MmIsAddressValid(void *);
NTSTATUS WINAPI PsSetLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE);
void WINAPI RtlInitializeGenericTableAvl(PRTL_AVL_TABLE,PRTL_AVL_COMPARE_ROUTINE,PRTL_AVL_ALLOCATE_ROUTINE, PRTL_AVL_FREE_ROUTINE,void *);
void WINAPI RtlInsertElementGenericTableAvl(PRTL_AVL_TABLE,void *,ULONG,BOOL*);
--
2.13.1

View File

@ -1,4 +0,0 @@
Fixes: Implement ntoskrnl driver testing framework.
Depends: ntoskrnl-Stubs
Depends: winedevice-Default_Drivers
Disabled: true

View File

@ -1,4 +1,4 @@
From 44d20d13197dfd845a2fb6f7f40bac51e089e5ef Mon Sep 17 00:00:00 2001
From 7c5d975bef7261f253bf80f4ae5a0e424073d480 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Tue, 6 Jun 2017 21:08:51 +0200
Subject: ntoskrnl.exe: Implement NtBuildNumber.
@ -6,10 +6,12 @@ Subject: ntoskrnl.exe: Implement NtBuildNumber.
---
dlls/ntoskrnl.exe/ntoskrnl.c | 11 +++++++++--
dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 2 +-
2 files changed, 10 insertions(+), 3 deletions(-)
dlls/ntoskrnl.exe/tests/driver.c | 30 ++++++++++++++++++++++++++++++
include/ddk/wdm.h | 1 +
4 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index a263941..3059dfb 100644
index ae699dc..21507dc 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -52,6 +52,7 @@ WINE_DECLARE_DEBUG_CHANNEL(plugplay);
@ -20,7 +22,7 @@ index a263941..3059dfb 100644
extern LONG CALLBACK vectored_handler( EXCEPTION_POINTERS *ptrs );
@@ -2655,6 +2656,13 @@ NTSTATUS WINAPI IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock, PVOID tag,
@@ -2724,6 +2725,13 @@ NTSTATUS WINAPI IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock, PVOID tag,
return STATUS_NOT_IMPLEMENTED;
}
@ -34,7 +36,7 @@ index a263941..3059dfb 100644
/*****************************************************
* DllMain
@@ -2662,7 +2670,6 @@ NTSTATUS WINAPI IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock, PVOID tag,
@@ -2731,7 +2739,6 @@ NTSTATUS WINAPI IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock, PVOID tag,
BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
{
static void *handler;
@ -42,7 +44,7 @@ index a263941..3059dfb 100644
switch(reason)
{
@@ -2671,7 +2678,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
@@ -2740,7 +2747,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
#if defined(__i386__) || defined(__x86_64__)
handler = RtlAddVectoredExceptionHandler( TRUE, vectored_handler );
#endif
@ -52,10 +54,10 @@ index a263941..3059dfb 100644
case DLL_PROCESS_DETACH:
if (reserved) break;
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
index 134cf71..34b1f52 100644
index fc2fd94..7c40d5c 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
+++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
@@ -742,7 +742,7 @@
@@ -743,7 +743,7 @@
@ stdcall NtAllocateLocallyUniqueId(ptr)
@ stdcall NtAllocateUuids(ptr ptr ptr ptr)
@ stdcall NtAllocateVirtualMemory(long ptr long ptr long long)
@ -64,6 +66,73 @@ index 134cf71..34b1f52 100644
@ stdcall NtClose(long)
@ stdcall NtConnectPort(ptr ptr ptr ptr ptr ptr ptr ptr)
@ stdcall NtCreateEvent(ptr long ptr long long)
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c
index 84cfff7..5fe997a 100644
--- a/dlls/ntoskrnl.exe/tests/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.c
@@ -143,6 +143,22 @@ static void winetest_end_todo(void)
#define todo_wine todo_if(running_under_wine)
#define todo_wine_if(is_todo) todo_if((is_todo) && running_under_wine)
+static void *get_proc_address(const char *name)
+{
+ UNICODE_STRING name_u;
+ ANSI_STRING name_a;
+ NTSTATUS status;
+ void *ret;
+
+ RtlInitAnsiString(&name_a, name);
+ status = RtlAnsiStringToUnicodeString(&name_u, &name_a, TRUE);
+ if (status) return NULL;
+
+ ret = MmGetSystemRoutineAddress(&name_u);
+ RtlFreeUnicodeString(&name_u);
+ return ret;
+}
+
static void test_currentprocess(void)
{
PEPROCESS current;
@@ -172,6 +188,19 @@ todo_wine
IoFreeMdl(mdl);
}
+static void test_version(void)
+{
+ USHORT *pNtBuildNumber;
+ ULONG build;
+
+ pNtBuildNumber = get_proc_address("NtBuildNumber");
+ ok(!!pNtBuildNumber, "Could not get pointer to NtBuildNumber\n");
+
+ PsGetVersion(NULL, NULL, &build, NULL);
+ ok(*pNtBuildNumber == build, "Expected build number %u, got %u\n", build, *pNtBuildNumber);
+ return;
+}
+
static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
{
ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength;
@@ -197,6 +226,7 @@ static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
test_currentprocess();
test_mdl_map();
+ test_version();
/* print process report */
if (test_input->winetest_debug)
diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h
index cab9828..d6b808f 100644
--- a/include/ddk/wdm.h
+++ b/include/ddk/wdm.h
@@ -1421,6 +1421,7 @@ PVOID WINAPI MmAllocateContiguousMemory(SIZE_T,PHYSICAL_ADDRESS);
PVOID WINAPI MmAllocateNonCachedMemory(SIZE_T);
PMDL WINAPI MmAllocatePagesForMdl(PHYSICAL_ADDRESS,PHYSICAL_ADDRESS,PHYSICAL_ADDRESS,SIZE_T);
void WINAPI MmFreeNonCachedMemory(PVOID,SIZE_T);
+void * WINAPI MmGetSystemRoutineAddress(UNICODE_STRING*);
PVOID WINAPI MmMapLockedPagesSpecifyCache(PMDL,KPROCESSOR_MODE,MEMORY_CACHING_TYPE,PVOID,ULONG,ULONG);
MM_SYSTEMSIZE WINAPI MmQuerySystemSize(void);
void WINAPI MmProbeAndLockPages(PMDLX, KPROCESSOR_MODE, LOCK_OPERATION);
--
2.7.4

View File

@ -1,16 +1,17 @@
From 8f1d4c0a6fec701d3af943188952d55f8b56582a Mon Sep 17 00:00:00 2001
From e4a32c13ea03d6bfc08f78d93b517d612005a395 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Tue, 6 Jun 2017 23:42:56 +0200
Subject: ntoskrnl.exe: Implement ExInitializeNPagedLookasideList.
---
dlls/ntoskrnl.exe/ntoskrnl.c | 19 ++++++++++-
include/ddk/wdm.h | 76 ++++++++++++++++++++++++++++++++++++++++++--
include/winnt.h | 2 ++
3 files changed, 93 insertions(+), 4 deletions(-)
dlls/ntoskrnl.exe/ntoskrnl.c | 19 +++++++++-
dlls/ntoskrnl.exe/tests/driver.c | 37 +++++++++++++++++--
include/ddk/wdm.h | 76 ++++++++++++++++++++++++++++++++++++++--
include/winnt.h | 2 ++
4 files changed, 127 insertions(+), 7 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 81f5738..a9f7029 100644
index 21507dc..a865cd8 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -1814,7 +1814,24 @@ void WINAPI ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
@ -39,8 +40,90 @@ index 81f5738..a9f7029 100644
}
/***********************************************************************
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c
index 5fe997a..1ef27fb 100644
--- a/dlls/ntoskrnl.exe/tests/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.c
@@ -22,6 +22,9 @@
#include <stdarg.h>
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
@@ -201,6 +204,33 @@ static void test_version(void)
return;
}
+static void test_lookaside_list(void)
+{
+ NPAGED_LOOKASIDE_LIST list;
+ ULONG tag = 0x454e4957; /* WINE */
+
+ ExInitializeNPagedLookasideList(&list, NULL, NULL, POOL_NX_ALLOCATION, LOOKASIDE_MINIMUM_BLOCK_SIZE, tag, 0);
+ ok(list.L.Depth == 4, "Expected 4 got %u\n", list.L.Depth);
+ ok(list.L.MaximumDepth == 256, "Expected 256 got %u\n", list.L.MaximumDepth);
+ ok(list.L.TotalAllocates == 0, "Expected 0 got %u\n", list.L.TotalAllocates);
+ ok(list.L.u2.AllocateMisses == 0, "Expected 0 got %u\n", list.L.u2.AllocateMisses);
+ ok(list.L.TotalFrees == 0, "Expected 0 got %u\n", list.L.TotalFrees);
+ ok(list.L.u3.FreeMisses == 0, "Expected 0 got %u\n", list.L.u3.FreeMisses);
+ ok(list.L.Type == (NonPagedPool|POOL_NX_ALLOCATION),
+ "Expected NonPagedPool|POOL_NX_ALLOCATION got %u\n", list.L.Type);
+ ok(list.L.Tag == tag, "Expected %x got %x\n", tag, list.L.Tag);
+ ok(list.L.Size == LOOKASIDE_MINIMUM_BLOCK_SIZE,
+ "Expected %u got %u\n", LOOKASIDE_MINIMUM_BLOCK_SIZE, list.L.Size);
+ ok(list.L.LastTotalAllocates == 0,"Expected 0 got %u\n", list.L.LastTotalAllocates);
+ ok(list.L.u6.LastAllocateMisses == 0,"Expected 0 got %u\n", list.L.u6.LastAllocateMisses);
+ ExDeleteNPagedLookasideList(&list);
+
+ list.L.Depth = 0;
+ ExInitializeNPagedLookasideList(&list, NULL, NULL, 0, LOOKASIDE_MINIMUM_BLOCK_SIZE, tag, 20);
+ ok(list.L.Depth == 4, "Expected 4 got %u\n", list.L.Depth);
+ ExDeleteNPagedLookasideList(&list);
+}
+
static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
{
ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength;
@@ -227,6 +257,7 @@ static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
test_currentprocess();
test_mdl_map();
test_version();
+ test_lookaside_list();
/* print process report */
if (test_input->winetest_debug)
@@ -261,7 +292,7 @@ static NTSTATUS test_basic_ioctl(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *
static NTSTATUS WINAPI driver_Create(DEVICE_OBJECT *device, IRP *irp)
{
- irp->IoStatus.Status = STATUS_SUCCESS;
+ irp->IoStatus.u.Status = STATUS_SUCCESS;
IoCompleteRequest(irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
@@ -283,14 +314,14 @@ static NTSTATUS WINAPI driver_IoControl(DEVICE_OBJECT *device, IRP *irp)
break;
}
- irp->IoStatus.Status = status;
+ irp->IoStatus.u.Status = status;
IoCompleteRequest(irp, IO_NO_INCREMENT);
return status;
}
static NTSTATUS WINAPI driver_Close(DEVICE_OBJECT *device, IRP *irp)
{
- irp->IoStatus.Status = STATUS_SUCCESS;
+ irp->IoStatus.u.Status = STATUS_SUCCESS;
IoCompleteRequest(irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h
index 8634f36..8453079 100644
index d6b808f..b43ec62 100644
--- a/include/ddk/wdm.h
+++ b/include/ddk/wdm.h
@@ -144,20 +144,18 @@ typedef enum _KWAIT_REASON

View File

@ -1864,7 +1864,11 @@ if test "$enable_winedevice_Default_Drivers" -eq 1; then
if test "$enable_dxva2_Video_Decoder" -gt 1; then
abort "Patchset dxva2-Video_Decoder disabled, but winedevice-Default_Drivers depends on that."
fi
if test "$enable_ntoskrnl_Stubs" -gt 1; then
abort "Patchset ntoskrnl-Stubs disabled, but winedevice-Default_Drivers depends on that."
fi
enable_dxva2_Video_Decoder=1
enable_ntoskrnl_Stubs=1
fi
if test "$enable_wined3d_Indexed_Vertex_Blending" -eq 1; then
@ -5673,7 +5677,8 @@ fi
# | * [#37355] Add stub for ntoskrnl.Mm{Map,Unmap}LockedPages
# |
# | Modified files:
# | * dlls/ntoskrnl.exe/ntoskrnl.c, dlls/ntoskrnl.exe/ntoskrnl.exe.spec, include/ddk/wdm.h, include/winnt.h
# | * dlls/ntoskrnl.exe/ntoskrnl.c, dlls/ntoskrnl.exe/ntoskrnl.exe.spec, dlls/ntoskrnl.exe/tests/driver.c, include/ddk/wdm.h,
# | include/winnt.h
# |
if test "$enable_ntoskrnl_Stubs" -eq 1; then
patch_apply ntoskrnl-Stubs/0005-ntoskrnl.exe-Improve-KeReleaseMutex-stub.patch
@ -7997,13 +8002,13 @@ fi
# Patchset winedevice-Default_Drivers
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * dxva2-Video_Decoder
# | * dxva2-Video_Decoder, Compiler_Warnings, ntoskrnl-Stubs
# |
# | Modified files:
# | * configure.ac, dlls/dxgkrnl.sys/Makefile.in, dlls/dxgkrnl.sys/dxgkrnl.sys.spec, dlls/dxgkrnl.sys/main.c,
# | dlls/dxgmms1.sys/Makefile.in, dlls/dxgmms1.sys/dxgmms1.sys.spec, dlls/dxgmms1.sys/main.c, dlls/win32k.sys/Makefile.in,
# | dlls/win32k.sys/main.c, dlls/win32k.sys/win32k.sys.spec, loader/wine.inf.in, programs/winedevice/device.c,
# | tools/make_specfiles
# | dlls/dxgmms1.sys/Makefile.in, dlls/dxgmms1.sys/dxgmms1.sys.spec, dlls/dxgmms1.sys/main.c,
# | dlls/ntoskrnl.exe/tests/driver.c, dlls/win32k.sys/Makefile.in, dlls/win32k.sys/main.c, dlls/win32k.sys/win32k.sys.spec,
# | include/ddk/ntddk.h, loader/wine.inf.in, programs/winedevice/device.c, tools/make_specfiles
# |
if test "$enable_winedevice_Default_Drivers" -eq 1; then
patch_apply winedevice-Default_Drivers/0001-win32k.sys-Add-stub-driver.patch

View File

@ -1,17 +1,122 @@
From 5148db493d915193f38d4b7f4f555030a8e9c476 Mon Sep 17 00:00:00 2001
From 0b0d7c4983de54b3ca98a52a4afdd55c92a53031 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 8 Jun 2017 23:50:03 +0200
Subject: programs/winedevice: Load some common drivers and fix ldr order.
---
programs/winedevice/device.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
dlls/ntoskrnl.exe/tests/driver.c | 52 ++++++++++++++++++++++++++++++++++++++++
include/ddk/ntddk.h | 1 +
programs/winedevice/device.c | 26 ++++++++++++++++++++
3 files changed, 79 insertions(+)
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c
index 1ef27fb..6bf2e76 100644
--- a/dlls/ntoskrnl.exe/tests/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.c
@@ -31,6 +31,7 @@
#include "winbase.h"
#include "winternl.h"
#include "winioctl.h"
+#include "ddk/ntddk.h"
#include "ddk/wdm.h"
#include "driver.h"
@@ -40,6 +41,8 @@ static const WCHAR driver_device[] = {'\\','D','e','v','i','c','e',
static const WCHAR driver_link[] = {'\\','D','o','s','D','e','v','i','c','e','s',
'\\','W','i','n','e','T','e','s','t','D','r','i','v','e','r',0};
+static LDR_MODULE *ldr_module;
+
static HANDLE okfile;
static LONG successes;
static LONG failures;
@@ -231,6 +234,52 @@ static void test_lookaside_list(void)
ExDeleteNPagedLookasideList(&list);
}
+static void test_default_modules(void)
+{
+ BOOL win32k = FALSE, dxgkrnl = FALSE, dxgmms1 = FALSE;
+ LIST_ENTRY *start, *entry;
+ ANSI_STRING name_a;
+ LDR_MODULE *mod;
+ NTSTATUS status;
+
+ /* Try to find start of the InLoadOrderModuleList list */
+ for (start = ldr_module->InLoadOrderModuleList.Flink; ; start = start->Flink)
+ {
+ mod = CONTAINING_RECORD(start, LDR_MODULE, InLoadOrderModuleList);
+
+ if (!MmIsAddressValid(&mod->BaseAddress) || !mod->BaseAddress) break;
+ if (!MmIsAddressValid(&mod->LoadCount) || !mod->LoadCount) break;
+ if (!MmIsAddressValid(&mod->SizeOfImage) || !mod->SizeOfImage) break;
+ if (!MmIsAddressValid(&mod->EntryPoint) || mod->EntryPoint < mod->BaseAddress ||
+ (DWORD_PTR)mod->EntryPoint > (DWORD_PTR)mod->BaseAddress + mod->SizeOfImage) break;
+ }
+
+ for (entry = start->Flink; entry != start; entry = entry->Flink)
+ {
+ mod = CONTAINING_RECORD(entry, LDR_MODULE, InLoadOrderModuleList);
+
+ status = RtlUnicodeStringToAnsiString(&name_a, &mod->BaseDllName, TRUE);
+ ok(!status, "RtlUnicodeStringToAnsiString failed with %08x\n", status);
+ if (status) continue;
+
+ if (entry == start->Flink)
+ {
+ ok(!strncmp(name_a.Buffer, "ntoskrnl.exe", name_a.Length),
+ "Expected ntoskrnl.exe, got %.*s\n", name_a.Length, name_a.Buffer);
+ }
+
+ if (!strncmp(name_a.Buffer, "win32k.sys", name_a.Length)) win32k = TRUE;
+ if (!strncmp(name_a.Buffer, "dxgkrnl.sys", name_a.Length)) dxgkrnl = TRUE;
+ if (!strncmp(name_a.Buffer, "dxgmms1.sys", name_a.Length)) dxgmms1 = TRUE;
+
+ RtlFreeAnsiString(&name_a);
+ }
+
+ ok(win32k, "Failed to find win32k.sys\n");
+ ok(dxgkrnl, "Failed to find dxgkrnl.sys\n");
+ ok(dxgmms1, "Failed to find dxgmms1.sys\n");
+}
+
static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
{
ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength;
@@ -258,6 +307,7 @@ static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
test_mdl_map();
test_version();
test_lookaside_list();
+ test_default_modules();
/* print process report */
if (test_input->winetest_debug)
@@ -346,6 +396,8 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry)
DbgPrint("loading driver\n");
+ ldr_module = (LDR_MODULE *)driver->DriverSection;
+
/* Allow unloading of the driver */
driver->DriverUnload = driver_Unload;
diff --git a/include/ddk/ntddk.h b/include/ddk/ntddk.h
index 5c124ca..e76ccc9 100644
--- a/include/ddk/ntddk.h
+++ b/include/ddk/ntddk.h
@@ -214,6 +214,7 @@ NTSTATUS WINAPI IoQueryDeviceDescription(PINTERFACE_TYPE,PULONG,PCONFIGURATION_
PCONFIGURATION_TYPE,PULONG,PIO_QUERY_DEVICE_ROUTINE,PVOID);
void WINAPI IoRegisterDriverReinitialization(PDRIVER_OBJECT,PDRIVER_REINITIALIZE,PVOID);
NTSTATUS WINAPI IoRegisterShutdownNotification(PDEVICE_OBJECT);
+BOOLEAN WINAPI MmIsAddressValid(void *);
NTSTATUS WINAPI PsSetLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE);
void WINAPI RtlInitializeGenericTableAvl(PRTL_AVL_TABLE,PRTL_AVL_COMPARE_ROUTINE,PRTL_AVL_ALLOCATE_ROUTINE, PRTL_AVL_FREE_ROUTINE,void *);
void WINAPI RtlInsertElementGenericTableAvl(PRTL_AVL_TABLE,void *,ULONG,BOOL*);
diff --git a/programs/winedevice/device.c b/programs/winedevice/device.c
index b2eb0eed7f2..90bf9d6f9cc 100644
index fa8b268..aad5981 100644
--- a/programs/winedevice/device.c
+++ b/programs/winedevice/device.c
@@ -583,7 +583,33 @@ static DWORD WINAPI service_handler( DWORD ctrl, DWORD event_type, LPVOID event_
@@ -560,7 +560,33 @@ static DWORD WINAPI service_handler( DWORD ctrl, DWORD event_type, LPVOID event_
static void WINAPI ServiceMain( DWORD argc, LPWSTR *argv )
{
@ -46,5 +151,5 @@ index b2eb0eed7f2..90bf9d6f9cc 100644
if (!(stop_event = CreateEventW( NULL, TRUE, FALSE, NULL )))
return;
--
2.13.1
2.7.4

View File

@ -1,2 +1,3 @@
Fixes: Simulate a more realistic kernel environment in ntoskrnl/winedevice
Depends: dxva2-Video_Decoder
Depends: ntoskrnl-Stubs