ntoskrnl-Synchronization: Add patchset.

This commit is contained in:
Zebediah Figura 2018-09-18 21:26:55 -05:00
parent 912b650b76
commit a840ce50e7
26 changed files with 1792 additions and 126 deletions

View File

@ -1,25 +0,0 @@
From 0d4bc7ee9451dbd89bec8b76ef0608b78582cf25 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov@etersoft.ru>
Date: Fri, 30 Jan 2015 00:30:45 +0100
Subject: ntoskrnl.exe: Improve KeReleaseMutex stub.
---
dlls/ntoskrnl.exe/ntoskrnl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index c90b351..7bc716c 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -1356,7 +1356,7 @@ NTSTATUS WINAPI KeWaitForMutexObject(PRKMUTEX Mutex, KWAIT_REASON WaitReason, KP
LONG WINAPI KeReleaseMutex(PRKMUTEX Mutex, BOOLEAN Wait)
{
FIXME( "stub: %p, %d\n", Mutex, Wait );
- return STATUS_NOT_IMPLEMENTED;
+ return STATUS_SUCCESS;
}
--
2.2.2

View File

@ -1,26 +0,0 @@
From 1826c593593f1b66ec4f4704299fdb1485a9b432 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov@etersoft.ru>
Date: Fri, 30 Jan 2015 00:32:38 +0100
Subject: ntoskrnl.exe: Improve KeInitializeSemaphore stub.
---
dlls/ntoskrnl.exe/ntoskrnl.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 7bc716c..36331a1 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -1366,6 +1366,9 @@ LONG WINAPI KeReleaseMutex(PRKMUTEX Mutex, BOOLEAN Wait)
void WINAPI KeInitializeSemaphore( PRKSEMAPHORE Semaphore, LONG Count, LONG Limit )
{
FIXME( "(%p %d %d) stub\n", Semaphore , Count, Limit );
+
+ RtlZeroMemory(Semaphore, sizeof(KSEMAPHORE));
+ Semaphore->Header.Type = 5;
}
--
2.2.2

View File

@ -1,31 +0,0 @@
From e08f2a919e3f1f8129d4f40d0a9232c363e4da2b Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov@etersoft.ru>
Date: Fri, 30 Jan 2015 01:06:36 +0100
Subject: ntoskrnl.exe: Implement KeInitializeMutex.
---
dlls/ntoskrnl.exe/ntoskrnl.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 10957e8..3ff5d63 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -1356,7 +1356,13 @@ void WINAPI KeInitializeEvent( PRKEVENT Event, EVENT_TYPE Type, BOOLEAN State )
*/
void WINAPI KeInitializeMutex(PRKMUTEX Mutex, ULONG Level)
{
- FIXME( "stub: %p, %u\n", Mutex, Level );
+ TRACE( "%p, %u\n", Mutex, Level );
+ RtlZeroMemory( Mutex, sizeof(KMUTEX) );
+ Mutex->Header.Type = 2;
+ Mutex->Header.Size = 8;
+ Mutex->Header.SignalState = 1;
+ InitializeListHead( &Mutex->Header.WaitListHead );
+ Mutex->ApcDisable = 1;
}
--
2.3.0

View File

@ -1,4 +1,4 @@
From 7892a3f8ead52c2a89052fc9e82c8674c31164eb Mon Sep 17 00:00:00 2001
From 23f0efa72624556184b079814d4b58ea02105b8a 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: [PATCH] ntoskrnl.exe: Implement NtBuildNumber.
@ -10,7 +10,7 @@ Subject: [PATCH] ntoskrnl.exe: Implement NtBuildNumber.
3 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 466962a..0fea91b 100644
index e030b48..14a6e82 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -57,6 +57,7 @@ WINE_DECLARE_DEBUG_CHANNEL(plugplay);
@ -21,7 +21,7 @@ index 466962a..0fea91b 100644
extern LONG CALLBACK vectored_handler( EXCEPTION_POINTERS *ptrs );
@@ -2939,6 +2940,13 @@ NTSTATUS WINAPI IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock, PVOID tag,
@@ -2826,6 +2827,13 @@ NTSTATUS WINAPI IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock, PVOID tag,
return STATUS_NOT_IMPLEMENTED;
}
@ -35,7 +35,7 @@ index 466962a..0fea91b 100644
/*****************************************************
* DllMain
@@ -2946,7 +2954,6 @@ NTSTATUS WINAPI IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock, PVOID tag,
@@ -2833,7 +2841,6 @@ NTSTATUS WINAPI IoAcquireRemoveLockEx(PIO_REMOVE_LOCK lock, PVOID tag,
BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
{
static void *handler;
@ -43,7 +43,7 @@ index 466962a..0fea91b 100644
switch(reason)
{
@@ -2955,7 +2962,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
@@ -2842,7 +2849,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
#if defined(__i386__) || defined(__x86_64__)
handler = RtlAddVectoredExceptionHandler( TRUE, vectored_handler );
#endif
@ -53,7 +53,7 @@ index 466962a..0fea91b 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 63c1b8e..72a9f7f 100644
index cbc047f..d0e239e 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
+++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
@@ -743,7 +743,7 @@
@ -66,7 +66,7 @@ index 63c1b8e..72a9f7f 100644
@ 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 d424396..57aaa28 100644
index efd6053..2e1107b 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)
@ -92,8 +92,8 @@ index d424396..57aaa28 100644
static void test_currentprocess(void)
{
PEPROCESS current;
@@ -210,6 +226,18 @@ static void test_load_driver(void)
ok(!ret, "got %#x\n", ret);
@@ -497,6 +513,18 @@ static void test_sync(void)
KeCancelTimer(&timer);
}
+static void test_version(void)
@ -111,14 +111,14 @@ index d424396..57aaa28 100644
static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
{
ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength;
@@ -237,6 +265,7 @@ static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
test_mdl_map();
@@ -526,6 +554,7 @@ static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
test_init_funcs();
test_load_driver();
test_sync();
+ test_version();
/* print process report */
if (test_input->winetest_debug)
--
1.9.1
2.7.4

View File

@ -1,4 +1,4 @@
From 36bd8e4497945604cda44057c9dbb500080700a7 Mon Sep 17 00:00:00 2001
From 7b85e96f6dbced2fa2bb4c8f73b26abfd442dfef 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: [PATCH] ntoskrnl.exe: Implement ExInitializeNPagedLookasideList.
@ -11,7 +11,7 @@ Subject: [PATCH] ntoskrnl.exe: Implement ExInitializeNPagedLookasideList.
4 files changed, 127 insertions(+), 7 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 0fea91b..4bd0ff7 100644
index 14a6e82..6123a45 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -2029,7 +2029,24 @@ void WINAPI ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
@ -41,7 +41,7 @@ index 0fea91b..4bd0ff7 100644
/***********************************************************************
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c
index 57aaa28..ab55b48 100644
index 2e1107b..4f32c30 100644
--- a/dlls/ntoskrnl.exe/tests/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.c
@@ -22,6 +22,9 @@
@ -54,7 +54,7 @@ index 57aaa28..ab55b48 100644
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
@@ -238,6 +241,33 @@ static void test_version(void)
@@ -525,6 +528,33 @@ static void test_version(void)
ok(*pNtBuildNumber == build, "Expected build number %u, got %u\n", build, *pNtBuildNumber);
}
@ -88,15 +88,15 @@ index 57aaa28..ab55b48 100644
static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
{
ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength;
@@ -266,6 +296,7 @@ static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
test_init_funcs();
@@ -555,6 +585,7 @@ static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
test_load_driver();
test_sync();
test_version();
+ test_lookaside_list();
/* print process report */
if (test_input->winetest_debug)
@@ -317,7 +348,7 @@ static NTSTATUS test_load_driver_ioctl(IRP *irp, IO_STACK_LOCATION *stack, ULONG
@@ -606,7 +637,7 @@ static NTSTATUS test_load_driver_ioctl(IRP *irp, IO_STACK_LOCATION *stack, ULONG
static NTSTATUS WINAPI driver_Create(DEVICE_OBJECT *device, IRP *irp)
{
@ -105,7 +105,7 @@ index 57aaa28..ab55b48 100644
IoCompleteRequest(irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
@@ -342,14 +373,14 @@ static NTSTATUS WINAPI driver_IoControl(DEVICE_OBJECT *device, IRP *irp)
@@ -631,14 +662,14 @@ static NTSTATUS WINAPI driver_IoControl(DEVICE_OBJECT *device, IRP *irp)
break;
}
@ -123,12 +123,12 @@ index 57aaa28..ab55b48 100644
return STATUS_SUCCESS;
}
diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h
index 0cd1673..ed27180 100644
index b5e4424..9ff245e 100644
--- a/include/ddk/wdm.h
+++ b/include/ddk/wdm.h
@@ -144,20 +144,18 @@ typedef enum _KWAIT_REASON
MaximumWaitReason,
} KWAIT_REASON;
@@ -153,20 +153,18 @@ typedef struct _KWAIT_BLOCK {
USHORT WaitType;
} KWAIT_BLOCK, *PKWAIT_BLOCK, *RESTRICTED_POINTER PRKWAIT_BLOCK;
-typedef struct _ALLOCATE_FUNCTION *PALLOCATE_FUNCTION;
typedef struct _IO_TIMER *PIO_TIMER;
@ -148,7 +148,7 @@ index 0cd1673..ed27180 100644
typedef struct _FAST_MUTEX
{
@@ -182,6 +180,11 @@ typedef struct _VPB {
@@ -191,6 +189,11 @@ typedef struct _VPB {
WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
} VPB, *PVPB;
@ -160,7 +160,7 @@ index 0cd1673..ed27180 100644
typedef enum _POOL_TYPE {
NonPagedPool,
PagedPool,
@@ -1221,6 +1224,71 @@ typedef struct _KLOCK_QUEUE_HANDLE {
@@ -1230,6 +1233,71 @@ typedef struct _KLOCK_QUEUE_HANDLE {
KIRQL OldIrql;
} KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE;
@ -232,7 +232,7 @@ index 0cd1673..ed27180 100644
typedef NTSTATUS (NTAPI EX_CALLBACK_FUNCTION)(void *CallbackContext, void *Argument1, void *Argument2);
typedef EX_CALLBACK_FUNCTION *PEX_CALLBACK_FUNCTION;
@@ -1373,8 +1441,10 @@ PVOID WINAPI ExAllocatePool(POOL_TYPE,SIZE_T);
@@ -1382,8 +1450,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);
@ -244,7 +244,7 @@ index 0cd1673..ed27180 100644
PSLIST_ENTRY WINAPI ExInterlockedPushEntrySList(PSLIST_HEADER,PSLIST_ENTRY,PKSPIN_LOCK);
void WINAPI ExReleaseFastMutexUnsafe(PFAST_MUTEX);
diff --git a/include/winnt.h b/include/winnt.h
index f1c49f2..90efd6a 100644
index 66720a2..2b15c8c 100644
--- a/include/winnt.h
+++ b/include/winnt.h
@@ -755,6 +755,8 @@ typedef struct _MEMORY_BASIC_INFORMATION
@ -257,5 +257,5 @@ index f1c49f2..90efd6a 100644
#ifdef __GNUC__
# define CONTAINING_RECORD(address, type, field) ({ \
--
1.9.1
2.7.4

View File

@ -6,3 +6,4 @@ Fixes: Implement ntoskrnl.NtBuildNumber
Fixes: Implement ntoskrnl.ExInitializeNPagedLookasideList
# ExInitializeNPagedLookasideList() is wanted by sfvfs02.sys, used by World Racing.
Depends: Compiler_Warnings
Depends: ntoskrnl-Synchronization

View File

@ -0,0 +1,229 @@
From 48adc4c6f5342cc5b0299b4890a92684d5762756 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 17:10:47 -0500
Subject: [PATCH 01/17] ntoskrnl.exe: Implement KeWaitForMultipleObjects().
We have plenty of space in which to store a kernel handle inside a
DISPATCHER_HEADER. However, the storage is volatile, and there is no way to
know when to close it. Therefore, we create the handle when
KeWaitForMultipleObjects() is called, and keep it open as long as at least
one thread is waiting on the object.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/Makefile.in | 3 +-
dlls/ntoskrnl.exe/ntoskrnl.c | 13 -----
dlls/ntoskrnl.exe/sync.c | 114 ++++++++++++++++++++++++++++++++++++++++++
include/ddk/ntddk.h | 9 ----
include/ddk/wdm.h | 10 ++++
5 files changed, 126 insertions(+), 23 deletions(-)
create mode 100644 dlls/ntoskrnl.exe/sync.c
diff --git a/dlls/ntoskrnl.exe/Makefile.in b/dlls/ntoskrnl.exe/Makefile.in
index 5b03c59..b8128fc 100644
--- a/dlls/ntoskrnl.exe/Makefile.in
+++ b/dlls/ntoskrnl.exe/Makefile.in
@@ -5,6 +5,7 @@ DELAYIMPORTS = user32
C_SRCS = \
instr.c \
- ntoskrnl.c
+ ntoskrnl.c \
+ sync.c
RC_SRCS = ntoskrnl.rc
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 9fbf22d..28671c8 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -2297,19 +2297,6 @@ NTSTATUS WINAPI KeWaitForSingleObject(PVOID Object,
}
/***********************************************************************
- * KeWaitForMultipleObjects (NTOSKRNL.EXE.@)
- */
-NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG Count, PVOID Object[], WAIT_TYPE WaitType,
- KWAIT_REASON WaitReason, KPROCESSOR_MODE WaitMode,
- BOOLEAN Alertable, PLARGE_INTEGER Timeout,
- PKWAIT_BLOCK WaitBlockArray)
-{
- FIXME( "stub: %u, %p, %d, %d, %d, %d, %p, %p\n", Count, Object, WaitType, WaitReason, WaitMode,
- Alertable, Timeout, WaitBlockArray );
- return STATUS_NOT_IMPLEMENTED;
-}
-
-/***********************************************************************
* IoRegisterFileSystem (NTOSKRNL.EXE.@)
*/
VOID WINAPI IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject)
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c
new file mode 100644
index 0000000..19af4f6
--- /dev/null
+++ b/dlls/ntoskrnl.exe/sync.c
@@ -0,0 +1,114 @@
+/*
+ * Kernel synchronization
+ *
+ * Copyright (C) 2018 Zebediah Figura
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
+#include "windef.h"
+#include "winbase.h"
+#include "winternl.h"
+#include "ddk/ntddk.h"
+#include "ddk/wdm.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(ntoskrnl);
+
+enum object_type
+{
+ TYPE_MANUAL_EVENT = 0,
+ TYPE_AUTO_EVENT = 1,
+};
+
+static CRITICAL_SECTION sync_cs;
+static CRITICAL_SECTION_DEBUG sync_cs_debug =
+{
+ 0, 0, &sync_cs,
+ { &sync_cs_debug.ProcessLocksList, &sync_cs_debug.ProcessLocksList },
+ 0, 0, { (DWORD_PTR)(__FILE__ ": sync_cs") }
+};
+static CRITICAL_SECTION sync_cs = { &sync_cs_debug, -1, 0, 0, 0, 0 };
+
+/***********************************************************************
+ * KeWaitForMultipleObjects (NTOSKRNL.EXE.@)
+ */
+NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG count, void *pobjs[],
+ WAIT_TYPE wait_type, KWAIT_REASON reason, KPROCESSOR_MODE mode,
+ BOOLEAN alertable, LARGE_INTEGER *timeout, KWAIT_BLOCK *wait_blocks)
+{
+ DISPATCHER_HEADER **objs = (DISPATCHER_HEADER **)pobjs;
+ HANDLE handles[MAXIMUM_WAIT_OBJECTS];
+ NTSTATUS ret;
+ ULONG i;
+
+ TRACE("count %u, objs %p, wait_type %u, reason %u, mode %d, alertable %u, timeout %p, wait_blocks %p.\n",
+ count, objs, wait_type, reason, mode, alertable, timeout, wait_blocks);
+
+ /* We co-opt DISPATCHER_HEADER.WaitListHead:
+ * Blink stores a handle to the synchronization object,
+ * Flink stores the number of threads currently waiting on this object. */
+
+ EnterCriticalSection( &sync_cs );
+ for (i = 0; i < count; i++)
+ {
+ ++*((ULONG_PTR *)&objs[i]->WaitListHead.Flink);
+ if (!objs[i]->WaitListHead.Blink)
+ {
+ switch (objs[i]->Type)
+ {
+ case TYPE_MANUAL_EVENT:
+ objs[i]->WaitListHead.Blink = CreateEventW( NULL, TRUE, objs[i]->SignalState, NULL );
+ break;
+ case TYPE_AUTO_EVENT:
+ objs[i]->WaitListHead.Blink = CreateEventW( NULL, FALSE, objs[i]->SignalState, NULL );
+ break;
+ }
+ }
+
+ handles[i] = objs[i]->WaitListHead.Blink;
+ }
+ LeaveCriticalSection( &sync_cs );
+
+ ret = NtWaitForMultipleObjects( count, handles, (wait_type == WaitAny), alertable, timeout );
+
+ EnterCriticalSection( &sync_cs );
+ for (i = 0; i < count; i++)
+ {
+ if (ret == i || (!ret && wait_type == WaitAll))
+ {
+ switch (objs[i]->Type)
+ {
+ case TYPE_AUTO_EVENT:
+ objs[i]->SignalState = FALSE;
+ break;
+ }
+ }
+
+ if (!--*((ULONG_PTR *)&objs[i]->WaitListHead.Flink))
+ {
+ CloseHandle(objs[i]->WaitListHead.Blink);
+ objs[i]->WaitListHead.Blink = NULL;
+ }
+ }
+ LeaveCriticalSection( &sync_cs );
+
+ return ret;
+}
diff --git a/include/ddk/ntddk.h b/include/ddk/ntddk.h
index e76ccc9..6b3a30e 100644
--- a/include/ddk/ntddk.h
+++ b/include/ddk/ntddk.h
@@ -140,15 +140,6 @@ typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION
LARGE_INTEGER ValidDataLength;
} FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION;
-typedef struct _KWAIT_BLOCK {
- LIST_ENTRY WaitListEntry;
- struct _KTHREAD *RESTRICTED_POINTER Thread;
- PVOID Object;
- struct _KWAIT_BLOCK *RESTRICTED_POINTER NextWaitBlock;
- USHORT WaitKey;
- USHORT WaitType;
-} KWAIT_BLOCK, *PKWAIT_BLOCK, *RESTRICTED_POINTER PRKWAIT_BLOCK;
-
typedef struct _RTL_BALANCED_LINKS {
struct _RTL_BALANCED_LINKS *Parent;
struct _RTL_BALANCED_LINKS *LeftChild;
diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h
index 0cd1673..32e8f8b 100644
--- a/include/ddk/wdm.h
+++ b/include/ddk/wdm.h
@@ -144,6 +144,15 @@ typedef enum _KWAIT_REASON
MaximumWaitReason,
} KWAIT_REASON;
+typedef struct _KWAIT_BLOCK {
+ LIST_ENTRY WaitListEntry;
+ struct _KTHREAD *RESTRICTED_POINTER Thread;
+ PVOID Object;
+ struct _KWAIT_BLOCK *RESTRICTED_POINTER NextWaitBlock;
+ USHORT WaitKey;
+ USHORT WaitType;
+} KWAIT_BLOCK, *PKWAIT_BLOCK, *RESTRICTED_POINTER PRKWAIT_BLOCK;
+
typedef struct _ALLOCATE_FUNCTION *PALLOCATE_FUNCTION;
typedef struct _IO_TIMER *PIO_TIMER;
typedef struct _IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE;
@@ -1421,6 +1430,7 @@ LONG WINAPI KeResetEvent(PRKEVENT);
LONG WINAPI KeSetEvent(PRKEVENT,KPRIORITY,BOOLEAN);
KPRIORITY WINAPI KeSetPriorityThread(PKTHREAD,KPRIORITY);
void WINAPI KeSetSystemAffinityThread(KAFFINITY);
+NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG,void*[],WAIT_TYPE,KWAIT_REASON,KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*,KWAIT_BLOCK*);
PVOID WINAPI MmAllocateContiguousMemory(SIZE_T,PHYSICAL_ADDRESS);
PVOID WINAPI MmAllocateNonCachedMemory(SIZE_T);
--
2.7.4

View File

