PspTerminateProcess 结束冰刃进程

本文介绍了一种通过编写Windows内核驱动程序来终止指定进程的方法。利用未公开的`PspTerminateProcess`函数,文章给出了具体实现代码示例,并展示了如何针对特定进程ID结束进程。
#include <ntddk.h>

typedef  NTSTATUS  ( * PSPTERPROC) ( PEPROCESS Process , NTSTATUS ExitStatus );
PSPTERPROC MyPspTerminateProcess ;
NTSTATUS
PsLookupProcessByProcessId(
                        IN HANDLE ProcessId ,
                        OUT PEPROCESS * Process
                        );

void Unload( PDRIVER_OBJECT pDriverObj)
{
        DbgPrint( "Driver Stop /n ");
}

NTSTATUS DriverEntry( PDRIVER_OBJECT pDriverObj , PUNICODE_STRING pRegistryString)
{
        PEPROCESS hProcess;
        MyPspTerminateProcess =( PSPTERPROC) 0x805c8642;

        //比如冰刃的进程ID为1732
        if( PsLookupProcessByProcessId( 1732 , & hProcess) == STATUS_SUCCESS)
        {
                     MyPspTerminateProcess( hProcess , 0);
        }
        pDriverObj -> DriverUnload = Unload;
        return STATUS_SUCCESS;
}

-----------------------------------------------------------------------------
以上代码使用了系统未导出函数PspTerminateProcess结束了冰刃,
函数的地址是我用WinDbg看到的,所以可能在不同的系统里地址不同。

 

