NTSTATUS KeWaitForSingleObject(
PVOID Object,
KWAIT_REASON WaitReason,
KPROCESSOR_MODE WaitMode,
BOOLEAN Alertable,
PLARGE_INTEGER Timeout
);
MSDN: Callers of KeWaitForSingleObject must be running at IRQL <= DISPATCH_LEVEL. However, if Timeout = NULL or *Timeout != 0, the caller must be running at IRQL <= APC_LEVEL and in a nonarbitrary thread context. (If Timeout != NULL and *Timeout = 0, the caller must be running at IRQL <= DISPATCH_LEVEL.)
Timeout 값이 0이 아닌 값을 가지면, DISPATCH_LEVEL 보다 낮은 IRQL에서 KeWaitForSingleObject를 호출해야 하지만, DISPATCH_LEVEL에서 KeWaitForSingleObject를 무한 대기 또는 특정 시간 대기를 위해 호출 할 때 BSOD ATTEMPTED_SWITCH_FROM_DPC가 발생.
(회피 방법1)
//<1> 5초 대기
if(KeReadStateEvent(&Event) == 0)
{
LARGE_INTEGER Seconds_5;
Seconds_5.QuadPart = -5 * 10 * 1000 * 1000;
KeDelayExecutionThread( KernelMode, FALSE, &Seconds_5 );
}
//<2> 매 5초 경과 후 이벤트 상태 체크 1분 동안 확인
if(KeReadStateEvent(&Event) == 0)
{
int cnts = 0;
do {
LARGE_INTEGER Seconds_5;
Seconds_5.QuadPart = -5 * 10 * 1000 * 1000;
KeDelayExecutionThread( KernelMode, FALSE, &Seconds_5 );
++cnts;
} while(KeReadStateEvent(&Event) == 0 && cnts < 12);
}
'All about Programming' 카테고리의 다른 글
Windbg 설정 (0) | 2019.07.15 |
---|---|
Windows Class Filter Driver 설치 방법 (0) | 2019.07.12 |
System Reboot (시스템 재부팅) From Device Driver (0) | 2019.06.26 |
Volume Shadow Copy(vss)를 이용한 Volume 마운트 (0) | 2019.06.07 |
Hyper-v can't connect to localhost (0) | 2019.05.30 |