Signed-off-by: Derek Lesho dereklesho52@Gmail.com --- dlls/ntoskrnl.exe/ntoskrnl.c | 9 +++++++++ dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 2 +- dlls/ntoskrnl.exe/tests/driver.c | 22 ++++++++++++++++++++++ include/ddk/ntifs.h | 1 + 4 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index 80e53b4f72..46fd243d75 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -3015,6 +3015,15 @@ HANDLE WINAPI PsGetCurrentThreadId(void) }
+/*********************************************************************** + * PsIsSystemThread (NTOSKRNL.EXE.@) + */ +BOOLEAN WINAPI PsIsSystemThread(PETHREAD thread) +{ + return ((PKTHREAD)thread)->process == PsInitialSystemProcess; +} + + /*********************************************************************** * PsGetVersion (NTOSKRNL.EXE.@) */ diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec index f948c6befe..399258cdfd 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec @@ -907,7 +907,7 @@ @ stdcall PsImpersonateClient(ptr ptr long long long) @ extern PsInitialSystemProcess @ stub PsIsProcessBeingDebugged -@ stub PsIsSystemThread +@ stdcall PsIsSystemThread(ptr) @ stub PsIsThreadImpersonating @ stub PsIsThreadTerminating @ stub PsJobType diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index 66465bb5ae..ebfdb05b86 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -29,6 +29,7 @@ #include "winternl.h" #include "winioctl.h" #include "ddk/ntddk.h" +#include "ddk/ntifs.h" #include "ddk/wdm.h"
#include "driver.h" @@ -826,6 +827,26 @@ static void test_ob_reference(const WCHAR *test_path) ok(!status, "ZwClose failed: %#x\n", status); }
+static void WINAPI system_thread( void *arg ) +{ + BOOLEAN result = PsIsSystemThread((PETHREAD)KeGetCurrentThread()); + +todo_wine + ok((result), "got %u\n", result); + + PsTerminateSystemThread( STATUS_SUCCESS ); +} + +static void test_system_thread(void) +{ + BOOLEAN result = PsIsSystemThread((PETHREAD)KeGetCurrentThread()); + +todo_wine + ok(!(result), "got %u\n", result); + + run_thread( system_thread, (void*)0 ); +} + static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info) { ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength; @@ -868,6 +889,7 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st test_stack_callout(); test_lookaside_list(); test_ob_reference(test_input->path); + test_system_thread();
/* print process report */ if (winetest_debug) diff --git a/include/ddk/ntifs.h b/include/ddk/ntifs.h index ffa103bcc5..61f7526cbf 100644 --- a/include/ddk/ntifs.h +++ b/include/ddk/ntifs.h @@ -133,5 +133,6 @@ BOOLEAN WINAPI FsRtlIsNameInExpression(PUNICODE_STRING, PUNICODE_STRING, BOOLEAN NTSTATUS WINAPI ObQueryNameString(PVOID,POBJECT_NAME_INFORMATION,ULONG,PULONG); void WINAPI PsRevertToSelf(void); NTSTATUS WINAPI PsLookupProcessByProcessId(HANDLE,PEPROCESS*); +BOOLEAN WINAPI PsIsSystemThread(PETHREAD);
#endif