enum XP_SYSTEM
{
xpNextProcess
=
0x88
,
xpPrevProcess
=
0x8c
,
xpImageFileName
=
0x174
,
xpDebugProt
=
0x0bc
};
PETHREAD pThreadObj
=
NULL;
BOOLEAN bTerminated
=
FALSE;
VOID DebugPortReset(PVOID pContext);
VOID DriverUnload(PDRIVER_OBJECT pDriverObject)
{
bTerminated
=
TRUE;
KeWaitForSingleObject(pThreadObj, Executive, KernelMode, FALSE, NULL);
ObDereferenceObject(pThreadObj);
}
NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pRegistryPath)
{
HANDLE hThread
=
0
;
NTSTATUS status
=
STATUS_SUCCESS;
KdPrint((
"Driver Entry\n"
));
pDriverObject
-
>DriverUnload
=
DriverUnload;
status
=
PsCreateSystemThread(&hThread, THREAD_ALL_ACCESS, NULL, NULL, NULL, DebugPortReset, NULL);
if
(NT_SUCCESS(status))
{
KdPrint((
"Thread Created\n"
));
status
=
ObReferenceObjectByHandle(hThread, THREAD_ALL_ACCESS,
*
PsThreadType, KernelMode, &pThreadObj, NULL);
ZwClose(hThread);
if
(!NT_SUCCESS(status))
{
bTerminated
=
TRUE;
}
}
return
status;
}
VOID DebugPortReset(PVOID pContext)
{
PEPROCESS pCurrentProcess
=
NULL;
PEPROCESS pPreviousProcess
=
NULL;
LARGE_INTEGER inteval;
inteval.QuadPart
=
-
20000000
;
KeSetPriorityThread(KeGetCurrentThread(), LOW_REALTIME_PRIORITY);
while
(!bTerminated)
{
pCurrentProcess
=
PsGetCurrentProcess();
pPreviousProcess
=
(PEPROCESS)(
*
((PULONG_PTR)((ULONG_PTR)pCurrentProcess
+
xpPrevProcess))
-
xpNextProcess);
while
(pCurrentProcess !
=
pPreviousProcess)
{
if
(strcmp(((PCHAR)((ULONG_PTR)pCurrentProcess
+
xpImageFileName)),
"notepad.exe"
)
=
=
0
)
{
KdPrint((
"找到notepad进程 开始清零\n"
));
*
(PULONG)((ULONG)pCurrentProcess
+
xpDebugProt)
=
0
;
break
;
}
pCurrentProcess
=
(PEPROCESS)(
*
((PULONG_PTR)((ULONG_PTR)pCurrentProcess
+
xpNextProcess))
-
xpNextProcess);
}
KeDelayExecutionThread(KernelMode, FALSE, &inteval);
}
}