[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:
parent
3111bdaa18
commit
aa4154894c
@ -287,17 +287,17 @@ align 4
|
|||||||
proc get_coff_sym stdcall, pSym:dword,count:dword, sz_sym:dword
|
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
|
test eax, eax
|
||||||
jz .ok
|
jz .ok
|
||||||
add [pSym], 18
|
add [pSym], sizeof.COFF_SYM
|
||||||
dec [count]
|
dec [count]
|
||||||
jnz @b
|
jnz @b
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
.ok:
|
.ok:
|
||||||
mov eax, [pSym]
|
mov eax, [pSym]
|
||||||
mov eax, [eax+8]
|
mov eax, [eax+COFF_SYM.Value]
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
@ -964,7 +964,7 @@ proc load_library stdcall, file_name:dword, encoding:dword
|
|||||||
movzx ecx, [edx + COFF_HEADER.nSections]
|
movzx ecx, [edx + COFF_HEADER.nSections]
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
|
|
||||||
add edx, 20
|
add edx, sizeof.COFF_HEADER
|
||||||
@@:
|
@@:
|
||||||
call coff_get_align
|
call coff_get_align
|
||||||
add ebx, eax
|
add ebx, eax
|
||||||
@ -1045,7 +1045,7 @@ proc load_library stdcall, file_name:dword, encoding:dword
|
|||||||
movzx ecx, [edx + COFF_HEADER.nSections]
|
movzx ecx, [edx + COFF_HEADER.nSections]
|
||||||
lea ecx, [ecx*5]
|
lea ecx, [ecx*5]
|
||||||
lea edi, [edi + ecx*8+20]
|
lea edi, [edi + ecx*8+20]
|
||||||
add edx, 20
|
add edx, sizeof.COFF_HEADER
|
||||||
@@:
|
@@:
|
||||||
movzx eax, [edx + COFF_SECTION.NumReloc]
|
movzx eax, [edx + COFF_SECTION.NumReloc]
|
||||||
lea eax, [eax*5]
|
lea eax, [eax*5]
|
||||||
@ -1097,7 +1097,7 @@ proc load_library stdcall, file_name:dword, encoding:dword
|
|||||||
; fixup symbols
|
; fixup symbols
|
||||||
mov edx, ebx
|
mov edx, ebx
|
||||||
mov eax, [ebx + COFF_HEADER.nSymbols]
|
mov eax, [ebx + COFF_HEADER.nSymbols]
|
||||||
add edx, 20
|
add edx, sizeof.COFF_HEADER
|
||||||
mov ecx, [esi + DLLDESCR.symbols_num]
|
mov ecx, [esi + DLLDESCR.symbols_num]
|
||||||
lea ecx, [ecx*9]
|
lea ecx, [ecx*9]
|
||||||
add ecx, ecx
|
add ecx, ecx
|
||||||
@ -1184,7 +1184,7 @@ proc load_library stdcall, file_name:dword, encoding:dword
|
|||||||
shr ecx, 12
|
shr ecx, 12
|
||||||
.map_pages_loop:
|
.map_pages_loop:
|
||||||
mov eax, [page_tabs + ecx*4]
|
mov eax, [page_tabs + ecx*4]
|
||||||
and eax, not 0xFFF
|
and eax, -PAGE_SIZE
|
||||||
or al, PG_UR
|
or al, PG_UR
|
||||||
xchg eax, [page_tabs + edx*4]
|
xchg eax, [page_tabs + edx*4]
|
||||||
test al, 1
|
test al, 1
|
||||||
@ -1194,7 +1194,7 @@ proc load_library stdcall, file_name:dword, encoding:dword
|
|||||||
invlpg [ebx+edi]
|
invlpg [ebx+edi]
|
||||||
inc ecx
|
inc ecx
|
||||||
inc edx
|
inc edx
|
||||||
add edi, 0x1000
|
add edi, PAGE_SIZE
|
||||||
cmp edi, [esi + DLLDESCR.size]
|
cmp edi, [esi + DLLDESCR.size]
|
||||||
jb .map_pages_loop
|
jb .map_pages_loop
|
||||||
|
|
||||||
|
@ -1141,8 +1141,8 @@ f68:
|
|||||||
.18:
|
.18:
|
||||||
mov eax, edx
|
mov eax, edx
|
||||||
.19:
|
.19:
|
||||||
cmp ecx, OS_BASE
|
stdcall is_string_userspace, ecx
|
||||||
jae .fail
|
jnz .fail
|
||||||
stdcall load_library, ecx, eax
|
stdcall load_library, ecx, eax
|
||||||
mov [esp + SYSCALL_STACK._eax], eax
|
mov [esp + SYSCALL_STACK._eax], eax
|
||||||
ret
|
ret
|
||||||
|
@ -4820,6 +4820,30 @@ proc is_region_userspace stdcall, base:dword, len:dword
|
|||||||
ret
|
ret
|
||||||
endp
|
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
|
if ~ lang eq sp
|
||||||
diff16 "end of .text segment",0,$
|
diff16 "end of .text segment",0,$
|
||||||
end if
|
end if
|
||||||
|
Loading…
Reference in New Issue
Block a user