From 39d4709d97ac8646b730a13ea047f8db2e458790 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Sat, 20 Oct 2007 21:02:38 +0000 Subject: [PATCH] yet another stdcall fix git-svn-id: svn://kolibrios.org@662 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/core/dll.inc | 13 ++++++++++--- kernel/trunk/core/exports.inc | 23 ++++++++++++----------- kernel/trunk/core/heap.inc | 32 +++++++++++++++++++++++++++++++- kernel/trunk/core/memory.inc | 7 +++++++ kernel/trunk/core/peload.inc | 2 +- kernel/trunk/video/cursors.inc | 12 ++++++++++-- 6 files changed, 71 insertions(+), 18 deletions(-) diff --git a/kernel/trunk/core/dll.inc b/kernel/trunk/core/dll.inc index 2ed9b12256..aa2dd63f81 100644 --- a/kernel/trunk/core/dll.inc +++ b/kernel/trunk/core/dll.inc @@ -431,9 +431,7 @@ proc get_fileinfo stdcall, file_name:dword, info:dword xor eax, eax mov ebx, [file_name] - ; sub ebx, new_app_base mov ecx, [info] - ; sub ecx, new_app_base mov [cmd], 5 mov [offset], eax @@ -445,7 +443,6 @@ proc get_fileinfo stdcall, file_name:dword, info:dword mov eax, 70 lea ebx, [cmd] - ; sub ebx, new_app_base int 0x40 ret endp @@ -517,6 +514,10 @@ proc load_file stdcall, file_name:dword file2 dd ? endl + push ebx + push esi + push edi + lea eax, [attr] stdcall get_fileinfo, [file_name], eax test eax, eax @@ -561,12 +562,18 @@ proc load_file stdcall, file_name:dword @@: mov ebx, [file_size] pop eax + pop edi + pop esi + pop ebx ret .cleanup: stdcall kernel_free, [file] .fail: xor eax, eax xor ebx, ebx + pop edi + pop esi + pop ebx ret endp diff --git a/kernel/trunk/core/exports.inc b/kernel/trunk/core/exports.inc index 43061b19d8..6698bf130c 100644 --- a/kernel/trunk/core/exports.inc +++ b/kernel/trunk/core/exports.inc @@ -104,10 +104,10 @@ kernel_export: dd szAllocKernelSpace, alloc_kernel_space ;stdcall dd szFreeKernelSpace , free_kernel_space ;stdcall - dd szKernelAlloc , kernel_alloc - dd szKernelFree , kernel_free - dd szUserAlloc , user_alloc - dd szUserFree , user_free + dd szKernelAlloc , kernel_alloc ;stdcall + dd szKernelFree , kernel_free ;stdcall + dd szUserAlloc , user_alloc ;stdcall + dd szUserFree , user_free ;stdcall dd szKmalloc , malloc dd szKfree , free dd szCreateRingBuffer, create_ring_buffer @@ -121,17 +121,18 @@ kernel_export: dd szDestroyEvent , destroy_event dd szClearEvent , clear_event - dd szLoadCursor , load_cursor - dd szSelectHwCursor , select_hw_cursor ;indirect - dd szSetHwCursor , set_hw_cursor ;indirect - dd szHwCursorRestore , hw_restore ;indirect - dd szHwCursorCreate , create_cursor + dd szLoadCursor , load_cursor ;stdcall + + dd szSelectHwCursor , select_hw_cursor ;import + dd szSetHwCursor , set_hw_cursor ;import + dd szHwCursorRestore , hw_restore ;import + dd szHwCursorCreate , create_cursor ;import dd szSysMsgBoardStr , sys_msg_board_str dd szGetCurrentTask , get_curr_task - dd szLoadFile , load_file + dd szLoadFile , load_file ;stdcall dd szSendEvent , send_event - dd szSetMouseData , set_mouse_data + dd szSetMouseData , set_mouse_data ;stdcall dd szSleep , delay_ms dd szGetTimerTicks , get_timer_ticks diff --git a/kernel/trunk/core/heap.inc b/kernel/trunk/core/heap.inc index 58126fb17a..dbc91e1310 100644 --- a/kernel/trunk/core/heap.inc +++ b/kernel/trunk/core/heap.inc @@ -537,6 +537,9 @@ proc kernel_alloc stdcall, size:dword pages_count dd ? endl + push ebx + push edi + mov eax, [size] add eax, 4095 and eax, not 4095; @@ -591,9 +594,13 @@ proc kernel_alloc stdcall, size:dword jnz @B .end: mov eax, [lin_addr] + pop edi + pop ebx ret .err: xor eax, eax + pop edi + pop ebx ret endp @@ -665,7 +672,6 @@ proc init_heap mov [ebx+APPDATA.heap_top], eax sub eax, esi - ; add esi, new_app_base shr esi, 10 mov ecx, eax sub eax, 4096 @@ -677,6 +683,10 @@ endp align 4 proc user_alloc stdcall, alloc_size:dword + push ebx + push esi + push edi + mov ecx, [alloc_size] add ecx, (4095+4096) and ecx, not 4095 @@ -725,6 +735,10 @@ l_0: call update_mem_size lea eax, [esi+4096] + + pop edi + pop esi + pop ebx ret test_used: test al, USED_BLOCK @@ -736,16 +750,23 @@ m_next: jmp l_0 m_exit: xor eax, eax + pop edi + pop esi + pop ebx ret endp align 4 proc user_free stdcall, base:dword + push esi + mov esi, [base] test esi, esi jz .exit + push ebx + xor ebx, ebx shr esi, 12 mov eax, [page_tabs+(esi-1)*4] @@ -776,6 +797,8 @@ proc user_free stdcall, base:dword dec ecx jnz .release .released: + push edi + mov edx, [current_slot] mov esi, dword [edx+APPDATA.heap_base] mov edi, dword [edx+APPDATA.heap_top] @@ -783,13 +806,20 @@ proc user_free stdcall, base:dword neg ebx call update_mem_size call user_normalize + pop edi + pop ebx + pop esi ret .exit: xor eax, eax inc eax + pop esi ret .cantfree: xor eax, eax + pop edi + pop ebx + pop esi ret endp diff --git a/kernel/trunk/core/memory.inc b/kernel/trunk/core/memory.inc index eb49c49b0b..0a746c9a7f 100644 --- a/kernel/trunk/core/memory.inc +++ b/kernel/trunk/core/memory.inc @@ -1134,6 +1134,8 @@ proc create_ring_buffer stdcall, size:dword, flags:dword test eax, eax jz .fail + push ebx + mov [buf_ptr], eax mov ebx, [size] @@ -1146,6 +1148,8 @@ proc create_ring_buffer stdcall, size:dword, flags:dword test eax, eax jz .mm_fail + push edi + or eax, [flags] mov edi, [buf_ptr] mov ebx, [buf_ptr] @@ -1164,10 +1168,13 @@ proc create_ring_buffer stdcall, size:dword, flags:dword jnz @B mov eax, [buf_ptr] + pop edi + pop ebx ret .mm_fail: stdcall free_kernel_space, [buf_ptr] xor eax, eax + pop ebx .fail: ret endp diff --git a/kernel/trunk/core/peload.inc b/kernel/trunk/core/peload.inc index ee9f37939b..c02e06b290 100644 --- a/kernel/trunk/core/peload.inc +++ b/kernel/trunk/core/peload.inc @@ -29,7 +29,7 @@ endp align 4 -map_PE: +map_PE: ;stdcall base:dword, image:dword cld push ebp push edi diff --git a/kernel/trunk/video/cursors.inc b/kernel/trunk/video/cursors.inc index ada2774dfe..468abb7203 100644 --- a/kernel/trunk/video/cursors.inc +++ b/kernel/trunk/video/cursors.inc @@ -362,9 +362,13 @@ proc load_cursor stdcall, src:dword, flags:dword stdcall load_file, [src] test eax, eax - jz .exit + jz .fail mov [src], eax @@: + push ebx + push esi + push edi + mov eax, [CURRENT_TASK] shl eax, 5 mov eax, [CURRENT_TASK+eax+4] @@ -372,11 +376,15 @@ proc load_cursor stdcall, src:dword, flags:dword mov ecx, [flags] call [create_cursor] ;eax, ebx, ecx mov [handle], eax -.fail: + cmp word [flags], LOAD_FROM_FILE jne .exit stdcall kernel_free, [src] .exit: + pop edi + pop esi + pop ebx +.fail: mov eax, [handle] ret endp