forked from KolibriOS/kolibrios
*Fixed bug in procedure starting applications
from /rd and /fd when some memory after end of image hasn't been initialized by zero. *Kernel now takes into account size of image when starting from /rd and /fd. (previously it assumes that size of file is equal to size of image) git-svn-id: svn://kolibrios.org@130 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
e3172037f7
commit
b573c43d09
@ -177,6 +177,7 @@ new_start_application_floppy:
|
|||||||
mov edx,eax ;read file block to current page
|
mov edx,eax ;read file block to current page
|
||||||
mov eax,[esp+4] ;restore pointer to file name
|
mov eax,[esp+4] ;restore pointer to file name
|
||||||
mov ecx,8 ;number of blocks read
|
mov ecx,8 ;number of blocks read
|
||||||
|
mov ebp,edx ;save buffer address for .endofimage
|
||||||
push ebx
|
push ebx
|
||||||
mov edi,[esp+16]
|
mov edi,[esp+16]
|
||||||
; cli
|
; cli
|
||||||
@ -184,17 +185,33 @@ new_start_application_floppy:
|
|||||||
;ebx=file size
|
;ebx=file size
|
||||||
; sti
|
; sti
|
||||||
pop ecx
|
pop ecx
|
||||||
|
add ecx,8
|
||||||
|
test eax,eax
|
||||||
|
jnz .endloop1 ;check io errors
|
||||||
|
mov eax,[app_i_end]
|
||||||
|
add eax,511
|
||||||
|
shr eax,9
|
||||||
|
cmp ecx,eax
|
||||||
|
jg .endofimage ;we have loaded whole program
|
||||||
|
add ebx,511
|
||||||
shr ebx,9
|
shr ebx,9
|
||||||
cmp ecx,ebx
|
cmp ecx,ebx
|
||||||
jg .endloop1 ;if end of file?
|
jg .endloop1 ;if end of file?
|
||||||
mov ebx,ecx
|
mov ebx,ecx
|
||||||
test eax,eax
|
|
||||||
jnz .endloop1 ;check io errors
|
|
||||||
pop edx
|
pop edx
|
||||||
add ebx,8 ;go to next page
|
|
||||||
add edx,4
|
add edx,4
|
||||||
jmp .loop1
|
jmp .loop1
|
||||||
|
|
||||||
|
.endofimage: ;set to zero memory at end of page
|
||||||
|
mov ecx,[app_i_end]
|
||||||
|
and ecx,4096-1
|
||||||
|
jz .endloop1
|
||||||
|
lea edi,[ebp+ecx]
|
||||||
|
neg ecx
|
||||||
|
add ecx,4096
|
||||||
|
xor eax,eax
|
||||||
|
cld
|
||||||
|
rep stosb
|
||||||
.endloop1:
|
.endloop1:
|
||||||
add esp,8+4 ;pop linear address of page table entry and pointer to file name
|
add esp,8+4 ;pop linear address of page table entry and pointer to file name
|
||||||
call new_start_application_fl.add_app_parameters
|
call new_start_application_fl.add_app_parameters
|
||||||
@ -342,23 +359,40 @@ new_start_application_fl:
|
|||||||
mov edx,eax ;read file block to current page
|
mov edx,eax ;read file block to current page
|
||||||
mov eax,[esp+4] ;restore pointer to file name
|
mov eax,[esp+4] ;restore pointer to file name
|
||||||
mov ecx,8 ;number of blocks read
|
mov ecx,8 ;number of blocks read
|
||||||
|
mov ebp,edx ;save buffer address for .endofimage
|
||||||
push ebx
|
push ebx
|
||||||
cli
|
cli
|
||||||
call fileread
|
call fileread
|
||||||
;ebx=file size
|
;ebx=file size
|
||||||
call safe_sti
|
call safe_sti
|
||||||
pop ecx
|
pop ecx
|
||||||
|
add ecx,8
|
||||||
|
test eax,eax
|
||||||
|
jnz .endloop1 ;check io errors
|
||||||
|
mov eax,[app_i_end]
|
||||||
|
add eax,511
|
||||||
|
shr eax,9
|
||||||
|
cmp ecx,eax
|
||||||
|
jg .endofimage ;we have loaded whole program
|
||||||
|
add ebx,511
|
||||||
shr ebx,9
|
shr ebx,9
|
||||||
cmp ecx,ebx
|
cmp ecx,ebx
|
||||||
jg .endloop1 ;if end of file?
|
jg .endloop1 ;if end of file?
|
||||||
mov ebx,ecx
|
mov ebx,ecx
|
||||||
test eax,eax
|
|
||||||
jnz .endloop1 ;check io errors
|
|
||||||
pop edx
|
pop edx
|
||||||
add ebx,8 ;go to next page
|
|
||||||
add edx,4
|
add edx,4
|
||||||
jmp .loop1
|
jmp .loop1
|
||||||
|
|
||||||
|
.endofimage: ;set to zero memory at end of page
|
||||||
|
mov ecx,[app_i_end]
|
||||||
|
and ecx,4096-1
|
||||||
|
jz .endloop1
|
||||||
|
lea edi,[ebp+ecx]
|
||||||
|
neg ecx
|
||||||
|
add ecx,4096
|
||||||
|
xor eax,eax
|
||||||
|
cld
|
||||||
|
rep stosb
|
||||||
.endloop1:
|
.endloop1:
|
||||||
add esp,8 ;pop linear address of page table entry and pointer to file name
|
add esp,8 ;pop linear address of page table entry and pointer to file name
|
||||||
call .add_app_parameters
|
call .add_app_parameters
|
||||||
|
Loading…
Reference in New Issue
Block a user