Re: 请教:在内核中如何关中断?

Windows内核调试

请教:在内核中如何关中断?


pch 2008-09-08, 15:18 下午
请教:在内核中如何关中断?

Re: 请教:在内核中如何关中断?


格蠹老雷 2008-09-08, 22:51 下午
如果不是64位的驱动,那么可以使用嵌入式汇编:
_asm {
cli
}


Re: 请教:在内核中如何关中断?


王宇 2008-09-09, 09:06 上午
类似的,开中断也是一样,请参看Win源码:

; arg6 - LoaderBlock
; arg5 - processor number
; arg4 - addr of prcb
; arg3 - idle thread's stack
; arg2 - addr of current thread obj
; arg1 - addr of current process obj

; initialize system data structures
; and HAL.

stdCall _KiInitializeKernel,

;
; Set idle thread priority.
;

mov ebx,PCR[PcPrcbData+PbCurrentThread] ; get idle thread address
mov byte ptr [ebx]+ThPriority, 0 ; set idle thread priority

;
; Control is returned to the idle thread with IRQL at HIGH_LEVEL. Lower IRQL
; to DISPATCH_LEVEL and set wait IRQL of idle thread.
;

sti /* Force interrupts enabled */
LowerIrql DISPATCH_LEVEL
mov byte ptr [ebx]+ThWaitIrql, DISPATCH_LEVEL

.........


其中 KiInitializeKernel() 是核心启动例程。

Re: 请教:在内核中如何关中断?


王宇 2008-09-09, 09:12 上午
论坛似乎将 尖括号对 认为是“注释”? 上面的 _KiInitializeKernel 例程参数被截断了(这里的masm语法格式将参数置于尖括号内),它的完整参数如下:

offset _KiInitialProcess,ebx,edx,dword ptr PCR[PcPrcb],eax,_KeLoaderBlock

另外,看着 KPCR 和 KPCRB 长起来的感觉很不错~

Re: 请教:在内核中如何关中断?


skyworth 2008-10-30, 15:50 下午
言下之意,如果是64位驱动,那么这个指令不行??

Re: 请教:在内核中如何关中断?


格蠹老雷 2008-10-30, 21:21 下午
是Windows SDK/DDK/WDK在编译64位程序时不再支持嵌入式汇编。

Powered by Community Server Powered by CnForums.Net