Windows驱动笔记
+ -

PsSetCreateProcessNotifyRoutineEx和PsSetLoadImageNotifyRoutine日志记录

2024-12-02 0 0

分别使用如下方法进行回调设置:

    NTSTATUS Status = PsSetCreateProcessNotifyRoutineEx(&InjCreateProcessNotifyRoutineEx, FALSE);
    if (!NT_SUCCESS(Status))
    {
        return Status;
    }

    //加载映射
    Status = PsSetLoadImageNotifyRoutine(&InjLoadImageNotifyRoutine);
    if (!NT_SUCCESS(Status))
    {
        //失败了,取消进程的回调
        PsSetCreateProcessNotifyRoutineEx(&InjCreateProcessNotifyRoutineEx, TRUE);
    }

对于创建进程:

//进程创建
VOID InjCreateProcessNotifyRoutineEx(
    _Inout_ PEPROCESS Process,
    _In_ HANDLE ProcessId,
    _Inout_opt_ PPS_CREATE_NOTIFY_INFO CreateInfo
)
{
    if (CreateInfo)
    {
        KdPrint(("[Procss] %wZ\n", CreateInfo->ImageFileName));
        }
}

对于Image加载:

//映像加载
VOID InjLoadImageNotifyRoutine(
    _In_opt_ PUNICODE_STRING FullImageName,
    _In_ HANDLE ProcessId,
    _In_ PIMAGE_INFO ImageInfo
)
{
    KdPrint(("[img]%wZ %d,%p\n", FullImageName, (ULONG)(ULONG_PTR)ProcessId, ImageInfo));
}

以打开一个记事本为例,输出日志如下:

[Procss] \??\C:\Windows\system32\notepad.exe
[img]\Windows\System32\policymanager.dll 4732,FFFFD280A58E5AB8
[img]\Device\HarddiskVolume4\Windows\System32\notepad.exe 2264,FFFFD280A69976C0
[img]\Windows\System32\deviceaccess.dll 332,FFFFD280A528E6F8
[img]\SystemRoot\System32\ntdll.dll 2264,FFFFD280A69976C0
[img]\Windows\System32\aepic.dll 332,FFFFD280A528E6F8

0 篇笔记 写笔记

PsSetCreateProcessNotifyRoutineEx报错STATUS_ACCESS_DENIED-0xC0000022
PsSetCreateProcessNotifyRoutineEx调用时报错误STATUS_ACCESS_DENIED,文档给的解释是:The image that contains the callback routine pointer did not have IMAGE_DLLCHARACT......
PsSetCreateProcessNotifyRoutineExPsSetLoadImageNotifyRoutine日志记录
分别使用如下方法进行回调设置: NTSTATUS Status = PsSetCreateProcessNotifyRoutineEx(&InjCreateProcessNotifyRoutineEx, FALSE); if (!NT_SUCCESS(Status)) ......
作者信息
我爱内核
Windows驱动开发,网站开发
好好学习,天天向上。
取消
感谢您的支持,我会继续努力的!
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

您的支持,是我们前进的动力!