************* Preparing the environment for Debugger Extensions Gallery repositories ************** ExtensionRepository : Implicit UseExperimentalFeatureForNugetShare : true AllowNugetExeUpdate : true NonInteractiveNuget : true AllowNugetMSCredentialProviderInstall : true AllowParallelInitializationOfLocalRepositories : true EnableRedirectToChakraJsProvider : false -- Configuring repositories ----> Repository : LocalInstalled, Enabled: true ----> Repository : UserExtensions, Enabled: true >>>>>>>>>>>>> Preparing the environment for Debugger Extensions Gallery repositories completed, duration 0.015 seconds ************* Waiting for Debugger Extensions Gallery to Initialize ************** >>>>>>>>>>>>> Waiting for Debugger Extensions Gallery to Initialize completed, duration 0.016 seconds ----> Repository : UserExtensions, Enabled: true, Packages count: 0 ----> Repository : LocalInstalled, Enabled: true, Packages count: 45 Microsoft (R) Windows Debugger Version 10.0.27920.1001 AMD64 Copyright (c) Microsoft Corporation. All rights reserved. Loading Dump File [D:\CTF\music\[Misc]我不要革命失败\071825-14921-01.dmp] Mini Kernel Dump File: Only registers and stack trace are available ************* Path validation summary ************** Response Time (ms) Location Deferred srv* Symbol search path is: srv* Executable search path is: Windows 10 Kernel Version 22621 MP (32 procs) Free x64 Product: WinNt, suite: TerminalServer SingleUserTS Personal Edition build lab: 22621.1.amd64fre.ni_release.220506-1250 Kernel base = 0xfffff803`17200000 PsLoadedModuleList = 0xfffff803`17e130c0 Debug session time: Fri Jul 18 22:35:54.900 2025 (UTC + 8:00) System Uptime: 0 days 0:35:21.567 Loading Kernel Symbols ............................................................... ................................................................ ................................................................ ........................................ Loading User Symbols Loading unloaded module list ...................... For analysis of this file, run !analyze -v nt!KeBugCheckEx: fffff803`17612740 48894c2408 mov qword ptr [rsp+8],rcx ss:0018:fffffc01`fe187860=00000000000000ef 14: kd> !analyze -v Loading Kernel Symbols ............................................................... ................................................................ ................................................................ ........................................ Loading User Symbols Loading unloaded module list ...................... ******************************************************************************* * * * Bugcheck Analysis * * * ******************************************************************************* CRITICAL_PROCESS_DIED (ef) A critical system process died Arguments: Arg1: ffffd18e9cfbc140, Process object or thread object Arg2: 0000000000000000, If this is 0, a process died. If this is 1, a thread died. Arg3: ffffd18e9cfbc140, The process object that initiated the termination. Arg4: 0000000000000000, Additional triage data. Debugging Details: ------------------ KEY_VALUES_STRING: 1 Key : Analysis.CPU.mSec Value: 1718 Key : Analysis.Elapsed.mSec Value: 5022 Key : Analysis.IO.Other.Mb Value: 0 Key : Analysis.IO.Read.Mb Value: 1 Key : Analysis.IO.Write.Mb Value: 0 Key : Analysis.Init.CPU.mSec Value: 453 Key : Analysis.Init.Elapsed.mSec Value: 284292 Key : Analysis.Memory.CommitPeak.Mb Value: 113 Key : Analysis.Version.DbgEng Value: 10.0.27920.1001 Key : Analysis.Version.Description Value: 10.2506.23.01 amd64fre Key : Analysis.Version.Ext Value: 1.2506.23.1 Key : Bugcheck.Code.LegacyAPI Value: 0xef Key : Bugcheck.Code.TargetModel Value: 0xef Key : CriticalProcessDied.ExceptionCode Value: 0xa422e080 Key : CriticalProcessDied.Process Value: svchost.exe Key : Failure.Bucket Value: 0xEF_svchost.exe_BUGCHECK_CRITICAL_PROCESS_a422e080_nt!PspCatchCriticalBreak Key : Failure.Hash Value: {139516e8-a181-e0a0-49d2-c73372114d37} Key : Hypervisor.Enlightenments.ValueHex Value: 0x1417df84 Key : Hypervisor.Flags.AnyHypervisorPresent Value: 1 Key : Hypervisor.Flags.ApicEnlightened Value: 0 Key : Hypervisor.Flags.ApicVirtualizationAvailable Value: 1 Key : Hypervisor.Flags.AsyncMemoryHint Value: 0 Key : Hypervisor.Flags.CoreSchedulerRequested Value: 0 Key : Hypervisor.Flags.CpuManager Value: 1 Key : Hypervisor.Flags.DeprecateAutoEoi Value: 1 Key : Hypervisor.Flags.DynamicCpuDisabled Value: 1 Key : Hypervisor.Flags.Epf Value: 0 Key : Hypervisor.Flags.ExtendedProcessorMasks Value: 1 Key : Hypervisor.Flags.HardwareMbecAvailable Value: 1 Key : Hypervisor.Flags.MaxBankNumber Value: 0 Key : Hypervisor.Flags.MemoryZeroingControl Value: 0 Key : Hypervisor.Flags.NoExtendedRangeFlush Value: 0 Key : Hypervisor.Flags.NoNonArchCoreSharing Value: 1 Key : Hypervisor.Flags.Phase0InitDone Value: 1 Key : Hypervisor.Flags.PowerSchedulerQos Value: 0 Key : Hypervisor.Flags.RootScheduler Value: 0 Key : Hypervisor.Flags.SynicAvailable Value: 1 Key : Hypervisor.Flags.UseQpcBias Value: 0 Key : Hypervisor.Flags.Value Value: 21631230 Key : Hypervisor.Flags.ValueHex Value: 0x14a10fe Key : Hypervisor.Flags.VpAssistPage Value: 1 Key : Hypervisor.Flags.VsmAvailable Value: 1 Key : Hypervisor.RootFlags.AccessStats Value: 1 Key : Hypervisor.RootFlags.CrashdumpEnlightened Value: 1 Key : Hypervisor.RootFlags.CreateVirtualProcessor Value: 1 Key : Hypervisor.RootFlags.DisableHyperthreading Value: 0 Key : Hypervisor.RootFlags.HostTimelineSync Value: 1 Key : Hypervisor.RootFlags.HypervisorDebuggingEnabled Value: 0 Key : Hypervisor.RootFlags.IsHyperV Value: 1 Key : Hypervisor.RootFlags.LivedumpEnlightened Value: 1 Key : Hypervisor.RootFlags.MapDeviceInterrupt Value: 1 Key : Hypervisor.RootFlags.MceEnlightened Value: 1 Key : Hypervisor.RootFlags.Nested Value: 0 Key : Hypervisor.RootFlags.StartLogicalProcessor Value: 1 Key : Hypervisor.RootFlags.Value Value: 1015 Key : Hypervisor.RootFlags.ValueHex Value: 0x3f7 Key : WER.OS.Branch Value: ni_release Key : WER.OS.Version Value: 10.0.22621.1 Key : WER.System.BIOSRevision Value: 5.27.0.0 BUGCHECK_CODE: ef BUGCHECK_P1: ffffd18e9cfbc140 BUGCHECK_P2: 0 BUGCHECK_P3: ffffd18e9cfbc140 BUGCHECK_P4: 0 FILE_IN_CAB: 071825-14921-01.dmp FAULTING_THREAD: ffffd18ea422e080 PROCESS_NAME: svchost.exe CRITICAL_PROCESS: svchost.exe ERROR_CODE: (NTSTATUS) 0xa422e080 - <Unable to get error code text> BLACKBOXBSD: 1 (!blackboxbsd) BLACKBOXNTFS: 1 (!blackboxntfs) BLACKBOXPNP: 1 (!blackboxpnp) BLACKBOXWINLOGON: 1 (!blackboxwinlogon) CUSTOMER_CRASH_COUNT: 1 STACK_TEXT: fffffc01`fe187858 fffff803`17bb417b : 00000000`000000ef ffffd18e`9cfbc140 00000000`00000000 ffffd18e`9cfbc140 : nt!KeBugCheckEx fffffc01`fe187860 fffff803`17afcccb : ffffd18e`9cfbc140 00000000`00000002 00000000`00000000 fffff803`1749b62f : nt!PspCatchCriticalBreak+0x11b fffffc01`fe1878f0 fffff803`17923f7b : ffffd18e`9cfbc140 00000000`c0000374 ffffd18e`9cfbc140 00000000`00000000 : nt!PspTerminateAllThreads+0x14f54b fffffc01`fe187960 fffff803`17923d51 : ffffffff`ffffffff ffffd18e`9cfbc140 ffffd18e`a422e080 ffffd18e`9cfbc140 : nt!PspTerminateProcess+0xe7 fffffc01`fe1879a0 fffff803`176274e5 : ffffd18e`00001248 ffffd18e`a422e080 ffffd18e`9cfbc140 ffffffff`f70f2e80 : nt!NtTerminateProcess+0xb1 fffffc01`fe187a20 00007ffc`0a80f974 : 00007ffc`0a87c890 00007ffc`0a8da86c 000000c8`8fb7b760 00000000`00000000 : nt!KiSystemServiceCopyEnd+0x25 000000c8`8fb7a6c8 00007ffc`0a87c890 : 00007ffc`0a8da86c 000000c8`8fb7b760 00000000`00000000 00000000`00000000 : 0x00007ffc`0a80f974 000000c8`8fb7a6d0 00007ffc`0a8da86c : 000000c8`8fb7b760 00000000`00000000 00000000`00000000 00000000`0010c849 : 0x00007ffc`0a87c890 000000c8`8fb7a6d8 000000c8`8fb7b760 : 00000000`00000000 00000000`00000000 00000000`0010c849 00007ffc`0a7ff1b7 : 0x00007ffc`0a8da86c 000000c8`8fb7a6e0 00000000`00000000 : 00000000`00000000 00000000`0010c849 00007ffc`0a7ff1b7 000000c8`8fb7a800 : 0x000000c8`8fb7b760 SYMBOL_NAME: nt!PspCatchCriticalBreak+11b MODULE_NAME: nt IMAGE_NAME: ntkrnlmp.exe IMAGE_VERSION: 10.0.22621.2428 STACK_COMMAND: .process /r /p 0xffffd18e9cfbc140; .thread 0xffffd18ea422e080 ; kb BUCKET_ID_FUNC_OFFSET: 11b FAILURE_BUCKET_ID: 0xEF_svchost.exe_BUGCHECK_CRITICAL_PROCESS_a422e080_nt!PspCatchCriticalBreak OS_VERSION: 10.0.22621.1 BUILDLAB_STR: ni_release OSPLATFORM_TYPE: x64 OSNAME: Windows 10 FAILURE_ID_HASH: {139516e8-a181-e0a0-49d2-c73372114d37} Followup: MachineOwner --------- 指出崩溃类型(即蓝屏显示的终止代码)_故障进程
最新发布
09-23
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值