2018-09-18 19:26:55 -07:00
|
|
|
From 23f0efa72624556184b079814d4b58ea02105b8a Mon Sep 17 00:00:00 2001
|
2017-06-10 07:33:34 -07:00
|
|
|
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
|
|
|
Date: Tue, 6 Jun 2017 21:08:51 +0200
|
2018-07-09 15:39:20 -07:00
|
|
|
Subject: [PATCH] ntoskrnl.exe: Implement NtBuildNumber.
|
2017-06-10 07:33:34 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
dlls/ntoskrnl.exe/ntoskrnl.c | 11 +++++++++--
|
|
|
|
dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 2 +-
|
2018-08-29 16:25:58 -07:00
|
|
|
dlls/ntoskrnl.exe/tests/driver.c | 29 +++++++++++++++++++++++++++++
|
|
|
|
3 files changed, 39 insertions(+), 3 deletions(-)
|
2017-06-10 07:33:34 -07:00
|
|
|
|
|
|
|
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
|
2018-09-18 19:26:55 -07:00
|
|
|
index e030b48..14a6e82 100644
|
2017-06-10 07:33:34 -07:00
|
|
|
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
|
|
|
|
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
|
2018-08-29 16:25:58 -07:00
|
|
|
@@ -57,6 +57,7 @@ WINE_DECLARE_DEBUG_CHANNEL(plugplay);
|
2017-06-10 07:33:34 -07:00
|
|
|
|
|
|
|
BOOLEAN KdDebuggerEnabled = FALSE;
|
|
|
|
ULONG InitSafeBootMode = 0;
|
|
|
|
+USHORT NtBuildNumber = 0;
|
|
|
|
|
|
|
|
extern LONG CALLBACK vectored_handler( EXCEPTION_POINTERS *ptrs );
|
|
|
|
|
2018-09-18 19:26:55 -07:00
|
|
|
@@ -2826,6 +2827,13 @@ NTSTATUS WINAPI IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock, PVOID tag,
|
2017-06-10 07:33:34 -07:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static void ntoskrnl_init(void)
|
|
|
|
+{
|
|
|
|
+ LARGE_INTEGER count;
|
|
|
|
+
|
|
|
|
+ KeQueryTickCount( &count ); /* initialize the global KeTickCount */
|
|
|
|
+ NtBuildNumber = NtCurrentTeb()->Peb->OSBuildNumber;
|
|
|
|
+}
|
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* DllMain
|
2018-09-18 19:26:55 -07:00
|
|
|
@@ -2833,7 +2841,6 @@ NTSTATUS WINAPI IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock, PVOID tag,
|
2017-06-10 07:33:34 -07:00
|
|
|
BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
|
|
|
|
{
|
|
|
|
static void *handler;
|
|
|
|
- LARGE_INTEGER count;
|
|
|
|
|
|
|
|
switch(reason)
|
|
|
|
{
|
2018-09-18 19:26:55 -07:00
|
|
|
@@ -2842,7 +2849,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
|
2017-06-10 07:33:34 -07:00
|
|
|
#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
|
2018-09-18 19:26:55 -07:00
|
|
|
index cbc047f..d0e239e 100644
|
2017-06-10 07:33:34 -07:00
|
|
|
--- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
|
|
|
|
+++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
|
2018-05-02 16:37:53 -07:00
|
|
|
@@ -743,7 +743,7 @@
|
2018-02-27 17:59:50 -08:00
|
|
|
@ stdcall NtAllocateLocallyUniqueId(ptr)
|
|
|
|
@ stdcall NtAllocateUuids(ptr ptr ptr ptr)
|
|
|
|
@ stdcall NtAllocateVirtualMemory(long ptr long ptr long long)
|
2017-06-10 07:33:34 -07:00
|
|
|
-@ stub NtBuildNumber
|
|
|
|
+@ extern NtBuildNumber
|
2018-02-27 17:59:50 -08:00
|
|
|
@ stdcall NtClose(long)
|
|
|
|
@ stdcall NtConnectPort(ptr ptr ptr ptr ptr ptr ptr ptr)
|
|
|
|
@ stdcall NtCreateEvent(ptr long ptr long long)
|
2018-05-02 16:37:53 -07:00
|
|
|
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c
|
2018-09-18 19:26:55 -07:00
|
|
|
index efd6053..2e1107b 100644
|
2018-05-02 16:37:53 -07:00
|
|
|
--- 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;
|
2018-09-18 19:26:55 -07:00
|
|
|
@@ -497,6 +513,18 @@ static void test_sync(void)
|
|
|
|
KeCancelTimer(&timer);
|
2018-05-02 16:37:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
+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);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
|
|
|
|
{
|
|
|
|
ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength;
|
2018-09-18 19:26:55 -07:00
|
|
|
@@ -526,6 +554,7 @@ static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
|
2018-07-09 15:39:20 -07:00
|
|
|
test_init_funcs();
|
2018-08-29 16:25:58 -07:00
|
|
|
test_load_driver();
|
2018-09-18 19:26:55 -07:00
|
|
|
test_sync();
|
2018-05-02 16:37:53 -07:00
|
|
|
+ test_version();
|
|
|
|
|
|
|
|
/* print process report */
|
|
|
|
if (test_input->winetest_debug)
|
2017-06-10 07:33:34 -07:00
|
|
|
--
|
2018-09-18 19:26:55 -07:00
|
|
|
2.7.4
|
2017-06-10 07:33:34 -07:00
|
|
|
|