[kernel] Add is_string_userspace func, like is_region_userspace

git-svn-id: svn://kolibrios.org@9823 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Ivan Baravy 2022-05-31 07:27:00 +00:00
parent 3111bdaa18
commit aa4154894c
3 changed files with 34 additions and 10 deletions

View File

@ -287,17 +287,17 @@ align 4
proc get_coff_sym stdcall, pSym:dword,count:dword, sz_sym:dword
@@:
stdcall strncmp, [pSym], [sz_sym], 8
stdcall strncmp, [pSym], [sz_sym], sizeof.COFF_SYM.Name
test eax, eax
jz .ok
add [pSym], 18
add [pSym], sizeof.COFF_SYM
dec [count]
jnz @b
xor eax, eax
ret
.ok:
mov eax, [pSym]
mov eax, [eax+8]
mov eax, [eax+COFF_SYM.Value]
ret
endp
@ -964,7 +964,7 @@ proc load_library stdcall, file_name:dword, encoding:dword
movzx ecx, [edx + COFF_HEADER.nSections]
xor ebx, ebx
add edx, 20
add edx, sizeof.COFF_HEADER
@@:
call coff_get_align
add ebx, eax
@ -1045,7 +1045,7 @@ proc load_library stdcall, file_name:dword, encoding:dword
movzx ecx, [edx + COFF_HEADER.nSections]
lea ecx, [ecx*5]
lea edi, [edi + ecx*8+20]
add edx, 20
add edx, sizeof.COFF_HEADER
@@:
movzx eax, [edx + COFF_SECTION.NumReloc]
lea eax, [eax*5]
@ -1097,7 +1097,7 @@ proc load_library stdcall, file_name:dword, encoding:dword
; fixup symbols
mov edx, ebx
mov eax, [ebx + COFF_HEADER.nSymbols]
add edx, 20
add edx, sizeof.COFF_HEADER
mov ecx, [esi + DLLDESCR.symbols_num]
lea ecx, [ecx*9]
add ecx, ecx
@ -1184,7 +1184,7 @@ proc load_library stdcall, file_name:dword, encoding:dword
shr ecx, 12
.map_pages_loop:
mov eax, [page_tabs + ecx*4]
and eax, not 0xFFF
and eax, -PAGE_SIZE
or al, PG_UR
xchg eax, [page_tabs + edx*4]
test al, 1
@ -1194,7 +1194,7 @@ proc load_library stdcall, file_name:dword, encoding:dword
invlpg [ebx+edi]
inc ecx
inc edx
add edi, 0x1000
add edi, PAGE_SIZE
cmp edi, [esi + DLLDESCR.size]
jb .map_pages_loop

View File

@ -1141,8 +1141,8 @@ f68:
.18:
mov eax, edx
.19:
cmp ecx, OS_BASE
jae .fail
stdcall is_string_userspace, ecx
jnz .fail
stdcall load_library, ecx, eax
mov [esp + SYSCALL_STACK._eax], eax
ret

View File

@ -4820,6 +4820,30 @@ proc is_region_userspace stdcall, base:dword, len:dword
ret
endp
align 4
; @brief Check whether given string lays in userspace memory, i.e. below OS_BASE
; @param base Base address of string
; @return ZF = 1 if string in userspace memory,
; zf = 0 otherwise
proc is_string_userspace stdcall, base:dword
push eax ecx edi
xor eax, eax
mov edi, [base]
mov ecx, OS_BASE-1
sub ecx, edi
jb .done ; zf
inc ecx
cmp ecx, 0x10000 ; don't allow strings larger than 64k?
jbe @f
mov ecx, 0x10000
@@:
repnz scasb
.done:
pop edi ecx eax
ret
endp
if ~ lang eq sp
diff16 "end of .text segment",0,$
end if