-
Notifications
You must be signed in to change notification settings - Fork 0
/
pendprocess.c
48 lines (43 loc) · 1.1 KB
/
pendprocess.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <ntifs.h>
NTKERNELAPI NTSTATUS PsSuspendProcess(PEPROCESS proc); //暂停进程
NTKERNELAPI NTSTATUS PsResumeProcess(PEPROCESS proc); //恢复进程
PEPROCESS GetEprocessByPid(HANDLE pid)
{
//根据PID 返回PEPROCESS
PEPROCESS pEpro = NULL;
NTSTATUS ntStatus = STATUS_UNSUCCESSFUL;
ntStatus = PsLookupProcessByProcessId(pid, &pEpro);
if (NT_SUCCESS(ntStatus))
{
return pEpro;
}
return NULL;
}
NTSTATUS TestSusPendProcess(ULONG pid)
{
NTSTATUS status = STATUS_UNSUCCESSFUL;
PEPROCESS pCurrentEprocess = NULL;
pCurrentEprocess = GetEprocessByPid((HANDLE)pid);
if (pCurrentEprocess != NULL)
{
PsSuspendProcess(pCurrentEprocess);
status = STATUS_SUCCESS;
DbgPrint("挂起进程成功\r\n");
ObDereferenceObject(pCurrentEprocess);
}
return status;
}
NTSTATUS TestPsResumeProcess(ULONG pid)
{
NTSTATUS status = STATUS_UNSUCCESSFUL;
PEPROCESS pCurrentEprocess = NULL;
pCurrentEprocess = GetEprocessByPid((HANDLE)pid);
if (pCurrentEprocess != NULL)
{
PsResumeProcess(pCurrentEprocess);
status = STATUS_SUCCESS;
DbgPrint("继续运行进程成功\r\n");
ObDereferenceObject(pCurrentEprocess);
}
return status;
}