一段强行结束进程的代码
// 先往指定进程内存区域写 0 ,然后再灭掉......
void DestroyProcess( DWORD eproc)
{
DWORD VirtualAddr;
PHYSICAL_ADDRESS physical_addr;
DWORD AddrTmp;
PVOID ProcessHandle;
KeAttachProcess( (PEPROCESS)eproc ); //这句做什么的??
for ( VirtualAddr = 0x1000; VirtualAddr < *(DWORD*)MmSystemRangeStart; VirtualAddr+=0x1000) //0x1000??
{
// 跳过不再内存里的
physical_addr = MmGetPhysicalAddress( (PVOID)VirtualAddr);
if ( physical_addr.HighPart > g_PhysicalPage.HighPart )
continue;
if ( physical_addr.HighPart == g_PhysicalPage.HighPart &&
physical_addr.LowPart >= g_PhysicalPage.LowPart )
continue;
if ( (physical_addr.HighPart | physical_addr.LowPart) == 0 )
continue;
AddrTmp = (DWORD)MmGetVirtualForPhysical( physical_addr);
if ( AddrTmp != VirtualAddr)
continue;
DisableWPBitAndCli();
RtlZeroMemory( (PVOID)VirtualAddr, 0x1000);
RELoadCR0AndSti();
}
KeDetachProcess();
if ( ObOpenObjectByPointer( (PVOID)eproc, 0, NULL, 0, NULL, KernelMode, &ProcessHandle) != STATUS_SUCCESS)
return;
ZwTerminateProcess( (HANDLE)ProcessHandle, STATUS_SUCCESS);
ZwClose( (HANDLE)ProcessHandle );
return;
}
内存清零原理??
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!