亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? usercall_asm.s

?? ReactOS是一些高手根據(jù)Windows XP的內(nèi)核編寫出的類XP。內(nèi)核實現(xiàn)機(jī)理和API函數(shù)調(diào)用幾乎相同。甚至可以兼容XP的程序。喜歡研究系統(tǒng)內(nèi)核的人可以看一看。
?? S
字號:
/*
 * COPYRIGHT:       See COPYING in the top level directory
 * PROJECT:         ReactOS Kernel
 * FILE:            ntoskrnl/ke/i386/usercall_asm.S
 * PURPOSE:         User-Mode callbacks and return.
 * PROGRAMMERS:     Alex Ionescu (alex@relsoft.net)
 */

/* INCLUDES ******************************************************************/

#include <asm.h>
#include <internal/i386/asmmacro.S>
.intel_syntax noprefix

/* FUNCTIONS ****************************************************************/

.globl _KiGetUserModeStackAddress@0
.func KiGetUserModeStackAddress@0
_KiGetUserModeStackAddress@0:

    /* Get the current thread's trapframe and return the esp */
    mov eax, fs:[KPCR_CURRENT_THREAD]
    mov eax, [eax+KTHREAD_TRAP_FRAME]
    lea eax, [eax+KTRAP_FRAME_ESP]
    ret

.endfunc

/*++
 * @name KiCallUserMode 
 *
 *     The KiSwitchToUserMode routine sets up a Trap Frame and a Callback stack
 *     for the purpose of switching to user mode. The actual final jump is done
 *     by KiServiceExit which will treat this as a syscall return.
 *
 * @param OutputBuffer
 *        Pointer to a caller-allocated buffer where to receive the return data
 *        from the user-mode function
 *
 * @param OutputLength
 *        Size of the Output Buffer described above.
 *
 * @return None. Jumps into KiServiceExit.
 *
 * @remark If there is not enough Kernel Stack space, the routine will increase the
 *         Kernel Stack.
 *
 *         User mode execution resumes at ntdll!KiUserCallbackDispatcher.
 *
 *         This call MUST be paired by interrupt 0x2B or NtCallbackReturn.
 *
 *--*/
.globl _KiCallUserMode@8
.func KiCallUserMode@8
_KiCallUserMode@8:

    /* Save volatile registers */
    push ebp
    push ebx
    push esi
    push edi

    /* Get the current thread */
    mov ebx, fs:[KPCR_CURRENT_THREAD]

    /* Make sure we're at passive */
#if DBG
    call _KeGetCurrentIrql@0
    or al, al
    jz AtPassive

    /* We're not, bugcheck! */
    push 0
    push 0
    push eax
    push 0
    push IRQL_GT_ZERO_AT_SYSTEM_SERVICE
    call _KeBugCheckEx@20

AtPassive:

    /* Make sure that we are not attached and that APCs are not disabled */
    movzx eax, byte ptr [ebx+KTHREAD_APC_STATE_INDEX]
    mov edx, [ebx+KTHREAD_COMBINED_APC_DISABLE]
    or eax, eax
    jnz InvalidIndex
    or edx, edx
    jz ApcsEnabled

InvalidIndex:

    push 0
    push edx
    push eax
    push 0
    push APC_INDEX_MISMATCH
    call _KeBugCheckEx@20
ApcsEnabled:
#endif

    /* Get the lowest stack limit and check if we can handle it */
    lea eax, [esp-0x3000]
    cmp eax, [ebx+KTHREAD_STACK_LIMIT]
    jnb StackOk

    /* We can't, we'll have to grow our stack */
    push esp
    call _MmGrowKernelStack@4

    /* Quit if we failed */
    or eax, eax
    jnz GrowFailed

    /* Save the current callback stack */
