Subversion Repositories Kolibri OS

Rev

Rev 7321 | Rev 7323 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7321 Rev 7322
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
7
 
8
$Revision: 7321 $
8
$Revision: 7322 $
9
 
9
 
10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11
;;                                                            ;;
11
;;                                                            ;;
12
;;                     SYSENTER ENTRY                         ;;
12
;;                     SYSENTER ENTRY                         ;;
13
;;                                                            ;;
13
;;                                                            ;;
14
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
 
15
 
16
align 32
16
align 32
17
sysenter_entry:
17
sysenter_entry:
18
        ; Настраиваем стек
18
        ; Настраиваем стек
19
        mov     esp, [ss:tss._esp0]
19
        mov     esp, [ss:tss._esp0]
20
        sti
20
        sti
21
        push    ebp                     ; save app esp + 4
21
        push    ebp                     ; save app esp + 4
22
        mov     ebp, [ebp]              ; ebp - original ebp
22
        mov     ebp, [ebp]              ; ebp - original ebp
23
        ;------------------
23
        ;------------------
24
        pushad
24
        pushad
25
        cld
25
        cld
26
 
26
 
27
        call    protect_from_terminate
27
        call    protect_from_terminate
28
 
28
 
29
        movzx   eax, byte [esp+28]
29
        movzx   eax, byte [esp+28]
30
        mov     edx, dword [esp+20]
30
        mov     edx, dword [esp+20]
31
        call    dword [servetable2 + eax * 4]
31
        call    dword [servetable2 + eax * 4]
32
 
32
 
33
        call    unprotect_from_terminate
33
        call    unprotect_from_terminate
34
        popad
34
        popad
35
        ;------------------
35
        ;------------------
36
        xchg    ecx, [ss:esp]           ; в вершин стека - app ecx, ecx - app esp + 4
36
        xchg    ecx, [ss:esp]           ; в вершин стека - app ecx, ecx - app esp + 4
37
        sub     ecx, 4
37
        sub     ecx, 4
38
        xchg    edx, [ecx]              ; edx - return point, & save original edx
38
        xchg    edx, [ecx]              ; edx - return point, & save original edx
39
        push    edx
39
        push    edx
40
        mov     edx, [ss:esp + 4]
40
        mov     edx, [ss:esp + 4]
41
        mov     [ecx + 4], edx          ; save original ecx
41
        mov     [ecx + 4], edx          ; save original ecx
42
        pop     edx
42
        pop     edx
43
        sysexit
43
        sysexit
44
 
44
 
45
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
45
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
46
;;                                                            ;;
46
;;                                                            ;;
47
;;                   SYSTEM CALL ENTRY                        ;;
47
;;                   SYSTEM CALL ENTRY                        ;;
48
;;                                                            ;;
48
;;                                                            ;;
49
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
49
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
50
 
50
 
51
align 16
51
align 16
52
i40:
52
i40:
53
        pushad
53
        pushad
54
        cld
54
        cld
55
        call    protect_from_terminate
55
        call    protect_from_terminate
56
        movzx   eax, byte [esp+28]
56
        movzx   eax, byte [esp+28]
57
        mov     edx, dword [esp+20]
57
        mov     edx, dword [esp+20]
58
        call    dword [servetable2 + eax * 4]
58
        call    dword [servetable2 + eax * 4]
59
        call    unprotect_from_terminate
59
        call    unprotect_from_terminate
60
        popad
60
        popad
61
        iretd
61
        iretd
62
 
62
 
63
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
63
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
64
;;                                                            ;;
64
;;                                                            ;;
65
;;                     SYSCALL ENTRY                          ;;
65
;;                     SYSCALL ENTRY                          ;;
66
;;                                                            ;;
66
;;                                                            ;;
67
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
67
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
68
align 32
68
align 32
69
syscall_entry:
69
syscall_entry:
70
  ;     cli                 syscall clear IF
70
  ;     cli                 syscall clear IF
71
        xchg    esp, [ss:tss._esp0]
71
        xchg    esp, [ss:tss._esp0]
72
        push    ecx
72
        push    ecx
73
        lea     ecx, [esp+4]
73
        lea     ecx, [esp+4]
74
        xchg    ecx, [ss:tss._esp0]
