2011-10-14 23:38:50 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2015-01-08 21:10:22 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
|
2011-10-14 23:38:50 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; SYSENTER ENTRY ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
align 32
|
|
|
|
sysenter_entry:
|
2013-05-28 00:16:00 +02:00
|
|
|
; Настраиваем стек
|
2011-10-14 23:38:50 +02:00
|
|
|
mov esp, [ss:tss._esp0]
|
|
|
|
sti
|
|
|
|
push ebp ; save app esp + 4
|
|
|
|
mov ebp, [ebp] ; ebp - original ebp
|
|
|
|
;------------------
|
|
|
|
pushad
|
|
|
|
cld
|
|
|
|
|
2013-03-01 11:27:19 +01:00
|
|
|
call protect_from_terminate
|
|
|
|
|
|
|
|
movzx eax, byte [esp+28]
|
2013-03-01 11:30:42 +01:00
|
|
|
mov edx, dword [esp+20]
|
2011-10-14 23:38:50 +02:00
|
|
|
call dword [servetable2 + eax * 4]
|
|
|
|
|
2013-03-01 11:27:19 +01:00
|
|
|
call unprotect_from_terminate
|
2011-10-14 23:38:50 +02:00
|
|
|
popad
|
|
|
|
;------------------
|
2013-05-28 00:16:00 +02:00
|
|
|
xchg ecx, [ss:esp] ; в вершин стека - app ecx, ecx - app esp + 4
|
2011-10-14 23:38:50 +02:00
|
|
|
sub ecx, 4
|
|
|
|
xchg edx, [ecx] ; edx - return point, & save original edx
|
|
|
|
push edx
|
|
|
|
mov edx, [ss:esp + 4]
|
|
|
|
mov [ecx + 4], edx ; save original ecx
|
|
|
|
pop edx
|
|
|
|
sysexit
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; SYSTEM CALL ENTRY ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
align 16
|
|
|
|
i40:
|
|
|
|
pushad
|
|
|
|
cld
|
2013-03-01 11:27:19 +01:00
|
|
|
call protect_from_terminate
|
|
|
|
movzx eax, byte [esp+28]
|
2013-03-01 11:30:42 +01:00
|
|
|
mov edx, dword [esp+20]
|
2011-10-14 23:38:50 +02:00
|
|
|
call dword [servetable2 + eax * 4]
|
2013-03-01 11:27:19 +01:00
|
|
|
call unprotect_from_terminate
|
2011-10-14 23:38:50 +02:00
|
|
|
popad
|
|
|
|
iretd
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; SYSCALL ENTRY ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
align 32
|
|
|
|
syscall_entry:
|
|
|
|
; cli syscall clear IF
|
|
|
|
xchg esp, [ss:tss._esp0]
|
|
|
|
push ecx
|
|
|
|
lea ecx, [esp+4]
|
|
|
|
xchg ecx, [ss:tss._esp0]
|
|
|
|
sti
|
|
|
|
push ecx
|
|
|
|
mov ecx, [ecx]
|
|
|
|
;------------------
|
|
|
|
pushad
|
|
|
|
cld
|
2013-03-01 11:27:19 +01:00
|
|
|
call protect_from_terminate
|
2011-10-14 23:38:50 +02:00
|
|
|
|
2013-03-01 11:27:19 +01:00
|
|
|
movzx eax, byte [esp+28]
|
2013-03-01 11:30:42 +01:00
|
|
|
mov edx, dword [esp+20]
|
2011-10-14 23:38:50 +02:00
|
|
|
call dword [servetable2 + eax * 4]
|
|
|
|
|
2013-03-01 11:27:19 +01:00
|
|
|
call unprotect_from_terminate
|
2011-10-14 23:38:50 +02:00
|
|
|
popad
|
|
|
|
;------------------
|
|
|
|
mov ecx, [ss:esp+4]
|
|
|
|
pop esp
|
|
|
|
sysret
|
|
|
|
|
|
|
|
iglobal
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; SYSTEM FUNCTIONS TABLE ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
align 4
|
|
|
|
servetable2:
|
|
|
|
|
|
|
|
dd syscall_draw_window ; 0-DrawWindow
|
|
|
|
dd syscall_setpixel ; 1-SetPixel
|
|
|
|
dd sys_getkey ; 2-GetKey
|
|
|
|
dd sys_clock ; 3-GetTime
|
|
|
|
dd syscall_writetext ; 4-WriteText
|
2013-03-01 11:27:19 +01:00
|
|
|
dd delay_hs_unprotected ; 5-DelayHs
|
2013-11-21 17:07:16 +01:00
|
|
|
dd undefined_syscall ; 6-deprecated OpenRamdiskFile
|
2011-10-14 23:38:50 +02:00
|
|
|
dd syscall_putimage ; 7-PutImage
|
|
|
|
dd syscall_button ; 8-DefineButton
|
|
|
|
dd sys_cpuusage ; 9-GetProcessInfo
|
|
|
|
dd sys_waitforevent ; 10-WaitForEvent
|
|
|
|
dd sys_getevent ; 11-CheckForEvent
|
|
|
|
dd sys_redrawstat ; 12-BeginDraw and EndDraw
|
|
|
|
dd syscall_drawrect ; 13-DrawRect
|
|
|
|
dd syscall_getscreensize ; 14-GetScreenSize
|
|
|
|
dd sys_background ; 15-bgr
|
|
|
|
dd sys_cachetodiskette ; 16-FlushFloppyCache
|
|
|
|
dd sys_getbutton ; 17-GetButton
|
|
|
|
dd sys_system ; 18-System Services
|
|
|
|
dd paleholder ; 19-reserved
|
|
|
|
dd sys_midi ; 20-ResetMidi and OutputMidi
|
|
|
|
dd sys_setup ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
|
|
|
|
dd sys_settime ; 22-setting date,time,clock and alarm-clock
|
|
|
|
dd sys_wait_event_timeout ; 23-TimeOutWaitForEvent
|
|
|
|
dd syscall_cdaudio ; 24-PlayCdTrack,StopCd and GetCdPlaylist
|
2012-03-26 23:10:43 +02:00
|
|
|
dd syscall_putarea_backgr ; 25-Put Area to background
|
2011-10-14 23:38:50 +02:00
|
|
|
dd sys_getsetup ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
|
|
|
|
dd undefined_syscall ; 27-reserved
|
|
|
|
dd undefined_syscall ; 28-reserved
|
|
|
|
dd sys_date ; 29-GetDate
|
|
|
|
dd sys_current_directory ; 30-Get/SetCurrentDirectory
|
|
|
|
dd undefined_syscall ; 31-reserved
|
|
|
|
dd undefined_syscall ; 32-reserved
|
|
|
|
dd undefined_syscall ; 33-reserved
|
2012-03-27 15:25:30 +02:00
|
|
|
dd syscall_getpixel_WinMap ; 34-GetPixel WinMap
|
2011-10-14 23:38:50 +02:00
|
|
|
dd syscall_getpixel ; 35-GetPixel
|
|
|
|
dd syscall_getarea ; 36-GetArea
|
|
|
|
dd readmousepos ; 37-GetMousePosition_ScreenRelative,.
|
|
|
|
dd syscall_drawline ; 38-DrawLine
|
|
|
|
dd sys_getbackground ; 39-GetBackgroundSize,ReadBgrData,.
|
|
|
|
dd set_app_param ; 40-WantEvents
|
|
|
|
dd undefined_syscall ; 41- deprecated GetIrqOwner
|
|
|
|
dd undefined_syscall ; 42- deprecated ReadIrqData
|
|
|
|
dd sys_outport ; 43-SendDeviceData
|
|
|
|
dd undefined_syscall ; 44- deprecated ProgramIrqs
|
|
|
|
dd undefined_syscall ; 45- deprecated ReserveIrq and FreeIrq
|
|
|
|
dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
|
|
|
|
dd display_number ; 47-WriteNum
|
|
|
|
dd syscall_display_settings ; 48-SetRedrawType and SetButtonType
|
|
|
|
dd sys_apm ; 49-Advanced Power Management (APM)
|
|
|
|
dd syscall_set_window_shape ; 50-Window shape & scale
|
|
|
|
dd syscall_threads ; 51-Threads
|
2013-07-25 14:27:56 +02:00
|
|
|
dd undefined_syscall ; 52- deprecated Stack driver status
|
|
|
|
dd undefined_syscall ; 53- deprecated Socket interface
|
2013-11-10 05:10:03 +01:00
|
|
|
dd sys_clipboard ; 54-Custom clipboard
|
2011-10-14 23:38:50 +02:00
|
|
|
dd sound_interface ; 55-Sound interface
|
|
|
|
dd undefined_syscall ; 56-reserved
|
|
|
|
dd sys_pcibios ; 57-PCI BIOS32
|
2013-11-21 17:07:16 +01:00
|
|
|
dd undefined_syscall ; 58-deprecated Common file system interface
|
2011-10-14 23:38:50 +02:00
|
|
|
dd undefined_syscall ; 59-reserved
|
|
|
|
dd sys_IPC ; 60-Inter Process Communication
|
|
|
|
dd sys_gs ; 61-Direct graphics access
|
2013-06-07 16:12:54 +02:00
|
|
|
dd pci_api ; 62-PCI functions
|
|
|
|
dd sys_msg_board ; 63-System message board
|
2011-10-14 23:38:50 +02:00
|
|
|
dd sys_resize_app_memory ; 64-Resize application memory usage
|
|
|
|
dd sys_putimage_palette ; 65-PutImagePalette
|
|
|
|
dd sys_process_def ; 66-Process definitions - keyboard
|
|
|
|
dd syscall_move_window ; 67-Window move or resize
|
|
|
|
dd f68 ; 68-Some internal services
|
|
|
|
dd sys_debug_services ; 69-Debug
|
2013-03-01 11:27:19 +01:00
|
|
|
dd file_system_lfn ; 70-Common file system interface, version 2
|
2011-10-14 23:38:50 +02:00
|
|
|
dd syscall_window_settings ; 71-Window settings
|
|
|
|
dd sys_sendwindowmsg ; 72-Send window message
|
|
|
|
dd blit_32 ; 73-blitter;
|
2013-05-28 19:34:26 +02:00
|
|
|
dd sys_network ; 74-reserved for new stack
|
|
|
|
dd sys_socket ; 75-reserved for new stack
|
|
|
|
dd sys_protocols ; 76-reserved for new stack
|
2017-06-16 00:36:39 +02:00
|
|
|
dd sys_posix ; posix support
|
2016-12-15 18:38:17 +01:00
|
|
|
dd undefined_syscall ; 78-free
|
|
|
|
dd undefined_syscall ; 79-free
|
|
|
|
dd fileSystemUnicode ; 80-File system interface for different encodings
|
2018-08-25 01:55:36 +02:00
|
|
|
dd setInt0x40 ; 81-Implementation of the function in the system
|
2016-01-19 02:02:44 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
times 255 - ( ($-servetable2) /4 ) dd undefined_syscall
|
|
|
|
dd sys_end ; -1-end application
|
|
|
|
|
|
|
|
endg
|
2018-08-25 01:55:36 +02:00
|
|
|
|
|
|
|
; Author Pavel Iakovlev
|
|
|
|
; Return EAX = 0 security kernel, error set function
|
|
|
|
; Return Else EAX > 0 success set function
|
2018-08-25 12:09:02 +02:00
|
|
|
align 32
|
2018-08-25 01:55:36 +02:00
|
|
|
setInt0x40:
|
2018-08-25 15:22:48 +02:00
|
|
|
|
2018-08-25 01:55:36 +02:00
|
|
|
; !!! kernel security !!!
|
2018-08-25 12:09:02 +02:00
|
|
|
and ebx, 0FFh
|
2018-08-25 01:55:36 +02:00
|
|
|
mov eax, dword [servetable2 + ebx * 4]
|
2018-08-25 15:22:48 +02:00
|
|
|
; cmp eax, undefined_syscall
|
|
|
|
; jne errorSet0x40
|
2018-08-25 01:55:36 +02:00
|
|
|
; -----------------------
|
2018-08-25 15:22:48 +02:00
|
|
|
|
2018-08-25 01:55:36 +02:00
|
|
|
pushad
|
|
|
|
add edx, 16
|
|
|
|
stdcall kernel_alloc, edx
|
2018-08-25 12:09:02 +02:00
|
|
|
push eax
|
|
|
|
pop dword[tempPointerAlloc]
|
2018-08-25 01:55:36 +02:00
|
|
|
popad
|
2018-08-25 15:22:48 +02:00
|
|
|
|
|
|
|
|
2018-08-25 01:55:36 +02:00
|
|
|
push ebx
|
2018-08-25 12:09:02 +02:00
|
|
|
push dword[tempPointerAlloc]
|
|
|
|
pop eax
|
2018-08-25 01:55:36 +02:00
|
|
|
mov ebx, eax
|
|
|
|
add eax, edx
|
2018-08-25 15:22:48 +02:00
|
|
|
|
2018-08-25 12:09:02 +02:00
|
|
|
push 0
|
|
|
|
pop dword[hashDataFunction1]
|
|
|
|
push 1
|
|
|
|
pop dword[hashDataFunction2]
|
2018-08-25 15:22:48 +02:00
|
|
|
|
2018-08-25 01:55:36 +02:00
|
|
|
loopCopyMemory:
|
2018-08-25 12:09:02 +02:00
|
|
|
xor edx, edx
|
2018-08-25 15:22:48 +02:00
|
|
|
|
2018-08-25 12:09:02 +02:00
|
|
|
mov dl, byte[ecx]
|
|
|
|
mov byte[ebx], dl
|
2018-08-25 15:22:48 +02:00
|
|
|
|
2018-08-25 12:09:02 +02:00
|
|
|
; hash security function
|
|
|
|
add dword[hashDataFunction1], edx
|
|
|
|
mov edx, dword[hashDataFunction1]
|
|
|
|
add dword[hashDataFunction2], edx
|
|
|
|
;-----------------------------
|
2018-08-25 15:22:48 +02:00
|
|
|
|
2018-08-25 01:55:36 +02:00
|
|
|
inc ebx
|
|
|
|
inc ecx
|
|
|
|
cmp ebx, eax
|
|
|
|
jne loopCopyMemory
|
2018-08-25 15:22:48 +02:00
|
|
|
|
2018-08-25 01:55:36 +02:00
|
|
|
pop ebx
|
2018-08-25 15:22:48 +02:00
|
|
|
|
2018-08-25 12:09:02 +02:00
|
|
|
; check hash security data
|
|
|
|
; cmp edi, dword[hashDataFunction1]
|
|
|
|
; jne errorSet0x40
|
|
|
|
; cmp esi, dword[hashDataFunction2]
|
|
|
|
; jne errorSet0x40
|
|
|
|
;-------------------------------
|
2018-08-25 15:22:48 +02:00
|
|
|
|
2018-08-25 01:55:36 +02:00
|
|
|
mov eax, dword[tempPointerAlloc]
|
|
|
|
mov dword [servetable2 + ebx * 4], eax
|
|
|
|
jmp successSet0x40
|
2018-08-25 15:22:48 +02:00
|
|
|
|
2018-08-25 01:55:36 +02:00
|
|
|
errorSet0x40:
|
|
|
|
xor eax, eax
|
2018-08-25 15:22:48 +02:00
|
|
|
|
2018-08-25 01:55:36 +02:00
|
|
|
successSet0x40:
|
|
|
|
ret
|
2018-08-25 15:22:48 +02:00
|
|
|
|
2018-08-25 01:55:36 +02:00
|
|
|
tempPointerAlloc dd ?
|
2018-08-25 15:22:48 +02:00
|
|
|
;hashDataFunction1 dd ?
|
|
|
|
;hashDataFunction2 dd ?
|
2018-08-25 01:55:36 +02:00
|
|
|
;-------------------
|