首页
社区
课程
招聘
[求助]内核异常是否会用到KTRAP_FRAME?
发表于: 2015-5-7 20:03 4919

[求助]内核异常是否会用到KTRAP_FRAME?

2015-5-7 20:03
4919
我感觉会用到构建不完整的KTRAP_FRAME有时会出问题。在异常代码里找了半天,也没找到关键代码证据,请有经验的大牛给确认一下,看代码看的我头痛了,实在找不到。

[课程]FART 脱壳王!加量不加价!FART作者讲授!

收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 52
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
ENTER_TRAP macro    AssistLabel, TargetLabel
        local b

.FPO ( FPO_LOCALS, FPO_PARAMS, FPO_PROLOG, FPO_REGS, FPO_USE_EBP, FPO_TRAPFRAME )

;
;   Fill in parts of frame we care about
;

if DBG
ifndef  _Ki16BitStackException
    EXTRNP   _Ki16BitStackException
endif
endif ; DBG

        mov     word ptr [esp+2], 0 ; Clear upper word of ErrorCode

        push    ebp                 ; Save the non-volatile registers
        push    ebx
        push    esi
        push    edi

        push    fs                  ; Save and set FS to PCR.
        mov     ebx,KGDT_R0_PCR
        mov     fs,bx
        mov     ebx, fs:[PcExceptionList] ;Save ExceptionList
        push    ebx
if DBG
        push    -1                  ; Don't need to save ThPreviousMode from trap
else
        sub     esp, 4              ; pad dword
endif
        push    eax                 ; Save the volatile registers
        push    ecx
        push    edx

        push    ds                  ; Save segments
        push    es
        push    gs

;
;   Skip allocate reset of trap frame and Set up DS/ES, they may be trash
;

        mov     ax,KGDT_R3_DATA OR RPL_MASK
        sub     esp,TsSegGs
        mov     ds,ax
        mov     es,ax

if DBG
;
; The code here check if the exception occurred in ring 0
; ABIOS code. If yes, this is a fatal condition.  We will
; put out message and bugcheck.
;

        cmp     esp, 10000h             ; Is the trap in abios?
        jb      _Ki16BitStackException       ; if b, yes, switch stack and bugcheck.

endif ; DBG

        mov     ebp,esp

        test    dword ptr [esp].TsEflags,EFLAGS_V86_MASK

        jnz     V86_&AssistLabel

V86_&TargetLabel:

ifdef PcPrcbData
        mov     ecx,PCR[PcPrcbData+PbCurrentThread] ; get current thread address
else
        mov     ecx,PCR[PcPrcb]
        mov     ecx,[ecx].PbCurrentThread ; get current thread address
endif
        cld

        and     dword ptr [ebp].TsDr7, 0
        test    byte ptr [ecx].ThDebugActive, 0ffh ; See if debug registers need saving

        jnz     Dr_&AssistLabel

Dr_&TargetLabel:

        SET_DEBUG_DATA

        endm
2015-5-8 08:56
0
雪    币: 23
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
Ki16BitStackException
没符号是吧,难怪找不到,感谢
关键证据:
mov     ebx, fs:[PcExceptionList] ;Save ExceptionList
push    ebx直接转exception的异常处理了。如果没设置直接bosd
2015-5-8 10:15
0
游客
登录 | 注册 方可回帖
返回
//