mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 14:53:09 +00:00
cleanup/reformat syscall code, save return value as soon as possible so that eax is freed up, which also simplifies the implementation of KiAfterSystemCallHook(), also removes a couple redundant instructions.
svn path=/trunk/; revision=9955
This commit is contained in:
parent
aa33e15965
commit
209e1d7692
2 changed files with 222 additions and 203 deletions
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: syscall.S,v 1.14 2004/04/07 15:35:14 ekohl Exp $
|
/* $Id: syscall.S,v 1.15 2004/07/01 01:52:37 royce Exp $
|
||||||
*
|
*
|
||||||
* FILE: ntoskrnl/hal/x86/syscall.s
|
* FILE: ntoskrnl/hal/x86/syscall.s
|
||||||
* PURPOSE: 2E trap handler
|
* PURPOSE: 2E trap handler
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
#include <ddk/status.h>
|
#include <ddk/status.h>
|
||||||
#include <internal/i386/segment.h>
|
#include <internal/i386/segment.h>
|
||||||
#include <internal/ps.h>
|
#include <internal/ps.h>
|
||||||
|
#include <internal/i386/ke.h>
|
||||||
#include <roscfg.h>
|
#include <roscfg.h>
|
||||||
|
|
||||||
#define KernelMode (0)
|
#define KernelMode (0)
|
||||||
|
@ -116,18 +117,18 @@ L3:
|
||||||
* register.
|
* register.
|
||||||
*/
|
*/
|
||||||
movl KTHREAD_TRAP_FRAME(%esi), %ebx
|
movl KTHREAD_TRAP_FRAME(%esi), %ebx
|
||||||
movl %ebx, 0x3C(%esp)
|
movl %ebx, KTRAP_FRAME_EDX(%esp)
|
||||||
|
|
||||||
|
/* Allocate new Kernel stack frame */
|
||||||
|
movl %esp,%ebp
|
||||||
|
|
||||||
/* Save a pointer to the trap frame in the TCB */
|
/* Save a pointer to the trap frame in the TCB */
|
||||||
movl %esp, KTHREAD_TRAP_FRAME(%esi)
|
movl %ebp, KTHREAD_TRAP_FRAME(%esi)
|
||||||
|
|
||||||
/* Set ES to kernel segment */
|
/* Set ES to kernel segment */
|
||||||
movw $KERNEL_DS,%bx
|
movw $KERNEL_DS,%bx
|
||||||
movw %bx,%es
|
movw %bx,%es
|
||||||
|
|
||||||
/* Allocate new Kernel stack frame */
|
|
||||||
movl %esp,%ebp
|
|
||||||
|
|
||||||
/* Users's current stack frame pointer is source */
|
/* Users's current stack frame pointer is source */
|
||||||
movl %edx,%esi
|
movl %edx,%esi
|
||||||
|
|
||||||
|
@ -139,6 +140,7 @@ L3:
|
||||||
cmpl %es:_KeServiceDescriptorTable + 8, %eax
|
cmpl %es:_KeServiceDescriptorTable + 8, %eax
|
||||||
jbe new_serviceInRange
|
jbe new_serviceInRange
|
||||||
movl $STATUS_INVALID_SYSTEM_SERVICE, %eax
|
movl $STATUS_INVALID_SYSTEM_SERVICE, %eax
|
||||||
|
movl %eax, KTRAP_FRAME_EAX(%ebp) /* save our return value in PKTRAP_FRAME->Eax */
|
||||||
jmp KeReturnFromSystemCall
|
jmp KeReturnFromSystemCall
|
||||||
|
|
||||||
new_serviceInRange:
|
new_serviceInRange:
|
||||||
|
@ -174,21 +176,13 @@ new_serviceInRange:
|
||||||
movl %es:_KeServiceDescriptorTable, %ecx
|
movl %es:_KeServiceDescriptorTable, %ecx
|
||||||
movl %es:(%ecx, %eax, 4), %eax
|
movl %es:(%ecx, %eax, 4), %eax
|
||||||
call *%eax
|
call *%eax
|
||||||
|
movl %eax, KTRAP_FRAME_EAX(%ebp) /* save our return value in PKTRAP_FRAME->Eax */
|
||||||
|
|
||||||
#if CHECKED
|
#if CHECKED
|
||||||
/* Bump Service Counter */
|
/* Bump Service Counter */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Deallocate the kernel stack frame */
|
jmp KeDeallocateStackAndReturnFromSystemCallWithHook
|
||||||
movl %ebp,%esp
|
|
||||||
|
|
||||||
/* Call the post system call hook and deliver any pending APCs */
|
|
||||||
pushl %ebp
|
|
||||||
pushl %eax
|
|
||||||
call _KiAfterSystemCallHook
|
|
||||||
addl $8,%esp
|
|
||||||
|
|
||||||
jmp KeReturnFromSystemCall
|
|
||||||
|
|
||||||
new_useShadowTable:
|
new_useShadowTable:
|
||||||
|
|
||||||
|
@ -198,6 +192,7 @@ new_useShadowTable:
|
||||||
cmpl %es:_KeServiceDescriptorTableShadow + 24, %eax
|
cmpl %es:_KeServiceDescriptorTableShadow + 24, %eax
|
||||||
jbe new_shadowServiceInRange
|
jbe new_shadowServiceInRange
|
||||||
movl $STATUS_INVALID_SYSTEM_SERVICE, %eax
|
movl $STATUS_INVALID_SYSTEM_SERVICE, %eax
|
||||||
|
movl %eax, KTRAP_FRAME_EAX(%ebp) /* save our return value in PKTRAP_FRAME->Eax */
|
||||||
jmp KeReturnFromSystemCall
|
jmp KeReturnFromSystemCall
|
||||||
|
|
||||||
new_shadowServiceInRange:
|
new_shadowServiceInRange:
|
||||||
|
@ -238,20 +233,21 @@ new_shadowServiceInRange:
|
||||||
movl %es:_KeServiceDescriptorTableShadow + 16, %ecx
|
movl %es:_KeServiceDescriptorTableShadow + 16, %ecx
|
||||||
movl %es:(%ecx, %eax, 4), %eax
|
movl %es:(%ecx, %eax, 4), %eax
|
||||||
call *%eax
|
call *%eax
|
||||||
|
movl %eax, KTRAP_FRAME_EAX(%ebp) /* save our return value in PKTRAP_FRAME->Eax */
|
||||||
|
|
||||||
#if CHECKED
|
#if CHECKED
|
||||||
/* Bump Service Counter */
|
/* Bump Service Counter */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
KeDeallocateStackAndReturnFromSystemCallWithHook:
|
||||||
/* Deallocate the kernel stack frame */
|
/* Deallocate the kernel stack frame */
|
||||||
movl %ebp,%esp
|
movl %ebp,%esp
|
||||||
|
|
||||||
KeReturnFromSystemCallWithHook:
|
KeReturnFromSystemCallWithHook:
|
||||||
/* Call the post system call hook and deliver any pending APCs */
|
/* Call the post system call hook and deliver any pending APCs */
|
||||||
pushl %esp
|
pushl %esp
|
||||||
pushl %eax
|
|
||||||
call _KiAfterSystemCallHook
|
call _KiAfterSystemCallHook
|
||||||
addl $8,%esp
|
addl $4,%esp
|
||||||
|
|
||||||
KeReturnFromSystemCall:
|
KeReturnFromSystemCall:
|
||||||
|
|
||||||
|
@ -260,9 +256,10 @@ KeReturnFromSystemCall:
|
||||||
movl %fs:0x124, %esi
|
movl %fs:0x124, %esi
|
||||||
|
|
||||||
/* Restore the old trap frame pointer */
|
/* Restore the old trap frame pointer */
|
||||||
movl 0x3c(%esp), %ebx
|
movl KTRAP_FRAME_EDX(%esp), %ebx
|
||||||
movl %ebx, KTHREAD_TRAP_FRAME(%esi)
|
movl %ebx, KTHREAD_TRAP_FRAME(%esi)
|
||||||
|
|
||||||
|
KiRosTrapReturn:
|
||||||
/* Skip debug information and unsaved registers */
|
/* Skip debug information and unsaved registers */
|
||||||
addl $0x30, %esp
|
addl $0x30, %esp
|
||||||
popl %gs
|
popl %gs
|
||||||
|
@ -270,7 +267,7 @@ KeReturnFromSystemCall:
|
||||||
popl %ds
|
popl %ds
|
||||||
popl %edx
|
popl %edx
|
||||||
popl %ecx
|
popl %ecx
|
||||||
addl $0x4, %esp /* Don't restore eax */
|
popl %eax
|
||||||
|
|
||||||
/* Restore the old previous mode */
|
/* Restore the old previous mode */
|
||||||
popl %ebx
|
popl %ebx
|
||||||
|
@ -288,3 +285,23 @@ KeReturnFromSystemCall:
|
||||||
addl $0x4, %esp /* Ignore error code */
|
addl $0x4, %esp /* Ignore error code */
|
||||||
|
|
||||||
iret
|
iret
|
||||||
|
|
||||||
|
/* R3: NOTE: This is part of my in-progress attempt at correcting NtContinue
|
||||||
|
* It is not being called, yet...
|
||||||
|
*/
|
||||||
|
.globl @KeRosTrapReturn@8
|
||||||
|
@KeRosTrapReturn@8:
|
||||||
|
/* Call the post system call hook and deliver any pending APCs */
|
||||||
|
pushl %esp
|
||||||
|
call _KiAfterSystemCallHook
|
||||||
|
addl $4,%esp
|
||||||
|
|
||||||
|
/* Restore the user context */
|
||||||
|
/* Get a pointer to the current thread */
|
||||||
|
movl %fs:0x124, %esi
|
||||||
|
/* Restore the old trap frame pointer */
|
||||||
|
movl %edx, KTHREAD_TRAP_FRAME(%esi)
|
||||||
|
|
||||||
|
/* point %esp to the trap frame to restore */
|
||||||
|
movl %ecx, %esp
|
||||||
|
jmp KiRosTrapReturn;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: usercall.c,v 1.26 2004/06/23 22:32:24 ion Exp $
|
/* $Id: usercall.c,v 1.27 2004/07/01 01:52:37 royce Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -26,7 +26,8 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
VOID KiSystemCallHook(ULONG Nr, ...)
|
VOID
|
||||||
|
KiSystemCallHook(ULONG Nr, ...)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -46,7 +47,8 @@ VOID KiSystemCallHook(ULONG Nr, ...)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG KiAfterSystemCallHook(ULONG NtStatus, PKTRAP_FRAME TrapFrame)
|
VOID
|
||||||
|
KiAfterSystemCallHook(PKTRAP_FRAME TrapFrame)
|
||||||
{
|
{
|
||||||
if (KeGetCurrentThread()->Alerted[1] != 0 && TrapFrame->Cs != KERNEL_CS)
|
if (KeGetCurrentThread()->Alerted[1] != 0 && TrapFrame->Cs != KERNEL_CS)
|
||||||
{
|
{
|
||||||
|
@ -56,11 +58,11 @@ ULONG KiAfterSystemCallHook(ULONG NtStatus, PKTRAP_FRAME TrapFrame)
|
||||||
{
|
{
|
||||||
KiDeliverUserApc(TrapFrame);
|
KiDeliverUserApc(TrapFrame);
|
||||||
}
|
}
|
||||||
return(NtStatus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID KiServiceCheck (ULONG Nr)
|
VOID
|
||||||
|
KiServiceCheck (ULONG Nr)
|
||||||
{
|
{
|
||||||
PETHREAD Thread;
|
PETHREAD Thread;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue