From b573c43d09c13ad89c3a98df9e38bae726d1469b Mon Sep 17 00:00:00 2001 From: "Andrey Halyavin (halyavin)" Date: Tue, 15 Aug 2006 16:59:11 +0000 Subject: [PATCH] *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 --- kernel/trunk/core/newproce.inc | 46 +++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/kernel/trunk/core/newproce.inc b/kernel/trunk/core/newproce.inc index 5f41898809..7eaab77d37 100644 --- a/kernel/trunk/core/newproce.inc +++ b/kernel/trunk/core/newproce.inc @@ -177,6 +177,7 @@ new_start_application_floppy: mov edx,eax ;read file block to current page mov eax,[esp+4] ;restore pointer to file name mov ecx,8 ;number of blocks read + mov ebp,edx ;save buffer address for .endofimage push ebx mov edi,[esp+16] ; cli @@ -184,17 +185,33 @@ new_start_application_floppy: ;ebx=file size ; sti 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 cmp ecx,ebx jg .endloop1 ;if end of file? mov ebx,ecx - test eax,eax - jnz .endloop1 ;check io errors pop edx - add ebx,8 ;go to next page add edx,4 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: add esp,8+4 ;pop linear address of page table entry and pointer to file name 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 eax,[esp+4] ;restore pointer to file name mov ecx,8 ;number of blocks read + mov ebp,edx ;save buffer address for .endofimage push ebx cli call fileread ;ebx=file size call safe_sti 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 cmp ecx,ebx jg .endloop1 ;if end of file? mov ebx,ecx - test eax,eax - jnz .endloop1 ;check io errors pop edx - add ebx,8 ;go to next page add edx,4 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: add esp,8 ;pop linear address of page table entry and pointer to file name call .add_app_parameters