@ -0,0 +1,68 @@
From 6b6a079747a9d92f5cd2b3b11a3b350c24f2ceb1 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 17:34:35 -0500
Subject: [PATCH 02/17] ntoskrnl.exe: Implement KeInitializeEvent().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/ntoskrnl.c | 9 ---------
dlls/ntoskrnl.exe/sync.c | 13 +++++++++++++
include/ddk/wdm.h | 1 +
3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 28671c8..e61b18d 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -2085,15 +2085,6 @@ PRKTHREAD WINAPI KeGetCurrentThread(void)
return NULL;
}
-/***********************************************************************
- * KeInitializeEvent (NTOSKRNL.EXE.@)
- */
-void WINAPI KeInitializeEvent( PRKEVENT Event, EVENT_TYPE Type, BOOLEAN State )
-{
- FIXME( "stub: %p %d %d\n", Event, Type, State );
-}
-
-
/***********************************************************************
* KeInitializeMutex (NTOSKRNL.EXE.@)
*/
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c
index 19af4f6..e7ff7ec 100644
--- a/dlls/ntoskrnl.exe/sync.c
+++ b/dlls/ntoskrnl.exe/sync.c
@@ -112,3 +112,16 @@ NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG count, void *pobjs[],
return ret;
}
+
+/***********************************************************************
+ * KeInitializeEvent (NTOSKRNL.EXE.@)
+ */
+void WINAPI KeInitializeEvent( PRKEVENT event, EVENT_TYPE type, BOOLEAN state )
+{
+ TRACE("event %p, type %u, state %u.\n", event, type, state);
+
+ event->Header.Type = type;
+ event->Header.SignalState = state;
+ event->Header.WaitListHead.Blink = NULL;
+ event->Header.WaitListHead.Flink = NULL;
+}
diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h
index 32e8f8b..350a08e 100644
--- a/include/ddk/wdm.h
+++ b/include/ddk/wdm.h
@@ -1419,6 +1419,7 @@ NTSTATUS WINAPI IoSetDeviceInterfaceState(UNICODE_STRING*,BOOLEAN);
NTSTATUS WINAPI IoWMIRegistrationControl(PDEVICE_OBJECT,ULONG);
PKTHREAD WINAPI KeGetCurrentThread(void);
+void WINAPI KeInitializeEvent(PRKEVENT,EVENT_TYPE,BOOLEAN);
void WINAPI KeInitializeSemaphore(PRKSEMAPHORE,LONG,LONG);
void WINAPI KeInitializeTimerEx(PKTIMER,TIMER_TYPE);
void WINAPI KeQuerySystemTime(LARGE_INTEGER*);
--
2.7.4

View File

@ -0,0 +1,71 @@
From e79d53d2194bc662be4853e2adf9e98be03751ce Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 17:39:23 -0500
Subject: [PATCH 03/17] ntoskrnl.exe: Implement KeSetEvent().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/ntoskrnl.c | 10 ----------
dlls/ntoskrnl.exe/sync.c | 21 +++++++++++++++++++++
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index e61b18d..97bb30b 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -2248,16 +2248,6 @@ LONG WINAPI KeResetEvent( PRKEVENT Event )
/***********************************************************************
- * KeSetEvent (NTOSKRNL.EXE.@)
- */
-LONG WINAPI KeSetEvent( PRKEVENT Event, KPRIORITY Increment, BOOLEAN Wait )
-{
- FIXME("(%p, %d, %d): stub\n", Event, Increment, Wait);
- return 0;
-}
-
-
-/***********************************************************************
* KeSetPriorityThread (NTOSKRNL.EXE.@)
*/
KPRIORITY WINAPI KeSetPriorityThread( PKTHREAD Thread, KPRIORITY Priority )
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c
index e7ff7ec..05d50ef 100644
--- a/dlls/ntoskrnl.exe/sync.c
+++ b/dlls/ntoskrnl.exe/sync.c
@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
+#include "wine/port.h"
#include <stdarg.h>
#include "ntstatus.h"
@@ -125,3 +127,22 @@ void WINAPI KeInitializeEvent( PRKEVENT event, EVENT_TYPE type, BOOLEAN state )
event->Header.WaitListHead.Blink = NULL;
event->Header.WaitListHead.Flink = NULL;
}
+
+/***********************************************************************
+ * KeSetEvent (NTOSKRNL.EXE.@)
+ */
+LONG WINAPI KeSetEvent( PRKEVENT event, KPRIORITY increment, BOOLEAN wait )
+{
+ HANDLE handle = event->Header.WaitListHead.Blink;
+ LONG ret;
+
+ TRACE("event %p, increment %d, wait %u.\n", event, increment, wait);
+
+ EnterCriticalSection( &sync_cs );
+ ret = interlocked_xchg( &event->Header.SignalState, TRUE );
+ if (handle)
+ SetEvent( handle );
+ LeaveCriticalSection( &sync_cs );
+
+ return ret;
+}
--
2.7.4

View File

@ -0,0 +1,62 @@
From 87d1900d05c4944b1d1d2cc046e6adf89ae53b78 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 17:41:17 -0500
Subject: [PATCH 04/17] ntoskrnl.exe: Implement KeResetEvent().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/ntoskrnl.c | 10 ----------
dlls/ntoskrnl.exe/sync.c | 19 +++++++++++++++++++
2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 97bb30b..99fa910 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -2238,16 +2238,6 @@ ULONG WINAPI KeQueryTimeIncrement(void)
/***********************************************************************
- * KeResetEvent (NTOSKRNL.EXE.@)
- */
-LONG WINAPI KeResetEvent( PRKEVENT Event )
-{
- FIXME("(%p): stub\n", Event);
- return 0;
-}
-
-
-/***********************************************************************
* KeSetPriorityThread (NTOSKRNL.EXE.@)
*/
KPRIORITY WINAPI KeSetPriorityThread( PKTHREAD Thread, KPRIORITY Priority )
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c
index 05d50ef..f011a60 100644
--- a/dlls/ntoskrnl.exe/sync.c
+++ b/dlls/ntoskrnl.exe/sync.c
@@ -146,3 +146,22 @@ LONG WINAPI KeSetEvent( PRKEVENT event, KPRIORITY increment, BOOLEAN wait )
return ret;
}
+
+/***********************************************************************
+ * KeResetEvent (NTOSKRNL.EXE.@)
+ */
+LONG WINAPI KeResetEvent( PRKEVENT event )
+{
+ HANDLE handle = event->Header.WaitListHead.Blink;
+ LONG ret;
+
+ TRACE("event %p.\n", event);
+
+ EnterCriticalSection( &sync_cs );
+ ret = interlocked_xchg( &event->Header.SignalState, FALSE );
+ if (handle)
+ ResetEvent( handle );
+ LeaveCriticalSection( &sync_cs );
+
+ return ret;
+}
--
2.7.4

View File

@ -0,0 +1,62 @@
From c5f36ac202c20faa00fc67c9d1cdc977ce877933 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 17:42:12 -0500
Subject: [PATCH 05/17] ntoskrnl.exe: Implement KeClearEvent().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/ntoskrnl.c | 8 --------
dlls/ntoskrnl.exe/sync.c | 8 ++++++++
include/ddk/wdm.h | 1 +
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 99fa910..646c528 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -3730,14 +3730,6 @@ NTSTATUS WINAPI IoCreateFile(HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBUT
}
/***********************************************************************
- * KeClearEvent (NTOSKRNL.EXE.@)
- */
-VOID WINAPI KeClearEvent(PRKEVENT event)
-{
- FIXME("stub: %p\n", event);
-}
-
-/***********************************************************************
* KeAcquireInStackQueuedSpinLock (NTOSKRNL.EXE.@)
*/
#ifdef DEFINE_FASTCALL2_ENTRYPOINT
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c
index f011a60..a905fb3 100644
--- a/dlls/ntoskrnl.exe/sync.c
+++ b/dlls/ntoskrnl.exe/sync.c
@@ -165,3 +165,11 @@ LONG WINAPI KeResetEvent( PRKEVENT event )
return ret;
}
+
+/***********************************************************************
+ * KeClearEvent (NTOSKRNL.EXE.@)
+ */
+void WINAPI KeClearEvent( PRKEVENT event )
+{
+ KeResetEvent( event );
+}
diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h
index 350a08e..0fe73f2 100644
--- a/include/ddk/wdm.h
+++ b/include/ddk/wdm.h
@@ -1418,6 +1418,7 @@ void WINAPI IoReleaseCancelSpinLock(KIRQL);
NTSTATUS WINAPI IoSetDeviceInterfaceState(UNICODE_STRING*,BOOLEAN);
NTSTATUS WINAPI IoWMIRegistrationControl(PDEVICE_OBJECT,ULONG);
+void WINAPI KeClearEvent(PRKEVENT);
PKTHREAD WINAPI KeGetCurrentThread(void);
void WINAPI KeInitializeEvent(PRKEVENT,EVENT_TYPE,BOOLEAN);
void WINAPI KeInitializeSemaphore(PRKSEMAPHORE,LONG,LONG);
--
2.7.4

View File

@ -0,0 +1,71 @@
From cd87de5d368ccc030a11ddbcd409e8e1866f123a Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 17:44:30 -0500
Subject: [PATCH 06/17] ntoskrnl.exe: Implement KeWaitForSingleObject().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/ntoskrnl.c | 13 -------------
dlls/ntoskrnl.exe/sync.c | 9 +++++++++
include/ddk/wdm.h | 1 +
3 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 646c528..3002d4e 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -2255,19 +2255,6 @@ VOID WINAPI KeSetSystemAffinityThread(KAFFINITY Affinity)
}
/***********************************************************************
- * KeWaitForSingleObject (NTOSKRNL.EXE.@)
- */
-NTSTATUS WINAPI KeWaitForSingleObject(PVOID Object,
- KWAIT_REASON WaitReason,
- KPROCESSOR_MODE WaitMode,
- BOOLEAN Alertable,
- PLARGE_INTEGER Timeout)
-{
- FIXME( "stub: %p, %d, %d, %d, %p\n", Object, WaitReason, WaitMode, Alertable, Timeout );
- return STATUS_NOT_IMPLEMENTED;
-}
-
-/***********************************************************************
* IoRegisterFileSystem (NTOSKRNL.EXE.@)
*/
VOID WINAPI IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject)
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c
index a905fb3..423fdcf 100644
--- a/dlls/ntoskrnl.exe/sync.c
+++ b/dlls/ntoskrnl.exe/sync.c
@@ -116,6 +116,15 @@ NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG count, void *pobjs[],
}
/***********************************************************************
+ * KeWaitForSingleObject (NTOSKRNL.EXE.@)
+ */
+NTSTATUS WINAPI KeWaitForSingleObject( void *obj, KWAIT_REASON reason,
+ KPROCESSOR_MODE mode, BOOLEAN alertable, LARGE_INTEGER *timeout )
+{
+ return KeWaitForMultipleObjects( 1, &obj, WaitAny, reason, mode, alertable, timeout, NULL );
+}
+
+/***********************************************************************
* KeInitializeEvent (NTOSKRNL.EXE.@)
*/
void WINAPI KeInitializeEvent( PRKEVENT event, EVENT_TYPE type, BOOLEAN state )
diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h
index 0fe73f2..6b6ac19 100644
--- a/include/ddk/wdm.h
+++ b/include/ddk/wdm.h
@@ -1433,6 +1433,7 @@ LONG WINAPI KeSetEvent(PRKEVENT,KPRIORITY,BOOLEAN);
KPRIORITY WINAPI KeSetPriorityThread(PKTHREAD,KPRIORITY);
void WINAPI KeSetSystemAffinityThread(KAFFINITY);
NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG,void*[],WAIT_TYPE,KWAIT_REASON,KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*,KWAIT_BLOCK*);
+NTSTATUS WINAPI KeWaitForSingleObject(void*,KWAIT_REASON,KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*);
PVOID WINAPI MmAllocateContiguousMemory(SIZE_T,PHYSICAL_ADDRESS);
PVOID WINAPI MmAllocateNonCachedMemory(SIZE_T);
--
2.7.4

View File

@ -0,0 +1,148 @@
From 87f7e2ba60c625a3d409f49842c2311f8396b873 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 18:31:40 -0500
Subject: [PATCH 07/17] ntoskrnl.exe/tests: Add some tests for synchronization
functions.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/tests/driver.c | 116 +++++++++++++++++++++++++++++++++++++++
1 file changed, 116 insertions(+)
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c
index 68b6730..07a0adb 100644
--- a/dlls/ntoskrnl.exe/tests/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.c
@@ -210,6 +210,121 @@ static void test_load_driver(void)
ok(!ret, "got %#x\n", ret);
}
+static NTSTATUS wait_single(void *obj, ULONGLONG timeout)
+{
+ LARGE_INTEGER integer;
+
+ integer.QuadPart = timeout;
+ return KeWaitForSingleObject(obj, Executive, KernelMode, FALSE, &integer);
+}
+
+static NTSTATUS wait_multiple(ULONG count, void *objs[], WAIT_TYPE wait_type, ULONGLONG timeout)
+{
+ LARGE_INTEGER integer;
+
+ integer.QuadPart = timeout;
+ return KeWaitForMultipleObjects(count, objs, wait_type, Executive, KernelMode, FALSE, &integer, NULL);
+}
+
+static void test_sync(void)
+{
+ KEVENT manual_event, auto_event;
+ void *objs[2];
+ NTSTATUS ret;
+
+ KeInitializeEvent(&manual_event, NotificationEvent, FALSE);
+
+ ret = wait_single(&manual_event, 0);
+ ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
+
+ KeSetEvent(&manual_event, 0, FALSE);
+
+ ret = wait_single(&manual_event, 0);
+ ok(ret == 0, "got %#x\n", ret);
+
+ ret = wait_single(&manual_event, 0);
+ ok(ret == 0, "got %#x\n", ret);
+
+ KeResetEvent(&manual_event);
+
+ ret = wait_single(&manual_event, 0);
+ ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
+
+ KeInitializeEvent(&auto_event, SynchronizationEvent, FALSE);
+
+ ret = wait_single(&auto_event, 0);
+ ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
+
+ KeSetEvent(&auto_event, 0, FALSE);
+
+ ret = wait_single(&auto_event, 0);
+ ok(ret == 0, "got %#x\n", ret);
+
+ ret = wait_single(&auto_event, 0);
+ ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
+
+ KeInitializeEvent(&auto_event, SynchronizationEvent, TRUE);
+
+ ret = wait_single(&auto_event, 0);
+ ok(ret == 0, "got %#x\n", ret);
+
+ objs[0] = &manual_event;
+ objs[1] = &auto_event;
+
+ ret = wait_multiple(2, objs, WaitAny, 0);
+ ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
+
+ KeSetEvent(&manual_event, 0, FALSE);
+ KeSetEvent(&auto_event, 0, FALSE);
+
+ ret = wait_multiple(2, objs, WaitAny, 0);
+ ok(ret == 0, "got %#x\n", ret);
+
+ ret = wait_single(&auto_event, 0);
+ ok(ret == 0, "got %#x\n", ret);
+
+ KeResetEvent(&manual_event);
+ KeSetEvent(&auto_event, 0, FALSE);
+
+ ret = wait_multiple(2, objs, WaitAny, 0);
+ ok(ret == 1, "got %#x\n", ret);
+
+ ret = wait_multiple(2, objs, WaitAny, 0);
+ ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
+
+ KeSetEvent(&manual_event, 0, FALSE);
+ KeSetEvent(&auto_event, 0, FALSE);
+
+ ret = wait_multiple(2, objs, WaitAll, 0);
+ ok(ret == 0, "got %#x\n", ret);
+
+ ret = wait_multiple(2, objs, WaitAll, 0);
+ ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
+
+ KeSetEvent(&auto_event, 0, FALSE);
+ KeResetEvent(&manual_event);
+
+ ret = wait_multiple(2, objs, WaitAll, 0);
+ ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
+
+ ret = wait_single(&auto_event, 0);
+ ok(ret == 0, "got %#x\n", ret);
+
+ objs[0] = &auto_event;
+ objs[1] = &manual_event;
+ KeSetEvent(&manual_event, 0, FALSE);
+ KeSetEvent(&auto_event, 0, FALSE);
+
+ ret = wait_multiple(2, objs, WaitAny, 0);
+ ok(ret == 0, "got %#x\n", ret);
+
+ ret = wait_multiple(2, objs, WaitAny, 0);
+ ok(ret == 1, "got %#x\n", ret);
+
+ ret = wait_multiple(2, objs, WaitAny, 0);
+ ok(ret == 1, "got %#x\n", ret);
+}
+
static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
{
ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength;
@@ -237,6 +352,7 @@ static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
test_mdl_map();
test_init_funcs();
test_load_driver();
+ test_sync();
/* print process report */
if (test_input->winetest_debug)
--
2.7.4

View File

@ -0,0 +1,64 @@
From 26324192918d2d16d92978abebed83d63c7ffc3f Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 20:22:29 -0500
Subject: [PATCH 08/17] ntoskrnl.exe: Implement KeInitializeSemaphore().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/ntoskrnl.c | 9 ---------
dlls/ntoskrnl.exe/sync.c | 15 +++++++++++++++
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 3002d4e..db8af82 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -2116,15 +2116,6 @@ LONG WINAPI KeReleaseMutex(PRKMUTEX Mutex, BOOLEAN Wait)
/***********************************************************************
- * KeInitializeSemaphore (NTOSKRNL.EXE.@)
- */
-void WINAPI KeInitializeSemaphore( PRKSEMAPHORE Semaphore, LONG Count, LONG Limit )
-{
- FIXME( "(%p %d %d) stub\n", Semaphore , Count, Limit );
-}
-
-
-/***********************************************************************
* KeInitializeSpinLock (NTOSKRNL.EXE.@)
*/
void WINAPI KeInitializeSpinLock( PKSPIN_LOCK SpinLock )
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c
index 423fdcf..c072d36 100644
--- a/dlls/ntoskrnl.exe/sync.c
+++ b/dlls/ntoskrnl.exe/sync.c
@@ -38,6 +38,7 @@ enum object_type
{
TYPE_MANUAL_EVENT = 0,
TYPE_AUTO_EVENT = 1,
+ TYPE_SEMAPHORE = 5,
};
static CRITICAL_SECTION sync_cs;
@@ -182,3 +183,17 @@ void WINAPI KeClearEvent( PRKEVENT event )
{
KeResetEvent( event );
}
+
+/***********************************************************************
+ * KeInitializeSemaphore (NTOSKRNL.EXE.@)
+ */
+void WINAPI KeInitializeSemaphore( PRKSEMAPHORE semaphore, LONG count, LONG limit )
+{
+ TRACE("semaphore %p, count %d, limit %d.\n", semaphore, count, limit);
+
+ semaphore->Header.Type = TYPE_SEMAPHORE;
+ semaphore->Header.SignalState = count;
+ semaphore->Header.WaitListHead.Blink = NULL;
+ semaphore->Header.WaitListHead.Flink = NULL;
+ semaphore->Limit = limit;
+}
--
2.7.4

View File

@ -0,0 +1,176 @@
From 503285d89d3c0d63331697d6e87d0b225d2ccb05 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 20:45:54 -0500
Subject: [PATCH 09/17] ntoskrnl.exe: Implement KeReleaseSemaphore() and
waiting on semaphores.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/ntoskrnl.c | 11 -------
dlls/ntoskrnl.exe/sync.c | 31 +++++++++++++++++++
dlls/ntoskrnl.exe/tests/driver.c | 64 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 95 insertions(+), 11 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index db8af82..b367323 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -2209,17 +2209,6 @@ void WINAPI KeQueryTickCount( LARGE_INTEGER *count )
/***********************************************************************
- * KeReleaseSemaphore (NTOSKRNL.EXE.@)
- */
-LONG WINAPI KeReleaseSemaphore( PRKSEMAPHORE Semaphore, KPRIORITY Increment,
- LONG Adjustment, BOOLEAN Wait )
-{
- FIXME("(%p %d %d %d) stub\n", Semaphore, Increment, Adjustment, Wait );
- return 0;
-}
-
-
-/***********************************************************************
* KeQueryTimeIncrement (NTOSKRNL.EXE.@)
*/
ULONG WINAPI KeQueryTimeIncrement(void)
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c
index c072d36..30160f7 100644
--- a/dlls/ntoskrnl.exe/sync.c
+++ b/dlls/ntoskrnl.exe/sync.c
@@ -83,6 +83,13 @@ NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG count, void *pobjs[],
case TYPE_AUTO_EVENT:
objs[i]->WaitListHead.Blink = CreateEventW( NULL, FALSE, objs[i]->SignalState, NULL );
break;
+ case TYPE_SEMAPHORE:
+ {
+ KSEMAPHORE *semaphore = CONTAINING_RECORD(objs[i], KSEMAPHORE, Header);
+ objs[i]->WaitListHead.Blink = CreateSemaphoreW( NULL,
+ semaphore->Header.SignalState, semaphore->Limit, NULL );
+ break;
+ }
}
}
@@ -102,6 +109,9 @@ NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG count, void *pobjs[],
case TYPE_AUTO_EVENT:
objs[i]->SignalState = FALSE;
break;
+ case TYPE_SEMAPHORE:
+ --objs[i]->SignalState;
+ break;
}
}
@@ -197,3 +207,24 @@ void WINAPI KeInitializeSemaphore( PRKSEMAPHORE semaphore, LONG count, LONG limi
semaphore->Header.WaitListHead.Flink = NULL;
semaphore->Limit = limit;
}
+
+/***********************************************************************
+ * KeReleaseSemaphore (NTOSKRNL.EXE.@)
+ */
+LONG WINAPI KeReleaseSemaphore( PRKSEMAPHORE semaphore, KPRIORITY increment,
+ LONG count, BOOLEAN wait )
+{
+ HANDLE handle = semaphore->Header.WaitListHead.Blink;
+ LONG ret;
+
+ TRACE("semaphore %p, increment %d, count %d, wait %u.\n",
+ semaphore, increment, count, wait);
+
+ EnterCriticalSection( &sync_cs );
+ ret = interlocked_xchg_add( &semaphore->Header.SignalState, count );
+ if (handle)
+ ReleaseSemaphore( handle, count, NULL );
+ LeaveCriticalSection( &sync_cs );
+
+ return ret;
+}
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c
index 07a0adb..852a726 100644
--- a/dlls/ntoskrnl.exe/tests/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.c
@@ -228,9 +228,11 @@ static NTSTATUS wait_multiple(ULONG count, void *objs[], WAIT_TYPE wait_type, UL
static void test_sync(void)
{
+ KSEMAPHORE semaphore, semaphore2;
KEVENT manual_event, auto_event;
void *objs[2];
NTSTATUS ret;
+ int i;
KeInitializeEvent(&manual_event, NotificationEvent, FALSE);
@@ -323,6 +325,68 @@ static void test_sync(void)
ret = wait_multiple(2, objs, WaitAny, 0);
ok(ret == 1, "got %#x\n", ret);
+
+ /* test semaphores */
+ KeInitializeSemaphore(&semaphore, 0, 5);
+
+ ret = wait_single(&semaphore, 0);
+ ok(ret == STATUS_TIMEOUT, "got %u\n", ret);
+
+ ret = KeReleaseSemaphore(&semaphore, 0, 1, FALSE);
+ ok(ret == 0, "got prev %d\n", ret);
+
+ ret = KeReleaseSemaphore(&semaphore, 0, 2, FALSE);
+ ok(ret == 1, "got prev %d\n", ret);
+
+ ret = KeReleaseSemaphore(&semaphore, 0, 1, FALSE);
+ ok(ret == 3, "got prev %d\n", ret);
+
+ for (i = 0; i < 4; i++)
+ {
+ ret = wait_single(&semaphore, 0);
+ ok(ret == 0, "got %#x\n", ret);
+ }
+
+ ret = wait_single(&semaphore, 0);
+ ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
+
+ KeInitializeSemaphore(&semaphore2, 3, 5);
+
+ ret = KeReleaseSemaphore(&semaphore2, 0, 1, FALSE);
+ ok(ret == 3, "got prev %d\n", ret);
+
+ for (i = 0; i < 4; i++)
+ {
+ ret = wait_single(&semaphore2, 0);
+ ok(ret == 0, "got %#x\n", ret);
+ }
+
+ objs[0] = &semaphore;
+ objs[1] = &semaphore2;
+
+ ret = wait_multiple(2, objs, WaitAny, 0);
+ ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
+
+ KeReleaseSemaphore(&semaphore, 0, 1, FALSE);
+ KeReleaseSemaphore(&semaphore2, 0, 1, FALSE);
+
+ ret = wait_multiple(2, objs, WaitAny, 0);
+ ok(ret == 0, "got %#x\n", ret);
+
+ ret = wait_multiple(2, objs, WaitAny, 0);
+ ok(ret == 1, "got %#x\n", ret);
+
+ ret = wait_multiple(2, objs, WaitAny, 0);
+ ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
+
+ KeReleaseSemaphore(&semaphore, 0, 1, FALSE);
+ KeReleaseSemaphore(&semaphore2, 0, 1, FALSE);
+
+ ret = wait_multiple(2, objs, WaitAll, 0);
+ ok(ret == 0, "got %#x\n", ret);
+
+ ret = wait_multiple(2, objs, WaitAny, 0);
+ ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
}
static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
--
2.7.4

View File

@ -0,0 +1,76 @@
From 07bc793086700ec42b25667e3e019a616ed13723 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 21:24:51 -0500
Subject: [PATCH 10/17] ntoskrnl.exe: Implement KeInitializeMutex().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/ntoskrnl.c | 9 ---------
dlls/ntoskrnl.exe/sync.c | 14 ++++++++++++++
include/ddk/wdm.h | 1 +
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index b367323..920fb74 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -2086,15 +2086,6 @@ PRKTHREAD WINAPI KeGetCurrentThread(void)
}
/***********************************************************************
- * KeInitializeMutex (NTOSKRNL.EXE.@)
- */
-void WINAPI KeInitializeMutex(PRKMUTEX Mutex, ULONG Level)
-{
- FIXME( "stub: %p, %u\n", Mutex, Level );
-}
-
-
- /***********************************************************************
* KeWaitForMutexObject (NTOSKRNL.EXE.@)
*/
NTSTATUS WINAPI KeWaitForMutexObject(PRKMUTEX Mutex, KWAIT_REASON WaitReason, KPROCESSOR_MODE WaitMode,
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c
index 30160f7..7535ae8 100644
--- a/dlls/ntoskrnl.exe/sync.c
+++ b/dlls/ntoskrnl.exe/sync.c
@@ -38,6 +38,7 @@ enum object_type
{
TYPE_MANUAL_EVENT = 0,
TYPE_AUTO_EVENT = 1,
+ TYPE_MUTEX = 2,
TYPE_SEMAPHORE = 5,
};
@@ -228,3 +229,16 @@ LONG WINAPI KeReleaseSemaphore( PRKSEMAPHORE semaphore, KPRIORITY increment,
return ret;
}
+
+/***********************************************************************
+ * KeInitializeMutex (NTOSKRNL.EXE.@)
+ */
+void WINAPI KeInitializeMutex( PRKMUTEX mutex, ULONG level )
+{
+ TRACE("mutex %p, level %u.\n", mutex, level);
+
+ mutex->Header.Type = TYPE_MUTEX;
+ mutex->Header.SignalState = 1;
+ mutex->Header.WaitListHead.Blink = NULL;
+ mutex->Header.WaitListHead.Flink = NULL;
+}
diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h
index 6b6ac19..c8adc7d 100644
--- a/include/ddk/wdm.h
+++ b/include/ddk/wdm.h
@@ -1421,6 +1421,7 @@ NTSTATUS WINAPI IoWMIRegistrationControl(PDEVICE_OBJECT,ULONG);
void WINAPI KeClearEvent(PRKEVENT);
PKTHREAD WINAPI KeGetCurrentThread(void);
void WINAPI KeInitializeEvent(PRKEVENT,EVENT_TYPE,BOOLEAN);
+void WINAPI KeInitializeMutex(PRKMUTEX,ULONG);
void WINAPI KeInitializeSemaphore(PRKSEMAPHORE,LONG,LONG);
void WINAPI KeInitializeTimerEx(PKTIMER,TIMER_TYPE);
void WINAPI KeQuerySystemTime(LARGE_INTEGER*);
--
2.7.4

View File

@ -0,0 +1,214 @@
From 7505150045f3ce4cd805e863913289156322b41d Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 21:43:37 -0500
Subject: [PATCH 11/17] ntoskrnl.exe: Implement KeReleaseMutex() and waiting on
mutexes.
We can get away with storing the mutex object in the KMUTEX for as long as
it's held, since on Windows it's illegal to destroy a mutex until it's
released.
Setting the flag OBJ_KERNEL_HANDLE on okfile is necessary to allow it to be
written to by system threads.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/ntoskrnl.c | 10 -------
dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 2 +-
dlls/ntoskrnl.exe/sync.c | 44 ++++++++++++++++++++++++++--
dlls/ntoskrnl.exe/tests/driver.c | 58 +++++++++++++++++++++++++++++++++++++
4 files changed, 101 insertions(+), 13 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 920fb74..cc88100 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -2096,16 +2096,6 @@ NTSTATUS WINAPI KeWaitForMutexObject(PRKMUTEX Mutex, KWAIT_REASON WaitReason, KP
}
- /***********************************************************************
- * KeReleaseMutex (NTOSKRNL.EXE.@)
- */
-LONG WINAPI KeReleaseMutex(PRKMUTEX Mutex, BOOLEAN Wait)
-{
- FIXME( "stub: %p, %d\n", Mutex, Wait );
- return STATUS_NOT_IMPLEMENTED;
-}
-
-
/***********************************************************************
* KeInitializeSpinLock (NTOSKRNL.EXE.@)
*/
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
index 422d575..f089f41 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
+++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
@@ -1402,7 +1402,7 @@
@ stdcall -private ZwUnloadKey(ptr) NtUnloadKey
@ stdcall -private ZwUnmapViewOfSection(long ptr) NtUnmapViewOfSection
@ stdcall -private ZwWaitForMultipleObjects(long ptr long long ptr) NtWaitForMultipleObjects
-@ stdcall -private ZwWaitForSingleObject(long long ptr) NtWaitForSingleObject
+@ stdcall ZwWaitForSingleObject(long long ptr) NtWaitForSingleObject
@ stdcall ZwWriteFile(long long ptr ptr ptr ptr long ptr ptr) NtWriteFile
@ stdcall -private ZwYieldExecution() NtYieldExecution
@ stdcall -private -arch=arm,x86_64 -norelay __chkstk()
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c
index 7535ae8..a038a07 100644
--- a/dlls/ntoskrnl.exe/sync.c
+++ b/dlls/ntoskrnl.exe/sync.c
@@ -84,6 +84,9 @@ NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG count, void *pobjs[],
case TYPE_AUTO_EVENT:
objs[i]->WaitListHead.Blink = CreateEventW( NULL, FALSE, objs[i]->SignalState, NULL );
break;
+ case TYPE_MUTEX:
+ objs[i]->WaitListHead.Blink = CreateMutexW( NULL, FALSE, NULL );
+ break;
case TYPE_SEMAPHORE:
{
KSEMAPHORE *semaphore = CONTAINING_RECORD(objs[i], KSEMAPHORE, Header);
@@ -110,6 +113,7 @@ NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG count, void *pobjs[],
case TYPE_AUTO_EVENT:
objs[i]->SignalState = FALSE;
break;
+ case TYPE_MUTEX:
case TYPE_SEMAPHORE:
--objs[i]->SignalState;
break;
@@ -118,8 +122,22 @@ NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG count, void *pobjs[],
if (!--*((ULONG_PTR *)&objs[i]->WaitListHead.Flink))
{
- CloseHandle(objs[i]->WaitListHead.Blink);
- objs[i]->WaitListHead.Blink = NULL;
+ switch (objs[i]->Type)
+ {
+ case TYPE_MANUAL_EVENT:
+ case TYPE_AUTO_EVENT:
+ case TYPE_SEMAPHORE:
+ CloseHandle(objs[i]->WaitListHead.Blink);
+ objs[i]->WaitListHead.Blink = NULL;
+ break;
+ case TYPE_MUTEX:
+ if (objs[i]->SignalState == 1)
+ {
+ CloseHandle(objs[i]->WaitListHead.Blink);
+ objs[i]->WaitListHead.Blink = NULL;
+ }
+ break;
+ }
}
}
LeaveCriticalSection( &sync_cs );
@@ -242,3 +260,25 @@ void WINAPI KeInitializeMutex( PRKMUTEX mutex, ULONG level )
mutex->Header.WaitListHead.Blink = NULL;
mutex->Header.WaitListHead.Flink = NULL;
}
+
+/***********************************************************************
+ * KeReleaseMutex (NTOSKRNL.EXE.@)
+ */
+LONG WINAPI KeReleaseMutex( PRKMUTEX mutex, BOOLEAN wait )
+{
+ HANDLE handle = mutex->Header.WaitListHead.Blink;
+ LONG ret;
+
+ TRACE("mutex %p, wait %u.\n", mutex, wait);
+
+ EnterCriticalSection( &sync_cs );
+ ret = mutex->Header.SignalState++;
+ if (!ret && !mutex->Header.WaitListHead.Flink)
+ {
+ CloseHandle( handle );
+ mutex->Header.WaitListHead.Blink = NULL;
+ }
+ LeaveCriticalSection( &sync_cs );
+
+ return ret;
+}
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c
index 852a726..e758e3f 100644
--- a/dlls/ntoskrnl.exe/tests/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.c
@@ -226,6 +226,36 @@ static NTSTATUS wait_multiple(ULONG count, void *objs[], WAIT_TYPE wait_type, UL
return KeWaitForMultipleObjects(count, objs, wait_type, Executive, KernelMode, FALSE, &integer, NULL);
}
+static void run_thread(PKSTART_ROUTINE proc, void *arg)
+{
+ OBJECT_ATTRIBUTES attr = {0};
+ HANDLE thread;
+ NTSTATUS ret;
+
+ attr.Length = sizeof(attr);
+ attr.Attributes = OBJ_KERNEL_HANDLE;
+ ret = PsCreateSystemThread(&thread, THREAD_ALL_ACCESS, &attr, NULL, NULL, proc, arg);
+ ok(!ret, "got %#x\n", ret);
+
+ ret = ZwWaitForSingleObject(thread, FALSE, NULL);
+ ok(!ret, "got %#x\n", ret);
+ ret = ZwClose(thread);
+ ok(!ret, "got %#x\n", ret);
+}
+
+static KMUTEX test_mutex;
+
+static void WINAPI mutex_thread(void *arg)
+{
+ NTSTATUS ret, expect = (NTSTATUS)(DWORD_PTR)arg;
+
+ ret = wait_single(&test_mutex, 0);
+ ok(ret == expect, "expected %#x, got %#x\n", expect, ret);
+
+ if (!ret) KeReleaseMutex(&test_mutex, FALSE);
+ PsTerminateSystemThread(STATUS_SUCCESS);
+}
+
static void test_sync(void)
{
KSEMAPHORE semaphore, semaphore2;
@@ -387,6 +417,33 @@ static void test_sync(void)
ret = wait_multiple(2, objs, WaitAny, 0);
ok(ret == STATUS_TIMEOUT, "got %#x\n", ret);
+
+ /* test mutexes */
+ KeInitializeMutex(&test_mutex, 0);
+
+ for (i = 0; i < 10; i++)
+ {
+ ret = wait_single(&test_mutex, 0);
+ ok(ret == 0, "got %#x\n", ret);
+ }
+
+ for (i = 0; i < 10; i++)
+ {
+ ret = KeReleaseMutex(&test_mutex, FALSE);
+ ok(ret == i - 9, "expected %d, got %d\n", i - 9, ret);
+ }
+
+ run_thread(mutex_thread, (void *)0);
+
+ ret = wait_single(&test_mutex, 0);
+ ok(ret == 0, "got %#x\n", ret);
+
+ run_thread(mutex_thread, (void *)STATUS_TIMEOUT);
+
+ ret = KeReleaseMutex(&test_mutex, 0);
+ ok(ret == 0, "got %#x\n", ret);
+
+ run_thread(mutex_thread, (void *)0);
}
static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
@@ -410,6 +467,7 @@ static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
winetest_debug = test_input->winetest_debug;
winetest_report_success = test_input->winetest_report_success;
attr.ObjectName = &pathU;
+ attr.Attributes = OBJ_KERNEL_HANDLE;
ZwOpenFile(&okfile, FILE_APPEND_DATA, &attr, &io, 0, 0);
test_currentprocess();
--
2.7.4

View File

@ -0,0 +1,57 @@
From 6f82120ba57b09b999bf02bf73828cf834601526 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 22:54:07 -0500
Subject: [PATCH 12/17] ntoskrnl.exe: Implement KeWaitForMutexObject().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/ntoskrnl.c | 11 -----------
dlls/ntoskrnl.exe/sync.c | 10 ++++++++++
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index cc88100..5034c5d 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -2085,17 +2085,6 @@ PRKTHREAD WINAPI KeGetCurrentThread(void)
return NULL;
}
- /***********************************************************************
- * KeWaitForMutexObject (NTOSKRNL.EXE.@)
- */
-NTSTATUS WINAPI KeWaitForMutexObject(PRKMUTEX Mutex, KWAIT_REASON WaitReason, KPROCESSOR_MODE WaitMode,
- BOOLEAN Alertable, PLARGE_INTEGER Timeout)
-{
- FIXME( "stub: %p, %d, %d, %d, %p\n", Mutex, WaitReason, WaitMode, Alertable, Timeout );
- return STATUS_NOT_IMPLEMENTED;
-}
-
-
/***********************************************************************
* KeInitializeSpinLock (NTOSKRNL.EXE.@)
*/
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c
index a038a07..acbbe3b 100644
--- a/dlls/ntoskrnl.exe/sync.c
+++ b/dlls/ntoskrnl.exe/sync.c
@@ -155,6 +155,16 @@ NTSTATUS WINAPI KeWaitForSingleObject( void *obj, KWAIT_REASON reason,
}
/***********************************************************************
+ * KeWaitForMutexObject (NTOSKRNL.EXE.@)
+ */
+NTSTATUS WINAPI KeWaitForMutexObject( PRKMUTEX mutex, KWAIT_REASON reason,
+ KPROCESSOR_MODE mode, BOOLEAN alertable, LARGE_INTEGER *timeout)
+{
+ return KeWaitForSingleObject( mutex, reason, mode, alertable, timeout );
+}
+
+
+/***********************************************************************
* KeInitializeEvent (NTOSKRNL.EXE.@)
*/
void WINAPI KeInitializeEvent( PRKEVENT event, EVENT_TYPE type, BOOLEAN state )
--
2.7.4

View File

@ -0,0 +1,86 @@
From c0897350d30abc3cfa7ee691ff99be58eb5c7456 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 22:30:05 -0500
Subject: [PATCH 13/17] ntoskrnl.exe: Implement KeInitializeTimerEx().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/ntoskrnl.c | 21 ---------------------
dlls/ntoskrnl.exe/sync.c | 25 +++++++++++++++++++++++++
2 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 5034c5d..24afdb6 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -2093,27 +2093,6 @@ void WINAPI KeInitializeSpinLock( PKSPIN_LOCK SpinLock )
FIXME( "stub: %p\n", SpinLock );
}
-
-/***********************************************************************
- * KeInitializeTimerEx (NTOSKRNL.EXE.@)
- */
-void WINAPI KeInitializeTimerEx( PKTIMER Timer, TIMER_TYPE Type )
-{
- FIXME( "stub: %p %d\n", Timer, Type );
-
- RtlZeroMemory(Timer, sizeof(KTIMER));
- Timer->Header.Type = Type ? 9 : 8;
-}
-
-
-/***********************************************************************
- * KeInitializeTimer (NTOSKRNL.EXE.@)
- */
-void WINAPI KeInitializeTimer( PKTIMER Timer )
-{
- KeInitializeTimerEx(Timer, NotificationTimer);
-}
-
/***********************************************************************
* KeInsertQueue (NTOSKRNL.EXE.@)
*/
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c
index acbbe3b..998cdf1 100644
--- a/dlls/ntoskrnl.exe/sync.c
+++ b/dlls/ntoskrnl.exe/sync.c
@@ -40,6 +40,8 @@ enum object_type
TYPE_AUTO_EVENT = 1,
TYPE_MUTEX = 2,
TYPE_SEMAPHORE = 5,
+ TYPE_MANUAL_TIMER = 8,
+ TYPE_AUTO_TIMER = 9,
};
static CRITICAL_SECTION sync_cs;
@@ -292,3 +294,26 @@ LONG WINAPI KeReleaseMutex( PRKMUTEX mutex, BOOLEAN wait )
return ret;
}
+
+/***********************************************************************
+ * KeInitializeTimerEx (NTOSKRNL.EXE.@)
+ */
+void WINAPI KeInitializeTimerEx( KTIMER *timer, TIMER_TYPE type )
+{
+ TRACE("timer %p, type %u.\n", timer, type);
+
+ RtlZeroMemory(timer, sizeof(KTIMER));
+ timer->Header.Type = (type == NotificationTimer) ? TYPE_MANUAL_TIMER : TYPE_AUTO_TIMER;
+ timer->Header.SignalState = FALSE;
+ timer->Header.Inserted = FALSE;
+ timer->Header.WaitListHead.Blink = NULL;
+ timer->Header.WaitListHead.Flink = NULL;
+}
+
+/***********************************************************************
+ * KeInitializeTimer (NTOSKRNL.EXE.@)
+ */
+void WINAPI KeInitializeTimer( KTIMER *timer )
+{
+ KeInitializeTimerEx(timer, NotificationTimer);
+}
--
2.7.4

View File

@ -0,0 +1,101 @@
From fc0b6eb91c49485a5f85e1df4f78e58e5e92fc93 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 22:52:48 -0500
Subject: [PATCH 14/17] ntoskrnl.exe: Implement KeSetTimerEx() and waiting on
timers.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/ntoskrnl.c | 9 ---------
dlls/ntoskrnl.exe/sync.c | 31 +++++++++++++++++++++++++++++++
include/ddk/wdm.h | 1 +
3 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 24afdb6..a7638c9 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -3625,15 +3625,6 @@ void WINAPI IoInvalidateDeviceRelations( DEVICE_OBJECT *device_object, DEVICE_RE
}
/***********************************************************************
- * KeSetTimerEx (NTOSKRNL.EXE.@)
- */
-BOOL WINAPI KeSetTimerEx( KTIMER *timer, LARGE_INTEGER duetime, LONG period, KDPC *dpc )
-{
- FIXME("stub: %p %s %u %p\n", timer, wine_dbgstr_longlong(duetime.QuadPart), period, dpc);
- return TRUE;
-}
-
-/***********************************************************************
* IoCreateFile (NTOSKRNL.EXE.@)
*/
NTSTATUS WINAPI IoCreateFile(HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr,
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c
index 998cdf1..46c214c 100644
--- a/dlls/ntoskrnl.exe/sync.c
+++ b/dlls/ntoskrnl.exe/sync.c
@@ -96,6 +96,9 @@ NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG count, void *pobjs[],
semaphore->Header.SignalState, semaphore->Limit, NULL );
break;
}
+ case TYPE_MANUAL_TIMER:
+ case TYPE_AUTO_TIMER:
+ break;
}
}
@@ -113,6 +116,7 @@ NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG count, void *pobjs[],
switch (objs[i]->Type)
{
case TYPE_AUTO_EVENT:
+ case TYPE_AUTO_TIMER:
objs[i]->SignalState = FALSE;
break;
case TYPE_MUTEX:
@@ -317,3 +321,30 @@ void WINAPI KeInitializeTimer( KTIMER *timer )
{
KeInitializeTimerEx(timer, NotificationTimer);
}
+
+/***********************************************************************
+ * KeSetTimerEx (NTOSKRNL.EXE.@)
+ */
+BOOLEAN WINAPI KeSetTimerEx( KTIMER *timer, LARGE_INTEGER duetime, LONG period, KDPC *dpc )
+{
+ BOOL manual = timer->Header.Type == TYPE_MANUAL_TIMER;
+ BOOL ret;
+
+ TRACE("timer %p, duetime %s, period %d, dpc %p.\n",
+ timer, wine_dbgstr_longlong(duetime.QuadPart), period, dpc);
+
+ if (dpc)
+ {
+ FIXME("Unhandled DPC %p.\n", dpc);
+ return FALSE;
+ }
+
+ EnterCriticalSection( &sync_cs );
+ ret = timer->Header.Inserted;
+ timer->Header.Inserted = TRUE;
+ timer->Header.WaitListHead.Blink = CreateWaitableTimerW( NULL, manual, NULL );
+ SetWaitableTimer( timer->Header.WaitListHead.Blink, &duetime, period, NULL, NULL, FALSE );
+ LeaveCriticalSection( &sync_cs );
+
+ return ret;
+}
diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h
index c8adc7d..483ee9f 100644
--- a/include/ddk/wdm.h
+++ b/include/ddk/wdm.h
@@ -1433,6 +1433,7 @@ LONG WINAPI KeResetEvent(PRKEVENT);
LONG WINAPI KeSetEvent(PRKEVENT,KPRIORITY,BOOLEAN);
KPRIORITY WINAPI KeSetPriorityThread(PKTHREAD,KPRIORITY);
void WINAPI KeSetSystemAffinityThread(KAFFINITY);
+BOOLEAN WINAPI KeSetTimerEx(KTIMER*,LARGE_INTEGER,LONG,KDPC*);
NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG,void*[],WAIT_TYPE,KWAIT_REASON,KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*,KWAIT_BLOCK*);
NTSTATUS WINAPI KeWaitForSingleObject(void*,KWAIT_REASON,KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*);
--
2.7.4

View File

@ -0,0 +1,64 @@
From 5ed6dd1e495351cb271ea302ad90689c76790f03 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 23:26:07 -0500
Subject: [PATCH 15/17] ntoskrnl.exe: Implement KeCancelTimer().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 2 +-
dlls/ntoskrnl.exe/sync.c | 16 ++++++++++++++++
include/ddk/wdm.h | 1 +
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
index f089f41..a22acf6 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
+++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
@@ -517,7 +517,7 @@
@ stub KeAttachProcess
@ stub KeBugCheck
@ stub KeBugCheckEx
-@ stub KeCancelTimer
+@ stdcall KeCancelTimer(ptr)
@ stub KeCapturePersistentThreadState
@ stdcall KeClearEvent(ptr)
@ stub KeConnectInterrupt
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c
index 46c214c..1b7650d 100644
--- a/dlls/ntoskrnl.exe/sync.c
+++ b/dlls/ntoskrnl.exe/sync.c
@@ -348,3 +348,19 @@ BOOLEAN WINAPI KeSetTimerEx( KTIMER *timer, LARGE_INTEGER duetime, LONG period,
return ret;
}
+
+BOOLEAN WINAPI KeCancelTimer( KTIMER *timer )
+{
+ BOOL ret;
+
+ TRACE("timer %p.\n", timer);
+
+ EnterCriticalSection( &sync_cs );
+ ret = timer->Header.Inserted;
+ timer->Header.Inserted = FALSE;
+ CloseHandle(timer->Header.WaitListHead.Blink);
+ timer->Header.WaitListHead.Blink = NULL;
+ LeaveCriticalSection( &sync_cs );
+
+ return ret;
+}
diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h
index 483ee9f..6be07b2 100644
--- a/include/ddk/wdm.h
+++ b/include/ddk/wdm.h
@@ -1418,6 +1418,7 @@ void WINAPI IoReleaseCancelSpinLock(KIRQL);
NTSTATUS WINAPI IoSetDeviceInterfaceState(UNICODE_STRING*,BOOLEAN);
NTSTATUS WINAPI IoWMIRegistrationControl(PDEVICE_OBJECT,ULONG);
+BOOLEAN WINAPI KeCancelTimer(KTIMER*);
void WINAPI KeClearEvent(PRKEVENT);
PKTHREAD WINAPI KeGetCurrentThread(void);
void WINAPI KeInitializeEvent(PRKEVENT,EVENT_TYPE,BOOLEAN);
--
2.7.4

View File

@ -0,0 +1,82 @@
From 3a663c622c17698fb567767ad15bb2e4d7e87671 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 19 Aug 2018 23:44:44 -0500
Subject: [PATCH 16/17] ntoskrnl.exe/tests: Add tests for waiting on timers.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/tests/driver.c | 51 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c
index e758e3f..efd6053 100644
--- a/dlls/ntoskrnl.exe/tests/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.c
@@ -260,6 +260,8 @@ static void test_sync(void)
{
KSEMAPHORE semaphore, semaphore2;
KEVENT manual_event, auto_event;
+ KTIMER timer;
+ LARGE_INTEGER timeout;
void *objs[2];
NTSTATUS ret;
int i;
@@ -444,6 +446,55 @@ static void test_sync(void)
ok(ret == 0, "got %#x\n", ret);
run_thread(mutex_thread, (void *)0);
+
+ /* test timers */
+ KeInitializeTimerEx(&timer, NotificationTimer);
+
+ timeout.QuadPart = -100;
+ KeSetTimerEx(&timer, timeout, 0, NULL);
+
+ ret = wait_single(&timer, 0);
+ ok(ret == WAIT_TIMEOUT, "got %#x\n", ret);
+
+ ret = wait_single(&timer, -200);
+ ok(ret == 0, "got %#x\n", ret);
+
+ ret = wait_single(&timer, 0);
+ ok(ret == 0, "got %#x\n", ret);
+
+ KeCancelTimer(&timer);
+ KeInitializeTimerEx(&timer, SynchronizationTimer);
+
+ KeSetTimerEx(&timer, timeout, 0, NULL);
+
+ ret = wait_single(&timer, 0);
+ ok(ret == WAIT_TIMEOUT, "got %#x\n", ret);
+
+ ret = wait_single(&timer, -200);
+ ok(ret == 0, "got %#x\n", ret);
+
+ ret = wait_single(&timer, 0);
+ ok(ret == WAIT_TIMEOUT, "got %#x\n", ret);
+
+ KeCancelTimer(&timer);
+ KeSetTimerEx(&timer, timeout, 10, NULL);
+
+ ret = wait_single(&timer, 0);
+ ok(ret == WAIT_TIMEOUT, "got %#x\n", ret);
+
+ ret = wait_single(&timer, -200);
+ ok(ret == 0, "got %#x\n", ret);
+
+ ret = wait_single(&timer, 0);
+ ok(ret == WAIT_TIMEOUT, "got %#x\n", ret);
+
+ ret = wait_single(&timer, -20 * 10000);
+ ok(ret == 0, "got %#x\n", ret);
+
+ ret = wait_single(&timer, -20 * 10000);
+ ok(ret == 0, "got %#x\n", ret);
+
+ KeCancelTimer(&timer);
}
static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
--
2.7.4

View File

