From 3a8ae3d4cb40657e3852618d2360273beb191ab9 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Fri, 10 Oct 2008 12:08:40 +0000 Subject: [PATCH] fix background buffer overrun git-svn-id: svn://kolibrios.org@875 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/kernel.asm | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index a88372ec1f..d7878a78a3 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -2273,21 +2273,27 @@ sys_background: sbgrr: ret - nosb1: +nosb1: cmp ebx,2 ; SET PIXEL jnz nosb2 - cmp ecx,[mem_BACKGROUND] - jae nosb2 + + mov ebx, [mem_BACKGROUND] + add ebx, 4095 + and ebx, -4096 + sub ebx, 4 + cmp ecx, ebx + ja @F + mov eax,[img_background] mov ebx,[eax+ecx] and ebx,0xFF000000 ;255*256*256*256 and edx,0x00FFFFFF ;255*256*256+255*256+255 add edx,ebx mov [eax+ecx],edx -; mov [bgrchanged],1 +@@: ret - nosb2: +nosb2: cmp ebx,3 ; DRAW BACKGROUND jnz nosb3 @@ -2431,19 +2437,25 @@ sys_getbackground: mov ax,[BgrDataHeight] mov [esp+36],eax ret - nogb1: + +nogb1: cmp eax,2 ; PIXEL jnz nogb2 -; mov edx,0x160000-16 -; cmp edx,ebx -; jbe nogb2 -; mov eax, [ebx+IMG_BACKGROUND] + + mov ecx, [mem_BACKGROUND] + add ecx, 4095 + and ecx, -4096 + sub ecx, 4 + cmp ebx, ecx + ja @F + mov eax,[img_background] mov eax,[ebx+eax] and eax, 0xFFFFFF mov [esp+36],eax +@@: ret nogb2: