From 827c16db5f9fcc84bd96844e4defc7914bb75938 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Fri, 29 Apr 2005 16:41:52 +0000 Subject: [PATCH] - added stubs for NtSuspendProcess and NtResumeProcess - the ProcessDebugPort information class is read-only on NT5.1+ svn path=/trunk/; revision=14862 --- reactos/include/ntos/ps.h | 2 +- reactos/include/ntos/zw.h | 26 ++++++++++ reactos/lib/ntdll/def/ntdll.def | 4 ++ reactos/ntoskrnl/ps/psmgr.c | 2 +- reactos/ntoskrnl/ps/query.c | 88 ++------------------------------- reactos/ntoskrnl/ps/suspend.c | 68 +++++++++++++++++++++++++ reactos/tools/nci/sysfuncs.lst | 2 + reactos/w32api/include/winnt.h | 1 + 8 files changed, 106 insertions(+), 87 deletions(-) diff --git a/reactos/include/ntos/ps.h b/reactos/include/ntos/ps.h index 9bdfad8e866..f3b0502df3e 100644 --- a/reactos/include/ntos/ps.h +++ b/reactos/include/ntos/ps.h @@ -70,7 +70,7 @@ #define PROCESS_SET_QUOTA (0x0100L) #define PROCESS_SET_INFORMATION (0x0200L) #define PROCESS_QUERY_INFORMATION (0x0400L) -#define PROCESS_SET_PORT (0x0800L) +#define PROCESS_SUSPEND_RESUME (0x0800L) #define PROCESS_ALL_ACCESS (0x1f0fffL) diff --git a/reactos/include/ntos/zw.h b/reactos/include/ntos/zw.h index 8063bb5e5e0..89dd4ba9f75 100755 --- a/reactos/include/ntos/zw.h +++ b/reactos/include/ntos/zw.h @@ -3713,6 +3713,20 @@ ZwResumeThread( IN HANDLE ThreadHandle, OUT PULONG SuspendCount OPTIONAL ); + + +NTSTATUS +STDCALL +NtResumeProcess( + IN HANDLE ProcessHandle + ); + +NTSTATUS +STDCALL +ZwResumeProcess( + IN HANDLE ProcessHandle + ); + /* * FUNCTION: Writes the content of a registry key to ascii file * ARGUMENTS: @@ -4879,6 +4893,18 @@ ZwSuspendThread( OUT PULONG PreviousSuspendCount OPTIONAL ); +NTSTATUS +STDCALL +NtSuspendProcess( + IN HANDLE ProcessHandle + ); + +NTSTATUS +STDCALL +ZwSuspendProcess( + IN HANDLE ProcessHandle + ); + /* * FUNCTION: Terminates the execution of a thread. * ARGUMENTS: diff --git a/reactos/lib/ntdll/def/ntdll.def b/reactos/lib/ntdll/def/ntdll.def index fd153307bf8..ccabed238e2 100644 --- a/reactos/lib/ntdll/def/ntdll.def +++ b/reactos/lib/ntdll/def/ntdll.def @@ -215,6 +215,7 @@ NtRequestPort@8 NtRequestWaitReplyPort@12 NtResetEvent@8 NtRestoreKey@12 +NtResumeProcess@4 NtResumeThread@8 NtSaveKey@8 NtSetContextThread@8 @@ -251,6 +252,7 @@ NtShutdownSystem@4 NtSignalAndWaitForSingleObject@16 NtStartProfile@4 NtStopProfile@4 +NtSuspendProcess@4 NtSuspendThread@8 NtSystemDebugControl@24 NtTerminateJobObject@8 @@ -843,6 +845,7 @@ ZwRequestPort@8 ZwRequestWaitReplyPort@12 ZwResetEvent@8 ZwRestoreKey@12 +ZwResumeProcess@4 ZwResumeThread@8 ZwSaveKey@8 ZwSetContextThread@8 @@ -878,6 +881,7 @@ ZwShutdownSystem@4 ZwSignalAndWaitForSingleObject@16 ZwStartProfile@4 ZwStopProfile@4 +ZwSuspendProcess@4 ZwSuspendThread@8 ZwSystemDebugControl@24 ZwTerminateProcess@8 diff --git a/reactos/ntoskrnl/ps/psmgr.c b/reactos/ntoskrnl/ps/psmgr.c index 482fb3c0f02..f598acc55db 100644 --- a/reactos/ntoskrnl/ps/psmgr.c +++ b/reactos/ntoskrnl/ps/psmgr.c @@ -22,7 +22,7 @@ static GENERIC_MAPPING PiProcessMapping = { STANDARD_RIGHTS_WRITE | PROCESS_CREATE_PROCESS | PROCESS_CREATE_THREAD | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_DUP_HANDLE | PROCESS_TERMINATE | PROCESS_SET_QUOTA | PROCESS_SET_INFORMATION | - PROCESS_SET_PORT, + PROCESS_SUSPEND_RESUME, STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE, PROCESS_ALL_ACCESS}; diff --git a/reactos/ntoskrnl/ps/query.c b/reactos/ntoskrnl/ps/query.c index b6dbac108a7..ab7d5a08ae8 100644 --- a/reactos/ntoskrnl/ps/query.c +++ b/reactos/ntoskrnl/ps/query.c @@ -16,7 +16,6 @@ /* GLOBALS ******************************************************************/ - static const INFORMATION_CLASS_INFO PsProcessInfoClass[] = { ICI_SQ_SAME( sizeof(PROCESS_BASIC_INFORMATION), sizeof(ULONG), ICIF_QUERY ), /* ProcessBasicInformation */ @@ -26,7 +25,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] = ICI_SQ_SAME( sizeof(KERNEL_USER_TIMES), sizeof(ULONG), ICIF_QUERY ), /* ProcessTimes */ ICI_SQ_SAME( sizeof(KPRIORITY), sizeof(ULONG), ICIF_SET ), /* ProcessBasePriority */ ICI_SQ_SAME( sizeof(ULONG), sizeof(ULONG), ICIF_SET ), /* ProcessRaisePriority */ - ICI_SQ_SAME( sizeof(HANDLE), sizeof(ULONG), ICIF_QUERY | ICIF_SET ), /* ProcessDebugPort */ + ICI_SQ_SAME( sizeof(HANDLE), sizeof(ULONG), ICIF_QUERY ), /* ProcessDebugPort */ ICI_SQ_SAME( sizeof(HANDLE), sizeof(ULONG), ICIF_SET ), /* ProcessExceptionPort */ ICI_SQ_SAME( sizeof(PROCESS_ACCESS_TOKEN), sizeof(ULONG), ICIF_SET ), /* ProcessAccessToken */ ICI_SQ_SAME( 0 /* FIXME */, sizeof(ULONG), ICIF_QUERY | ICIF_SET ), /* ProcessLdtInformation */ @@ -672,8 +671,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle, Access = PROCESS_SET_INFORMATION | PROCESS_SET_SESSIONID; break; case ProcessExceptionPort: - case ProcessDebugPort: - Access = PROCESS_SET_INFORMATION | PROCESS_SET_PORT; + Access = PROCESS_SET_INFORMATION | PROCESS_SUSPEND_RESUME; break; default: @@ -700,87 +698,6 @@ NtSetInformationProcess(IN HANDLE ProcessHandle, Status = STATUS_NOT_IMPLEMENTED; break; - case ProcessDebugPort: - { - HANDLE PortHandle = NULL; - - /* make a safe copy of the buffer on the stack */ - _SEH_TRY - { - PortHandle = *(PHANDLE)ProcessInformation; - Status = (PortHandle != NULL ? STATUS_SUCCESS : STATUS_INVALID_PARAMETER); - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - } - _SEH_END; - - if(NT_SUCCESS(Status)) - { - PEPORT DebugPort; - - /* in case we had success reading from the buffer, verify the provided - * LPC port handle - */ - Status = ObReferenceObjectByHandle(PortHandle, - 0, - LpcPortObjectType, - PreviousMode, - (PVOID)&DebugPort, - NULL); - if(NT_SUCCESS(Status)) - { - /* lock the process to be thread-safe! */ - - Status = PsLockProcess(Process, FALSE); - if(NT_SUCCESS(Status)) - { - /* - * according to "NT Native API" documentation, setting the debug - * port is only permitted once! - */ - if(Process->DebugPort == NULL) - { - /* keep the reference to the handle! */ - Process->DebugPort = DebugPort; - - if(Process->Peb) - { - /* we're now debugging the process, so set the flag in the PEB - structure. However, to access it we need to attach to the - process so we're sure we're in the right context! */ - - KeAttachProcess(&Process->Pcb); - _SEH_TRY - { - Process->Peb->BeingDebugged = TRUE; - } - _SEH_HANDLE - { - DPRINT1("Trying to set the Peb->BeingDebugged field of process 0x%x failed, exception: 0x%x\n", Process, _SEH_GetExceptionCode()); - } - _SEH_END; - KeDetachProcess(); - } - Status = STATUS_SUCCESS; - } - else - { - ObDereferenceObject(DebugPort); - Status = STATUS_PORT_ALREADY_SET; - } - PsUnlockProcess(Process); - } - else - { - ObDereferenceObject(DebugPort); - } - } - } - break; - } - case ProcessExceptionPort: { HANDLE PortHandle = NULL; @@ -988,6 +905,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle, case ProcessWx86Information: case ProcessHandleCount: case ProcessWow64Information: + case ProcessDebugPort: default: Status = STATUS_INVALID_INFO_CLASS; } diff --git a/reactos/ntoskrnl/ps/suspend.c b/reactos/ntoskrnl/ps/suspend.c index be6707d6f0c..5e73015379c 100644 --- a/reactos/ntoskrnl/ps/suspend.c +++ b/reactos/ntoskrnl/ps/suspend.c @@ -173,4 +173,72 @@ NtSuspendThread(IN HANDLE ThreadHandle, return Status; } + +/* + * @unimplemented + */ +NTSTATUS +STDCALL +NtSuspendProcess(IN HANDLE ProcessHandle) +{ + KPROCESSOR_MODE PreviousMode; + PEPROCESS Process; + NTSTATUS Status; + + PAGED_CODE(); + + PreviousMode = ExGetPreviousMode(); + + Status = ObReferenceObjectByHandle(ProcessHandle, + PROCESS_SUSPEND_RESUME, + PsProcessType, + PreviousMode, + (PVOID*)&Process, + NULL); + if (NT_SUCCESS(Status)) + { + /* FIXME */ + Status = STATUS_NOT_IMPLEMENTED; + DPRINT1("NtSuspendProcess not yet implemented!\n"); + + ObDereferenceObject(Process); + } + + return Status; +} + + +/* + * @unimplemented + */ +NTSTATUS +STDCALL +NtResumeProcess(IN HANDLE ProcessHandle) +{ + KPROCESSOR_MODE PreviousMode; + PEPROCESS Process; + NTSTATUS Status; + + PAGED_CODE(); + + PreviousMode = ExGetPreviousMode(); + + Status = ObReferenceObjectByHandle(ProcessHandle, + PROCESS_SUSPEND_RESUME, + PsProcessType, + PreviousMode, + (PVOID*)&Process, + NULL); + if (NT_SUCCESS(Status)) + { + /* FIXME */ + Status = STATUS_NOT_IMPLEMENTED; + DPRINT1("NtResumeProcess not yet implemented!\n"); + + ObDereferenceObject(Process); + } + + return Status; +} + /* EOF */ diff --git a/reactos/tools/nci/sysfuncs.lst b/reactos/tools/nci/sysfuncs.lst index 7b76c796e9e..ab956599dee 100644 --- a/reactos/tools/nci/sysfuncs.lst +++ b/reactos/tools/nci/sysfuncs.lst @@ -166,6 +166,7 @@ NtRequestPort 2 NtRequestWaitReplyPort 3 NtResetEvent 2 NtRestoreKey 3 +NtResumeProcess 1 NtResumeThread 2 NtSaveKey 2 NtSaveKeyEx 3 @@ -206,6 +207,7 @@ NtShutdownSystem 1 NtSignalAndWaitForSingleObject 4 NtStartProfile 1 NtStopProfile 1 +NtSuspendProcess 1 NtSuspendThread 2 NtSystemDebugControl 6 NtTerminateJobObject 2 diff --git a/reactos/w32api/include/winnt.h b/reactos/w32api/include/winnt.h index 35fdbc6785b..d5038b0766c 100644 --- a/reactos/w32api/include/winnt.h +++ b/reactos/w32api/include/winnt.h @@ -368,6 +368,7 @@ typedef DWORD FLONG; #define PROCESS_SET_QUOTA 256 #define PROCESS_SET_INFORMATION 512 #define PROCESS_QUERY_INFORMATION 1024 +#define PROCESS_SUSPEND_RESUME 2048 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xFFF) #define THREAD_TERMINATE 1 #define THREAD_SUSPEND_RESUME 2