@ -0,0 +1,64 @@
From 0f4c4d67760fc31cbb92112be492f9ede35a6170 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Wed, 22 Aug 2018 13:29:56 -0500
Subject: [PATCH 17/17] ntoskrnl.exe: Implement KeDelayExecutionThread().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/ntoskrnl.exe/ntoskrnl.c | 9 ---------
dlls/ntoskrnl.exe/sync.c | 9 +++++++++
include/ddk/wdm.h | 1 +
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index a7638c9..32fd1d0 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -2998,15 +2998,6 @@ NTSTATUS WINAPI CmUnRegisterCallback(LARGE_INTEGER cookie)
}
/***********************************************************************
- * KeDelayExecutionThread (NTOSKRNL.EXE.@)
- */
-NTSTATUS WINAPI KeDelayExecutionThread(KPROCESSOR_MODE waitmode, BOOLEAN alertable, PLARGE_INTEGER interval)
-{
- FIXME("(%u, %u, %p): stub\n", waitmode, alertable, interval);
- return STATUS_NOT_IMPLEMENTED;
-}
-
-/***********************************************************************
* IoAttachDevice (NTOSKRNL.EXE.@)
*/
NTSTATUS WINAPI IoAttachDevice(DEVICE_OBJECT *source, UNICODE_STRING *target, DEVICE_OBJECT *attached)
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c
index 1b7650d..21778a3 100644
--- a/dlls/ntoskrnl.exe/sync.c
+++ b/dlls/ntoskrnl.exe/sync.c
@@ -364,3 +364,12 @@ BOOLEAN WINAPI KeCancelTimer( KTIMER *timer )
return ret;
}
+
+/***********************************************************************
+ * KeDelayExecutionThread (NTOSKRNL.EXE.@)
+ */
+NTSTATUS WINAPI KeDelayExecutionThread( KPROCESSOR_MODE mode, BOOLEAN alertable, LARGE_INTEGER *timeout )
+{
+ TRACE("mode %d, alertable %u, timeout %p.\n", mode, alertable, timeout);
+ return NtDelayExecution( alertable, timeout );
+}
diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h
index 6be07b2..b5e4424 100644
--- a/include/ddk/wdm.h
+++ b/include/ddk/wdm.h
@@ -1420,6 +1420,7 @@ NTSTATUS WINAPI IoWMIRegistrationControl(PDEVICE_OBJECT,ULONG);
BOOLEAN WINAPI KeCancelTimer(KTIMER*);
void WINAPI KeClearEvent(PRKEVENT);
+NTSTATUS WINAPI KeDelayExecutionThread(KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*);
PKTHREAD WINAPI KeGetCurrentThread(void);
void WINAPI KeInitializeEvent(PRKEVENT,EVENT_TYPE,BOOLEAN);
void WINAPI KeInitializeMutex(PRKMUTEX,ULONG);
--
2.7.4

View File

@ -0,0 +1 @@
Fixes: [44588] Multiple kernel drivers need ntoskrnl.exe.KeWaitForMultipleObjects semi-stub (Franson VSerial service 'bizvserialnt.sys')

View File

@ -246,6 +246,7 @@ patch_enable_all ()
enable_ntdll_futex_condition_var="$1"
enable_ntdll_set_full_cpu_context="$1"
enable_ntoskrnl_Stubs="$1"
enable_ntoskrnl_Synchronization="$1"
enable_ntoskrnl_exe_Fix_Relocation="$1"
enable_nvapi_Stub_DLL="$1"
enable_nvcuda_CUDA_Support="$1"
@ -904,6 +905,9 @@ patch_enable ()
ntoskrnl-Stubs)
enable_ntoskrnl_Stubs="$2"
;;
ntoskrnl-Synchronization)
enable_ntoskrnl_Synchronization="$2"
;;
ntoskrnl.exe-Fix_Relocation)
enable_ntoskrnl_exe_Fix_Relocation="$2"
;;
@ -2009,7 +2013,11 @@ 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_ntoskrnl_Synchronization" -gt 1; then
abort "Patchset ntoskrnl-Synchronization disabled, but ntoskrnl-Stubs depends on that."
fi
enable_Compiler_Warnings=1
enable_ntoskrnl_Synchronization=1
fi
if test "$enable_ntdll_SystemRoot_Symlink" -eq 1; then
@ -5377,28 +5385,71 @@ if test "$enable_ntdll_set_full_cpu_context" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntoskrnl-Synchronization
# |
# | This patchset fixes the following Wine bugs:
# | * [#44588] Multiple kernel drivers need ntoskrnl.exe.KeWaitForMultipleObjects semi-stub (Franson VSerial service
# | 'bizvserialnt.sys')
# |
# | Modified files:
# | * dlls/ntoskrnl.exe/Makefile.in, dlls/ntoskrnl.exe/ntoskrnl.c, dlls/ntoskrnl.exe/ntoskrnl.exe.spec,
# | dlls/ntoskrnl.exe/sync.c, dlls/ntoskrnl.exe/tests/driver.c, include/ddk/ntddk.h, include/ddk/wdm.h
# |
if test "$enable_ntoskrnl_Synchronization" -eq 1; then
patch_apply ntoskrnl-Synchronization/0001-ntoskrnl.exe-Implement-KeWaitForMultipleObjects.patch
patch_apply ntoskrnl-Synchronization/0002-ntoskrnl.exe-Implement-KeInitializeEvent.patch
patch_apply ntoskrnl-Synchronization/0003-ntoskrnl.exe-Implement-KeSetEvent.patch
patch_apply ntoskrnl-Synchronization/0004-ntoskrnl.exe-Implement-KeResetEvent.patch
patch_apply ntoskrnl-Synchronization/0005-ntoskrnl.exe-Implement-KeClearEvent.patch
patch_apply ntoskrnl-Synchronization/0006-ntoskrnl.exe-Implement-KeWaitForSingleObject.patch
patch_apply ntoskrnl-Synchronization/0007-ntoskrnl.exe-tests-Add-some-tests-for-synchronizatio.patch
patch_apply ntoskrnl-Synchronization/0008-ntoskrnl.exe-Implement-KeInitializeSemaphore.patch
patch_apply ntoskrnl-Synchronization/0009-ntoskrnl.exe-Implement-KeReleaseSemaphore-and-waitin.patch
patch_apply ntoskrnl-Synchronization/0010-ntoskrnl.exe-Implement-KeInitializeMutex.patch
patch_apply ntoskrnl-Synchronization/0011-ntoskrnl.exe-Implement-KeReleaseMutex-and-waiting-on.patch
patch_apply ntoskrnl-Synchronization/0012-ntoskrnl.exe-Implement-KeWaitForMutexObject.patch
patch_apply ntoskrnl-Synchronization/0013-ntoskrnl.exe-Implement-KeInitializeTimerEx.patch
patch_apply ntoskrnl-Synchronization/0014-ntoskrnl.exe-Implement-KeSetTimerEx-and-waiting-on-t.patch
patch_apply ntoskrnl-Synchronization/0015-ntoskrnl.exe-Implement-KeCancelTimer.patch
patch_apply ntoskrnl-Synchronization/0016-ntoskrnl.exe-tests-Add-tests-for-waiting-on-timers.patch
patch_apply ntoskrnl-Synchronization/0017-ntoskrnl.exe-Implement-KeDelayExecutionThread.patch
(
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe: Implement KeWaitForMultipleObjects().", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe: Implement KeInitializeEvent().", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe: Implement KeSetEvent().", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe: Implement KeResetEvent().", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe: Implement KeClearEvent().", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe: Implement KeWaitForSingleObject().", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe/tests: Add some tests for synchronization functions.", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe: Implement KeInitializeSemaphore().", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe: Implement KeReleaseSemaphore() and waiting on semaphores.", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe: Implement KeInitializeMutex().", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe: Implement KeReleaseMutex() and waiting on mutexes.", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe: Implement KeWaitForMutexObject().", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe: Implement KeInitializeTimerEx().", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe: Implement KeSetTimerEx() and waiting on timers.", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe: Implement KeCancelTimer().", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe/tests: Add tests for waiting on timers.", 1 },';
printf '%s\n' '+ { "Zebediah Figura", "ntoskrnl.exe: Implement KeDelayExecutionThread().", 1 },';
) >> "$patchlist"
fi
# Patchset ntoskrnl-Stubs
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * Compiler_Warnings
# | * Compiler_Warnings, ntoskrnl-Synchronization
# |
# | Modified files:
# | * 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
patch_apply ntoskrnl-Stubs/0006-ntoskrnl.exe-Improve-KeInitializeSemaphore-stub.patch
patch_apply ntoskrnl-Stubs/0009-ntoskrnl.exe-Implement-MmMapLockedPages-and-MmUnmapL.patch
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/0013-ntoskrnl.exe-Implement-NtBuildNumber.patch
patch_apply ntoskrnl-Stubs/0014-ntoskrnl.exe-Implement-ExInitializeNPagedLookasideLi.patch
(
printf '%s\n' '+ { "Alexander Morozov", "ntoskrnl.exe: Improve KeReleaseMutex stub.", 1 },';
printf '%s\n' '+ { "Alexander Morozov", "ntoskrnl.exe: Improve KeInitializeSemaphore stub.", 1 },';
printf '%s\n' '+ { "Christian Costa", "ntoskrnl.exe: Implement MmMapLockedPages and MmUnmapLockedPages.", 1 },';
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.exe: Implement NtBuildNumber.", 1 },';
printf '%s\n' '+ { "Michael Müller", "ntoskrnl.exe: Implement ExInitializeNPagedLookasideList.", 1 },';
@ -7516,7 +7567,7 @@ fi
# Patchset winedevice-Default_Drivers
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * dxva2-Video_Decoder, Compiler_Warnings, ntoskrnl-Stubs
# | * dxva2-Video_Decoder, Compiler_Warnings, ntoskrnl-Synchronization, ntoskrnl-Stubs
# |
# | Modified files:
# | * configure.ac, dlls/dxgkrnl.sys/Makefile.in, dlls/dxgkrnl.sys/dxgkrnl.sys.spec, dlls/dxgkrnl.sys/main.c,

View File

@ -1,4 +1,4 @@
From 32348a62aff8d7611598f5635269b13e4d2b67de Mon Sep 17 00:00:00 2001
From 1d23775a328b0a6c59db7888e29449625d95c012 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: [PATCH] programs/winedevice: Load some common drivers and fix ldr
@ -10,7 +10,7 @@ Subject: [PATCH] programs/winedevice: Load some common drivers and fix ldr
2 files changed, 78 insertions(+)
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c
index ab55b48..a104d95 100644
index 4f32c30..efb9b94 100644
--- a/dlls/ntoskrnl.exe/tests/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.c
@@ -31,6 +31,7 @@
@ -30,7 +30,7 @@ index ab55b48..a104d95 100644
static HANDLE okfile;
static LONG successes;
static LONG failures;
@@ -268,6 +271,52 @@ static void test_lookaside_list(void)
@@ -555,6 +558,52 @@ static void test_lookaside_list(void)
ExDeleteNPagedLookasideList(&list);
}
@ -83,15 +83,15 @@ index ab55b48..a104d95 100644
static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
{
ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength;
@@ -297,6 +346,7 @@ static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
test_load_driver();
@@ -586,6 +635,7 @@ static NTSTATUS main_test(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info)
test_sync();
test_version();
test_lookaside_list();
+ test_default_modules();
/* print process report */
if (test_input->winetest_debug)
@@ -405,6 +455,8 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry)
@@ -694,6 +744,8 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry)
DbgPrint("loading driver\n");
@ -139,5 +139,5 @@ index 201a041..33b332d 100644
if (!(stop_event = CreateEventW( NULL, TRUE, FALSE, NULL )))
return;
--
1.9.1
2.7.4