2 * FILE: ntoskrnl/ke/i386/syscall.S
3 * COPYRIGHT: See COPYING in the top level directory
4 * PURPOSE: System Call Handler
5 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
9 #include <internal/i386/ke.h>
11 #include <ndk/i386/segment.h>
14 #define STATUS_INVALID_SYSTEM_SERVICE 0xC000001C
17 .globl _KiServiceExit2
18 .globl _KiFastCallEntry
19 .globl _KiSystemService
20 .globl _KiDebugService
21 .intel_syntax noprefix
24 * NOTE: I will create some macros for trap entry and exit,
25 * DR* register restoration, modified frame exit, etc, if GAS
26 * allows it/I find a way how. This would remove a lot of
27 * duplicated code in this file plus the other irq/trap asm files.
28 * I think this is similar to what NT does, if you look at teh
29 * Dr_kit*_a functions which look auto-generated.
33 * There are 3 main types of Trap Exits:
36 * - Clear interrupt flag
37 * - Common User APC Dispatching
38 * - Common exit code; segments and volatiles are not restored
39 * You use this for System Call return, when volatiles are irrelevant.
40 * (NtContinue, NtRaiseException, KiCallUserMode and all System Call returns)
43 * - Clear interrupt flag
44 * - Common User APC Dispatching
45 * - Common exit code; the entire frame is restored.
46 * You use this when volatiles and other registers need to be restored.
47 * For example, if debugging is active (NtContinue, NtRaiseException).
50 * - Clear interrupt flag
51 * - Common User APC Dispatching
52 * - Common exit code; the entire frame is restored but *NOT* the Previous Mode
53 * You use this in the same context as KiServiceExit2, but when the Previous Mode
54 * should be tampered with. Clearly, as its name suggests, this routine is mostly
55 * useful for End Of Interrupts.
56 * Note that this routine is EXPORTED.
57 * Note that this routine must called by a JMP, not a CALL.
61 * The common exit code has 3 modes of operation:
62 * - Whether or not to restore segments
63 * - Whether or not to restore volatiles
64 * - Whether or not to restore the previous mode
65 * All these are exemplified by the 3 trap exits shown above
69 * There is also common Debug Code present in the common exit code, which
70 * in turn calls common code to save the debug registers
75 * - Dig in trap code and see why we need to push/pop the segments,
76 * which -shouldn't- be needed on syscalls; one of the things
77 * missing for this to work is lazy loading in the GPF handler,
78 * but there are other things to consider.
79 * - Use macros and merge with trap.s nicely
83 * Entries will be discussed later.
86 /*** This file is a mess; it is being worked on. Please contact Alex:
87 *** alex@relsoft.net if you want to make any changes to it before this
91 /* FUNCTIONS ***************************************************************/
95 /* Restore ESP0 stack */
96 mov ecx, [fs:KPCR_TSS]
97 mov esp, ss:[ecx+KTSS_ESP0]
99 /* Generate V86M Stack for Trap 6 */
105 /* Generate interrupt stack for Trap 6 */
115 // ==================== UNIQUE SYSENTER STUB. DO NOT DUPLICATE ============//
117 mov ecx, PCR_SELECTOR
120 /* Set DS/ES to Kernel Selector */
125 /* Set the current stack to Kernel Stack */
126 mov ecx, [fs:KPCR_TSS]
127 mov esp, ss:[ecx+KTSS_ESP0]
129 /* Set up a fake INT Stack. */
131 push edx /* Ring 3 SS:ESP */
132 pushf /* Ring 3 EFLAGS */
133 push 2 /* Ring 0 EFLAGS */
134 add edx, 8 /* Skip user parameter list */
135 popf /* Set our EFLAGS */
136 or dword ptr [esp], X86_EFLAGS_IF /* Re-enable IRQs in EFLAGS, to fake INT */
138 push KUSER_SHARED_SYSCALL_RET
140 /* Setup the Trap Frame stack */
148 /* Save pointer to our PCR */
149 mov ebx, [fs:KPCR_SELF]
151 /* Get a pointer to the current thread */
152 mov esi, [ebx+KPCR_CURRENT_THREAD]
154 /* Set the exception handler chain terminator */
155 push [ebx+KPCR_EXCEPTION_LIST]
156 mov dword ptr [ebx+KPCR_EXCEPTION_LIST], -1
158 /* Use the thread's stack */
159 mov ebp, [esi+KTHREAD_INITIAL_STACK]
161 /* Push previous mode */
165 /* Save other registers */
166 sub $0xC, %esp // + 0x70
167 pushl $USER_DS // + 0x40
168 pushl $USER_DS // + 0x44
170 sub $0x30, %esp // + 0x70
171 .intel_syntax noprefix
173 /* Make space for us on the stack */
176 /* Write the previous mode */
177 mov byte ptr [esi+KTHREAD_PREVIOUS_MODE], UserMode
184 and dword ptr [ebp+KTRAP_FRAME_DR7], 0
186 /* Check if the thread was being debugged */
187 test byte ptr [esi+KTHREAD_DEBUG_ACTIVE], 0xFF
189 /* Jump to shared code or DR Save */
190 //jnz Dr_FastCallDrSave
195 // ==================== UNIQUE SYSCALL TRAP ENTRY DO NOT DUPLICATE ============//
196 /* Create a trap frame */
204 /* Load PCR Selector into fs */
205 mov ebx, PCR_SELECTOR
208 /* Get a pointer to the current thread */
209 mov esi, [fs:KPCR_CURRENT_THREAD]
211 /* Save the previous exception list */
212 push [fs:KPCR_EXCEPTION_LIST]
214 /* Set the exception handler chain terminator */
215 mov dword ptr [fs:KPCR_EXCEPTION_LIST], -1
217 /* Save the old previous mode */
218 push ss:[esi+KTHREAD_PREVIOUS_MODE]
221 /* Save other registers */
222 sub $0xC, %esp // + 0x70
226 sub $0x30, %esp // + 0x70
227 .intel_syntax noprefix
229 /* Set the new previous mode based on the saved CS selector */
232 mov byte ptr ss:[esi+KTHREAD_PREVIOUS_MODE], bl
234 /* Go on the Kernel stack frame */
237 /* Save the old trap frame pointer where EDX would be saved */
238 mov ebx, [esi+KTHREAD_TRAP_FRAME]
239 mov [ebp+KTRAP_FRAME_EDX], ebx
241 // ==================== COMMON DR SAVE CHECK.AND DEBUG FRAME SETUP ============//
243 and dword ptr [ebp+KTRAP_FRAME_DR7], 0
245 /* Check if the thread was being debugged */
246 test byte ptr [esi+KTHREAD_DEBUG_ACTIVE], 0xFF
250 /* Save a pointer to the trap frame in the TCB */
252 mov [esi+KTHREAD_TRAP_FRAME], ebp
254 /* Get the Debug Trap Frame EBP/EIP */
255 mov ebx, [ebp+KTRAP_FRAME_EBP]
256 mov edi, [ebp+KTRAP_FRAME_EIP]
260 * We want to know the address from where the syscall stub was called.
261 * If PrevMode is KernelMode, that address is stored in our own (kernel)
262 * stack, at location KTRAP_FRAME_ESP.
263 * If we're coming from UserMode, we load the usermode stack pointer
264 * and go back two frames (first frame is the syscall stub, second call
265 * is the caller of the stub).
267 mov edi, [ebp+KTRAP_FRAME_ESP]
268 test byte ptr [esi+KTHREAD_PREVIOUS_MODE], 0x01
274 /* Write the debug data */
275 mov [ebp+KTRAP_FRAME_DEBUGPOINTER], edx
276 mov dword ptr [ebp+KTRAP_FRAME_DEBUGARGMARK], 0xBADB0D00
277 mov [ebp+KTRAP_FRAME_DEBUGEBP], ebx
278 mov [ebp+KTRAP_FRAME_DEBUGEIP], edi
280 // ============= END OF COMMON DR SAVE CHECK.AND DEBUG FRAME SETUP ============//
281 /* Enable interrupts */
287 * Find out which table offset to use. Converts 0x1124 into 0x10.
288 * The offset is related to the Table Index as such: Offset = TableIndex x 10
295 /* Now add the thread's base system table to the offset */
296 add edi, [esi+KTHREAD_SERVICE_TABLE]
298 /* Get the true syscall ID and check it */
303 /* Invalid ID, try to load Win32K Table */
304 jnb KiBBTUnexpectedRange
306 #if 0 // <== Disabled for two reasons: We don't save TEB in 0x18, but KPCR.
307 // <== We don't have a KeGdiFlushUserBatch callback yet (needs to be
308 // sent through the PsInitializeWin32Callouts structure)
309 /* Check if this was Win32K */
314 mov ecx, [fs:KPCR_TEB]
316 /* Check if we should flush the User Batch */
318 or ebx, [ecx+TEB_GDI_BATCH_COUNT]
324 call [_KeGdiFlushUserBatch]
330 /* Users's current stack frame pointer is source */
333 /* Allocate room for argument list from kernel stack */
338 /* Get pointer to function */
342 /* Allocate space on our stack */
346 * Copy the arguments from the user stack to our stack
347 * FIXME: This needs to be probed with MmSystemRangeStart
355 * The following lines are for the benefit of GDB. It will see the return
356 * address of the "call ebx" below, find the last label before it and
357 * thinks that that's the start of the function. It will then check to see
358 * if it starts with a standard function prolog (push ebp, mov ebp,esp).
359 * When that standard function prolog is not found, it will stop the
360 * stack backtrace. Since we do want to backtrace into usermode, let's
361 * make GDB happy and create a standard prolog.
369 /* Do the System Call */
372 /* Deallocate the kernel stack frame */
375 KeReturnFromSystemCall:
377 /* Get the Current Thread */
378 mov ecx, [fs:KPCR_CURRENT_THREAD]
380 /* Restore the old trap frame pointer */
381 mov edx, [ebp+KTRAP_FRAME_EDX]
382 mov [ecx+KTHREAD_TRAP_FRAME], edx
385 /* Disable interrupts */
388 // ================= COMMON USER-MODE APC DELIVERY CHECK ============//
389 /* Check for V86 mode */
390 test dword ptr [ebp+KTRAP_FRAME_EFLAGS], X86_EFLAGS_VM
393 /* Deliver APCs only if we were called from user mode */
394 test byte ptr [ebp+KTRAP_FRAME_CS], 1
397 /* Get the current thread */
399 mov ebx, [fs:KPCR_CURRENT_THREAD]
401 /* Make it non-alerted */
402 mov byte ptr [ebx+KTHREAD_ALERTED], 0
404 /* And only if any are actually pending */
405 cmp byte ptr [ebx+KTHREAD_PENDING_USER_APC], 0
408 /* Save pointer to Trap Frame */
411 // ================= PRESENT ONLY IF VOLATILES NEEDED ============//
412 /* Save some stuff that raising IRQL will kill */
413 mov [ebx+KTRAP_FRAME_EAX], eax
414 mov dword ptr [ebx+KTRAP_FRAME_FS], TEB_SELECTOR
415 mov dword ptr [ebx+KTRAP_FRAME_DS], USER_DS
416 mov dword ptr [ebx+KTRAP_FRAME_ES], USER_DS
417 mov dword ptr [ebx+KTRAP_FRAME_GS], 0
418 // ============= END PRESENT ONLY IF VOLATILES NEEDED ============//
420 /* Raise IRQL to APC_LEVEL */
432 call _KiDeliverApc@12
434 /* Return to old IRQL */
438 /* Restore EAX (only in volatile case) */
439 mov eax, [ebx+KTRAP_FRAME_EAX]
442 // ============== END COMMON USER-MODE APC DELIVERY CHECK ============//
445 // ========================= COMMON TRAP EXIT CODE ===================//
446 /* Restore exception list */
447 mov edx, [esp+KTRAP_FRAME_EXCEPTION_LIST]
448 mov [fs:KPCR_EXCEPTION_LIST], edx
450 // ==================== ONLY IF PREVIOUS MODE NEEDED ==================//
451 /* Restore previous mode */
452 mov ecx, [esp+KTRAP_FRAME_PREVIOUS_MODE]
453 mov esi, [fs:KPCR_CURRENT_THREAD]
454 mov byte ptr [esi+KTHREAD_PREVIOUS_MODE], cl
455 // ==================== END IF PREVIOUS MODE NEEDED ===================//
458 test dword ptr [esp+KTRAP_FRAME_EFLAGS], X86_EFLAGS_VM
461 /* Check if the frame was edited */
463 test word ptr [esp+KTRAP_FRAME_CS], FRAME_EDITED
466 // ==================== ONLY IF FULL RESTORE NEEDED ===================//
467 /* Check the old mode */
468 cmp word ptr [esp+KTRAP_FRAME_CS], USER_CS
469 bt word ptr [esp+KTRAP_FRAME_CS], 0
472 // ==================== END IF FULL RESTORE NEEDED ====================//
474 /* Skip debug information and unsaved registers */
485 //lea esp, [ebp+KTRAP_FRAME_FS] <= BUG IN WIN32K CALLBACKS! STACK GETS SMASHED
489 /* Skip debug information and unsaved registers */
490 //lea esp, [ebp+KTRAP_FRAME_EDI] <= BUG IN WIN32K CALLBACKS! STACK GETS SMASHED
496 /* Check for ABIOS */
497 cmp word ptr [esp+8], 0x80
504 /* Check if previous CS is from user-mode */
505 test dword ptr [esp+4], 1
507 /* It is, so use Fast Exit */
510 /* Jump back to stub */
521 /* Is SYSEXIT Supported/Wanted? */
522 cmp dword ptr ss:[_KiFastSystemCallDisable], 0
524 test dword ptr [esp+8], X86_EFLAGS_TF
527 /* Restore FS to TIB */
528 mov ecx, TEB_SELECTOR
531 /* We will be cleaning up the stack ourselves */
532 pop edx /* New Ring 3 EIP */
533 add esp, 4 /* Skip Ring 3 DS */
534 /* and dword ptr [esp], ~X86_EFLAGS_IF Line below is equivalent to this,
535 but older binutils versions don't understand ~ */
536 and dword ptr [esp], 0xfffffdff /* Remove IRQ hack from EFLAGS */
537 popf /* Restore old EFLAGS */
538 pop ecx /* Old Ring 3 SS:ESP */
542 * ECX points to the old User Stack.
543 * EDX points to the instruction to execute in usermode after the sysenter
549 /* Move to EDX position */
550 add esp, KTRAP_FRAME_EDX
552 /* Restore volatiles */
559 /* Not yet supported */
564 mov eax, [esp+KTRAP_FRAME_EAX]
569 /* Restore segments and volatiles */
576 /* Jump back to mainline code */
580 /* Restore real CS value */
581 mov ebx, [esp+KTRAP_FRAME_TEMPCS]
582 mov [esp+KTRAP_FRAME_CS], ebx
585 * If ESP was modified, then a special interrupt exit stack
586 * must be created to "update" ESP's value in a legal manner
588 mov ebx, [esp+KTRAP_FRAME_TEMPESP]
590 mov [esp+KTRAP_FRAME_ERROR_CODE], ebx
592 /* Copy Interrupt Stack */
593 mov esi, [esp+KTRAP_FRAME_EFLAGS]
595 mov esi, [esp+KTRAP_FRAME_CS]
597 mov esi, [esp+KTRAP_FRAME_EIP]
601 add esp, KTRAP_FRAME_EDI
609 KiBBTUnexpectedRange:
611 /* If this isn't a Win32K call, fail */
615 /* Set up Win32K Table */
620 /* FIXME: Handle failure */
624 /* Try the Call again */
629 /* Invalid System Call */
630 mov eax, STATUS_INVALID_SYSTEM_SERVICE
631 jmp KeReturnFromSystemCall
635 /* Disable interrupts */
638 /* Check for V86 mode */
639 test dword ptr [ebp+KTRAP_FRAME_EFLAGS], X86_EFLAGS_VM
642 /* Deliver APCs only if we were called from user mode */
643 test byte ptr [ebp+KTRAP_FRAME_CS], 1
646 /* Get the current thread */
648 mov ebx, [fs:KPCR_CURRENT_THREAD]
650 /* Make it non-alerted */
651 mov byte ptr [ebx+KTHREAD_ALERTED], 0
653 /* And only if any are actually pending */
654 cmp byte ptr [ebx+KTHREAD_PENDING_USER_APC], 0
657 /* Save pointer to Trap Frame */
660 /* Raise IRQL to APC_LEVEL */
672 call _KiDeliverApc@12
674 /* Return to old IRQL */
682 /* Restore exception list */
683 mov edx, [esp+KTRAP_FRAME_EXCEPTION_LIST]
684 mov [fs:KPCR_EXCEPTION_LIST], edx
686 /* Restore previous mode */
687 mov ecx, [esp+KTRAP_FRAME_PREVIOUS_MODE]
688 mov esi, [fs:KPCR_CURRENT_THREAD]
689 mov byte ptr [esi+KTHREAD_PREVIOUS_MODE], cl
692 test dword ptr [esp+KTRAP_FRAME_EFLAGS], X86_EFLAGS_VM
695 /* Check if the frame was edited */
697 test word ptr [esp+KTRAP_FRAME_CS], FRAME_EDITED
700 /* Restore volatiles */
701 mov edx, [esp+KTRAP_FRAME_EDX]
702 mov ecx, [esp+KTRAP_FRAME_ECX]
703 mov eax, [esp+KTRAP_FRAME_EAX]
705 /* Check if it was kernel */
706 cmp word ptr [ebp+KTRAP_FRAME_CS], KERNEL_CS
710 lea esp, [ebp+KTRAP_FRAME_GS]
712 /* Restore segments and volatiles */
716 lea esp, [ebp+KTRAP_FRAME_FS]
720 /* Skip debug information and unsaved registers */
721 lea esp, [ebp+KTRAP_FRAME_EDI]
727 /* Check for ABIOS */
728 cmp word ptr [esp+8], 0x80
731 /* Pop error code and return */
736 /* Move to EDX position */
737 add esp, KTRAP_FRAME_EDX
739 /* Restore volatiles */
746 /* Restore real CS value */
747 mov ebx, [esp+KTRAP_FRAME_TEMPCS]
748 mov [esp+KTRAP_FRAME_CS], ebx
751 * If ESP was modified, then a special interrupt exit stack
752 * must be created to "update" ESP's value in a legal manner
754 mov ebx, [esp+KTRAP_FRAME_TEMPESP]
756 mov [esp+KTRAP_FRAME_ERROR_CODE], ebx
758 /* Copy Interrupt Stack */
759 mov esi, [esp+KTRAP_FRAME_EFLAGS]
761 mov esi, [esp+KTRAP_FRAME_CS]
763 mov esi, [esp+KTRAP_FRAME_EIP]
766 /* Restore volatiles */
767 mov eax, [esp+KTRAP_FRAME_EAX]
768 mov edx, [esp+KTRAP_FRAME_EDX]
769 mov ecx, [esp+KTRAP_FRAME_ECX]
772 add esp, KTRAP_FRAME_EDI
782 /* Create the Trap Frame */
790 /* Switch to correct FS */
794 /* Save Exception List */
795 push fs:[KPCR_EXCEPTION_LIST]
797 /* Traps don't need the previous mode */
800 /* Continue building the Trap Frame */
809 /* Switch Segments to Kernel */
817 /* Check if this was from V86 Mode */
818 test dword ptr [ebp+KTRAP_FRAME_EFLAGS], X86_EFLAGS_VM
821 /* Get current thread */
822 mov ecx, [fs:KPCR_CURRENT_THREAD]
826 and dword ptr [ebp+KTRAP_FRAME_DR7], 0
828 /* Check if the thread was being debugged */
829 test byte ptr [ecx+KTHREAD_DEBUG_ACTIVE], 0xFF
832 /* Get the Debug Trap Frame EBP/EIP */
833 mov ebx, [ebp+KTRAP_FRAME_EBP]
834 mov edi, [ebp+KTRAP_FRAME_EIP]
836 /* Write the debug data */
837 mov [ebp+KTRAP_FRAME_DEBUGPOINTER], edx
838 mov dword ptr [ebp+KTRAP_FRAME_DEBUGARGMARK], 0xBADB0D00
839 mov [ebp+KTRAP_FRAME_DEBUGEBP], ebx
840 mov [ebp+KTRAP_FRAME_DEBUGEIP], edi
842 /* Call debug service dispatcher */
843 push [ebp+KTRAP_FRAME_EDX]
844 push [ebp+KTRAP_FRAME_ECX]
845 push [ebp+KTRAP_FRAME_EAX]
846 call _KdpServiceDispatcher@12
848 /* Exit through common routine */
849 jmp Kei386EoiHelper@0
853 /* Disable interrupts */
856 /* Check for V86 mode */
857 test dword ptr [ebp+KTRAP_FRAME_EFLAGS], X86_EFLAGS_VM
860 /* Deliver APCs only if we were called from user mode */
861 test byte ptr [ebp+KTRAP_FRAME_CS], 1
864 /* Get the current thread */
866 mov ebx, [fs:KPCR_CURRENT_THREAD]
868 /* Make it non-alerted */
869 mov byte ptr [ebx+KTHREAD_ALERTED], 0
871 /* And only if any are actually pending */
872 cmp byte ptr [ebx+KTHREAD_PENDING_USER_APC], 0
875 /* Save pointer to Trap Frame */
878 /* Raise IRQL to APC_LEVEL */
890 call _KiDeliverApc@12
892 /* Return to old IRQL */
900 /* Restore exception list */
901 mov edx, [esp+KTRAP_FRAME_EXCEPTION_LIST]
902 mov [fs:KPCR_EXCEPTION_LIST], edx
905 test dword ptr [esp+KTRAP_FRAME_EFLAGS], X86_EFLAGS_VM
908 /* Check if the frame was edited */
910 test word ptr [esp+KTRAP_FRAME_CS], FRAME_EDITED
913 /* Restore volatiles */
914 mov edx, [esp+KTRAP_FRAME_EDX]
915 mov ecx, [esp+KTRAP_FRAME_ECX]
916 mov eax, [esp+KTRAP_FRAME_EAX]
918 /* Check if it was kernel */
919 cmp word ptr [ebp+KTRAP_FRAME_CS], KERNEL_CS
923 lea esp, [ebp+KTRAP_FRAME_GS]
925 /* Restore segments and volatiles */
929 lea esp, [ebp+KTRAP_FRAME_FS]
933 /* Skip debug information and unsaved registers */
934 lea esp, [ebp+KTRAP_FRAME_EDI]
940 /* Check for ABIOS */
941 cmp word ptr [esp+8], 0x80
944 /* Pop error code and return */
949 /* Move to EDX position */
950 add esp, KTRAP_FRAME_EDX
952 /* Restore volatiles */
959 /* Restore real CS value */
960 mov ebx, [esp+KTRAP_FRAME_TEMPCS]
961 mov [esp+KTRAP_FRAME_CS], ebx
964 * If ESP was modified, then a special interrupt exit stack
965 * must be created to "update" ESP's value in a legal manner
967 mov ebx, [esp+KTRAP_FRAME_TEMPESP]
969 mov [esp+KTRAP_FRAME_ERROR_CODE], ebx
971 /* Copy Interrupt Stack */
972 mov esi, [esp+KTRAP_FRAME_EFLAGS]
974 mov esi, [esp+KTRAP_FRAME_CS]
976 mov esi, [esp+KTRAP_FRAME_EIP]
979 /* Restore volatiles */
980 mov eax, [esp+KTRAP_FRAME_EAX]
981 mov edx, [esp+KTRAP_FRAME_EDX]
982 mov ecx, [esp+KTRAP_FRAME_ECX]
985 add esp, KTRAP_FRAME_EDI
993 .globl _NtRaiseException@12
994 _NtRaiseException@12:
996 /* NOTE: We -must- be called by Zw* to have the right frame! */
997 /* Push the stack frame */
1000 /* Get the current thread and restore its trap frame */
1001 mov ebx, [fs:KPCR_CURRENT_THREAD]
1002 mov edx, [ebp+KTRAP_FRAME_EDX]
1003 mov [ebx+KTHREAD_TRAP_FRAME], edx
1005 /* Set up stack frame */
1008 /* Get the Trap Frame in EBX */
1011 /* Get the exception list and restore */
1012 mov eax, [ebx+KTRAP_FRAME_EXCEPTION_LIST]
1013 mov [fs:KPCR_EXCEPTION_LIST], eax
1015 /* Get the parameters */
1016 mov edx, [ebp+16] /* Search frames */
1017 mov ecx, [ebp+12] /* Context */
1018 mov eax, [ebp+8] /* Exception Record */
1020 /* Raise the exception */
1026 call _KiRaiseException@20
1028 /* Restore trap frame in EBP */
1032 /* Check the result */
1036 /* Restore debug registers too */
1039 .globl _NtContinue@8
1042 /* NOTE: We -must- be called by Zw* to have the right frame! */
1043 /* Push the stack frame */
1046 /* Get the current thread and restore its trap frame */
1047 mov ebx, [fs:KPCR_CURRENT_THREAD]
1048 mov edx, [ebp+KTRAP_FRAME_EDX]
1049 mov [ebx+KTHREAD_TRAP_FRAME], edx
1051 /* Set up stack frame */
1054 /* Save the parameters */
1058 /* Call KiContinue */
1064 /* Check if we failed (bad context record) */
1068 /* Check if test alert was requested */
1069 cmp dword ptr [ebp+12], 0
1072 /* Test alert for the thread */
1073 mov al, [ebx+KTHREAD_PREVIOUS_MODE]
1075 call _KeTestAlertThread@4
1078 /* Return to previous context */