StackOk:
    push [ebx+KTHREAD_CALLBACK_STACK]

    /* Get and save the trap frame */
    mov edx, [ebx+KTHREAD_TRAP_FRAME]
    push edx

    /* Get and save the initial stack */
    mov esi, [ebx+KTHREAD_INITIAL_STACK]
    push esi

    /* Set the new callback stack */
    mov [ebx+KTHREAD_CALLBACK_STACK], esp

    /* Align stack on 16-byte boundary */
    and esp, ~15
    mov edi, esp

    /* Set destination and origin NPX Areas */
    sub esp, NPX_FRAME_LENGTH
    sub esi, NPX_FRAME_LENGTH

    /* Disable interrupts so we can fill the NPX State */
    cli

    /* Now copy the NPX State */
    mov ecx, [esi+FP_CONTROL_WORD]
    mov [esp+FP_CONTROL_WORD], ecx
    mov ecx, [esi+FP_STATUS_WORD]
    mov [esp+FP_STATUS_WORD], ecx
    mov ecx, [esi+FP_TAG_WORD]
    mov [esp+FP_TAG_WORD], ecx
    mov ecx, [esi+FP_DATA_SELECTOR]
    mov [esp+FP_DATA_SELECTOR], ecx
    mov ecx, [esi+FN_CR0_NPX_STATE]
    mov [esp+FN_CR0_NPX_STATE], ecx

    /* Get TSS */
    mov esi, fs:[KPCR_TSS]

    /* Set the stack address */
    mov [ebx+KTHREAD_INITIAL_STACK], edi

    /* Bias the stack for V86 mode */
    mov ecx, esp
    sub esp, 16
    test dword ptr [edx+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK
    jnz DontBias
    mov ecx, esp

DontBias:
    /* Set new stack address in TSS */
    mov [esi+KTSS_ESP0], ecx

    /* Allocate the trap frame and set it */
    sub esp, KTRAP_FRAME_V86_ES
    mov ebp, esp

    /* Set copy iterator and dest/origin parameters and do the copy */
    mov ecx, (KTRAP_FRAME_V86_ES - KTRAP_FRAME_FS) / 4
    lea edi, [esp+KTRAP_FRAME_FS]
    lea esi, [edx+KTRAP_FRAME_FS]
    rep movsd

    /* Copy DR7 */
    mov edi, [edx+KTRAP_FRAME_DR7]
    test edi, ~DR7_RESERVED_MASK
    mov [esp+KTRAP_FRAME_DR7], edi

    /* Check if we need to save debug registers */
    jnz SaveDebug

    /* Get user-mode dispatcher address and set it as EIP */
SetEip:
    mov eax, _KeUserCallbackDispatcher
    mov [esp+KTRAP_FRAME_EIP], eax

    /* Set the exception list */
    mov eax, fs:[KPCR_EXCEPTION_LIST]
    mov [esp+KTRAP_FRAME_EXCEPTION_LIST], eax

    /* Set the previous mode */
    mov eax, [edx+KTRAP_FRAME_PREVIOUS_MODE]
    mov [esp+KTRAP_FRAME_PREVIOUS_MODE], eax

    /* Bring interrupts back */
    sti

    /* Write the debug data */
    SET_TF_DEBUG_HEADER

    /* Exit to user-mode */
    jmp _KiServiceExit

SaveDebug:

    /* Copy all 5 DRs */
    mov ecx, 5
    lea edi, [esp+KTRAP_FRAME_DR0]
    lea esi, [edx+KTRAP_FRAME_DR0]
    rep movsd
    jmp SetEip

GrowFailed:
    /* Restore registers */
    pop edi
    pop esi
    pop ebx
    pop ebp

    /* Return */
    ret 8

.endfunc

/*++
 * @name NtCallbackReturn
 *
 *     The NtCallbackReturn routine returns to kernel mode after a user-mode
 *     callback was done through KeUserModeCallback. It uses the callback frame
 *     which was setup in order to return the information, restores the stack,
 *     and resumes execution where it was left off.
 *
 * @param Result
 *        Pointer to a caller-allocated buffer where the return data
 *               from the user-mode function is located.
 *
 * @param ResultLength
 *        Size of the Output Buffer described above.
 *
 * @param CallbackStatus
 *        Status code of the callback operation.
 *
 * @return Status code of the callback operation.
 *
 * @remark This call MUST be paired with KeUserModeCallback.
 *
 *--*/
.globl _NtCallbackReturn@12
.func NtCallbackReturn@12
_NtCallbackReturn@12:

    /* Get the current thread and make sure we have a callback stack */
    mov eax, fs:[KPCR_CURRENT_THREAD]
    mov ecx, [eax+KTHREAD_CALLBACK_STACK]
    test ecx, ecx
    jz NoStack

    /* Get the trap frame */
    mov ebx, [eax+KTHREAD_TRAP_FRAME]

    /* Restore the exception list */
    mov edx, [ebx+KTRAP_FRAME_EXCEPTION_LIST]
    mov fs:[KPCR_EXCEPTION_LIST], edx

    /* Get the result, the result length and the status */
    mov edi, [esp+4]
    mov esi, [esp+8]
    mov ebp, [esp+12]

    /* Store the results in the callback stack */
    mov ebx, [ecx+CBSTACK_RESULT]
    mov [ebx], edi
    mov ebx, [ecx+CBSTACK_RESULT_LENGTH]
    mov [ebx], esi

    /* Get the previous stack */
    mov ebx, [ecx]

    /* Disable interrupts for NPX save and stack switch */
    cli

    /* Get the initial stack and restore it */
    mov esi, [eax+KTHREAD_INITIAL_STACK]
    mov [eax+KTHREAD_INITIAL_STACK], ebx

    /* Set desination and origin NPX Frames */
    sub esi, NPX_FRAME_LENGTH
    sub ebx, NPX_FRAME_LENGTH

    /* Copy NPX Data */
    mov edx, [esi+FP_CONTROL_WORD]
    mov [ebx+FP_CONTROL_WORD], edx
    mov edx, [esi+FP_STATUS_WORD]
    mov [ebx+FP_STATUS_WORD], edx
    mov edx, [esi+FP_TAG_WORD]
    mov [ebx+FP_TAG_WORD], edx
    mov edx, [esi+FP_DATA_SELECTOR]
    mov [ebx+FP_DATA_SELECTOR], edx
    mov edx, [esi+FN_CR0_NPX_STATE]
    mov [ebx+FN_CR0_NPX_STATE], edx

    /* Check if we failed in user mode */
    cmp ebp, STATUS_CALLBACK_POP_STACK
    mov edi, [ecx+CBSTACK_TRAP_FRAME]
    jz UserFault

CheckDebug:

    /* Clear DR7 */
    and dword ptr [edi+KTRAP_FRAME_DR7], 0

    /* Check if debugging was active */
    test byte ptr [eax+KTHREAD_DEBUG_ACTIVE], 0xFF
    jnz RestoreDebug

    /* Get TSS */
    mov edx, fs:[KPCR_TSS]

    /* Restore stack pointer */
    lea esp, [ecx+CBSTACK_CALLBACK_STACK]

    /* Check if we were in V86 mode */
    test dword ptr [edi+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK
    jnz V86Ret
    sub ebx, 16

V86Ret:
    /* Restore the ESP in TSS */
    mov [edx+KTSS_ESP0], ebx

    /* Restore the trap frame */
    mov [eax+KTHREAD_TRAP_FRAME], edi

    /* Bring interrupts back */
    sti

    /* Restore the callback stack*/
    pop [eax+KTHREAD_CALLBACK_STACK]

    /* Set status and return */
    mov eax, ebp
    pop edi
    pop esi
    pop ebx
    pop ebp
    pop edx

    /* Clean stack and jump back */
    add esp, 8
    jmp edx

UserFault:
    /* Set size to copy */
    mov ecx, (KTRAP_FRAME_V86_ES - KTRAP_FRAME_FS) / 4

    /* Check if this was V86 mode */
    mov esi, [eax+KTHREAD_TRAP_FRAME]
    test dword ptr [esi+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK

    /* Save EDI and load destination */
    mov edx, edi
    lea edi, [edi+KTRAP_FRAME_FS]
    jz NotV86
    add ecx, 16 / 4

NotV86:
    /* Set source and copy */
    lea esi, [esi+KTRAP_FRAME_FS]
    rep movsd

    /* Restore ECX and ECX */
    mov ecx, [eax+KTHREAD_CALLBACK_STACK]
    mov edi, edx
    jmp CheckDebug

RestoreDebug:

    /* Not yet supported */
    int 3
    jmp $

NoStack:

    /* Return failure */
    mov eax, STATUS_NO_CALLBACK_ACTIVE
    ret 12
.endfunc

/*++
 * @name KeSwitchKernelStack 
 *
 *     The KeSwitchKernelStack routine switches from the current thread's stack
 *     to the new specified base and limit.
 *
 * @param StackBase
 *        Pointer to the new Stack Base of the thread.
 *
 * @param StackLimit
 *        Pointer to the new Stack Limit of the thread.
 *
 * @return The previous Stack Limit of the thread.
 *
 * @remark This routine should typically only be used when converting from a 
 *         non-GUI to a GUI Thread. The caller is responsible for freeing the
 *         previous stack. The new stack values MUST be valid before calling
 *         this routine.
 *
 *--*/
.globl _KeSwitchKernelStack@8
.func KeSwitchKernelStack@8
_KeSwitchKernelStack@8:

    /* Save volatiles */
    push esi
    push edi

    /* Get current thread */
    mov edx, fs:[KPCR_CURRENT_THREAD]

    /* Get new and current base */
    mov edi, [esp+12]
    mov ecx, [edx+KTHREAD_STACK_BASE]

    /* Fixup the frame pointer */
    sub ebp, ecx
    add ebp, edi

    /* Fixup the trap frame */
    mov eax, [edx+KTHREAD_TRAP_FRAME]
    sub eax, ecx
    add eax, edi
    mov [edx+KTHREAD_TRAP_FRAME], eax

    /* Calculate stack size */
    sub ecx, esp

    /* Get desination and origin */
    sub edi, ecx
    mov esi, esp

    /* Save stack pointer */
    push edi

    /* Copy stack */
    rep movsb

    /* Restore stack pointer */
    pop edi

    /* Save old stack base and get new limit/base */
    mov eax, [edx+KTHREAD_STACK_LIMIT]
    mov ecx, [esp+12]
    mov esi, [esp+16]

    /* Disable interrupts for stack switch */
    cli

    /* Set new base/limit */
    mov [edx+KTHREAD_STACK_BASE], ecx
    mov [edx+KTHREAD_STACK_LIMIT], esi

    /* Set LargeStack */
    mov byte ptr [edx+KTHREAD_LARGE_STACK], 1

    /* Set new initial stack */
    mov [edx+KTHREAD_INITIAL_STACK], ecx

    /* Get trap frame */
    mov esi, [edx+KTHREAD_TRAP_FRAME]

    /* Get TSS */
    mov edx, fs:[KPCR_TSS]

    /* Check if we came from V86 mode */
    test dword ptr [esi+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK

    /* Bias for NPX Area */
    lea ecx, [ecx-NPX_FRAME_LENGTH]
    jnz V86Switch
    sub ecx, 16

V86Switch:

    /* Update ESP in TSS */
    mov [edx+KTSS_ESP0], ecx

    /* Update stack pointer */
    mov esp, edi

    /* Bring back interrupts and return */
    sti
    pop edi
    pop esi
    ret 8
.endfunc

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
另类专区欧美蜜桃臀第一页| 夜夜嗨av一区二区三区中文字幕| 亚洲综合色网站| 美女视频一区在线观看| 99久久国产综合精品色伊| 91首页免费视频| 精品国产乱码久久久久久图片| 亚洲欧洲精品一区二区三区| 免费成人av资源网| 成人av影院在线| 日韩女优毛片在线| 亚洲自拍偷拍欧美| 粉嫩久久99精品久久久久久夜| 欧美日韩国产美| 亚洲天堂网中文字| 美女一区二区久久| 欧美午夜电影在线播放| 国产欧美精品日韩区二区麻豆天美| 日产欧产美韩系列久久99| 97久久精品人人做人人爽50路 | 亚洲一二三四在线| 国产精品一区二区果冻传媒| 91福利国产精品| 中文字幕精品三区| 久99久精品视频免费观看| 欧美色中文字幕| 国产精品国产自产拍高清av| 久久99精品久久久久久国产越南 | 亚洲欧美视频一区| 国产夫妻精品视频| 精品电影一区二区三区 | 国产三区在线成人av| 日本vs亚洲vs韩国一区三区| 欧美伊人久久大香线蕉综合69| 国产精品久久三| 国产传媒久久文化传媒| 精品福利av导航| 日本91福利区| 欧美久久久一区| 亚洲五码中文字幕| 欧美在线观看禁18| 亚洲精品一二三| 99这里都是精品| 欧美激情一区二区三区全黄| 狠狠狠色丁香婷婷综合激情| 日韩美女在线视频| 久久机这里只有精品| 欧美一区二区三区男人的天堂 | 国产黄色精品视频| 久久综合久久久久88| 狠狠色狠狠色综合| 91超碰这里只有精品国产| 亚洲欧美一区二区三区国产精品| 成人一区二区三区| 国产精品久久二区二区| 成人午夜伦理影院| 中文字幕一区二区三区精华液| 岛国av在线一区| 国产精品久久福利| 成人黄色电影在线| 自拍偷拍亚洲综合| 91国偷自产一区二区开放时间| 日韩理论片一区二区| 一本久久a久久精品亚洲| 一区二区在线观看免费| 欧美性生活久久| 亚洲精品国久久99热| 在线精品观看国产| 日韩精品久久理论片| 欧美无乱码久久久免费午夜一区| 亚洲国产精品嫩草影院| 在线播放/欧美激情| 另类小说一区二区三区| 国产精品欧美久久久久无广告| 在线精品视频一区二区三四| 美女网站一区二区| 成人免费在线视频观看| 在线不卡一区二区| 国产suv精品一区二区三区| 亚洲综合成人在线| 欧美精品一区二区久久久| eeuss鲁片一区二区三区在线观看| 亚洲高清不卡在线观看| 久久综合色一综合色88| 色综合中文综合网| 亚洲va韩国va欧美va| 久久九九久精品国产免费直播| 一本色道综合亚洲| 免费成人在线观看视频| 亚洲欧洲精品一区二区三区 | 欧美曰成人黄网| 激情久久五月天| 亚洲精选在线视频| 337p粉嫩大胆色噜噜噜噜亚洲| 91免费版pro下载短视频| 免费的成人av| 亚洲精品乱码久久久久久久久 | 精品福利二区三区| 91久久线看在观草草青青| 狠狠色综合色综合网络| 亚洲成a人片综合在线| 国产精品入口麻豆原神| 91精品在线一区二区| 9i看片成人免费高清| 激情欧美日韩一区二区| 亚洲午夜久久久久久久久电影院| 久久精品亚洲麻豆av一区二区 | 色综合久久天天| 国产一区二区三区免费播放| 亚洲国产wwwccc36天堂| 国产精品久久久久精k8| 26uuu国产电影一区二区| 欧美在线小视频| aaa国产一区| 国产精品1区2区| 老司机精品视频在线| 亚洲第四色夜色| 亚洲另类在线一区| 中文字幕免费不卡| 2021中文字幕一区亚洲| 欧美一区二区在线视频| 91久久国产最好的精华液| 成人开心网精品视频| 久久av资源网| 日本欧美加勒比视频| 亚洲成人免费视| 一区二区三区免费网站| 国产精品看片你懂得 | 在线视频国内自拍亚洲视频| 成人高清免费在线播放| 国产高清无密码一区二区三区| 麻豆精品久久精品色综合| 性做久久久久久免费观看| 一区二区三区在线免费视频| 国产精品久久久久久久久免费桃花| 欧美精品一区二区高清在线观看| 日韩一区二区三区免费看| 欧美日韩黄色影视| 欧美婷婷六月丁香综合色| 一本久道久久综合中文字幕| 91在线视频网址| 91在线视频观看| 91免费在线播放| 91视视频在线观看入口直接观看www| 成人免费毛片aaaaa**| 国产成人精品一区二| 国产a精品视频| 成人精品视频网站| 成人av资源网站| 成人av在线网| 99在线视频精品| 972aa.com艺术欧美| 一本大道久久精品懂色aⅴ| caoporn国产一区二区| 99久久99久久综合| 91色综合久久久久婷婷| 91麻豆免费观看| 在线免费av一区| 欧美日韩国产综合视频在线观看| 欧美日韩国产在线观看| 欧美日韩免费不卡视频一区二区三区| 精品视频资源站| 欧美一区二区视频在线观看2022 | 91亚洲精品乱码久久久久久蜜桃 | 久久成人久久鬼色| 韩国成人在线视频| 国产91精品免费| 99精品国产视频| 欧美三区在线视频| 日韩情涩欧美日韩视频| 亚洲精品一区二区三区精华液| 久久久久久电影| 亚洲视频狠狠干| 亚洲成人动漫精品| 久久疯狂做爰流白浆xx| 国产一区二区三区免费播放| 国产·精品毛片| 91色porny蝌蚪| 欧美人体做爰大胆视频| 日韩欧美国产1| 国产欧美一区二区三区沐欲| 中文字幕一区av| 丝袜美腿亚洲一区二区图片| 九一久久久久久| 99久久亚洲一区二区三区青草| 在线观看国产精品网站| 日韩欧美另类在线| 亚洲国产精华液网站w| 亚洲一区二区精品3399| 精品一区二区免费在线观看| 成人免费毛片嘿嘿连载视频| 欧美探花视频资源| 欧美不卡一二三| 国产精品动漫网站| 日韩av中文在线观看| 懂色中文一区二区在线播放| 欧美色手机在线观看| 亚洲影院在线观看| 国产在线视视频有精品| 91美女在线看|