323240867 发表于 2022-3-6 13:48

2022驱动学习-03解密过驱动保护原理

运行环境:
WIN10
涉及工具:
windbg,vs2019,VMware Workstation Pro
教程类型:
驱动学习笔记
视频是否带有论坛水印:

是否讲解思路和原理:

百度云盘
提取码:496u

1.启动运行环境








2.启动vs编写代码





3.调试打印结果





4.具体代码
#include <Ntddk.h>


UCHAR* PsGetProcessImageFileName(__in PEPROCESS Process);

VOID CreateProcessNotifyEx(
    __inout PEPROCESSProcess,
    __in HANDLEProcessId,
    __in_opt PPS_CREATE_NOTIFY_INFOCreateInfo
)
{
    //通过进程ID过去路径
    UCHAR* ImageFileName = PsGetProcessImageFileName(Process);
    DbgPrint("ImageFileName:%p\n", ImageFileName);
    if (CreateInfo != NULL) {

      //对比是不是计算器
      if (strstr((const char*)ImageFileName, "calc") != NULL) {
            //如果是计算器就返回错误
            DbgPrint("%s pid:%d path:%wZ Create\n", ImageFileName, ProcessId, CreateInfo->ImageFileName);
            CreateInfo->CreationStatus = STATUS_UNSUCCESSFUL;
      }
    }
    else {
      DbgPrint("Exit %s pid:%d %p\n", ImageFileName, ProcessId, Process);
    }
}

VOID Unload(
    _In_ struct _DRIVER_OBJECT* DriverObject) {
    UNREFERENCED_PARAMETER(DriverObject);


    DbgPrint("Unload!");

    //卸载挂钩函数
    PsSetCreateProcessNotifyRoutineEx(&CreateProcessNotifyEx, TRUE);
}

NTSTATUS DriverEntry(
    __in struct _DRIVER_OBJECT* DriverObject,
    __in PUNICODE_STRINGRegistryPath
)
{
    //告诉编译器,这个参数不适用
    UNREFERENCED_PARAMETER(RegistryPath);

    DbgPrint("DriverEntry! DriverObject:%p\n", DriverObject);

    //挂钩函数
    NTSTATUS Status = PsSetCreateProcessNotifyRoutineEx(&CreateProcessNotifyEx, FALSE);
    DbgPrint("Status:%d CreateProcessNotifyEx:%p\n", Status, &CreateProcessNotifyEx);

    //注册卸载函数
    DriverObject->DriverUnload = Unload;

    return STATUS_SUCCESS;
}

wtOEh5 发表于 2022-3-6 13:48

大佬无敌

evz8 发表于 2022-3-6 13:55

感谢楼主

PvdB87249 发表于 2022-3-6 13:56

谢谢分享

uhaBqCUNIlmY 发表于 2022-3-6 13:59

感谢大佬的分享

nUFzSs 发表于 2022-3-6 14:04

谢谢分享

DnpcWrkj65910 发表于 2022-3-6 14:05

感谢楼主

NkjsCOYQeKqH 发表于 2022-3-6 14:39

谢谢分享

mfleB 发表于 2022-3-6 14:42

感谢楼主

YLa3 发表于 2022-3-6 14:52

谢谢分享
页: [1] 2 3 4 5 6 7 8 9 10
查看完整版本: 2022驱动学习-03解密过驱动保护原理