Protect thread from external terminate while running any syscall except 5,10,23.

Now 18.2/18.12 are really safe through kernel-colored glasses (however, you still
should not use them except for really critical cases),
although the protection is sometimes quite excessive.

git-svn-id: svn://kolibrios.org@3303 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
CleverMouse 2013-03-01 10:27:19 +00:00
parent 37bf0fe5c1
commit a321a83609
3 changed files with 26 additions and 5 deletions

View File

@ -38,9 +38,13 @@ sysenter_entry:
pushad pushad
cld cld
movzx eax, al call protect_from_terminate
movzx eax, byte [esp+28]
mov edx, dword [esp+24]
call dword [servetable2 + eax * 4] call dword [servetable2 + eax * 4]
call unprotect_from_terminate
popad popad
;------------------ ;------------------
xchg ecx, [ss:esp] ; â âåðøèí ñòåêà - app ecx, ecx - app esp + 4 xchg ecx, [ss:esp] ; â âåðøèí ñòåêà - app ecx, ecx - app esp + 4
@ -62,8 +66,11 @@ align 16
i40: i40:
pushad pushad
cld cld
movzx eax, al call protect_from_terminate
movzx eax, byte [esp+28]
mov edx, dword [esp+24]
call dword [servetable2 + eax * 4] call dword [servetable2 + eax * 4]
call unprotect_from_terminate
popad popad
iretd iretd
@ -85,10 +92,13 @@ syscall_entry:
;------------------ ;------------------
pushad pushad
cld cld
call protect_from_terminate
movzx eax, al movzx eax, byte [esp+28]
mov edx, dword [esp+24]
call dword [servetable2 + eax * 4] call dword [servetable2 + eax * 4]
call unprotect_from_terminate
popad popad
;------------------ ;------------------
mov ecx, [ss:esp+4] mov ecx, [ss:esp+4]
@ -125,7 +135,7 @@ iglobal
dd sys_getkey ; 2-GetKey dd sys_getkey ; 2-GetKey
dd sys_clock ; 3-GetTime dd sys_clock ; 3-GetTime
dd syscall_writetext ; 4-WriteText dd syscall_writetext ; 4-WriteText
dd delay_hs ; 5-DelayHs dd delay_hs_unprotected ; 5-DelayHs
dd syscall_openramdiskfile ; 6-OpenRamdiskFile dd syscall_openramdiskfile ; 6-OpenRamdiskFile
dd syscall_putimage ; 7-PutImage dd syscall_putimage ; 7-PutImage
dd syscall_button ; 8-DefineButton dd syscall_button ; 8-DefineButton
@ -190,7 +200,7 @@ iglobal
dd syscall_move_window ; 67-Window move or resize dd syscall_move_window ; 67-Window move or resize
dd f68 ; 68-Some internal services dd f68 ; 68-Some internal services
dd sys_debug_services ; 69-Debug dd sys_debug_services ; 69-Debug
dd file_system_lfn_protected; 70-Common file system interface, version 2 dd file_system_lfn ; 70-Common file system interface, version 2
dd syscall_window_settings ; 71-Window settings dd syscall_window_settings ; 71-Window settings
dd sys_sendwindowmsg ; 72-Send window message dd sys_sendwindowmsg ; 72-Send window message
dd blit_32 ; 73-blitter; dd blit_32 ; 73-blitter;

View File

@ -467,9 +467,11 @@ sys_waitforevent: ;; f10
;-------------------------------------- ;--------------------------------------
align 4 align 4
sys_wait_event_timeout: ;; f23 sys_wait_event_timeout: ;; f23
call unprotect_from_terminate
mov edx, get_event_for_app; wait_test mov edx, get_event_for_app; wait_test
call Wait_events_ex ; ebx - timeout call Wait_events_ex ; ebx - timeout
mov [esp+32], eax mov [esp+32], eax
call protect_from_terminate
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4

View File

@ -3735,6 +3735,15 @@ set_app_param:
mov [esp+32], eax ; return old mask value mov [esp+32], eax ; return old mask value
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
; this is for syscall
proc delay_hs_unprotected
call unprotect_from_terminate
call delay_hs
call protect_from_terminate
ret
endp
align 4 align 4
delay_hs: ; delay in 1/100 secs delay_hs: ; delay in 1/100 secs
; ebx = delay time ; ebx = delay time