74
        xchg    ecx, [ss:tss._esp0]
75
        sti
75
        sti
76
        push    ecx
76
        push    ecx
77
        mov     ecx, [ecx]
77
        mov     ecx, [ecx]
78
        ;------------------
78
        ;------------------
79
        pushad
79
        pushad
80
        cld
80
        cld
81
        call    protect_from_terminate
81
        call    protect_from_terminate
82
 
82
 
83
        movzx   eax, byte [esp+28]
83
        movzx   eax, byte [esp+28]
84
        mov     edx, dword [esp+20]
84
        mov     edx, dword [esp+20]
85
        call    dword [servetable2 + eax * 4]
85
        call    dword [servetable2 + eax * 4]
86
 
86
 
87
        call    unprotect_from_terminate
87
        call    unprotect_from_terminate
88
        popad
88
        popad
89
        ;------------------
89
        ;------------------
90
        mov     ecx, [ss:esp+4]
90
        mov     ecx, [ss:esp+4]
91
        pop     esp
91
        pop     esp
92
        sysret
92
        sysret
93
 
93
 
94
iglobal
94
iglobal
95
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
95
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
96
  ;; SYSTEM FUNCTIONS TABLE ;;
96
  ;; SYSTEM FUNCTIONS TABLE ;;
97
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
97
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
98
  align 4
98
  align 4
99
  servetable2:
99
  servetable2:
100
 
100
 
101
      dd syscall_draw_window     ; 0-DrawWindow
101
      dd syscall_draw_window     ; 0-DrawWindow
102
      dd syscall_setpixel        ; 1-SetPixel
102
      dd syscall_setpixel        ; 1-SetPixel
103
      dd sys_getkey              ; 2-GetKey
103
      dd sys_getkey              ; 2-GetKey
104
      dd sys_clock               ; 3-GetTime
104
      dd sys_clock               ; 3-GetTime
105
      dd syscall_writetext       ; 4-WriteText
105
      dd syscall_writetext       ; 4-WriteText
106
      dd delay_hs_unprotected    ; 5-DelayHs
106
      dd delay_hs_unprotected    ; 5-DelayHs
107
      dd undefined_syscall       ; 6-deprecated OpenRamdiskFile
107
      dd undefined_syscall       ; 6-deprecated OpenRamdiskFile
108
      dd syscall_putimage        ; 7-PutImage
108
      dd syscall_putimage        ; 7-PutImage
109
      dd syscall_button          ; 8-DefineButton
109
      dd syscall_button          ; 8-DefineButton
110
      dd sys_cpuusage            ; 9-GetProcessInfo
110
      dd sys_cpuusage            ; 9-GetProcessInfo
111
      dd sys_waitforevent        ; 10-WaitForEvent
111
      dd sys_waitforevent        ; 10-WaitForEvent
112
      dd sys_getevent            ; 11-CheckForEvent
112
      dd sys_getevent            ; 11-CheckForEvent
113
      dd sys_redrawstat          ; 12-BeginDraw and EndDraw
113
      dd sys_redrawstat          ; 12-BeginDraw and EndDraw
114
      dd syscall_drawrect        ; 13-DrawRect
114
      dd syscall_drawrect        ; 13-DrawRect
115
      dd syscall_getscreensize   ; 14-GetScreenSize
115
      dd syscall_getscreensize   ; 14-GetScreenSize
116
      dd sys_background          ; 15-bgr
116
      dd sys_background          ; 15-bgr
117
      dd sys_cachetodiskette     ; 16-FlushFloppyCache
117
      dd sys_cachetodiskette     ; 16-FlushFloppyCache
118
      dd sys_getbutton           ; 17-GetButton
118
      dd sys_getbutton           ; 17-GetButton
119
      dd sys_system              ; 18-System Services
119
      dd sys_system              ; 18-System Services
120
      dd paleholder              ; 19-reserved
120
      dd paleholder              ; 19-reserved
121
      dd sys_midi                ; 20-ResetMidi and OutputMidi
121
      dd sys_midi                ; 20-ResetMidi and OutputMidi
122
      dd sys_setup               ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
122
      dd sys_setup               ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
123
      dd sys_settime             ; 22-setting date,time,clock and alarm-clock
