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 ? .tmp_task_mutex dd ?
} }
struc LIB ;struc LIB
{ .lib_name rb 16 ;{ .lib_name rb 16
.lib_base dd ? ; .lib_base dd ?
.lib_start dd ? ; .lib_start dd ?
.export dd ? ; .export dd ?
.import dd ? ; .import dd ?
} ;}
struc SRV struc SRV
{ .srv_name rb 16 { .srv_name rb 16 ;ASCIIZ string
.magic dd ? .magic dd ? ;+0x10 ;'SRV '
.size dd ? .size dd ? ;+0x14 ;size of structure SRV
.base dd ? .fd dd ? ;+0x18 ;next SRV descriptor
.entry dd ? .bk dd ? ;+0x1C ;prev SRV descriptor
.srv_proc dd ? .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 struc COFF_HEADER
{ .machine dw ? { .machine dw ?
.nSections dw ? .nSections dw ?
@ -459,12 +464,9 @@ virtual at 0
IOCTL IOCTL IOCTL IOCTL
end virtual end virtual
;virtual at 0
SRV_SIZE equ 36 ; LIB LIB
;end virtual
virtual at 0
LIB LIB
end virtual
virtual at 0 virtual at 0
SRV SRV SRV SRV

View File

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

View File

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

View File

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

View File

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