diff --git a/patches/ntoskrnl-DriverTest/0002-ntoskrnl.exe-tests-Add-kernel-compliant-test-functio.patch b/patches/ntoskrnl-DriverTest/0002-ntoskrnl.exe-tests-Add-kernel-compliant-test-functio.patch index 5a9e3217..eacf0eb6 100644 --- a/patches/ntoskrnl-DriverTest/0002-ntoskrnl.exe-tests-Add-kernel-compliant-test-functio.patch +++ b/patches/ntoskrnl-DriverTest/0002-ntoskrnl.exe-tests-Add-kernel-compliant-test-functio.patch @@ -1,4 +1,4 @@ -From f928d6182289fb703fff3bd549b9df9b6a6558c6 Mon Sep 17 00:00:00 2001 +From 8c09da5559b124f97fd5f24540c25b28009562f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Tue, 20 Jan 2015 18:39:36 +0100 Subject: ntoskrnl.exe/tests: Add kernel compliant test functions. @@ -6,23 +6,23 @@ Subject: ntoskrnl.exe/tests: Add kernel compliant test functions. --- dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 2 +- dlls/ntoskrnl.exe/tests/driver.sys/Makefile.in | 3 +- - dlls/ntoskrnl.exe/tests/driver.sys/driver.c | 38 ++--- - dlls/ntoskrnl.exe/tests/driver.sys/driver.h | 18 ++- + dlls/ntoskrnl.exe/tests/driver.sys/driver.c | 65 ++++++--- + dlls/ntoskrnl.exe/tests/driver.sys/driver.h | 11 +- dlls/ntoskrnl.exe/tests/driver.sys/test.c | 195 +++++++++++++++++++++++++ - dlls/ntoskrnl.exe/tests/driver.sys/test.h | 181 +++++++++++++++++++++++ + dlls/ntoskrnl.exe/tests/driver.sys/test.h | 158 ++++++++++++++++++++ dlls/ntoskrnl.exe/tests/driver.sys/util.h | 47 ++++++ - dlls/ntoskrnl.exe/tests/ntoskrnl.c | 53 +++++-- + dlls/ntoskrnl.exe/tests/ntoskrnl.c | 36 ++--- include/wine/test.h | 39 ++++- - 9 files changed, 535 insertions(+), 41 deletions(-) + 9 files changed, 509 insertions(+), 47 deletions(-) create mode 100644 dlls/ntoskrnl.exe/tests/driver.sys/test.c create mode 100644 dlls/ntoskrnl.exe/tests/driver.sys/test.h create mode 100644 dlls/ntoskrnl.exe/tests/driver.sys/util.h diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec -index 1319ada..06794ba 100644 +index 25649c9b3b6..99c5749c6cf 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec -@@ -1423,7 +1423,7 @@ +@@ -1427,7 +1427,7 @@ @ cdecl -private _strrev(str) msvcrt._strrev @ cdecl -private _strset(str long) msvcrt._strset @ cdecl -private _strupr(str) msvcrt._strupr @@ -32,7 +32,7 @@ index 1319ada..06794ba 100644 @ cdecl -private _wcsicmp(wstr wstr) msvcrt._wcsicmp @ cdecl -private _wcslwr(wstr) msvcrt._wcslwr diff --git a/dlls/ntoskrnl.exe/tests/driver.sys/Makefile.in b/dlls/ntoskrnl.exe/tests/driver.sys/Makefile.in -index bc040e4..b3a6839 100644 +index 1c49b2bd5cd..b200eec7e95 100644 --- a/dlls/ntoskrnl.exe/tests/driver.sys/Makefile.in +++ b/dlls/ntoskrnl.exe/tests/driver.sys/Makefile.in @@ -8,4 +8,5 @@ CROSSFLAGS = -nostartfiles -nostdlib -nodefaultlibs \ @@ -43,7 +43,7 @@ index bc040e4..b3a6839 100644 + driver.c \ + test.c diff --git a/dlls/ntoskrnl.exe/tests/driver.sys/driver.c b/dlls/ntoskrnl.exe/tests/driver.sys/driver.c -index 35f78d1..f39aa37 100644 +index 35f78d1ab2f..78fb55a961c 100644 --- a/dlls/ntoskrnl.exe/tests/driver.sys/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.sys/driver.c @@ -30,6 +30,9 @@ @@ -56,11 +56,17 @@ index 35f78d1..f39aa37 100644 #include "driver.h" const WCHAR driver_device[] = {'\\','D','e','v','i','c','e', -@@ -37,24 +40,17 @@ const WCHAR driver_device[] = {'\\','D','e','v','i','c','e', +@@ -37,24 +40,25 @@ 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}; -- ++/* In each kernel testcase the following variables are available: ++ * ++ * device - DEVICE_OBJECT used for ioctl ++ * irp - IRP pointer passed to ioctl ++ * __state - used internally for test macros ++ */ + -static NTSTATUS test_basic_ioctl(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info) +KERNEL_TESTCASE(PsGetCurrentProcessId) { @@ -77,8 +83,9 @@ index 35f78d1..f39aa37 100644 - - for (i = 0; i < sizeof(str)-1; i++) - buffer[i] = str[i]; -+ test->processid = (DWORD)(ULONG_PTR)PsGetCurrentProcessId(); -+ ok(test->processid, "Expected processid to be non zero\n"); ++ struct test_PsGetCurrentProcessId *test = (void *)&__state->userdata; ++ test->pid = (DWORD)(ULONG_PTR)PsGetCurrentProcessId(); ++ ok(test->pid, "Expected processid to be non zero\n"); + return STATUS_SUCCESS; +} @@ -90,12 +97,32 @@ index 35f78d1..f39aa37 100644 return STATUS_SUCCESS; } -@@ -72,16 +68,20 @@ static NTSTATUS WINAPI driver_IoControl(DEVICE_OBJECT *device, IRP *irp) +@@ -69,19 +73,44 @@ static NTSTATUS WINAPI driver_Create(DEVICE_OBJECT *device, IRP *irp) + static NTSTATUS WINAPI driver_IoControl(DEVICE_OBJECT *device, IRP *irp) + { + IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp); ++ struct kernel_test_state *state = irp->AssociatedIrp.SystemBuffer; NTSTATUS status = STATUS_NOT_SUPPORTED; ULONG_PTR information = 0; ++ if (!state) ++ { ++ status = STATUS_ACCESS_VIOLATION; ++ goto done; ++ } ++ ++ if (stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(*state) || ++ stack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(*state)) ++ { ++ status = STATUS_BUFFER_TOO_SMALL; ++ goto done; ++ } ++ ++ kernel_memset(&state->temp, 0, sizeof(state->temp)); ++ kernel_memset(&state->output, 0, sizeof(state->output)); ++ +#define DECLARE_TEST(name) \ -+ case WINE_IOCTL_##name: status = RUN_TESTCASE(name, irp, stack, &information); break; ++ case WINE_IOCTL_##name: status = test_##name(device, irp, state); break; + switch (stack->Parameters.DeviceIoControl.IoControlCode) { @@ -111,14 +138,18 @@ index 35f78d1..f39aa37 100644 +#undef DECLARE_TEST + ++ kernel_memset(&state->temp, 0, sizeof(state->temp)); ++ if (status == STATUS_SUCCESS) information = sizeof(*state); ++ ++done: irp->IoStatus.Status = status; irp->IoStatus.Information = information; IoCompleteRequest(irp, IO_NO_INCREMENT); diff --git a/dlls/ntoskrnl.exe/tests/driver.sys/driver.h b/dlls/ntoskrnl.exe/tests/driver.sys/driver.h -index 372e908..e48bbdd 100644 +index 372e9080896..1af2dcec249 100644 --- a/dlls/ntoskrnl.exe/tests/driver.sys/driver.h +++ b/dlls/ntoskrnl.exe/tests/driver.sys/driver.h -@@ -20,9 +20,19 @@ +@@ -20,9 +20,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ @@ -129,22 +160,15 @@ index 372e908..e48bbdd 100644 - */ +#define WINE_IOCTL_PsGetCurrentProcessId WINE_TEST_IOCTL(0) +#define WINE_IOCTL_PsGetCurrentThread WINE_TEST_IOCTL(1) -+ -+struct test_PsGetCurrentProcessId_state -+{ -+ struct kernel_test_state __state; -+ DWORD processid; /* output */ -+}; -+ -+struct test_PsGetCurrentThread_state -+{ -+ struct kernel_test_state __state; -+}; -#define IOCTL_WINETEST_BASIC_IOCTL CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS) ++struct test_PsGetCurrentProcessId ++{ ++ DWORD pid; ++}; diff --git a/dlls/ntoskrnl.exe/tests/driver.sys/test.c b/dlls/ntoskrnl.exe/tests/driver.sys/test.c new file mode 100644 -index 0000000..01adf60 +index 00000000000..01adf609371 --- /dev/null +++ b/dlls/ntoskrnl.exe/tests/driver.sys/test.c @@ -0,0 +1,195 @@ @@ -345,10 +369,10 @@ index 0000000..01adf60 +} diff --git a/dlls/ntoskrnl.exe/tests/driver.sys/test.h b/dlls/ntoskrnl.exe/tests/driver.sys/test.h new file mode 100644 -index 0000000..6f1df76 +index 00000000000..65d08c0d645 --- /dev/null +++ b/dlls/ntoskrnl.exe/tests/driver.sys/test.h -@@ -0,0 +1,181 @@ +@@ -0,0 +1,158 @@ +/* + * ntoskrnl.exe testing framework + * @@ -374,6 +398,7 @@ index 0000000..6f1df76 + +struct kernel_test_state +{ ++ char userdata[1024]; + struct + { + int debug_level; @@ -443,66 +468,42 @@ index 0000000..6f1df76 + winetest_end_todo(__state, windows)) +#define todo_wine todo(0) + -+#define KERNEL_TESTCASE(name) \ -+ static NTSTATUS test_##name(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info, \ -+ struct test_##name##_state *test, struct kernel_test_state *__state); \ -+ \ -+ static NTSTATUS __test_##name(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info) \ -+ { \ -+ ULONG input_length = stack->Parameters.DeviceIoControl.InputBufferLength; \ -+ ULONG output_length = stack->Parameters.DeviceIoControl.OutputBufferLength; \ -+ struct kernel_test_state *state = irp->AssociatedIrp.SystemBuffer; \ -+ NTSTATUS status; \ -+ \ -+ if (!state) \ -+ return STATUS_ACCESS_VIOLATION; \ -+ \ -+ if (input_length < sizeof(struct test_##name##_state) || \ -+ output_length < sizeof(struct test_##name##_state)) \ -+ return STATUS_BUFFER_TOO_SMALL; \ -+ \ -+ kernel_memset(&state->temp, 0, sizeof(state->temp)); \ -+ kernel_memset(&state->output, 0, sizeof(state->output)); \ -+ status = test_##name(irp, stack, info, irp->AssociatedIrp.SystemBuffer, state); \ -+ \ -+ kernel_memset(&state->temp, 0, sizeof(state->temp)); \ -+ *info = sizeof(struct test_##name##_state); \ -+ return status; \ -+ } \ -+ \ -+ static NTSTATUS test_##name(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info, \ -+ struct test_##name##_state *test, struct kernel_test_state *__state) -+ -+#define RUN_TESTCASE(name, irp, stack, info) \ -+ __test_##name(irp, stack, info) ++#define KERNEL_TESTCASE(name) \ ++ static NTSTATUS test_##name(DEVICE_OBJECT *device, IRP *irp, \ ++ struct kernel_test_state *__state) + +#else + +#include + -+#define wine_run_kernel_test(device, ioctl, state, size, returned) \ -+ __wine_run_kernel_test(__FILE__, __LINE__, device, ioctl, state, size, returned) ++#define wine_run_kernel_test(device_path, ioctl, state) \ ++ __wine_run_kernel_test(__FILE__, __LINE__, device_path, ioctl, state) + -+static BOOL __wine_run_kernel_test(const char* file, int line, HANDLE device, DWORD ioctl, -+ void *data, DWORD size, DWORD *returned) ++static void __wine_run_kernel_test(const char *file, int line, const char *device_path, ++ DWORD ioctl, struct kernel_test_state *state) +{ -+ struct kernel_test_state *state = data; -+ DWORD bytes_returned; -+ BOOL res; ++ struct kernel_test_state temp_state; ++ DWORD returned; ++ HANDLE device; ++ BOOL ret; + -+ if (!returned) -+ returned = &bytes_returned; ++ device = CreateFileA(device_path, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); ++ ok_(file, line)(device != INVALID_HANDLE_VALUE, "CreateFileA failed with error %u\n", GetLastError()); ++ if (device == INVALID_HANDLE_VALUE) return; ++ ++ if (!state) ++ { ++ state = &temp_state; ++ memset(state, 0, sizeof(*state)); ++ } + -+ memset(state, 0, sizeof(*state)); + state->input.debug_level = winetest_get_debug(); + state->input.report_success = winetest_get_report_success(); + state->input.windows = !strcmp(winetest_platform, "windows"); + -+ res = DeviceIoControl(device, ioctl, data, size, data, size, returned, NULL); -+ -+ if (returned == &bytes_returned) -+ ok_(file, line)(bytes_returned == size, -+ "DeviceIoControl returned %u bytes, expected %u bytes\n", bytes_returned, size); ++ ret = DeviceIoControl(device, ioctl, state, sizeof(*state), state, sizeof(*state), &returned, NULL); ++ ok_(file, line)(ret, "DeviceIoControl failed with error %u\n", GetLastError()); ++ ok_(file, line)(returned == sizeof(*state), "DeviceIoControl returned %u bytes\n", returned); + + if (state->output.offset >= sizeof(state->output.debug)) + state->output.offset = sizeof(state->output.debug) - 1; @@ -524,7 +525,7 @@ index 0000000..6f1df76 + winetest_add_todo_successes(state->output.todo_successes); + winetest_add_skipped(state->output.skipped); + -+ return res; ++ CloseHandle(device); +} + +#endif @@ -532,7 +533,7 @@ index 0000000..6f1df76 +#endif /* _WINE_KERNEL_TEST_ */ diff --git a/dlls/ntoskrnl.exe/tests/driver.sys/util.h b/dlls/ntoskrnl.exe/tests/driver.sys/util.h new file mode 100644 -index 0000000..881a4a2 +index 00000000000..881a4a2952f --- /dev/null +++ b/dlls/ntoskrnl.exe/tests/driver.sys/util.h @@ -0,0 +1,47 @@ @@ -584,7 +585,7 @@ index 0000000..881a4a2 + return ptr; +} diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c -index 9b8a6a7..64e9d97 100644 +index 9b8a6a7c5b0..6f020101b4c 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -25,6 +25,7 @@ @@ -595,7 +596,7 @@ index 9b8a6a7..64e9d97 100644 #include "driver.sys/driver.h" static const char driver_name[] = "WineTestDriver"; -@@ -184,29 +185,52 @@ err: +@@ -184,29 +185,21 @@ err: return NULL; } @@ -606,62 +607,38 @@ index 9b8a6a7..64e9d97 100644 - DWORD bytes_returned; - char buf[32]; - HANDLE file; -+ struct test_PsGetCurrentProcessId_state state; -+ DWORD processid; -+ HANDLE device; - BOOL res; +- BOOL res; ++ struct kernel_test_state state; ++ struct test_PsGetCurrentProcessId *test = (void *)&state.userdata; - file = CreateFileA(device_path, GENERIC_READ | GENERIC_WRITE, - 0, NULL, OPEN_EXISTING, 0, NULL); - if (file == INVALID_HANDLE_VALUE) -+ trace("Running tests for PsGetCurrentProcessId\n"); -+ -+ device = CreateFileA(device_path, GENERIC_READ | GENERIC_WRITE, -+ 0, NULL, OPEN_EXISTING, 0, NULL); -+ if (device == INVALID_HANDLE_VALUE) - { - ok(0, "Connecting to driver failed with %x\n", GetLastError()); - return; - } - +- { +- ok(0, "Connecting to driver failed with %x\n", GetLastError()); +- return; +- } +- - res = DeviceIoControl(file, IOCTL_WINETEST_BASIC_IOCTL, NULL, 0, buf, - sizeof(buf), &bytes_returned, NULL); -+ res = wine_run_kernel_test(device, WINE_IOCTL_PsGetCurrentProcessId, &state, sizeof(state), NULL); - ok(res, "DeviceIoControl failed with %x\n", GetLastError()); +- ok(res, "DeviceIoControl failed with %x\n", GetLastError()); - ok(bytes_returned == sizeof(str)-1, "Unexpected number of bytes\n"); - ok(!memcmp(buf, str, sizeof(str)-1), "Unexpected response data\n"); ++ memset(&state, 0, sizeof(state)); ++ trace("Running tests for PsGetCurrentProcessId\n"); ++ wine_run_kernel_test(device_path, WINE_IOCTL_PsGetCurrentProcessId, &state); ++ ok(test->pid == GetCurrentProcessId(), "Expected pid %u, got %u\n", GetCurrentProcessId(), test->pid); ++} - CloseHandle(file); -+ processid = GetCurrentProcessId(); -+ ok(state.processid == processid, "Expected processid %u, got %u\n", processid, state.processid); -+ -+ CloseHandle(device); -+} -+ +static void test_PsGetCurrentThread(void) +{ -+ struct test_PsGetCurrentThread_state state; -+ HANDLE device; -+ BOOL res; -+ + trace("Running tests for PsGetCurrentThread\n"); -+ -+ device = CreateFileA(device_path, GENERIC_READ | GENERIC_WRITE, -+ 0, NULL, OPEN_EXISTING, 0, NULL); -+ if (device == INVALID_HANDLE_VALUE) -+ { -+ ok(0, "Connecting to driver failed with %x\n", GetLastError()); -+ return; -+ } -+ -+ res = wine_run_kernel_test(device, WINE_IOCTL_PsGetCurrentThread, &state, sizeof(state), NULL); -+ ok(res, "DeviceIoControl failed with %x\n", GetLastError()); -+ -+ CloseHandle(device); ++ wine_run_kernel_test(device_path, WINE_IOCTL_PsGetCurrentThread, NULL); } START_TEST(ntoskrnl) -@@ -220,7 +244,8 @@ START_TEST(ntoskrnl) +@@ -220,7 +213,8 @@ START_TEST(ntoskrnl) return; } @@ -672,7 +649,7 @@ index 9b8a6a7..64e9d97 100644 unload_driver(service, filename); } diff --git a/include/wine/test.h b/include/wine/test.h -index 0d81a24..63e2cfa 100644 +index af602c0fac0..e7d7961f2a9 100644 --- a/include/wine/test.h +++ b/include/wine/test.h @@ -61,7 +61,13 @@ extern int winetest_loop_todo(void); @@ -689,7 +666,7 @@ index 0d81a24..63e2cfa 100644 extern void winetest_wait_child_process( HANDLE process ); extern const char *wine_dbgstr_wn( const WCHAR *str, int n ); -@@ -428,10 +434,39 @@ LONG winetest_get_failures(void) +@@ -429,10 +435,39 @@ LONG winetest_get_failures(void) return failures; } @@ -732,5 +709,5 @@ index 0d81a24..63e2cfa 100644 void winetest_wait_child_process( HANDLE process ) -- -2.7.0 +2.13.1 diff --git a/patches/ntoskrnl-DriverTest/0003-ntoskrnl.exe-tests-Add-tests-for-NtBuildNumber.patch b/patches/ntoskrnl-DriverTest/0003-ntoskrnl.exe-tests-Add-tests-for-NtBuildNumber.patch new file mode 100644 index 00000000..f50e391d --- /dev/null +++ b/patches/ntoskrnl-DriverTest/0003-ntoskrnl.exe-tests-Add-tests-for-NtBuildNumber.patch @@ -0,0 +1,115 @@ +From 823f783bfa8b733abed5ec67d3119c2bbccf3d14 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +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 + diff --git a/patches/ntoskrnl-DriverTest/0004-ntoskrnl.exe-tests-Add-tests-for-ExInitializeNPagedL.patch b/patches/ntoskrnl-DriverTest/0004-ntoskrnl.exe-tests-Add-tests-for-ExInitializeNPagedL.patch new file mode 100644 index 00000000..9c539e43 --- /dev/null +++ b/patches/ntoskrnl-DriverTest/0004-ntoskrnl.exe-tests-Add-tests-for-ExInitializeNPagedL.patch @@ -0,0 +1,137 @@ +From 0ab2d5154c93ef99861a19381037728a034f9afa Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +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 + ++#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 + diff --git a/patches/ntoskrnl-DriverTest/definition b/patches/ntoskrnl-DriverTest/definition index 01e3ae96..e9ccae04 100644 --- a/patches/ntoskrnl-DriverTest/definition +++ b/patches/ntoskrnl-DriverTest/definition @@ -1 +1,2 @@ Fixes: Implement ntoskrnl driver testing framework. +Depends: ntoskrnl-Stubs diff --git a/patches/ntoskrnl-Stubs/0013-ntoskrnl.exe-Implement-NtBuildNumber.patch b/patches/ntoskrnl-Stubs/0013-ntoskrnl.exe-Implement-NtBuildNumber.patch new file mode 100644 index 00000000..8cc260b5 --- /dev/null +++ b/patches/ntoskrnl-Stubs/0013-ntoskrnl.exe-Implement-NtBuildNumber.patch @@ -0,0 +1,69 @@ +From 16d5776424063d794c42609a06d3a010d191dee3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Tue, 6 Jun 2017 21:08:51 +0200 +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(-) + +diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c +index 9332c3ef2a6..0a5c22fc8c0 100644 +--- a/dlls/ntoskrnl.exe/ntoskrnl.c ++++ b/dlls/ntoskrnl.exe/ntoskrnl.c +@@ -52,6 +52,7 @@ WINE_DECLARE_DEBUG_CHANNEL(plugplay); + + BOOLEAN KdDebuggerEnabled = FALSE; + ULONG InitSafeBootMode = 0; ++USHORT NtBuildNumber = 0; + + extern LONG CALLBACK vectored_handler( EXCEPTION_POINTERS *ptrs ); + +@@ -2657,6 +2658,13 @@ NTSTATUS WINAPI IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock, PVOID tag, + return STATUS_NOT_IMPLEMENTED; + } + ++static void ntoskrnl_init(void) ++{ ++ LARGE_INTEGER count; ++ ++ KeQueryTickCount( &count ); /* initialize the global KeTickCount */ ++ NtBuildNumber = NtCurrentTeb()->Peb->OSBuildNumber; ++} + + /***************************************************** + * DllMain +@@ -2664,7 +2672,6 @@ NTSTATUS WINAPI IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock, PVOID tag, + BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) + { + static void *handler; +- LARGE_INTEGER count; + + switch(reason) + { +@@ -2673,7 +2680,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) + #if defined(__i386__) || defined(__x86_64__) + handler = RtlAddVectoredExceptionHandler( TRUE, vectored_handler ); + #endif +- KeQueryTickCount( &count ); /* initialize the global KeTickCount */ ++ ntoskrnl_init(); + break; + case DLL_PROCESS_DETACH: + if (reserved) break; +diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +index aaa0d879219..1c862255dee 100644 +--- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec ++++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +@@ -740,7 +740,7 @@ + @ stdcall NtAllocateLocallyUniqueId(ptr) ntdll.NtAllocateLocallyUniqueId + @ stdcall NtAllocateUuids(ptr ptr ptr ptr) ntdll.NtAllocateUuids + @ stdcall NtAllocateVirtualMemory(long ptr long ptr long long) ntdll.NtAllocateVirtualMemory +-@ stub NtBuildNumber ++@ extern NtBuildNumber + @ stdcall NtClose(long) ntdll.NtClose + @ stdcall NtConnectPort(ptr ptr ptr ptr ptr ptr ptr ptr) ntdll.NtConnectPort + @ stdcall NtCreateEvent(ptr long ptr long long) ntdll.NtCreateEvent +-- +2.13.1 + diff --git a/patches/ntoskrnl-Stubs/0014-ntoskrnl.exe-Implement-ExInitializeNPagedLookasideLi.patch b/patches/ntoskrnl-Stubs/0014-ntoskrnl.exe-Implement-ExInitializeNPagedLookasideLi.patch new file mode 100644 index 00000000..da8c0ef5 --- /dev/null +++ b/patches/ntoskrnl-Stubs/0014-ntoskrnl.exe-Implement-ExInitializeNPagedLookasideLi.patch @@ -0,0 +1,178 @@ +From 57f2a16836c81b58f09e68c5bcbb2f491bb428fe Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +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(-) + +diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c +index 0a5c22fc8c0..30324fdebd0 100644 +--- a/dlls/ntoskrnl.exe/ntoskrnl.c ++++ b/dlls/ntoskrnl.exe/ntoskrnl.c +@@ -1801,7 +1801,24 @@ void WINAPI ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside, + ULONG Tag, + USHORT Depth) + { +- FIXME( "stub: %p, %p, %p, %u, %lu, %u, %u\n", Lookaside, Allocate, Free, Flags, Size, Tag, Depth ); ++ TRACE( "%p, %p, %p, %u, %lu, %u, %u\n", Lookaside, Allocate, Free, Flags, Size, Tag, Depth ); ++ ++ RtlInitializeSListHead( &Lookaside->L.u.ListHead ); ++ Lookaside->L.Depth = 4; ++ Lookaside->L.MaximumDepth = 256; ++ Lookaside->L.TotalAllocates = 0; ++ Lookaside->L.u2.AllocateMisses = 0; ++ Lookaside->L.TotalFrees = 0; ++ Lookaside->L.u3.FreeMisses = 0; ++ Lookaside->L.Type = NonPagedPool | Flags; ++ Lookaside->L.Tag = Tag; ++ Lookaside->L.Size = Size; ++ Lookaside->L.u4.Allocate = Allocate ? Allocate : ExAllocatePoolWithTag; ++ Lookaside->L.u5.Free = Free ? Free : ExFreePool; ++ Lookaside->L.LastTotalAllocates = 0; ++ Lookaside->L.u6.LastAllocateMisses = 0; ++ ++ /* FIXME: insert in global list of lookadside lists */ + } + + /*********************************************************************** +diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h +index b75ef9d56df..8f5b9094472 100644 +--- a/include/ddk/wdm.h ++++ b/include/ddk/wdm.h +@@ -143,20 +143,18 @@ typedef enum _KWAIT_REASON + MaximumWaitReason, + } KWAIT_REASON; + +-typedef struct _ALLOCATE_FUNCTION *PALLOCATE_FUNCTION; + typedef struct _IO_TIMER *PIO_TIMER; + typedef struct _IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE; + typedef struct _ETHREAD *PETHREAD; +-typedef struct _FREE_FUNCTION *PFREE_FUNCTION; + typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD; + typedef struct _EPROCESS *PEPROCESS; + typedef struct _ERESOURCE *PERESOURCE; + typedef struct _IO_WORKITEM *PIO_WORKITEM; +-typedef struct _NPAGED_LOOKASIDE_LIST *PNPAGED_LOOKASIDE_LIST; + typedef struct _PAGED_LOOKASIDE_LIST *PPAGED_LOOKASIDE_LIST; + typedef struct _OBJECT_TYPE *POBJECT_TYPE; + typedef struct _OBJECT_HANDLE_INFORMATION *POBJECT_HANDLE_INFORMATION; + typedef struct _ZONE_HEADER *PZONE_HEADER; ++typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX; + + typedef struct _FAST_MUTEX + { +@@ -181,6 +179,11 @@ typedef struct _VPB { + WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)]; + } VPB, *PVPB; + ++#define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 0x8 ++#define POOL_RAISE_IF_ALLOCATION_FAILURE 0x10 ++#define POOL_COLD_ALLOCATION 0x100 ++#define POOL_NX_ALLOCATION 0x200 ++ + typedef enum _POOL_TYPE { + NonPagedPool, + PagedPool, +@@ -1220,6 +1223,71 @@ typedef struct _KLOCK_QUEUE_HANDLE { + KIRQL OldIrql; + } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE; + ++typedef void * (NTAPI *PALLOCATE_FUNCTION)(POOL_TYPE, SIZE_T, ULONG); ++typedef void * (NTAPI *PALLOCATE_FUNCTION_EX)(POOL_TYPE, SIZE_T, ULONG, PLOOKASIDE_LIST_EX); ++typedef void (NTAPI *PFREE_FUNCTION)(void *); ++typedef void (NTAPI *PFREE_FUNCTION_EX)(void *, PLOOKASIDE_LIST_EX); ++ ++#ifdef _WIN64 ++#define LOOKASIDE_ALIGN DECLSPEC_CACHEALIGN ++#else ++#define LOOKASIDE_ALIGN ++#endif ++ ++#define LOOKASIDE_MINIMUM_BLOCK_SIZE (RTL_SIZEOF_THROUGH_FIELD(SLIST_ENTRY, Next)) ++ ++typedef struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE ++{ ++ union ++ { ++ SLIST_HEADER ListHead; ++ SINGLE_LIST_ENTRY SingleListHead; ++ } DUMMYUNIONNAME; ++ USHORT Depth; ++ USHORT MaximumDepth; ++ ULONG TotalAllocates; ++ union ++ { ++ ULONG AllocateMisses; ++ ULONG AllocateHits; ++ } DUMMYUNIONNAME2; ++ ULONG TotalFrees; ++ union ++ { ++ ULONG FreeMisses; ++ ULONG FreeHits; ++ } DUMMYUNIONNAME3; ++ POOL_TYPE Type; ++ ULONG Tag; ++ ULONG Size; ++ union ++ { ++ PALLOCATE_FUNCTION_EX AllocateEx; ++ PALLOCATE_FUNCTION Allocate; ++ } DUMMYUNIONNAME4; ++ union ++ { ++ PFREE_FUNCTION_EX FreeEx; ++ PFREE_FUNCTION Free; ++ } DUMMYUNIONNAME5; ++ LIST_ENTRY ListEntry; ++ ULONG LastTotalAllocates; ++ union ++ { ++ ULONG LastAllocateMisses; ++ ULONG LastAllocateHits; ++ } DUMMYUNIONNAME6; ++ ULONG Future[2]; ++} GENERAL_LOOKASIDE; ++ ++typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST ++{ ++ GENERAL_LOOKASIDE L; ++#if defined(__i386__) ++ KSPIN_LOCK Lock__ObsoleteButDoNotDelete; ++#endif ++} NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST; ++ + typedef NTSTATUS (NTAPI EX_CALLBACK_FUNCTION)(void *CallbackContext, void *Argument1, void *Argument2); + typedef EX_CALLBACK_FUNCTION *PEX_CALLBACK_FUNCTION; + +@@ -1277,8 +1345,10 @@ PVOID WINAPI ExAllocatePool(POOL_TYPE,SIZE_T); + PVOID WINAPI ExAllocatePoolWithQuota(POOL_TYPE,SIZE_T); + PVOID WINAPI ExAllocatePoolWithTag(POOL_TYPE,SIZE_T,ULONG); + PVOID WINAPI ExAllocatePoolWithQuotaTag(POOL_TYPE,SIZE_T,ULONG); ++void WINAPI ExDeleteNPagedLookasideList(PNPAGED_LOOKASIDE_LIST); + void WINAPI ExFreePool(PVOID); + void WINAPI ExFreePoolWithTag(PVOID,ULONG); ++void WINAPI ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST,PALLOCATE_FUNCTION,PFREE_FUNCTION,ULONG,SIZE_T,ULONG,USHORT); + + NTSTATUS WINAPI IoAllocateDriverObjectExtension(PDRIVER_OBJECT,PVOID,ULONG,PVOID*); + PVOID WINAPI IoAllocateErrorLogEntry(PVOID,UCHAR); +diff --git a/include/winnt.h b/include/winnt.h +index 3c5f0b8cb33..2cec63c895b 100644 +--- a/include/winnt.h ++++ b/include/winnt.h +@@ -755,6 +755,8 @@ typedef struct _MEMORY_BASIC_INFORMATION + #define UNICODE_STRING_MAX_CHARS 32767 + + #define FIELD_OFFSET(type, field) ((LONG)offsetof(type, field)) ++#define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field)) ++#define RTL_SIZEOF_THROUGH_FIELD(type, field) (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field)) + + #ifdef __GNUC__ + # define CONTAINING_RECORD(address, type, field) ({ \ +-- +2.13.1 + diff --git a/patches/ntoskrnl-Stubs/definition b/patches/ntoskrnl-Stubs/definition index 9145698a..e269362f 100644 --- a/patches/ntoskrnl-Stubs/definition +++ b/patches/ntoskrnl-Stubs/definition @@ -5,3 +5,7 @@ Fixes: Add stub for ntoskrnl.Mm{Map,Unmap}LockedPages Fixes: Implement ntoskrnl.KeInitializeMutex Fixes: Add stub for ntoskrnl.IoGetDeviceAttachmentBaseRef Fixes: Implement ntoskrnl.ExInterlockedPopEntrySList +Fixes: Implement ntoskrnl.NtBuildNumber +Fixes: Implement ntoskrnl.ExInitializeNPagedLookasideList +Depends: ntdll-NtAllocateUuids +Depends: Compiler_Warnings diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 0e9aa6a0..658d1052 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -52,7 +52,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "e0e4f9bbcda1243b9317dbfbeeff84a18b4e855c" + echo "74d93d9bc0acadacc97c3dc803ede6ed4b8becb1" } # Show version information @@ -2309,6 +2309,24 @@ if test "$enable_nvapi_Stub_DLL" -eq 1; then enable_nvcuda_CUDA_Support=1 fi +if test "$enable_ntoskrnl_DriverTest" -eq 1; then + if test "$enable_ntoskrnl_Stubs" -gt 1; then + abort "Patchset ntoskrnl-Stubs disabled, but ntoskrnl-DriverTest depends on that." + fi + enable_ntoskrnl_Stubs=1 +fi + +if test "$enable_ntoskrnl_Stubs" -eq 1; then + if test "$enable_Compiler_Warnings" -gt 1; then + abort "Patchset Compiler_Warnings disabled, but ntoskrnl-Stubs depends on that." + fi + if test "$enable_ntdll_NtAllocateUuids" -gt 1; then + abort "Patchset ntdll-NtAllocateUuids disabled, but ntoskrnl-Stubs depends on that." + fi + enable_Compiler_Warnings=1 + enable_ntdll_NtAllocateUuids=1 +fi + if test "$enable_ntdll_WriteWatches" -eq 1; then if test "$enable_ws2_32_WriteWatches" -gt 1; then abort "Patchset ws2_32-WriteWatches disabled, but ntdll-WriteWatches depends on that." @@ -6261,29 +6279,13 @@ if test "$enable_ntdll_call_thread_func_wrapper" -eq 1; then ) >> "$patchlist" fi -# Patchset ntoskrnl-DriverTest -# | -# | Modified files: -# | * aclocal.m4, configure.ac, dlls/ntoskrnl.exe/ntoskrnl.exe.spec, dlls/ntoskrnl.exe/tests/Makefile.in, -# | dlls/ntoskrnl.exe/tests/driver.sys/Makefile.in, dlls/ntoskrnl.exe/tests/driver.sys/driver.c, -# | dlls/ntoskrnl.exe/tests/driver.sys/driver.h, dlls/ntoskrnl.exe/tests/driver.sys/driver.sys.spec, -# | dlls/ntoskrnl.exe/tests/driver.sys/test.c, dlls/ntoskrnl.exe/tests/driver.sys/test.h, -# | dlls/ntoskrnl.exe/tests/driver.sys/util.h, dlls/ntoskrnl.exe/tests/ntoskrnl.c, include/wine/test.h, -# | tools/make_makefiles, tools/makedep.c -# | -if test "$enable_ntoskrnl_DriverTest" -eq 1; then - patch_apply ntoskrnl-DriverTest/0001-ntoskrnl.exe-tests-Add-initial-driver-testing-framew.patch - patch_apply ntoskrnl-DriverTest/0002-ntoskrnl.exe-tests-Add-kernel-compliant-test-functio.patch - ( - printf '%s\n' '+ { "Sebastian Lackner", "ntoskrnl.exe/tests: Add initial driver testing framework and corresponding changes to Makefile system.", 2 },'; - printf '%s\n' '+ { "Michael Müller", "ntoskrnl.exe/tests: Add kernel compliant test functions.", 1 },'; - ) >> "$patchlist" -fi - # Patchset ntoskrnl-Stubs # | +# | This patchset has the following (direct or indirect) dependencies: +# | * Compiler_Warnings, ntdll-NtAllocateUuids +# | # | Modified files: -# | * dlls/ntoskrnl.exe/ntoskrnl.c, dlls/ntoskrnl.exe/ntoskrnl.exe.spec, include/ddk/wdm.h +# | * dlls/ntoskrnl.exe/ntoskrnl.c, dlls/ntoskrnl.exe/ntoskrnl.exe.spec, include/ddk/wdm.h, include/winnt.h # | if test "$enable_ntoskrnl_Stubs" -eq 1; then patch_apply ntoskrnl-Stubs/0003-ntoskrnl.exe-Add-stubs-for-ExAcquireFastMutexUnsafe-.patch @@ -6296,6 +6298,8 @@ if test "$enable_ntoskrnl_Stubs" -eq 1; then patch_apply ntoskrnl-Stubs/0010-ntoskrnl.exe-Implement-KeInitializeMutex.patch patch_apply ntoskrnl-Stubs/0011-ntoskrnl.exe-Add-IoGetDeviceAttachmentBaseRef-stub.patch patch_apply ntoskrnl-Stubs/0012-ntoskrnl-Implement-ExInterlockedPopEntrySList.patch + patch_apply ntoskrnl-Stubs/0013-ntoskrnl.exe-Implement-NtBuildNumber.patch + patch_apply ntoskrnl-Stubs/0014-ntoskrnl.exe-Implement-ExInitializeNPagedLookasideLi.patch ( printf '%s\n' '+ { "Alexander Morozov", "ntoskrnl.exe: Add stubs for ExAcquireFastMutexUnsafe and ExReleaseFastMutexUnsafe.", 1 },'; printf '%s\n' '+ { "Alexander Morozov", "ntoskrnl.exe: Add stub for ObReferenceObjectByPointer.", 1 },'; @@ -6307,6 +6311,34 @@ if test "$enable_ntoskrnl_Stubs" -eq 1; then printf '%s\n' '+ { "Alexander Morozov", "ntoskrnl.exe: Implement KeInitializeMutex.", 1 },'; printf '%s\n' '+ { "Jarkko Korpi", "ntoskrnl.exe: Add IoGetDeviceAttachmentBaseRef stub.", 1 },'; printf '%s\n' '+ { "Michael Müller", "ntoskrnl: Implement ExInterlockedPopEntrySList.", 1 },'; + printf '%s\n' '+ { "Michael Müller", "ntoskrnl.exe: Implement NtBuildNumber.", 1 },'; + printf '%s\n' '+ { "Michael Müller", "ntoskrnl.exe: Implement ExInitializeNPagedLookasideList.", 1 },'; + ) >> "$patchlist" +fi + +# Patchset ntoskrnl-DriverTest +# | +# | This patchset has the following (direct or indirect) dependencies: +# | * Compiler_Warnings, ntdll-NtAllocateUuids, ntoskrnl-Stubs +# | +# | Modified files: +# | * aclocal.m4, configure.ac, dlls/ntoskrnl.exe/ntoskrnl.exe.spec, dlls/ntoskrnl.exe/tests/Makefile.in, +# | dlls/ntoskrnl.exe/tests/driver.sys/Makefile.in, dlls/ntoskrnl.exe/tests/driver.sys/driver.c, +# | dlls/ntoskrnl.exe/tests/driver.sys/driver.h, dlls/ntoskrnl.exe/tests/driver.sys/driver.sys.spec, +# | dlls/ntoskrnl.exe/tests/driver.sys/test.c, dlls/ntoskrnl.exe/tests/driver.sys/test.h, +# | dlls/ntoskrnl.exe/tests/driver.sys/util.h, dlls/ntoskrnl.exe/tests/ntoskrnl.c, include/wine/test.h, +# | tools/make_makefiles, tools/makedep.c +# | +if test "$enable_ntoskrnl_DriverTest" -eq 1; then + patch_apply ntoskrnl-DriverTest/0001-ntoskrnl.exe-tests-Add-initial-driver-testing-framew.patch + patch_apply ntoskrnl-DriverTest/0002-ntoskrnl.exe-tests-Add-kernel-compliant-test-functio.patch + patch_apply ntoskrnl-DriverTest/0003-ntoskrnl.exe-tests-Add-tests-for-NtBuildNumber.patch + patch_apply ntoskrnl-DriverTest/0004-ntoskrnl.exe-tests-Add-tests-for-ExInitializeNPagedL.patch + ( + printf '%s\n' '+ { "Sebastian Lackner", "ntoskrnl.exe/tests: Add initial driver testing framework and corresponding changes to Makefile system.", 2 },'; + printf '%s\n' '+ { "Michael Müller", "ntoskrnl.exe/tests: Add kernel compliant test functions.", 1 },'; + printf '%s\n' '+ { "Michael Müller", "ntoskrnl.exe/tests: Add tests for NtBuildNumber.", 1 },'; + printf '%s\n' '+ { "Michael Müller", "ntoskrnl.exe/tests: Add tests for ExInitializeNPagedLookasideList.", 1 },'; ) >> "$patchlist" fi