1
0

sys functions 71 and 69 without shift-registers call.(I'm not sure all change is right.

git-svn-id: svn://kolibrios.org@1329 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Alexey Teplov ( 2009-12-23 18:43:42 +00:00
parent 639a979c3a
commit e9e908d84d
6 changed files with 154 additions and 137 deletions

View File

@ -10,10 +10,12 @@ $Revision$
; diamond, 2006 ; diamond, 2006
sys_debug_services: sys_debug_services:
cmp eax, 9 cmp ebx, 9
ja @f ja @f
jmp dword [sys_debug_services_table+eax*4] jmp dword [sys_debug_services_table+ebx*4]
@@: ret @@: ret
iglobal
align 4
sys_debug_services_table: sys_debug_services_table:
dd debug_set_event_data dd debug_set_event_data
dd debug_getcontext dd debug_getcontext
@ -25,21 +27,21 @@ sys_debug_services_table:
dd debug_write_process_memory dd debug_write_process_memory
dd debug_terminate dd debug_terminate
dd debug_set_drx dd debug_set_drx
endg
debug_set_event_data: debug_set_event_data:
; in: ebx = pointer ; in: ecx = pointer
; destroys eax ; destroys eax
mov eax, [current_slot] mov eax, [current_slot]
mov [eax+APPDATA.dbg_event_mem], ebx mov [eax+APPDATA.dbg_event_mem], ecx
ret ret
get_debuggee_slot: get_debuggee_slot:
; in: ebx=PID ; in: ecx=PID
; out: CF=1 if error ; out: CF=1 if error
; CF=0 and eax=slot*0x20 if ok ; CF=0 and eax=slot*0x20 if ok
; out: interrupts disabled ; out: interrupts disabled
cli cli
mov eax, ebx mov eax, ecx
call pid_to_slot call pid_to_slot
test eax, eax test eax, eax
jz .ret_bad jz .ret_bad
@ -56,7 +58,7 @@ get_debuggee_slot:
ret ret
debug_detach: debug_detach:
; in: ebx=pid ; in: ecx=pid
; destroys eax,ebx ; destroys eax,ebx
call get_debuggee_slot call get_debuggee_slot
jc .ret jc .ret
@ -67,54 +69,55 @@ debug_detach:
ret ret
debug_terminate: debug_terminate:
; in: ebx=pid ; in: ecx=pid
call get_debuggee_slot call get_debuggee_slot
jc debug_detach.ret jc debug_detach.ret
mov ecx, eax mov ecx, eax
shr ecx, 5 shr ecx, 5
push 2 ; push 2
pop ebx ; pop ebx
jmp sys_system mov edx,esi
jmp sysfn_terminate
debug_suspend: debug_suspend:
; in: ebx=pid ; in: ecx=pid
; destroys eax,ebx ; destroys eax,ecx
cli cli
mov eax, ebx mov eax, ecx
call pid_to_slot call pid_to_slot
shl eax, 5 shl eax, 5
jz .ret jz .ret
mov bl, [CURRENT_TASK+eax+TASKDATA.state] ; process state mov cl, [CURRENT_TASK+eax+TASKDATA.state] ; process state
test bl, bl test cl, cl
jz .1 jz .1
cmp bl, 5 cmp cl, 5
jnz .ret jnz .ret
mov bl, 2 mov cl, 2
.2: mov [CURRENT_TASK+eax+TASKDATA.state], bl .2: mov [CURRENT_TASK+eax+TASKDATA.state], cl
.ret: .ret:
sti sti
ret ret
.1: .1:
inc ebx inc ecx
jmp .2 jmp .2
do_resume: do_resume:
mov bl, [CURRENT_TASK+eax+TASKDATA.state] mov cl, [CURRENT_TASK+eax+TASKDATA.state]
cmp bl, 1 cmp cl, 1
jz .1 jz .1
cmp bl, 2 cmp cl, 2
jnz .ret jnz .ret
mov bl, 5 mov cl, 5
.2: mov [CURRENT_TASK+eax+TASKDATA.state], bl .2: mov [CURRENT_TASK+eax+TASKDATA.state], cl
.ret: ret .ret: ret
.1: dec ebx .1: dec ecx
jmp .2 jmp .2
debug_resume: debug_resume:
; in: ebx=pid ; in: ecx=pid
; destroys eax,ebx ; destroys eax,ebx
cli cli
mov eax, ebx mov eax, ecx
call pid_to_slot call pid_to_slot
shl eax, 5 shl eax, 5
jz .ret jz .ret
@ -124,23 +127,24 @@ debug_resume:
debug_getcontext: debug_getcontext:
; in: ; in:
; ebx=pid ; ecx=pid
; ecx=sizeof(CONTEXT) ; edx=sizeof(CONTEXT)
; edx->CONTEXT ; esi->CONTEXT
; destroys eax,ecx,edx,esi,edi ; destroys eax,ecx,edx,esi,edi
cmp ecx, 28h cmp edx, 28h
jnz .ret jnz .ret
push ebx ; push ecx
mov ebx, edx ; mov ecx, esi
call check_region call check_region
pop ebx ; pop ecx
dec eax dec eax
jnz .ret jnz .ret
call get_debuggee_slot call get_debuggee_slot
jc .ret jc .ret
mov edi, esi
mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack] mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack]
lea esi, [eax+RING0_STACK_SIZE] lea esi, [eax+RING0_STACK_SIZE]
mov edi, edx
.ring0: .ring0:
; note that following code assumes that all interrupt/exception handlers ; note that following code assumes that all interrupt/exception handlers
; saves ring-3 context by pushad in this order ; saves ring-3 context by pushad in this order
@ -174,23 +178,24 @@ debug_getcontext:
debug_setcontext: debug_setcontext:
; in: ; in:
; ebx=pid ; ecx=pid
; ecx=sizeof(CONTEXT) ; edx=sizeof(CONTEXT)
; edx->CONTEXT ; esi->CONTEXT
; destroys eax,ecx,edx,esi,edi ; destroys eax,ecx,edx,esi,edi
cmp ecx, 28h cmp edx, 28h
jnz .ret jnz .ret
push ebx ; push ebx
mov ebx, edx ; mov ebx, edx
call check_region call check_region
pop ebx ; pop ebx
dec eax dec eax
jnz .ret jnz .ret
call get_debuggee_slot call get_debuggee_slot
jc .stiret jc .stiret
; mov esi, edx
mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack] mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack]
lea edi, [eax+RING0_STACK_SIZE] lea edi, [eax+RING0_STACK_SIZE]
mov esi, edx
.ring0: .ring0:
sub edi, 8+12+20h sub edi, 8+12+20h
mov eax, [esi+24h] ;edi mov eax, [esi+24h] ;edi
@ -227,67 +232,75 @@ debug_set_drx:
lea eax, [eax*8+SLOT_BASE+APPDATA.dbg_regs] lea eax, [eax*8+SLOT_BASE+APPDATA.dbg_regs]
; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3 ; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3
; [eax+10]=dr7 ; [eax+10]=dr7
cmp edx, OS_BASE cmp esi, OS_BASE
jae .errret jae .errret
cmp cl, 3 cmp dl, 3
ja .errret ja .errret
mov ebx, dr7 mov ecx, dr7
shr ebx, cl ;fix me
shr ebx, cl xchg ecx,edx
test ebx, 2 ; bit 1+2*index = G0..G3, global break enable shr edx, cl
shr edx, cl
xchg ecx,edx
test ecx, 2 ; bit 1+2*index = G0..G3, global break enable
jnz .errret2 jnz .errret2
test ch, ch test dh, dh
jns .new jns .new
; clear breakpoint ; clear breakpoint
movzx ecx, cl movzx edx, dl
add ecx, ecx add edx, edx
and dword [eax+ecx*2], 0 ; clear DR<i> and dword [eax+edx*2], 0 ; clear DR<i>
btr dword [eax+10h], ecx ; clear L<i> bit btr dword [eax+10h], edx ; clear L<i> bit
test byte [eax+10h], 55h test byte [eax+10h], 55h
jnz .okret jnz .okret
; imul eax, ebp, tss_step/32 ; imul eax, ebp, tss_step/32
; and byte [eax + tss_data + TSS._trap], not 1 ; and byte [eax + tss_data + TSS._trap], not 1
and [ebp*8 + SLOT_BASE+APPDATA.dbg_state], not 1 and [ebp*8 + SLOT_BASE+APPDATA.dbg_state], not 1
.okret: .okret:
and dword [esp+36], 0 and dword [esp+32], 0
sti sti
ret ret
.errret: .errret:
sti sti
mov dword [esp+36], 1 mov dword [esp+32], 1
ret ret
.errret2: .errret2:
sti sti
mov dword [esp+36], 2 mov dword [esp+32], 2
ret ret
.new: .new:
; add new breakpoint ; add new breakpoint
; cl=index; ch=flags; edx=address ; dl=index; dh=flags; esi=address
test ch, 0xF0 test dh, 0xF0
jnz .errret jnz .errret
mov bl, ch mov cl, dh
and bl, 3 and cl, 3
cmp bl, 2 cmp cl, 2
jz .errret jz .errret
mov bl, ch mov cl, dh
shr bl, 2 shr cl, 2
cmp bl, 2 cmp cl, 2
jz .errret jz .errret
test dl, bl
mov ebx,esi
test bl, dl
jnz .errret jnz .errret
or byte [eax+10h+1], 3 ; set GE and LE flags or byte [eax+10h+1], 3 ; set GE and LE flags
movzx ebx, ch
movzx ecx, cl movzx edx, dh
movzx ecx, dl
add ecx, ecx add ecx, ecx
bts dword [eax+10h], ecx ; set L<i> flag bts dword [eax+10h], ecx ; set L<i> flag
add ecx, ecx add ecx, ecx
mov [eax+ecx], edx ; set DR<i> mov [eax+ecx], ebx;esi ; set DR<i>
shl ebx, cl
mov edx, 0xF
shl edx, cl shl edx, cl
not edx mov ebx, 0xF
and [eax+10h+2], dx shl ebx, cl
or [eax+10h+2], bx ; set R/W and LEN fields not ebx
and [eax+10h+2], bx
or [eax+10h+2], dx ; set R/W and LEN fields
; imul eax, ebp, tss_step/32 ; imul eax, ebp, tss_step/32
; or byte [eax + tss_data + TSS._trap], 1 ; or byte [eax + tss_data + TSS._trap], 1
or [ebp*8 + SLOT_BASE+APPDATA.dbg_state], 1 or [ebp*8 + SLOT_BASE+APPDATA.dbg_state], 1
@ -295,51 +308,51 @@ debug_set_drx:
debug_read_process_memory: debug_read_process_memory:
; in: ; in:
; ebx=pid ; ecx=pid
; ecx=length ; edx=length
; esi->buffer in debugger ; edi->buffer in debugger
; edx=address in debuggee ; esi=address in debuggee
; out: [esp+36]=sizeof(read) ; out: [esp+36]=sizeof(read)
; destroys all ; destroys all
push ebx ; push ebx
mov ebx, esi ; mov ebx, esi
call check_region call check_region
pop ebx ; pop ebx
dec eax dec eax
jnz .err jnz .err
call get_debuggee_slot call get_debuggee_slot
jc .err jc .err
shr eax, 5 shr eax, 5
mov ebx, esi ; mov ebx, esi
call read_process_memory call read_process_memory
sti sti
mov dword [esp+36], eax mov dword [esp+32], eax
ret ret
.err: .err:
or dword [esp+36], -1 or dword [esp+32], -1
ret ret
debug_write_process_memory: debug_write_process_memory:
; in: ; in:
; ebx=pid ; ecx=pid
; ecx=length ; edx=length
; esi->buffer in debugger ; edi->buffer in debugger
; edx=address in debuggee ; esi=address in debuggee
; out: [esp+36]=sizeof(write) ; out: [esp+36]=sizeof(write)
; destroys all ; destroys all
push ebx ; push ebx
mov ebx, esi ; mov ebx, esi
call check_region call check_region
pop ebx ; pop ebx
dec eax dec eax
jnz debug_read_process_memory.err jnz debug_read_process_memory.err
call get_debuggee_slot call get_debuggee_slot
jc debug_read_process_memory.err jc debug_read_process_memory.err
shr eax, 5 shr eax, 5
mov ebx, esi ; mov ebx, esi
call write_process_memory call write_process_memory
sti sti
mov [esp+36], eax mov [esp+32], eax
ret ret
debugger_notify: debugger_notify:

View File

@ -172,9 +172,9 @@ iglobal
dd sys_process_def ; 66-Process definitions - keyboard dd sys_process_def ; 66-Process definitions - keyboard
dd sys_window_move ; 67-Window move or resize dd sys_window_move ; 67-Window move or resize
dd f68 ; 68-Some internal services dd f68 ; 68-Some internal services
dd sys_debug_services ; 69-Debug dd 0 ; 69-Debug
dd file_system_lfn ; 70-Common file system interface, version 2 dd file_system_lfn ; 70-Common file system interface, version 2
dd syscall_windowsettings ; 71-Window settings ; dd 0 ; 71-Window settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; NEW SYSTEM FUNCTIONS TABLE ;; ;; NEW SYSTEM FUNCTIONS TABLE ;;
@ -251,9 +251,9 @@ iglobal
dd cross_order ; 66-Process definitions - keyboard dd cross_order ; 66-Process definitions - keyboard
dd cross_order ; 67-Window move or resize dd cross_order ; 67-Window move or resize
dd cross_order ; 68-Some internal services dd cross_order ; 68-Some internal services
dd cross_order ; 69-Debug dd sys_debug_services ; 69-Debug
dd cross_order ; 70-Common file system interface, version 2 dd cross_order ; 70-Common file system interface, version 2
dd cross_order ; 71-Window settings dd syscall_windowsettings ; 71-Window settings
dd sys_sendwindowmsg ; 72-Send window message dd sys_sendwindowmsg ; 72-Send window message
times 255 - ( ($-servetable2) /4 ) dd undefined_syscall times 255 - ( ($-servetable2) /4 ) dd undefined_syscall
dd sys_end ; -1-end application dd sys_end ; -1-end application

View File

@ -631,24 +631,24 @@ pid_to_slot:
check_region: check_region:
;input: ;input:
; ebx - start of buffer ; esi - start of buffer
; ecx - size of buffer ; edx - size of buffer
;result: ;result:
; eax = 1 region lays in app memory ; eax = 1 region lays in app memory
; eax = 0 region don't lays in app memory ; eax = 0 region don't lays in app memory
mov eax,[CURRENT_TASK] mov eax,[CURRENT_TASK]
jmp check_process_region ; jmp check_process_region
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
check_process_region: ;check_process_region:
;input: ;input:
; eax - slot ; eax - slot
; ebx - start of buffer ; esi - start of buffer
; ecx - size of buffer ; edx - size of buffer
;result: ;result:
; eax = 1 region lays in app memory ; eax = 1 region lays in app memory
; eax = 0 region don't lays in app memory ; eax = 0 region don't lays in app memory
test ecx,ecx test edx,edx
jle .ok jle .ok
shl eax,5 shl eax,5
cmp word [CURRENT_TASK+eax+0xa],0 cmp word [CURRENT_TASK+eax+0xa],0
@ -716,9 +716,9 @@ align 4
proc read_process_memory proc read_process_memory
;Input: ;Input:
; eax - process slot ; eax - process slot
; ebx - buffer address ; ecx - buffer address
; ecx - buffer size ; edx - buffer size
; edx - start address in other process ; esi - start address in other process
;Output: ;Output:
; eax - number of bytes read. ; eax - number of bytes read.
locals locals
@ -730,10 +730,10 @@ proc read_process_memory
endl endl
mov [slot], eax mov [slot], eax
mov [buff], ebx mov [buff], ecx
and [r_count], 0 and [r_count], 0
mov [tmp_r_cnt], ecx mov [tmp_r_cnt], edx
mov [offset], edx mov [offset], esi
pushad pushad
.read_mem: .read_mem:
@ -786,9 +786,9 @@ align 4
proc write_process_memory proc write_process_memory
;Input: ;Input:
; eax - process slot ; eax - process slot
; ebx - buffer address ; ecx - buffer address
; ecx - buffer size ; edx - buffer size
; edx - start address in other process ; esi - start address in other process
;Output: ;Output:
; eax - number of bytes written ; eax - number of bytes written
@ -801,10 +801,10 @@ proc write_process_memory
endl endl
mov [slot], eax mov [slot], eax
mov [buff], ebx mov [buff], ecx
and [w_count], 0 and [w_count], 0
mov [tmp_w_cnt], ecx mov [tmp_w_cnt], edx
mov [offset], edx mov [offset], esi
pushad pushad
.read_mem: .read_mem:

View File

@ -212,17 +212,19 @@ pushad
;eax - address ;eax - address
;esi - slot ;esi - slot
push eax push eax
push ebx
push ecx push ecx
push edx push edx
mov edx,eax push esi
mov eax,esi
lea ebx,[esp+12] ; mov edx,eax
mov ecx,1 ; mov eax,esi
xchg eax,esi
lea ecx,[esp+12]
mov edx,1
call read_process_memory call read_process_memory
pop esi
pop edx pop edx
pop ecx pop ecx
pop ebx
pop eax pop eax
ret ret
.free_form: .free_form:

View File

@ -2032,7 +2032,7 @@ sysfn_terminate: ; 18.2 = TERMINATE
cmp edx,[application_table_status] ; clear app table stat cmp edx,[application_table_status] ; clear app table stat
jne noatsc jne noatsc
mov [application_table_status],0 and [application_table_status],0
noatsc: noatsc:
noprocessterminate: noprocessterminate:
ret ret
@ -2055,7 +2055,7 @@ sysfn_terminate2:
mov ecx,eax mov ecx,eax
cli cli
call sysfn_terminate call sysfn_terminate
mov [application_table_status],0 and [application_table_status],0
sti sti
and dword [esp+32],0 and dword [esp+32],0
ret ret
@ -3243,8 +3243,8 @@ sys_set_window:
syscall_windowsettings: syscall_windowsettings:
.set_window_caption: .set_window_caption:
dec eax ; subfunction #1 - set window caption dec ebx ; subfunction #1 - set window caption
jnz .get_window_caption jnz .exit_fail
; NOTE: only window owner thread can set its caption, ; NOTE: only window owner thread can set its caption,
; so there's no parameter for PID/TID ; so there's no parameter for PID/TID
@ -3262,7 +3262,7 @@ syscall_windowsettings:
; cmp ebx,ecx ; cmp ebx,ecx
; ja .exit_fail ; ja .exit_fail
mov [edi*8+SLOT_BASE+APPDATA.wnd_caption],ebx mov [edi*8+SLOT_BASE+APPDATA.wnd_caption],ecx
or [edi+window_data+WDATA.fl_wstyle],WSTYLE_HASCAPTION or [edi+window_data+WDATA.fl_wstyle],WSTYLE_HASCAPTION
call draw_window_caption call draw_window_caption
@ -3270,9 +3270,9 @@ syscall_windowsettings:
xor eax,eax ; eax = 0 (success) xor eax,eax ; eax = 0 (success)
ret ret
.get_window_caption: ; .get_window_caption:
dec eax ; subfunction #2 - get window caption ; dec eax ; subfunction #2 - get window caption
jnz .exit_fail ; jnz .exit_fail
; not implemented yet ; not implemented yet

View File

@ -143,22 +143,24 @@ ReadNoteByte:
;result: ;result:
; al - note ; al - note
push eax push eax
push ebx
push ecx push ecx
push edx push edx
push esi
mov eax,[pidProcessNote] mov eax,[pidProcessNote]
call pid_to_slot call pid_to_slot
test eax,eax test eax,eax
jz .failed jz .failed
lea ebx,[esp+12] lea ecx,[esp+12]
mov ecx,1 mov edx,1
mov edx,[memAdrNote] mov esi,[memAdrNote]
inc [memAdrNote] inc [memAdrNote]
call read_process_memory call read_process_memory
.failed: .failed:
pop esi
pop edx pop edx
pop ecx pop ecx
pop ebx
pop eax pop eax
ret ret
;------------------- END CODE ------------------- ;------------------- END CODE -------------------