yet another stdcall fix

git-svn-id: svn://kolibrios.org@662 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-10-20 21:02:38 +00:00
parent 0ceaac39cf
commit 39d4709d97
6 changed files with 71 additions and 18 deletions

View File

@ -431,9 +431,7 @@ proc get_fileinfo stdcall, file_name:dword, info:dword
xor eax, eax xor eax, eax
mov ebx, [file_name] mov ebx, [file_name]
; sub ebx, new_app_base
mov ecx, [info] mov ecx, [info]
; sub ecx, new_app_base
mov [cmd], 5 mov [cmd], 5
mov [offset], eax mov [offset], eax
@ -445,7 +443,6 @@ proc get_fileinfo stdcall, file_name:dword, info:dword
mov eax, 70 mov eax, 70
lea ebx, [cmd] lea ebx, [cmd]
; sub ebx, new_app_base
int 0x40 int 0x40
ret ret
endp endp
@ -517,6 +514,10 @@ proc load_file stdcall, file_name:dword
file2 dd ? file2 dd ?
endl endl
push ebx
push esi
push edi
lea eax, [attr] lea eax, [attr]
stdcall get_fileinfo, [file_name], eax stdcall get_fileinfo, [file_name], eax
test eax, eax test eax, eax
@ -561,12 +562,18 @@ proc load_file stdcall, file_name:dword
@@: @@:
mov ebx, [file_size] mov ebx, [file_size]
pop eax pop eax
pop edi
pop esi
pop ebx
ret ret
.cleanup: .cleanup:
stdcall kernel_free, [file] stdcall kernel_free, [file]
.fail: .fail:
xor eax, eax xor eax, eax
xor ebx, ebx xor ebx, ebx
pop edi
pop esi
pop ebx
ret ret
endp endp

View File

@ -104,10 +104,10 @@ kernel_export:
dd szAllocKernelSpace, alloc_kernel_space ;stdcall dd szAllocKernelSpace, alloc_kernel_space ;stdcall
dd szFreeKernelSpace , free_kernel_space ;stdcall dd szFreeKernelSpace , free_kernel_space ;stdcall
dd szKernelAlloc , kernel_alloc dd szKernelAlloc , kernel_alloc ;stdcall
dd szKernelFree , kernel_free dd szKernelFree , kernel_free ;stdcall
dd szUserAlloc , user_alloc dd szUserAlloc , user_alloc ;stdcall
dd szUserFree , user_free dd szUserFree , user_free ;stdcall
dd szKmalloc , malloc dd szKmalloc , malloc
dd szKfree , free dd szKfree , free
dd szCreateRingBuffer, create_ring_buffer dd szCreateRingBuffer, create_ring_buffer
@ -121,17 +121,18 @@ kernel_export:
dd szDestroyEvent , destroy_event dd szDestroyEvent , destroy_event
dd szClearEvent , clear_event dd szClearEvent , clear_event
dd szLoadCursor , load_cursor dd szLoadCursor , load_cursor ;stdcall
dd szSelectHwCursor , select_hw_cursor ;indirect
dd szSetHwCursor , set_hw_cursor ;indirect dd szSelectHwCursor , select_hw_cursor ;import
dd szHwCursorRestore , hw_restore ;indirect dd szSetHwCursor , set_hw_cursor ;import
dd szHwCursorCreate , create_cursor dd szHwCursorRestore , hw_restore ;import
dd szHwCursorCreate , create_cursor ;import
dd szSysMsgBoardStr , sys_msg_board_str dd szSysMsgBoardStr , sys_msg_board_str
dd szGetCurrentTask , get_curr_task dd szGetCurrentTask , get_curr_task
dd szLoadFile , load_file dd szLoadFile , load_file ;stdcall
dd szSendEvent , send_event dd szSendEvent , send_event
dd szSetMouseData , set_mouse_data dd szSetMouseData , set_mouse_data ;stdcall
dd szSleep , delay_ms dd szSleep , delay_ms
dd szGetTimerTicks , get_timer_ticks dd szGetTimerTicks , get_timer_ticks

View File

