From ae6ae91d1abf87847f2d9218512f29c94a101a76 Mon Sep 17 00:00:00 2001 From: Derek Lesho Date: Fri, 19 Apr 2019 18:24:54 +0200 Subject: [PATCH] ntoskrnl.exe: Implement PsLookupProcessByProcessId. Signed-off-by: Derek Lesho Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/ntoskrnl.exe/ntoskrnl.c | 30 +++++++++++++++++++----------- include/ddk/ntifs.h | 1 + 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index d31082be148..7f3ca058cef 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -2482,6 +2482,25 @@ PEPROCESS WINAPI IoGetCurrentProcess(void) return NULL; } +/*********************************************************************** + * PsLookupProcessByProcessId (NTOSKRNL.EXE.@) + */ +NTSTATUS WINAPI PsLookupProcessByProcessId( HANDLE processid, PEPROCESS *process ) +{ + NTSTATUS status; + HANDLE handle; + + TRACE( "(%p %p)\n", processid, process ); + + if (!(handle = OpenProcess( PROCESS_ALL_ACCESS, FALSE, HandleToUlong(processid) ))) + return STATUS_INVALID_PARAMETER; + + status = ObReferenceObjectByHandle( handle, PROCESS_ALL_ACCESS, PsProcessType, KernelMode, (void**)process, NULL ); + + NtClose( handle ); + return status; +} + static void *create_thread_object( HANDLE handle ) { @@ -3254,17 +3273,6 @@ NTSTATUS WINAPI PsSetLoadImageNotifyRoutine(PLOAD_IMAGE_NOTIFY_ROUTINE routine) return STATUS_SUCCESS; } -/***************************************************** - * PsLookupProcessByProcessId (NTOSKRNL.EXE.@) - */ -NTSTATUS WINAPI PsLookupProcessByProcessId(HANDLE processid, PEPROCESS *process) -{ - static int once; - if (!once++) FIXME("(%p %p) stub\n", processid, process); - return STATUS_NOT_IMPLEMENTED; -} - - /***************************************************** * IoSetThreadHardErrorMode (NTOSKRNL.EXE.@) */ diff --git a/include/ddk/ntifs.h b/include/ddk/ntifs.h index 9b57ae7ad77..ec4d1d5aa7f 100644 --- a/include/ddk/ntifs.h +++ b/include/ddk/ntifs.h @@ -131,6 +131,7 @@ typedef struct _FS_FILTER_CALLBACKS BOOLEAN WINAPI FsRtlIsNameInExpression(PUNICODE_STRING, PUNICODE_STRING, BOOLEAN, PWCH); NTSTATUS WINAPI ObQueryNameString(PVOID,POBJECT_NAME_INFORMATION,ULONG,PULONG); +NTSTATUS WINAPI PsLookupProcessByProcessId(HANDLE,PEPROCESS*); NTSTATUS WINAPI PsLookupThreadByThreadId(HANDLE,PETHREAD*); void WINAPI PsRevertToSelf(void);