123
      dd sys_settime             ; 22-setting date,time,clock and alarm-clock
124
      dd sys_wait_event_timeout  ; 23-TimeOutWaitForEvent
124
      dd sys_wait_event_timeout  ; 23-TimeOutWaitForEvent
125
      dd syscall_cdaudio         ; 24-PlayCdTrack,StopCd and GetCdPlaylist
125
      dd syscall_cdaudio         ; 24-PlayCdTrack,StopCd and GetCdPlaylist
126
      dd syscall_putarea_backgr  ; 25-Put Area to background
126
      dd syscall_putarea_backgr  ; 25-Put Area to background
127
      dd sys_getsetup            ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
127
      dd sys_getsetup            ; 26-GetMidiBase,GetKeymap,GetShiftKeymap,.
128
      dd undefined_syscall       ; 27-reserved
128
      dd undefined_syscall       ; 27-reserved
129
      dd undefined_syscall       ; 28-reserved
129
      dd undefined_syscall       ; 28-reserved
130
      dd sys_date                ; 29-GetDate
130
      dd sys_date                ; 29-GetDate
131
      dd sys_current_directory   ; 30-Get/SetCurrentDirectory
131
      dd sys_current_directory   ; 30-Get/SetCurrentDirectory
132
      dd undefined_syscall       ; 31-reserved
132
      dd undefined_syscall       ; 31-reserved
133
      dd undefined_syscall       ; 32-reserved
133
      dd undefined_syscall       ; 32-reserved
134
      dd undefined_syscall       ; 33-reserved
134
      dd undefined_syscall       ; 33-reserved
135
      dd syscall_getpixel_WinMap ; 34-GetPixel WinMap
135
      dd syscall_getpixel_WinMap ; 34-GetPixel WinMap
136
      dd syscall_getpixel        ; 35-GetPixel
136
      dd syscall_getpixel        ; 35-GetPixel
137
      dd syscall_getarea         ; 36-GetArea
137
      dd syscall_getarea         ; 36-GetArea
138
      dd readmousepos            ; 37-GetMousePosition_ScreenRelative,.
138
      dd readmousepos            ; 37-GetMousePosition_ScreenRelative,.
139
      dd syscall_drawline        ; 38-DrawLine
139
      dd syscall_drawline        ; 38-DrawLine
140
      dd sys_getbackground       ; 39-GetBackgroundSize,ReadBgrData,.
140
      dd sys_getbackground       ; 39-GetBackgroundSize,ReadBgrData,.
141
      dd set_app_param           ; 40-WantEvents
141
      dd set_app_param           ; 40-WantEvents
142
      dd undefined_syscall       ; 41- deprecated GetIrqOwner
142
      dd undefined_syscall       ; 41- deprecated GetIrqOwner
143
      dd undefined_syscall       ; 42- deprecated ReadIrqData
143
      dd undefined_syscall       ; 42- deprecated ReadIrqData
144
      dd sys_outport             ; 43-SendDeviceData
144
      dd sys_outport             ; 43-SendDeviceData
145
      dd undefined_syscall       ; 44- deprecated ProgramIrqs
145
      dd undefined_syscall       ; 44- deprecated ProgramIrqs
146
      dd undefined_syscall       ; 45- deprecated ReserveIrq and FreeIrq
146
      dd undefined_syscall       ; 45- deprecated ReserveIrq and FreeIrq
147
      dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
147
      dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
148
      dd display_number          ; 47-WriteNum
148
      dd display_number          ; 47-WriteNum
149
      dd syscall_display_settings ; 48-SetRedrawType and SetButtonType
149
      dd syscall_display_settings ; 48-SetRedrawType and SetButtonType
150
      dd sys_apm                 ; 49-Advanced Power Management (APM)
150
      dd sys_apm                 ; 49-Advanced Power Management (APM)
151
      dd syscall_set_window_shape ; 50-Window shape & scale
151
      dd syscall_set_window_shape ; 50-Window shape & scale
152
      dd syscall_threads         ; 51-Threads
152
      dd syscall_threads         ; 51-Threads
153
      dd undefined_syscall       ; 52- deprecated Stack driver status
153
      dd undefined_syscall       ; 52- deprecated Stack driver status
154
      dd undefined_syscall       ; 53- deprecated Socket interface
154
      dd undefined_syscall       ; 53- deprecated Socket interface
155
      dd sys_clipboard           ; 54-Custom clipboard
155
      dd sys_clipboard           ; 54-Custom clipboard
156
      dd sound_interface         ; 55-Sound interface
156
      dd sound_interface         ; 55-Sound interface
157
      dd undefined_syscall       ; 56-reserved
157
      dd undefined_syscall       ; 56-reserved
158
      dd sys_pcibios             ; 57-PCI BIOS32
158
      dd sys_pcibios             ; 57-PCI BIOS32
159
      dd undefined_syscall       ; 58-deprecated Common file system interface
159
      dd undefined_syscall       ; 58-deprecated Common file system interface
160
      dd undefined_syscall       ; 59-reserved
160
      dd undefined_syscall       ; 59-reserved
161
      dd sys_IPC                 ; 60-Inter Process Communication
161
      dd sys_IPC                 ; 60-Inter Process Communication
162
      dd sys_gs                  ; 61-Direct graphics access
162
      dd sys_gs                  ; 61-Direct graphics access
163
      dd pci_api                 ; 62-PCI functions
163
      dd pci_api                 ; 62-PCI functions
164
      dd sys_msg_board           ; 63-System message board
164
      dd sys_msg_board           ; 63-System message board
165
      dd sys_resize_app_memory   ; 64-Resize application memory usage
165
      dd sys_resize_app_memory   ; 64-Resize application memory usage
166
      dd sys_putimage_palette    ; 65-PutImagePalette
166
      dd sys_putimage_palette    ; 65-PutImagePalette
167
      dd sys_process_def         ; 66-Process definitions - keyboard
167
      dd sys_process_def         ; 66-Process definitions - keyboard
168
      dd syscall_move_window     ; 67-Window move or resize
168
      dd syscall_move_window     ; 67-Window move or resize
169
      dd f68                     ; 68-Some internal services
169
      dd f68                     ; 68-Some internal services
170
      dd sys_debug_services      ; 69-Debug
170
      dd sys_debug_services      ; 69-Debug
171
      dd file_system_lfn         ; 70-Common file system interface, version 2
171
      dd file_system_lfn         ; 70-Common file system interface, version 2
172
      dd syscall_window_settings ; 71-Window settings
172
      dd syscall_window_settings ; 71-Window settings
173
      dd sys_sendwindowmsg       ; 72-Send window message
173
      dd sys_sendwindowmsg       ; 72-Send window message
174
      dd blit_32                 ; 73-blitter;
174
      dd blit_32                 ; 73-blitter;
175
      dd sys_network             ; 74-reserved for new stack
175
      dd sys_network             ; 74-reserved for new stack
176
      dd sys_socket              ; 75-reserved for new stack
176
      dd sys_socket              ; 75-reserved for new stack
177
      dd sys_protocols           ; 76-reserved for new stack
177
      dd sys_protocols           ; 76-reserved for new stack
178
      dd sys_posix               ; posix support
178
      dd sys_posix               ; posix support
179
      dd undefined_syscall       ; 78-free
179
      dd undefined_syscall       ; 78-free
180
      dd undefined_syscall       ; 79-free
180
      dd undefined_syscall       ; 79-free
181
      dd fileSystemUnicode       ; 80-File system interface for different encodings
181
      dd fileSystemUnicode       ; 80-File system interface for different encodings
182
      dd setInt0x40              ; 81-Implementation of the function in the system
182
      dd setInt0x40              ; 81-Implementation of the function in the system
183
 
183
 
184
        times 255 - ( ($-servetable2) /4 )  dd undefined_syscall
184
        times 255 - ( ($-servetable2) /4 )  dd undefined_syscall
185
      dd sys_end                 ; -1-end application
185
      dd sys_end                 ; -1-end application
186
 
186
 
187
endg
187
endg
188
 
188
 
189
; Author Pavel Iakovlev
189
; Author Pavel Iakovlev
190
; Return EAX = 0 security kernel, error set function
190
; Return EAX = 0 security kernel, error set function
191
; Return Else EAX > 0 success set function
191
; Return Else EAX > 0 success set function
192
align 32
192
align 32
193
setInt0x40:
193
setInt0x40:
194
 