@ -537,6 +537,9 @@ proc kernel_alloc stdcall, size:dword
pages_count dd ? pages_count dd ?
endl endl
push ebx
push edi
mov eax, [size] mov eax, [size]
add eax, 4095 add eax, 4095
and eax, not 4095; and eax, not 4095;
@ -591,9 +594,13 @@ proc kernel_alloc stdcall, size:dword
jnz @B jnz @B
.end: .end:
mov eax, [lin_addr] mov eax, [lin_addr]
pop edi
pop ebx
ret ret
.err: .err:
xor eax, eax xor eax, eax
pop edi
pop ebx
ret ret
endp endp
@ -665,7 +672,6 @@ proc init_heap
mov [ebx+APPDATA.heap_top], eax mov [ebx+APPDATA.heap_top], eax
sub eax, esi sub eax, esi
; add esi, new_app_base
shr esi, 10 shr esi, 10
mov ecx, eax mov ecx, eax
sub eax, 4096 sub eax, 4096
@ -677,6 +683,10 @@ endp
align 4 align 4
proc user_alloc stdcall, alloc_size:dword proc user_alloc stdcall, alloc_size:dword
push ebx
push esi
push edi
mov ecx, [alloc_size] mov ecx, [alloc_size]
add ecx, (4095+4096) add ecx, (4095+4096)
and ecx, not 4095 and ecx, not 4095
@ -725,6 +735,10 @@ l_0:
call update_mem_size call update_mem_size
lea eax, [esi+4096] lea eax, [esi+4096]
pop edi
pop esi
pop ebx
ret ret
test_used: test_used:
test al, USED_BLOCK test al, USED_BLOCK
@ -736,16 +750,23 @@ m_next:
jmp l_0 jmp l_0
m_exit: m_exit:
xor eax, eax xor eax, eax
pop edi
pop esi
pop ebx
ret ret
endp endp
align 4 align 4
proc user_free stdcall, base:dword proc user_free stdcall, base:dword
push esi
mov esi, [base] mov esi, [base]
test esi, esi test esi, esi
jz .exit jz .exit
push ebx
xor ebx, ebx xor ebx, ebx
shr esi, 12 shr esi, 12
mov eax, [page_tabs+(esi-1)*4] mov eax, [page_tabs+(esi-1)*4]
@ -776,6 +797,8 @@ proc user_free stdcall, base:dword
dec ecx dec ecx
jnz .release jnz .release
.released: .released:
push edi
mov edx, [current_slot] mov edx, [current_slot]
mov esi, dword [edx+APPDATA.heap_base] mov esi, dword [edx+APPDATA.heap_base]
mov edi, dword [edx+APPDATA.heap_top] mov edi, dword [edx+APPDATA.heap_top]
@ -783,13 +806,20 @@ proc user_free stdcall, base:dword
neg ebx neg ebx
call update_mem_size call update_mem_size
call user_normalize call user_normalize
pop edi
pop ebx
pop esi
ret ret
.exit: .exit:
xor eax, eax xor eax, eax
inc eax inc eax
pop esi
ret ret
.cantfree: .cantfree:
xor eax, eax xor eax, eax
pop edi
pop ebx
pop esi
ret ret
endp endp

View File

@ -1134,6 +1134,8 @@ proc create_ring_buffer stdcall, size:dword, flags:dword
test eax, eax test eax, eax
jz .fail jz .fail
push ebx
mov [buf_ptr], eax mov [buf_ptr], eax
mov ebx, [size] mov ebx, [size]
@ -1146,6 +1148,8 @@ proc create_ring_buffer stdcall, size:dword, flags:dword
test eax, eax test eax, eax
jz .mm_fail jz .mm_fail
push edi
or eax, [flags] or eax, [flags]
mov edi, [buf_ptr] mov edi, [buf_ptr]
mov ebx, [buf_ptr] mov ebx, [buf_ptr]
@ -1164,10 +1168,13 @@ proc create_ring_buffer stdcall, size:dword, flags:dword
jnz @B jnz @B
mov eax, [buf_ptr] mov eax, [buf_ptr]
pop edi
pop ebx
ret ret
.mm_fail: .mm_fail:
stdcall free_kernel_space, [buf_ptr] stdcall free_kernel_space, [buf_ptr]
xor eax, eax xor eax, eax
pop ebx
.fail: .fail:
ret ret
endp endp

View File

@ -29,7 +29,7 @@ endp
align 4 align 4
map_PE: map_PE: ;stdcall base:dword, image:dword
cld cld
push ebp push ebp
push edi push edi

View File

@ -362,9 +362,13 @@ proc load_cursor stdcall, src:dword, flags:dword
stdcall load_file, [src] stdcall load_file, [src]
test eax, eax test eax, eax
jz .exit jz .fail
mov [src], eax mov [src], eax
@@: @@:
push ebx
push esi
push edi
mov eax, [CURRENT_TASK] mov eax, [CURRENT_TASK]
shl eax, 5 shl eax, 5
mov eax, [CURRENT_TASK+eax+4] mov eax, [CURRENT_TASK+eax+4]
@ -372,11 +376,15 @@ proc load_cursor stdcall, src:dword, flags:dword
mov ecx, [flags] mov ecx, [flags]
call [create_cursor] ;eax, ebx, ecx call [create_cursor] ;eax, ebx, ecx
mov [handle], eax mov [handle], eax
.fail:
cmp word [flags], LOAD_FROM_FILE cmp word [flags], LOAD_FROM_FILE
jne .exit jne .exit
stdcall kernel_free, [src] stdcall kernel_free, [src]
.exit: .exit:
pop edi
pop esi
pop ebx
.fail:
mov eax, [handle] mov eax, [handle]
ret ret
endp endp