//让OD能XXXXXX
if (IsFromDebugProcess(RPsGetCurrentProcess()))
{
OldZwOpenThread = OriginalServiceDescriptorTable->ServiceTable[ZwOpenThreadIndex];
}
status = OldZwOpenThread(
ThreadHandle,
AccessMask,
ObjectAttributes,
ClientId
);
if (NT_SUCCESS(status))
{
//如果是自己的驱动调用,则返回哦
if (ulPage >= ulMyDriverBase && ulPage <= ulMyDriverBase+ulMyDriverSize){
return status;
}
//好像这里的判断是多余的~
if (KeGetCurrentIrql() != PASSIVE_LEVEL){
return status;
}
//如果退出了
if (!bIsInitSuccess){
return status;
}
//如果没有保护
if (!bProtectProcess){
return status;
}
//过滤掉桌面进程以及csrss进程
if (_stricmp(PsGetProcessImageFileName(RPsGetCurrentProcess()),"explorer.exe") == 0 ||
RPsGetCurrentProcess() == CsrssEProcess)
{
return status;
}
//get ethread
status = ObReferenceObjectByHandle(
ThreadHandle,
THREAD_ALL_ACCESS,
*PsThreadType,
KernelMode,
(PVOID*)&EThread,
NULL
);
if (NT_SUCCESS(status))
{
ObDereferenceObject(EThread);
//get eprocess
EProcess = IoThreadToProcess(EThread);
if (IsFromDebugProcess(EProcess))
{
if (DebugOn)
KdPrint(("open OD Thread by %s\n",PsGetProcessImageFileName(RPsGetCurrentProcess())));
return STATUS_ACCESS_DENIED;
}
}
status = STATUS_SUCCESS;
}
return status;
}