194
 
195
           ; !!! kernel security !!!
195
;           !!! kernel security !!!
196
        and     ebx, 0FFh
196
        and     ebx, 0FFh
197
        mov     eax, dword [servetable2 + ebx * 4]
197
        mov     eax, dword [servetable2 + ebx * 4]
198
;       cmp     eax, undefined_syscall
198
;       cmp     eax, undefined_syscall
199
;       jne     errorSet0x40
199
;       jne     errorSet0x40
200
           ; -----------------------
200
;          -----------------------
201
 
201
 
202
        pushad
202
        pushad
203
        add     edx, 16
203
        add     edx, 16
204
        stdcall kernel_alloc, edx
204
        stdcall kernel_alloc, edx
205
        push    eax
205
        push    eax
206
        pop     dword[tempPointerAlloc]
206
        pop     dword[tempPointerAlloc]
207
        popad
207
        popad
208
 
208
 
209
 
209
 
210
        push    ebx
210
        push    ebx
211
        push    dword[tempPointerAlloc]
211
        push    dword[tempPointerAlloc]
212
        pop     eax
212
        pop     eax
213
        mov     ebx, eax
213
        mov     ebx, eax
214
        add     eax, edx
214
        add     eax, edx
215
 
215
 
216
        push    0
216
        push    0
217
        pop     dword[hashDataFunction1]
217
        pop     dword[hashDataFunction1]
218
        push    1
218
        push    1
219
        pop     dword[hashDataFunction2]
219
        pop     dword[hashDataFunction2]
220
 
220
 
221
        loopCopyMemory:
221
        loopCopyMemory:
222
        xor     edx, edx
222
        xor     edx, edx
223
 
223
 
224
        mov     dl, byte[ecx]
224
        mov     dl, byte[ecx]
225
        mov     byte[ebx], dl
225
        mov     byte[ebx], dl
226
 
226
 
227
        ; hash security function
227
;              hash security function
228
        add     dword[hashDataFunction1], edx
228
;       add     dword[hashDataFunction1], edx
229
        mov     edx, dword[hashDataFunction1]
229
;       mov     edx, dword[hashDataFunction1]
230
        add     dword[hashDataFunction2], edx
230
;       add     dword[hashDataFunction2], edx
231
        ;-----------------------------
231
;          -----------------------------
232
 
232
 
233
        inc     ebx
233
        inc     ebx
234
        inc     ecx
234
        inc     ecx
235
        cmp     ebx, eax
235
        cmp     ebx, eax
236
        jne     loopCopyMemory
236
        jne     loopCopyMemory
237
 
237
 
238
        pop     ebx
238
        pop     ebx
239
 
239
 
240
        ; check hash security data
240
;       check hash security data
241
        ; cmp     edi, dword[hashDataFunction1]
241
;       cmp     edi, dword[hashDataFunction1]
242
        ; jne     errorSet0x40
242
;       jne     errorSet0x40
243
        ; cmp     esi, dword[hashDataFunction2]
243
;       cmp     esi, dword[hashDataFunction2]
244
        ; jne     errorSet0x40
244
;       jne     errorSet0x40
245
        ;-------------------------------
245
;       -------------------------------
246
 
246
 
247
        mov     eax, dword[tempPointerAlloc]
247
        mov     eax, dword[tempPointerAlloc]
248
        mov     dword [servetable2 + ebx * 4], eax
248
        mov     dword [servetable2 + ebx * 4], eax
249
        jmp     successSet0x40
249
        jmp     successSet0x40
250
 
250
 
251
        errorSet0x40:
251
        errorSet0x40:
252
        xor     eax, eax
252
        xor     eax, eax
253
 
253
 
254
        successSet0x40:
254
        successSet0x40:
255
        ret
255
        ret
256
 
256
 
257
tempPointerAlloc dd ?
257
tempPointerAlloc dd ?
258
;hashDataFunction1 dd ?
258
;hashDataFunction1 dd ?
259
;hashDataFunction2 dd ?
259
;hashDataFunction2 dd ?
260
;-------------------
260
;-------------------