Improve syscall entrypoint
This commit is contained in:
parent
750bfbdc60
commit
4046dd7d6c
@ -32,7 +32,7 @@ stab: ; syscall table
|
||||
dw err, sret ; return version num
|
||||
dw err, sret ; reset disks
|
||||
dw setdd, sret ; select disk
|
||||
dw err, sretb ; open file
|
||||
dw open, sretb ; open file
|
||||
.end:
|
||||
|
||||
section .text
|
||||
@ -46,6 +46,8 @@ absolute 0
|
||||
|
||||
; saved userdata
|
||||
PSPAX: resw 1
|
||||
PSPCX: resw 1
|
||||
PSPBP: resw 1
|
||||
; SS:SP
|
||||
PSPSP: resw 1
|
||||
PSPSS: resw 1
|
||||
@ -69,11 +71,10 @@ pspds: xor ax, ax
|
||||
mov ds, [curpsp]
|
||||
ret
|
||||
|
||||
; Fix CS:AX pointer for reloc
|
||||
fixax: call .l01
|
||||
.l01: pop bx
|
||||
sub bx, .l01
|
||||
add ax, bx
|
||||
; Get reloc offset into CX
|
||||
reloff: call .l01
|
||||
.l01: pop cx
|
||||
sub cx, .l01
|
||||
ret
|
||||
|
||||
int21: push ds
|
||||
@ -82,6 +83,8 @@ int21: push ds
|
||||
call pspds
|
||||
pop word [PSPAX]
|
||||
pop word [PSPDS]
|
||||
mov [PSPCX], cx
|
||||
mov [PSPBP], bp
|
||||
mov [PSPSS], ss
|
||||
mov [PSPSP], sp
|
||||
mov [PSPDX], dx
|
||||
@ -89,27 +92,28 @@ int21: push ds
|
||||
mov [PSPBX], bx
|
||||
|
||||
mov ss, ax
|
||||
mov sp, ( stack+stacksize )
|
||||
; get ptr to syscall table
|
||||
mov al, [PSPAX+1]
|
||||
mov sp, stack
|
||||
; get offset for PIC
|
||||
call reloff
|
||||
; get ptr into syscall table
|
||||
mov al, [PSPAX+1] ; ah is still 0
|
||||
shl ax, 1
|
||||
shl ax, 1
|
||||
add ax, stab
|
||||
call fixax
|
||||
add ax, cx
|
||||
mov bx, ax
|
||||
; load sysret ptr
|
||||
push bx
|
||||
mov ax, [cs:bx+2]
|
||||
call fixax
|
||||
pop bx
|
||||
add ax, cx
|
||||
push ax
|
||||
; load handler ptr
|
||||
mov ax, [cs:bx]
|
||||
call fixax
|
||||
add ax, cx
|
||||
push ax
|
||||
; restore user data
|
||||
mov bx, [PSPBX]
|
||||
mov ax, [PSPAX]
|
||||
mov cx, [PSPCX]
|
||||
mov bx, [PSPBX]
|
||||
mov ds, [PSPDS]
|
||||
; launch ROP chain
|
||||
ret
|
||||
|
Loading…
Reference in New Issue
Block a user