gpt4 book ai didi

进程监控 CreateProcessNotifyRoutineEx

转载 作者:行者123 更新时间:2023-12-02 10:56:11 28 4
gpt4 key购买 nike

我正在开发一个用于监视进程创建的驱动程序,我编写了一个简单的代码来完成它。我使用 PsSetCreateProcessNotifyRoutineEx。但这行不通!我完全遵循微软帮助on this link

#include <ntddk.h>

NTSTATUS DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
);

VOID UnloadRoutine(
IN PDRIVER_OBJECT DriverObject
);

VOID CreateProcessNotifyEx(
__inout PEPROCESS Process,
__in HANDLE ProcessId,
__in_opt PPS_CREATE_NOTIFY_INFO CreateInfo
);



VOID CreateProcessNotifyEx(
__inout PEPROCESS Process,
__in HANDLE ProcessId,
__in_opt PPS_CREATE_NOTIFY_INFO CreateInfo

)
{
if (CreateInfo)
{
if(CreateInfo->FileOpenNameAvailable==TRUE)
{
DbgPrintEx(
DPFLTR_IHVDRIVER_ID,
DPFLTR_INFO_LEVEL,
"PID : 0x%X (%d) ImageName :%wZ CmdLine : %wZ \n",
ProcessId,ProcessId,
CreateInfo->ImageFileName,
CreateInfo->CommandLine
);
}
}

}


VOID UnloadRoutine(IN PDRIVER_OBJECT DriverObject)
{
PsSetCreateProcessNotifyRoutineEx((PCREATE_PROCESS_NOTIFY_ROUTINE_EX) CreateProcessNotifyEx, TRUE);
DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL,"Unloaded\n");
}

NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
{

NTSTATUS status = PsSetCreateProcessNotifyRoutineEx((PCREATE_PROCESS_NOTIFY_ROUTINE_EX)CreateProcessNotifyEx, FALSE);
if(!NT_SUCCESS(status))
{
DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL,"Faild to PsSetCreateProcessNotifyRoutineEx .status : 0x%X \n",status);
}
DriverObject->DriverUnload = UnloadRoutine;
DbgPrintEx( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL,"Load\n");

return STATUS_SUCCESS;

}

此驱动器加载并正确运行,但运行程序(新进程)时,没有发生任何事情并且无法注册 PsSetCreateProcessNotifyRoutineEx 并且我收到 0xC0000022 错误(拒绝访问)。 enter image description here

有什么想法吗?

最佳答案

我总是必须找到我的答案;)

要解决此问题,只需将此值 LINKER_FLAGS=/integritycheck 添加到 SOURCE 文件即可!

之前:

TARGETNAME=ProcView
TARGETPATH=.
TARGETTYPE=DRIVER

SOURCES=ProcView.c

现在:

TARGETNAME=ProcView
TARGETPATH=.
TARGETTYPE=DRIVER
LINKER_FLAGS=/integritycheck
SOURCES=ProcView.c

enter image description here

关于进程监控 CreateProcessNotifyRoutineEx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20502929/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com