mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-11-28 11:43:09 +03:00
kernel.load_file_umode: allocate physical storage before unpacking
git-svn-id: svn://kolibrios.org@4237 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
89e5a3c15c
commit
145adf316e
@ -544,7 +544,6 @@ proc load_file_umode stdcall, file_name:dword
|
|||||||
push edi
|
push edi
|
||||||
push ebx
|
push ebx
|
||||||
|
|
||||||
|
|
||||||
lea eax, [attr]
|
lea eax, [attr]
|
||||||
stdcall get_fileinfo, [file_name], eax ;find file and get info
|
stdcall get_fileinfo, [file_name], eax ;find file and get info
|
||||||
test eax, eax
|
test eax, eax
|
||||||
@ -570,11 +569,26 @@ proc load_file_umode stdcall, file_name:dword
|
|||||||
|
|
||||||
mov ebx, [eax+4] ;get real size of file
|
mov ebx, [eax+4] ;get real size of file
|
||||||
mov [file_size], ebx
|
mov [file_size], ebx
|
||||||
stdcall user_alloc, ebx ;and allocate memory from user heap
|
stdcall user_alloc, ebx ;and allocate space from user heap
|
||||||
mov [um_file], eax
|
mov [um_file], eax
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .err_2
|
jz .err_2
|
||||||
|
|
||||||
|
mov edx, [file_size] ;preallocate page memory
|
||||||
|
shr eax, 10
|
||||||
|
lea edi, [page_tabs+eax]
|
||||||
|
add edx, 4095
|
||||||
|
shr edx, 12
|
||||||
|
@@:
|
||||||
|
call alloc_page
|
||||||
|
test eax, eax
|
||||||
|
jz .err_3
|
||||||
|
|
||||||
|
or eax, PG_UW
|
||||||
|
stosd
|
||||||
|
dec edx
|
||||||
|
jnz @B
|
||||||
|
|
||||||
pushad
|
pushad
|
||||||
mov ecx, unpack_mutex
|
mov ecx, unpack_mutex
|
||||||
call mutex_lock
|
call mutex_lock
|
||||||
@ -587,15 +601,28 @@ proc load_file_umode stdcall, file_name:dword
|
|||||||
|
|
||||||
stdcall kernel_free, [km_file] ;we don't need packed file anymore
|
stdcall kernel_free, [km_file] ;we don't need packed file anymore
|
||||||
.exit:
|
.exit:
|
||||||
|
|
||||||
|
mov edi, [um_file]
|
||||||
|
mov esi, [um_file]
|
||||||
|
mov eax, [file_size]
|
||||||
|
mov edx, eax
|
||||||
|
|
||||||
|
add edi, eax ;cleanup remain space
|
||||||
|
mov ecx, 4096 ;from file end
|
||||||
|
and eax, 4095
|
||||||
|
jz @f
|
||||||
|
sub ecx, eax
|
||||||
|
xor eax, eax
|
||||||
|
cld
|
||||||
|
rep stosb
|
||||||
|
@@:
|
||||||
mov eax, [um_file]
|
mov eax, [um_file]
|
||||||
mov edx, [file_size]
|
|
||||||
|
|
||||||
pop ebx
|
pop ebx
|
||||||
pop edi
|
pop edi
|
||||||
pop esi
|
pop esi
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
.raw_file: ; sometimes we load unpacked file
|
.raw_file: ; sometimes we load unpacked file
|
||||||
stdcall user_alloc, ebx ; allocate space from user heap
|
stdcall user_alloc, ebx ; allocate space from user heap
|
||||||
mov [um_file], eax
|
mov [um_file], eax
|
||||||
@ -619,13 +646,14 @@ proc load_file_umode stdcall, file_name:dword
|
|||||||
@@:
|
@@:
|
||||||
lodsd
|
lodsd
|
||||||
and eax, 0xFFFFF000
|
and eax, 0xFFFFF000
|
||||||
or eax, PG_USER
|
or eax, PG_UW
|
||||||
stosd
|
stosd
|
||||||
loop @B
|
loop @B
|
||||||
|
|
||||||
stdcall free_kernel_space, [km_file] ; release allocated kernel space
|
stdcall free_kernel_space, [km_file] ; release allocated kernel space
|
||||||
jmp .exit ; physical pages still in use
|
jmp .exit ; physical pages still in use
|
||||||
|
.err_3:
|
||||||
|
stdcall user_free, [um_file]
|
||||||
.err_2:
|
.err_2:
|
||||||
stdcall kernel_free, [km_file]
|
stdcall kernel_free, [km_file]
|
||||||
.err_1:
|
.err_1:
|
||||||
|
Loading…
Reference in New Issue
Block a user