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 c1cfb032dd..07e9104498 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -2307,15 +2307,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.@) */ diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c index 8011b56754..2190faa81f 100644 --- a/dlls/ntoskrnl.exe/sync.c +++ b/dlls/ntoskrnl.exe/sync.c @@ -36,6 +36,7 @@ enum object_type { TYPE_MANUAL_EVENT = 0, TYPE_AUTO_EVENT = 1, + TYPE_SEMAPHORE = 5, };
static CRITICAL_SECTION sync_cs; @@ -172,3 +173,17 @@ LONG WINAPI KeResetEvent( PRKEVENT event )
return ret; } + +/*********************************************************************** + * 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; +}
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 07e9104498..d0e77c5df7 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -2400,17 +2400,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.@) */ diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c index 2190faa81f..77178462f5 100644 --- a/dlls/ntoskrnl.exe/sync.c +++ b/dlls/ntoskrnl.exe/sync.c @@ -81,6 +81,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; + } } }
@@ -100,6 +107,9 @@ NTSTATUS WINAPI KeWaitForMultipleObjects(ULONG count, void *pobjs[], case TYPE_AUTO_EVENT: objs[i]->SignalState = FALSE; break; + case TYPE_SEMAPHORE: + --objs[i]->SignalState; + break; } }
@@ -187,3 +197,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 = InterlockedExchangeAdd( &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 07a0adba60..852a726413 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)
Zebediah Figura z.figura12@gmail.com wrote:
case TYPE_SEMAPHORE:
{
KSEMAPHORE *semaphore = CONTAINING_RECORD(objs[i], KSEMAPHORE, Header);
objs[i]->WaitListHead.Blink = CreateSemaphoreW( NULL,
semaphore->Header.SignalState, semaphore->Limit, NULL );
break;
}
...
- EnterCriticalSection( &sync_cs );
- ret = InterlockedExchangeAdd( &semaphore->Header.SignalState, count );
- if (handle)
ReleaseSemaphore( handle, count, NULL );
- LeaveCriticalSection( &sync_cs );
Wouldn't it be better to use native instead of win32 APIs? This way you would be able to propagate errors instead of ignoring them.
On 11/27/18 12:58 AM, Dmitry Timoshkov wrote:
Zebediah Figura z.figura12@gmail.com wrote:
case TYPE_SEMAPHORE:
{
KSEMAPHORE *semaphore = CONTAINING_RECORD(objs[i], KSEMAPHORE, Header);
objs[i]->WaitListHead.Blink = CreateSemaphoreW( NULL,
semaphore->Header.SignalState, semaphore->Limit, NULL );
break;
}
...
- EnterCriticalSection( &sync_cs );
- ret = InterlockedExchangeAdd( &semaphore->Header.SignalState, count );
- if (handle)
ReleaseSemaphore( handle, count, NULL );
- LeaveCriticalSection( &sync_cs );
Wouldn't it be better to use native instead of win32 APIs? This way you would be able to propagate errors instead of ignoring them.
Kernel sync functions, as a rule, don't return errors. For example, KeReleaseSemaphore() returns the previous count, and raises an exception if the limit is exceeded. Similarly, while KeWaitForMultipleObjects() does return an NTSTATUS, error conditions (like passing more than 64 objects, or waiting too many times on a mutex) result in exceptions or panics.
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 d0e77c5df7..1d1033e793 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -2277,15 +2277,6 @@ PRKTHREAD WINAPI KeGetCurrentThread(void) return NULL; }
- /*********************************************************************** - * KeInitializeMutex (NTOSKRNL.EXE.@) - */ -void WINAPI KeInitializeMutex(PRKMUTEX Mutex, ULONG Level) -{ - FIXME( "stub: %p, %u\n", Mutex, Level ); -} - - /*********************************************************************** * KeWaitForMutexObject (NTOSKRNL.EXE.@) */ diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c index 77178462f5..6f356f6355 100644 --- a/dlls/ntoskrnl.exe/sync.c +++ b/dlls/ntoskrnl.exe/sync.c @@ -36,6 +36,7 @@ enum object_type { TYPE_MANUAL_EVENT = 0, TYPE_AUTO_EVENT = 1, + TYPE_MUTEX = 2, TYPE_SEMAPHORE = 5, };
@@ -218,3 +219,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 522bb3f9c8..831304eb53 100644 --- a/include/ddk/wdm.h +++ b/include/ddk/wdm.h @@ -1421,6 +1421,7 @@ NTSTATUS WINAPI IoWMIRegistrationControl(PDEVICE_OBJECT,ULONG);
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*);
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 | 46 +++++++++++++++++++++++++++-- dlls/ntoskrnl.exe/tests/driver.c | 58 +++++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 13 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index 1d1033e793..7838bd9545 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -2288,16 +2288,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 d127a25270..f56bde130d 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec @@ -1404,7 +1404,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 6f356f6355..0947b671f5 100644 --- a/dlls/ntoskrnl.exe/sync.c +++ b/dlls/ntoskrnl.exe/sync.c @@ -82,6 +82,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); @@ -108,6 +111,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; @@ -116,8 +120,24 @@ 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: + /* Native will panic if a mutex is destroyed while held, so we + * don't have to worry about leaking the handle here. */ + if (objs[i]->SignalState == 1) + { + CloseHandle(objs[i]->WaitListHead.Blink); + objs[i]->WaitListHead.Blink = NULL; + } + break; + } } } LeaveCriticalSection( &sync_cs ); @@ -232,3 +252,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 852a726413..82948823c5 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; /* needed to be accessible from system threads */ ZwOpenFile(&okfile, FILE_APPEND_DATA, &attr, &io, 0, 0);
test_currentprocess();
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 7838bd9545..861fb53996 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -2277,17 +2277,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 0947b671f5..84cb0cee73 100644 --- a/dlls/ntoskrnl.exe/sync.c +++ b/dlls/ntoskrnl.exe/sync.c @@ -154,6 +154,16 @@ NTSTATUS WINAPI KeWaitForSingleObject( void *obj, KWAIT_REASON reason, return KeWaitForMultipleObjects( 1, &obj, WaitAny, reason, mode, alertable, timeout, NULL ); }
+/*********************************************************************** + * 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.@) */
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 861fb53996..712681e0f9 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -3866,14 +3866,6 @@ NTSTATUS WINAPI IoCreateFile(HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBUT return STATUS_NOT_IMPLEMENTED; }
-/*********************************************************************** - * KeClearEvent (NTOSKRNL.EXE.@) - */ -VOID WINAPI KeClearEvent(PRKEVENT event) -{ - FIXME("stub: %p\n", event); -} - /*********************************************************************** * KeAcquireInStackQueuedSpinLock (NTOSKRNL.EXE.@) */ diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c index 84cb0cee73..e63c7935bb 100644 --- a/dlls/ntoskrnl.exe/sync.c +++ b/dlls/ntoskrnl.exe/sync.c @@ -215,6 +215,14 @@ LONG WINAPI KeResetEvent( PRKEVENT event ) return ret; }
+/*********************************************************************** + * KeClearEvent (NTOSKRNL.EXE.@) + */ +void WINAPI KeClearEvent( PRKEVENT event ) +{ + KeResetEvent( event ); +} + /*********************************************************************** * KeInitializeSemaphore (NTOSKRNL.EXE.@) */ diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h index 831304eb53..f70b745bc8 100644 --- a/include/ddk/wdm.h +++ b/include/ddk/wdm.h @@ -1419,6 +1419,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 KeInitializeMutex(PRKMUTEX,ULONG);