is_region_userspace: refactoring and fix

git-svn-id: svn://kolibrios.org@8329 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Rustem Gimadutdinov (rgimad) 2020-12-05 19:56:25 +00:00
parent 18d1174514
commit 7b4bf97ec8

View File

@ -1747,12 +1747,7 @@ sys_getsetup:
jnz .shift jnz .shift
; if given memory address belongs to kernel then error ; if given memory address belongs to kernel then error
push ebx stdcall is_region_userspace, ebx, 128
mov eax, ebx
mov ebx, 128
call is_region_userspace
pop ebx
test eax, eax
jz .addr_error jz .addr_error
mov eax, keymap mov eax, keymap
@ -1765,12 +1760,7 @@ sys_getsetup:
dec ecx dec ecx
jnz .alt jnz .alt
push ebx stdcall is_region_userspace, ebx, 128
mov eax, ebx
mov ebx, 128
call is_region_userspace
pop ebx
test eax, eax
jz .addr_error jz .addr_error
mov eax, keymap_shift mov eax, keymap_shift
@ -1783,12 +1773,7 @@ sys_getsetup:
dec ecx dec ecx
jne .country jne .country
push ebx stdcall is_region_userspace, ebx, 128
mov eax, ebx
mov ebx, 128
call is_region_userspace
pop ebx
test eax, eax
jz .addr_error jz .addr_error
mov eax, keymap_alt mov eax, keymap_alt
@ -2468,10 +2453,7 @@ sysfn_lastkey: ; 18.12 = return 0 (backward compatibility)
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
sysfn_getversion: ; 18.13 = get kernel ID and version sysfn_getversion: ; 18.13 = get kernel ID and version
; if given memory address belongs to kernel then error ; if given memory address belongs to kernel then error
mov eax, ecx stdcall is_region_userspace, ecx, version_end-version_inf
mov ebx, version_end-version_inf
call is_region_userspace
test eax, eax
jz .addr_error jz .addr_error
mov edi, ecx mov edi, ecx
@ -3182,12 +3164,7 @@ sys_cpuusage:
; +30 dword PID , process idenfification number ; +30 dword PID , process idenfification number
; ;
; if given memory address belongs to kernel then error ; if given memory address belongs to kernel then error
push ebx stdcall is_region_userspace, ebx, 0x4C
mov eax, ebx
mov ebx, 0x4C
call is_region_userspace
pop ebx
test eax, eax
jz .addr_error jz .addr_error
cmp ecx, -1 ; who am I ? cmp ecx, -1 ; who am I ?
@ -5701,18 +5678,27 @@ undefined_syscall: ; Undefined system call
mov [esp + 32], dword -1 mov [esp + 32], dword -1
ret ret
align 4
; check if given memory region lays in lower 2gb (userspace memory) or not ; check if given memory region lays in lower 2gb (userspace memory) or not
is_region_userspace: align 4
; in: eax = base proc is_region_userspace stdcall, base:dword, len:dword
; ebx = len ; in:
; out: eax = 1 if region in userspace memory, 0 if not ; base = base address of region
push esi edi ecx ; len = lenght of region
; out: ZF = 1 if region in userspace memory
; ZF = 0 otherwise
push eax ebx
mov eax, [base]
cmp eax, OS_BASE cmp eax, OS_BASE
ja @f ja @f
add eax, ebx mov ebx, 0xFFFFFFFF
sub ebx, [base]
inc ebx
cmp [len], ebx
ja @f
add eax, [len]
cmp eax, OS_BASE cmp eax, OS_BASE
ja @f ja @f
@ -5721,8 +5707,10 @@ is_region_userspace:
@@: @@:
xor eax, eax xor eax, eax
.ret: .ret:
pop ecx edi esi test eax, eax
pop ebx eax
ret ret
endp
if ~ lang eq sp if ~ lang eq sp
diff16 "end of .text segment",0,$ diff16 "end of .text segment",0,$