rewritten reg_service, get_service, stop_all_services

git-svn-id: svn://kolibrios.org@278 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-01-18 02:06:00 +00:00
parent a9706fb6ca
commit f825a71d89
5 changed files with 87 additions and 75 deletions

View File

@ -388,23 +388,28 @@ struc PG_DATA
.tmp_task_mutex dd ?
}
struc LIB
{ .lib_name rb 16
.lib_base dd ?
.lib_start dd ?
.export dd ?
.import dd ?
}
;struc LIB
;{ .lib_name rb 16
; .lib_base dd ?
; .lib_start dd ?
; .export dd ?
; .import dd ?
;}
struc SRV
{ .srv_name rb 16
.magic dd ?
.size dd ?
.base dd ?
.entry dd ?
.srv_proc dd ?
{ .srv_name rb 16 ;ASCIIZ string
.magic dd ? ;+0x10 ;'SRV '
.size dd ? ;+0x14 ;size of structure SRV
.fd dd ? ;+0x18 ;next SRV descriptor
.bk dd ? ;+0x1C ;prev SRV descriptor
.base dd ? ;+0x20 ;service base address
.entry dd ? ;+0x24 ;service START function
.srv_proc dd ? ;+0x28 ;main service handler
}
SRV_FD_OFFSET equ 0x18
SRV_SIZE equ 44
struc COFF_HEADER
{ .machine dw ?
.nSections dw ?
@ -459,12 +464,9 @@ virtual at 0
IOCTL IOCTL
end virtual
SRV_SIZE equ 36
virtual at 0
LIB LIB
end virtual
;virtual at 0
; LIB LIB
;end virtual
virtual at 0
SRV SRV

View File

@ -281,36 +281,31 @@ restore out_size
align 4
proc get_service stdcall, sz_name:dword
locals
srv_ptr dd ?
counter dd ?
endl
mov eax, [sz_name]
test eax, eax
jnz @F
ret
@@:
mov [srv_ptr], srv_tab
mov [counter], 16
mov edx, [srv.fd]
@@:
stdcall strncmp, [srv_ptr], [sz_name], 16
cmp edx, srv.fd-SRV_FD_OFFSET
je .not_load
stdcall strncmp, edx, [sz_name], 16
test eax, eax
je .ok
add [srv_ptr], SRV_SIZE
dec [counter]
jnz @B
mov edx, [edx+SRV.fd]
jmp @B
.not_load:
stdcall find_service, [sz_name]
test eax, eax
jnz @F
ret
@@:
jz @F
stdcall load_driver, eax
@@:
ret
.ok:
mov eax, [srv_ptr]
mov eax, edx
ret
endp
@ -343,40 +338,43 @@ proc find_service stdcall ,sz_name:dword
endp
align 4
proc reg_service stdcall, sz_name:dword, handler:dword
locals
srv dd ?
endl
mov eax, [sz_name]
reg_service:
.sz_name equ esp+4
.handler equ esp+8
mov eax, [.sz_name]
test eax, eax
jz .fail
mov ebx, [handler]
mov ebx, [.handler]
test ebx, ebx
jz .fail
call alloc_service
mov eax, SRV_SIZE
call malloc ;call alloc_service
test eax, eax
jz .fail
mov [srv], eax
mov edi, eax
mov esi, [sz_name]
mov ecx, 16
rep movsb
mov esi, [.sz_name]
mov ecx, 16/4
rep movsd
mov edi, eax
mov [edi+SRV.magic], ' SRV'
mov [edi+SRV.size], SRV_SIZE
mov ebx, [handler]
mov [edi+SRV.srv_proc], ebx
mov eax, [srv]
mov [eax+SRV.magic], ' SRV'
mov [eax+SRV.size], SRV_SIZE
mov ebx, srv.fd-SRV_FD_OFFSET
mov edx, [ebx+SRV.fd]
mov [eax+SRV.fd], edx
mov [eax+SRV.bk], ebx
mov [ebx+SRV.fd], eax
mov [edx+SRV.bk], eax
mov ecx, [.handler]
mov [eax+SRV.srv_proc], ecx
ret
.fail:
xor eax, eax
ret
endp
align 4
proc get_proc stdcall, exp:dword, sz_name:dword
@ -967,24 +965,26 @@ proc load_library stdcall, file_name:dword
ret
endp
align 4
proc stop_all_services
not [srv_map]
mov edx, [srv.fd]
.next:
bsf eax, [srv_map]
jnz .find
ret
.find:
btr [srv_map], eax
shl eax,0x02
lea eax,[srv_tab+eax+eax*8] ;srv_tab+eax*36
cmp [eax+SRV.magic], ' SRV'
cmp edx, srv.fd-SRV_FD_OFFSET
je .done
cmp [edx+SRV.magic], ' SRV'
jne .next
cmp [eax+SRV.size], SRV_SIZE
cmp [edx+SRV.size], SRV_SIZE
jne .next
mov ebx, [eax+SRV.entry]
mov ebx, [edx+SRV.entry]
mov edx, [edx+SRV.fd]
push edx
stdcall ebx, dword -1
pop edx
jmp .next
.done:
ret
endp

View File

@ -800,6 +800,7 @@ proc user_free stdcall, base:dword
ret
endp
if 0
align 4
proc alloc_dll
pushf
@ -833,3 +834,5 @@ proc alloc_service
lea eax,[srv_tab+eax+eax*8] ;srv_tab+eax*36
ret
endp
end if

View File

@ -1300,15 +1300,18 @@ align 16
mst MEM_STATE
dll_tab rb 32*32
srv_tab rb 36*32
; dll_tab rb 32*32
; srv_tab rb 36*32
mem_block_map rb 512
event_map rb 128
mem_block_list rd 64
mem_block_mask rd 2
dll_map rd 1
srv_map rd 1
; dll_map rd 1
; srv_map rd 1
srv.fd rd 1
srv.bk rd 1
mem_used_list rd 1
mem_block_arr rd 1

View File

@ -438,14 +438,18 @@ B32:
call init_events
mov [dll_map], 0xFFFFFFFF
mov [srv_map], 0xFFFFFFFF
; mov [dll_map], 0xFFFFFFFF
; mov [srv_map], 0xFFFFFFFF
call alloc_dll
mov edi, eax
mov esi, szKernel
mov ecx, 16
rep movsb
; call alloc_dll
; mov edi, eax
; mov esi, szKernel
; mov ecx, 16
; rep movsb
mov eax, srv.fd-SRV_FD_OFFSET
mov [srv.fd], eax
mov [srv.bk], eax
mov edi, irq_tab
xor eax, eax