| 
 | 
- #include <ntddk.h>
 
  
- // 进程创建和退出的回调函数
 
 - void ProcessNotifyCallback(
 
 -     _Inout_ PEPROCESS Process,
 
 -     _In_ HANDLE ProcessId,
 
 -     _Inout_opt_ PPS_CREATE_NOTIFY_INFO CreateInfo
 
 - )
 
 - {
 
 -     if (CreateInfo != NULL)
 
 -     {
 
 -         // 进程创建
 
 -         DbgPrint("Process created: PID=%d, ImageFileName=%wZ\n", HandleToULong(ProcessId), CreateInfo->ImageFileName);
 
 -     }
 
 -     else
 
 -     {
 
 -         // 进程退出
 
 -         DbgPrint("Process exited: PID=%d\n", HandleToULong(ProcessId));
 
 -     }
 
 - }
 
  
- // 驱动程序卸载函数
 
 - void DriverUnload(_In_ PDRIVER_OBJECT DriverObject)
 
 - {
 
 -     // 取消注册回调函数
 
 -     PsSetCreateProcessNotifyRoutineEx(ProcessNotifyCallback, TRUE);
 
 -     DbgPrint("Driver unloaded.\n");
 
 - }
 
  
- // 驱动程序入口点
 
 - extern "C" NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
 
 - {
 
 -     UNREFERENCED_PARAMETER(RegistryPath);
 
  
-     // 注册进程创建和退出的回调函数
 
 -     NTSTATUS status = PsSetCreateProcessNotifyRoutineEx(ProcessNotifyCallback, FALSE);
 
 -     if (!NT_SUCCESS(status))
 
 -     {
 
 -         DbgPrint("Failed to register process notify callback.\n");
 
 -         return status;
 
 -     }
 
  
-     // 设置卸载函数
 
 -     DriverObject->DriverUnload = DriverUnload;
 
  
-     DbgPrint("Driver loaded.\n");
 
  
-     return STATUS_SUCCESS;
 
 - }
 
  复制代码 |   
 
 
 
 |