|
if(KeGetCurrentIrql()>PASSIVE_LEVEL)作用?
[复制链接]
网上代码:
HANDLE openfile(WCHAR* name,ACCESS_MASK access,ULONG share)
{
//return 0 for error.
HANDLE hfile;
IO_STATUS_BLOCK iosb;
int stat;
OBJECT_ATTRIBUTES oba;
UNICODE_STRING nameus;
if(KeGetCurrentIrql()>PASSIVE_LEVEL){return 0;} RtlInitUnicodeString(&nameus,name);
InitializeObjectAttributes(&oba,&nameus,OBJ_KERNEL_HANDLE|OBJ_CASE_INSENSITIVE,0,0);
stat=IoCreateFile(&hfile,access,&oba,&iosb,0,FILE_ATTRIBUTE_NORMAL,share,FILE_OPEN,0,0,0,0,0,0);
if(!NT_SUCCESS(stat)){return 0;}
return hfile;
}
偶初学驱动编程,映像中有些内核函数必需在一定高的IRQL级上执行,故需要对当前CPUIRQL级进行判断以防止出错。这里为什么要规定必需处于IRQL最低级呢?
|
|