Rev 506 | Rev 520 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 506 | Rev 519 | ||
---|---|---|---|
1 | $Revision: 506 $ |
1 | $Revision: 519 $ |
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
3 | ;; ;; |
3 | ;; ;; |
4 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
4 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
6 | ;; ;; |
6 | ;; ;; |
7 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
7 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
8 | 8 | ||
9 | GREEDY_KERNEL equ 0 |
9 | GREEDY_KERNEL equ 0 |
10 | 10 | ||
11 | struc APP_HEADER_00 |
11 | struc APP_HEADER_00 |
12 | { .banner dq ? |
12 | { .banner dq ? |
13 | .version dd ? ;+8 |
13 | .version dd ? ;+8 |
14 | .start dd ? ;+12 |
14 | .start dd ? ;+12 |
15 | .i_end dd ? ;+16 |
15 | .i_end dd ? ;+16 |
16 | .mem_size dd ? ;+20 |
16 | .mem_size dd ? ;+20 |
17 | .i_param dd ? ;+24 |
17 | .i_param dd ? ;+24 |
18 | } |
18 | } |
19 | 19 | ||
20 | struc APP_HEADER_01 |
20 | struc APP_HEADER_01 |
21 | { .banner dq ? |
21 | { .banner dq ? |
22 | .version dd ? ;+8 |
22 | .version dd ? ;+8 |
23 | .start dd ? ;+12 |
23 | .start dd ? ;+12 |
24 | .i_end dd ? ;+16 |
24 | .i_end dd ? ;+16 |
25 | .mem_size dd ? ;+20 |
25 | .mem_size dd ? ;+20 |
26 | .stack_top dd ? ;+24 |
26 | .stack_top dd ? ;+24 |
27 | .i_param dd ? ;+28 |
27 | .i_param dd ? ;+28 |
28 | .i_icon dd ? ;+32 |
28 | .i_icon dd ? ;+32 |
29 | } |
29 | } |
30 | 30 | ||
31 | 31 | ||
32 | struc APP_PARAMS |
32 | struc APP_PARAMS |
33 | { .app_cmdline ;0x00 |
33 | { .app_cmdline ;0x00 |
34 | .app_path ;0x04 |
34 | .app_path ;0x04 |
35 | .app_eip ;0x08 |
35 | .app_eip ;0x08 |
36 | .app_esp ;0x0C |
36 | .app_esp ;0x0C |
37 | .app_mem ;0x10 |
37 | .app_mem ;0x10 |
38 | } |
38 | } |
39 | 39 | ||
40 | macro _clear_ op |
40 | macro _clear_ op |
41 | { mov ecx, op/4 |
41 | { mov ecx, op/4 |
42 | xor eax, eax |
42 | xor eax, eax |
43 | cld |
43 | cld |
44 | rep stosd |
44 | rep stosd |
45 | } |
45 | } |
46 | 46 | ||
47 | 47 | ||
48 | align 4 |
48 | align 4 |
49 | proc fs_execute |
49 | proc fs_execute |
50 | 50 | ||
51 | ;fn_read:dword, file_size:dword, cluster:dword |
51 | ;fn_read:dword, file_size:dword, cluster:dword |
52 | 52 | ||
53 | ; ebx - cmdline |
53 | ; ebx - cmdline |
54 | ; edx - flags |
54 | ; edx - flags |
55 | ; ebp - full filename |
55 | ; ebp - full filename |
56 | ; [esp+4] = procedure DoRead, [esp+8] = filesize & [esp+12]... - arguments for it |
56 | ; [esp+4] = procedure DoRead, [esp+8] = filesize & [esp+12]... - arguments for it |
57 | 57 | ||
58 | locals |
58 | locals |
59 | cmdline rd 64 ;256/4 |
59 | cmdline rd 64 ;256/4 |
60 | filename rd 256 ;1024/4 |
60 | filename rd 256 ;1024/4 |
61 | flags dd ? |
61 | flags dd ? |
62 | 62 | ||
63 | save_cr3 dd ? |
63 | save_cr3 dd ? |
64 | slot dd ? |
64 | slot dd ? |
65 | slot_base dd ? |
65 | slot_base dd ? |
66 | file_base dd ? |
66 | file_base dd ? |
67 | file_size dd ? |
67 | file_size dd ? |
68 | ;app header data |
68 | ;app header data |
69 | hdr_cmdline dd ? ;0x00 |
69 | hdr_cmdline dd ? ;0x00 |
70 | hdr_path dd ? ;0x04 |
70 | hdr_path dd ? ;0x04 |
71 | hdr_eip dd ? ;0x08 |
71 | hdr_eip dd ? ;0x08 |
72 | hdr_esp dd ? ;0x0C |
72 | hdr_esp dd ? ;0x0C |
73 | hdr_mem dd ? ;0x10 |
73 | hdr_mem dd ? ;0x10 |
74 | hdr_i_end dd ? ;0x14 |
74 | hdr_i_end dd ? ;0x14 |
75 | endl |
75 | endl |
76 | 76 | ||
77 | pushad |
77 | pushad |
78 | - | ||
79 | mov [cmdline], ebx |
78 | |
80 | mov [flags], edx |
79 | mov [flags], edx |
81 | 80 | ||
82 | ; [ebp] pointer to filename |
81 | ; [ebp] pointer to filename |
83 | 82 | ||
84 | lea eax, [filename] |
83 | lea eax, [filename] |
85 | mov dword [eax+1020],0 ;force terminate |
84 | mov dword [eax+1020],0 ;force terminate |
86 | ;string |
85 | ;string |
87 | stdcall k_strncpy, eax, [ebp], 1023 |
86 | stdcall strncpy, eax, [ebp], 1023 |
- | 87 | ||
- | 88 | mov [cmdline], ebx |
|
- | 89 | test ebx, ebx |
|
- | 90 | jz @F |
|
88 | 91 | ||
89 | lea eax, [cmdline] |
92 | lea eax, [cmdline] |
90 | mov dword [eax+252], 0 |
93 | mov dword [eax+252], 0 |
91 | stdcall k_strncpy, eax, [cmdline], 255 |
94 | stdcall strncpy, eax, ebx, 255 |
92 | 95 | @@: |
|
93 | lea eax, [filename] |
96 | lea eax, [filename] |
94 | stdcall load_file, eax |
97 | stdcall load_file, eax |
95 | mov ecx, -ERROR_FILE_NOT_FOUND |
98 | mov ecx, -ERROR_FILE_NOT_FOUND |
96 | test eax, eax |
99 | test eax, eax |
97 | jz .err_file |
100 | jz .err_file |
98 | 101 | ||
99 | mov [file_base], eax |
102 | mov [file_base], eax |
100 | mov [file_size], ebx |
103 | mov [file_size], ebx |
101 | 104 | ||
102 | lea ebx, [hdr_cmdline] |
105 | lea ebx, [hdr_cmdline] |
103 | call test_app_header |
106 | call test_app_header |
104 | mov ecx, -0x1F |
107 | mov ecx, -0x1F |
105 | test eax, eax |
108 | test eax, eax |
106 | jz .err_hdr |
109 | jz .err_hdr |
107 | 110 | ||
108 | ;mov esi, new_process_loading |
111 | ;mov esi, new_process_loading |
109 | ;call sys_msg_board_str ; write message to message board |
112 | ;call sys_msg_board_str ; write message to message board |
110 | DEBUGF 1,"%s",new_process_loading |
113 | DEBUGF 1,"%s",new_process_loading |
111 | 114 | ||
112 | .wait_lock: |
115 | .wait_lock: |
113 | cmp [application_table_status],0 |
116 | cmp [application_table_status],0 |
114 | je .get_lock |
117 | je .get_lock |
115 | call change_task |
118 | call change_task |
116 | jmp .wait_lock |
119 | jmp .wait_lock |
117 | 120 | ||
118 | .get_lock: |
121 | .get_lock: |
119 | mov eax, 1 |
122 | mov eax, 1 |
120 | xchg eax, [application_table_status] |
123 | xchg eax, [application_table_status] |
121 | cmp eax, 0 |
124 | cmp eax, 0 |
122 | jne .wait_lock |
125 | jne .wait_lock |
123 | 126 | ||
124 | call set_application_table_status |
127 | call set_application_table_status |
125 | 128 | ||
126 | call get_new_process_place |
129 | call get_new_process_place |
127 | test eax, eax |
130 | test eax, eax |
128 | mov ecx, -0x20 ; too many processes |
131 | mov ecx, -0x20 ; too many processes |
129 | jz .err |
132 | jz .err |
130 | 133 | ||
131 | mov [slot], eax |
134 | mov [slot], eax |
132 | shl eax, 8 |
135 | shl eax, 8 |
133 | add eax, SLOT_BASE |
136 | add eax, SLOT_BASE |
134 | mov [slot_base], eax |
137 | mov [slot_base], eax |
135 | mov edi, eax |
138 | mov edi, eax |
136 | _clear_ 256 ;clean extended information about process |
139 | _clear_ 256 ;clean extended information about process |
137 | 140 | ||
138 | ; write application name |
141 | ; write application name |
139 | lea edi, [filename] |
142 | lea eax, [filename] |
140 | mov al, '/' |
- | |
141 | call k_strrchr ; now eax points to name without path |
143 | stdcall strrchr, eax, '/' ; now eax points to name without path |
142 | 144 | ||
143 | lea esi, [eax+1] |
145 | lea esi, [eax+1] |
144 | test eax, eax |
146 | test eax, eax |
145 | jnz @F |
147 | jnz @F |
146 | lea esi, [filename] |
148 | lea esi, [filename] |
147 | @@: |
149 | @@: |
148 | mov ecx, 8 ; 8 chars for name |
150 | mov ecx, 8 ; 8 chars for name |
149 | mov edi, [slot_base] |
151 | mov edi, [slot_base] |
150 | .copy_process_name_loop: |
152 | .copy_process_name_loop: |
151 | lodsb |
153 | lodsb |
152 | cmp al, '.' |
154 | cmp al, '.' |
153 | jz .copy_process_name_done |
155 | jz .copy_process_name_done |
154 | test al, al |
156 | test al, al |
155 | jz .copy_process_name_done |
157 | jz .copy_process_name_done |
156 | stosb |
158 | stosb |
157 | loop .copy_process_name_loop |
159 | loop .copy_process_name_loop |
158 | .copy_process_name_done: |
160 | .copy_process_name_done: |
159 | 161 | ||
160 | mov ebx, cr3 |
162 | mov ebx, cr3 |
161 | mov [save_cr3], ebx |
163 | mov [save_cr3], ebx |
162 | 164 | ||
163 | stdcall create_app_space,[hdr_mem],[file_base],[file_size] |
165 | stdcall create_app_space,[hdr_mem],[file_base],[file_size] |
164 | mov ecx, -30 ; no memory |
166 | mov ecx, -30 ; no memory |
165 | test eax, eax |
167 | test eax, eax |
166 | jz .failed |
168 | jz .failed |
167 | 169 | ||
168 | mov ebx,[slot_base] |
170 | mov ebx,[slot_base] |
169 | mov [ebx+APPDATA.dir_table],eax |
171 | mov [ebx+APPDATA.dir_table],eax |
170 | mov eax,[hdr_mem] |
172 | mov eax,[hdr_mem] |
171 | mov [ebx+APPDATA.mem_size],eax |
173 | mov [ebx+APPDATA.mem_size],eax |
172 | 174 | ||
173 | if GREEDY_KERNEL |
175 | if GREEDY_KERNEL |
174 | else |
176 | else |
175 | mov ecx, [hdr_mem] |
177 | mov ecx, [hdr_mem] |
176 | mov edi, [file_size] |
178 | mov edi, [file_size] |
177 | add edi, 4095 |
179 | add edi, 4095 |
178 | and edi, not 4095 |
180 | and edi, not 4095 |
179 | sub ecx, edi |
181 | sub ecx, edi |
180 | jna @F |
182 | jna @F |
181 | 183 | ||
182 | xor eax, eax |
184 | xor eax, eax |
183 | ; add edi, new_app_base |
185 | ; add edi, new_app_base |
184 | cld |
186 | cld |
185 | rep stosb |
187 | rep stosb |
186 | @@: |
188 | @@: |
187 | end if |
189 | end if |
188 | 190 | ||
189 | ; release only virtual space, not phisical memory |
191 | ; release only virtual space, not phisical memory |
190 | 192 | ||
191 | stdcall free_kernel_space, [file_base] |
193 | stdcall free_kernel_space, [file_base] |
192 | lea eax, [hdr_cmdline] |
194 | lea eax, [hdr_cmdline] |
193 | lea ebx, [cmdline] |
195 | lea ebx, [cmdline] |
194 | lea ecx, [filename] |
196 | lea ecx, [filename] |
195 | stdcall set_app_params ,[slot],eax,ebx,ecx,[flags] |
197 | stdcall set_app_params ,[slot],eax,ebx,ecx,[flags] |
196 | 198 | ||
197 | mov eax, [save_cr3] |
199 | mov eax, [save_cr3] |
198 | call set_cr3 |
200 | call set_cr3 |
199 | 201 | ||
200 | xor ebx, ebx |
202 | xor ebx, ebx |
201 | mov [application_table_status],ebx ;unlock application_table_status mutex |
203 | mov [application_table_status],ebx ;unlock application_table_status mutex |
202 | mov eax,[process_number] ;set result |
204 | mov eax,[process_number] ;set result |
203 | ret |
205 | ret |
204 | .failed: |
206 | .failed: |
205 | mov eax, [save_cr3] |
207 | mov eax, [save_cr3] |
206 | call set_cr3 |
208 | call set_cr3 |
207 | .err: |
209 | .err: |
208 | .err_hdr: |
210 | .err_hdr: |
209 | stdcall kernel_free,[file_base] |
211 | stdcall kernel_free,[file_base] |
210 | .err_file: |
212 | .err_file: |
211 | xor eax, eax |
213 | xor eax, eax |
212 | mov [application_table_status],eax |
214 | mov [application_table_status],eax |
213 | mov eax, ecx |
215 | mov eax, ecx |
214 | ret |
216 | ret |
215 | endp |
217 | endp |
216 | 218 | ||
217 | align 4 |
219 | align 4 |
218 | test_app_header: |
220 | test_app_header: |
219 | virtual at eax |
221 | virtual at eax |
220 | APP_HEADER_00 APP_HEADER_00 |
222 | APP_HEADER_00 APP_HEADER_00 |
221 | end virtual |
223 | end virtual |
222 | virtual at eax |
224 | virtual at eax |
223 | APP_HEADER_01 APP_HEADER_01 |
225 | APP_HEADER_01 APP_HEADER_01 |
224 | end virtual |
226 | end virtual |
225 | 227 | ||
226 | cmp dword [eax], 'MENU' |
228 | cmp dword [eax], 'MENU' |
227 | jne .fail |
229 | jne .fail |
228 | cmp word [eax+4],'ET' |
230 | cmp word [eax+4],'ET' |
229 | jne .fail |
231 | jne .fail |
230 | 232 | ||
231 | cmp [eax+6], word '00' |
233 | cmp [eax+6], word '00' |
232 | jne .check_01_header |
234 | jne .check_01_header |
233 | 235 | ||
234 | mov ecx,[APP_HEADER_00.start] |
236 | mov ecx,[APP_HEADER_00.start] |
235 | mov [ebx+0x08], ecx ;app_eip |
237 | mov [ebx+0x08], ecx ;app_eip |
236 | mov edx,[APP_HEADER_00.mem_size] |
238 | mov edx,[APP_HEADER_00.mem_size] |
237 | mov [ebx+0x10], edx ;app_mem |
239 | mov [ebx+0x10], edx ;app_mem |
238 | shr edx,1 |
240 | shr edx,1 |
239 | sub edx,0x10 |
241 | sub edx,0x10 |
240 | mov [ebx+0x0C], edx ;app_esp |
242 | mov [ebx+0x0C], edx ;app_esp |
241 | mov ecx,[APP_HEADER_00.i_param] |
243 | mov ecx,[APP_HEADER_00.i_param] |
242 | mov [ebx], ecx ;app_cmdline |
244 | mov [ebx], ecx ;app_cmdline |
243 | mov [ebx+4], dword 0 ;app_path |
245 | mov [ebx+4], dword 0 ;app_path |
244 | mov edx, [APP_HEADER_00.i_end] |
246 | mov edx, [APP_HEADER_00.i_end] |
245 | mov [ebx+0x14], edx |
247 | mov [ebx+0x14], edx |
246 | ret |
248 | ret |
247 | 249 | ||
248 | .check_01_header: |
250 | .check_01_header: |
249 | 251 | ||
250 | cmp [eax+6],word '01' |
252 | cmp [eax+6],word '01' |
251 | jne .fail |
253 | jne .fail |
252 | 254 | ||
253 | mov ecx,[APP_HEADER_01.start] |
255 | mov ecx,[APP_HEADER_01.start] |
254 | mov [ebx+0x08], ecx ;app_eip |
256 | mov [ebx+0x08], ecx ;app_eip |
255 | mov edx,[APP_HEADER_01.mem_size] |
257 | mov edx,[APP_HEADER_01.mem_size] |
256 | 258 | ||
257 | ; \begin{diamond}[20.08.2006] |
259 | ; \begin{diamond}[20.08.2006] |
258 | ; sanity check (functions 19,58 load app_i_end bytes and that must |
260 | ; sanity check (functions 19,58 load app_i_end bytes and that must |
259 | ; fit in allocated memory to prevent kernel faults) |
261 | ; fit in allocated memory to prevent kernel faults) |
260 | cmp edx,[APP_HEADER_01.i_end] |
262 | cmp edx,[APP_HEADER_01.i_end] |
261 | jb .fail |
263 | jb .fail |
262 | ; \end{diamond}[20.08.2006] |
264 | ; \end{diamond}[20.08.2006] |
263 | 265 | ||
264 | mov [ebx+0x10], edx ;app_mem |
266 | mov [ebx+0x10], edx ;app_mem |
265 | mov ecx,[APP_HEADER_01.stack_top] |
267 | mov ecx,[APP_HEADER_01.stack_top] |
266 | mov [ebx+0x0C], ecx ;app_esp |
268 | mov [ebx+0x0C], ecx ;app_esp |
267 | mov edx,[APP_HEADER_01.i_param] |
269 | mov edx,[APP_HEADER_01.i_param] |
268 | mov [ebx], edx ;app_cmdline |
270 | mov [ebx], edx ;app_cmdline |
269 | mov ecx,[APP_HEADER_01.i_icon] |
271 | mov ecx,[APP_HEADER_01.i_icon] |
270 | mov [ebx+4], ecx ;app_path |
272 | mov [ebx+4], ecx ;app_path |
271 | mov edx, [APP_HEADER_01.i_end] |
273 | mov edx, [APP_HEADER_01.i_end] |
272 | mov [ebx+0x14], edx |
274 | mov [ebx+0x14], edx |
273 | ret |
275 | ret |
274 | .fail: |
276 | .fail: |
275 | xor eax, eax |
277 | xor eax, eax |
276 | ret |
278 | ret |
277 | 279 | ||
278 | align 4 |
280 | align 4 |
279 | proc get_new_process_place |
281 | proc get_new_process_place |
280 | ;input: |
282 | ;input: |
281 | ; none |
283 | ; none |
282 | ;result: |
284 | ;result: |
283 | ; eax=[new_process_place]<>0 - ok |
285 | ; eax=[new_process_place]<>0 - ok |
284 | ; 0 - failed. |
286 | ; 0 - failed. |
285 | ;This function find least empty slot. |
287 | ;This function find least empty slot. |
286 | ;It doesn't increase [TASK_COUNT]! |
288 | ;It doesn't increase [TASK_COUNT]! |
287 | mov eax,CURRENT_TASK |
289 | mov eax,CURRENT_TASK |
288 | mov ebx,[TASK_COUNT] |
290 | mov ebx,[TASK_COUNT] |
289 | inc ebx |
291 | inc ebx |
290 | shl ebx,5 |
292 | shl ebx,5 |
291 | add ebx,eax ;ebx - address of process information for (last+1) slot |
293 | add ebx,eax ;ebx - address of process information for (last+1) slot |
292 | .newprocessplace: |
294 | .newprocessplace: |
293 | ;eax = address of process information for current slot |
295 | ;eax = address of process information for current slot |
294 | cmp eax,ebx |
296 | cmp eax,ebx |
295 | jz .endnewprocessplace ;empty slot after high boundary |
297 | jz .endnewprocessplace ;empty slot after high boundary |
296 | add eax,0x20 |
298 | add eax,0x20 |
297 | cmp word [eax+0xa],9 ;check process state, 9 means that process slot is empty |
299 | cmp word [eax+0xa],9 ;check process state, 9 means that process slot is empty |
298 | jnz .newprocessplace |
300 | jnz .newprocessplace |
299 | .endnewprocessplace: |
301 | .endnewprocessplace: |
300 | mov ebx,eax |
302 | mov ebx,eax |
301 | sub eax,CURRENT_TASK |
303 | sub eax,CURRENT_TASK |
302 | shr eax,5 ;calculate slot index |
304 | shr eax,5 ;calculate slot index |
303 | cmp eax,256 |
305 | cmp eax,256 |
304 | jge .failed ;it should be <256 |
306 | jge .failed ;it should be <256 |
305 | mov word [ebx+0xa],9 ;set process state to 9 (for slot after hight boundary) |
307 | mov word [ebx+0xa],9 ;set process state to 9 (for slot after hight boundary) |
306 | ret |
308 | ret |
307 | .failed: |
309 | .failed: |
308 | xor eax,eax |
310 | xor eax,eax |
309 | ret |
311 | ret |
310 | endp |
312 | endp |
311 | 313 | ||
312 | align 4 |
314 | align 4 |
313 | proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword |
315 | proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword |
314 | locals |
316 | locals |
315 | app_pages dd ? |
317 | app_pages dd ? |
316 | img_pages dd ? |
318 | img_pages dd ? |
317 | dir_addr dd ? |
319 | dir_addr dd ? |
318 | app_tabs dd ? |
320 | app_tabs dd ? |
319 | endl |
321 | endl |
320 | 322 | ||
321 | mov ebx, pg_data.pg_mutex |
323 | mov ebx, pg_data.pg_mutex |
322 | call wait_mutex ;ebx |
324 | call wait_mutex ;ebx |
323 | 325 | ||
324 | xor eax, eax |
326 | xor eax, eax |
325 | mov [dir_addr], eax |
327 | mov [dir_addr], eax |
326 | 328 | ||
327 | mov eax, [app_size] |
329 | mov eax, [app_size] |
328 | add eax, 4095 |
330 | add eax, 4095 |
329 | and eax, NOT(4095) |
331 | and eax, NOT(4095) |
330 | mov [app_size], eax |
332 | mov [app_size], eax |
331 | mov ebx, eax |
333 | mov ebx, eax |
332 | shr eax, 12 |
334 | shr eax, 12 |
333 | mov [app_pages], eax |
335 | mov [app_pages], eax |
334 | 336 | ||
335 | add ebx, 0x3FFFFF |
337 | add ebx, 0x3FFFFF |
336 | and ebx, NOT(0x3FFFFF) |
338 | and ebx, NOT(0x3FFFFF) |
337 | shr ebx, 22 |
339 | shr ebx, 22 |
338 | mov [app_tabs], ebx |
340 | mov [app_tabs], ebx |
339 | 341 | ||
340 | mov ecx, [img_size] |
342 | mov ecx, [img_size] |
341 | add ecx, 4095 |
343 | add ecx, 4095 |
342 | and ecx, NOT(4095) |
344 | and ecx, NOT(4095) |
343 | 345 | ||
344 | mov [img_size], ecx |
346 | mov [img_size], ecx |
345 | shr ecx, 12 |
347 | shr ecx, 12 |
346 | mov [img_pages], ecx |
348 | mov [img_pages], ecx |
347 | 349 | ||
348 | if GREEDY_KERNEL |
350 | if GREEDY_KERNEL |
349 | lea eax, [ecx+ebx+2] ;only image size |
351 | lea eax, [ecx+ebx+2] ;only image size |
350 | else |
352 | else |
351 | lea eax, [eax+ebx+2] ;all requested memory |
353 | lea eax, [eax+ebx+2] ;all requested memory |
352 | end if |
354 | end if |
353 | cmp eax, [pg_data.pages_free] |
355 | cmp eax, [pg_data.pages_free] |
354 | ja .fail |
356 | ja .fail |
355 | 357 | ||
356 | call alloc_page |
358 | call alloc_page |
357 | test eax, eax |
359 | test eax, eax |
358 | jz .fail |
360 | jz .fail |
359 | mov [dir_addr], eax |
361 | mov [dir_addr], eax |
360 | stdcall map_page,[tmp_task_pdir],eax,dword PG_SW |
362 | stdcall map_page,[tmp_task_pdir],eax,dword PG_SW |
361 | 363 | ||
362 | mov edi, [tmp_task_pdir] |
364 | mov edi, [tmp_task_pdir] |
363 | mov ecx, (OS_BASE shr 20)/4 |
365 | mov ecx, (OS_BASE shr 20)/4 |
364 | xor eax, eax |
366 | xor eax, eax |
365 | cld |
367 | cld |
366 | rep stosd |
368 | rep stosd |
367 | 369 | ||
368 | mov ecx, (OS_BASE shr 20)/4 |
370 | mov ecx, (OS_BASE shr 20)/4 |
369 | mov esi, sys_pgdir+(OS_BASE shr 20) |
371 | mov esi, sys_pgdir+(OS_BASE shr 20) |
370 | rep movsd |
372 | rep movsd |
371 | 373 | ||
372 | mov eax, [dir_addr] |
374 | mov eax, [dir_addr] |
373 | or eax, PG_SW |
375 | or eax, PG_SW |
374 | mov [edi-4096+(page_tabs shr 20)], eax |
376 | mov [edi-4096+(page_tabs shr 20)], eax |
375 | 377 | ||
376 | and eax, -4096 |
378 | and eax, -4096 |
377 | call set_cr3 |
379 | call set_cr3 |
378 | 380 | ||
379 | mov edx, [app_tabs] |
381 | mov edx, [app_tabs] |
380 | mov edi, new_app_base |
382 | mov edi, new_app_base |
381 | @@: |
383 | @@: |
382 | call alloc_page |
384 | call alloc_page |
383 | test eax, eax |
385 | test eax, eax |
384 | jz .fail |
386 | jz .fail |
385 | 387 | ||
386 | stdcall map_page_table, edi, eax |
388 | stdcall map_page_table, edi, eax |
387 | add edi, 0x00400000 |
389 | add edi, 0x00400000 |
388 | dec edx |
390 | dec edx |
389 | jnz @B |
391 | jnz @B |
390 | 392 | ||
391 | mov edi, new_app_base |
393 | mov edi, new_app_base |
392 | shr edi, 10 |
394 | shr edi, 10 |
393 | add edi, page_tabs |
395 | add edi, page_tabs |
394 | 396 | ||
395 | mov ecx, [app_tabs] |
397 | mov ecx, [app_tabs] |
396 | shl ecx, 10 |
398 | shl ecx, 10 |
397 | xor eax, eax |
399 | xor eax, eax |
398 | rep stosd |
400 | rep stosd |
399 | 401 | ||
400 | mov ecx, [img_pages] |
402 | mov ecx, [img_pages] |
401 | mov ebx, PG_UW |
403 | mov ebx, PG_UW |
402 | mov edx, new_app_base |
404 | mov edx, new_app_base |
403 | mov esi, [img_base] |
405 | mov esi, [img_base] |
404 | mov edi, new_app_base |
406 | mov edi, new_app_base |
405 | shr esi, 10 |
407 | shr esi, 10 |
406 | shr edi, 10 |
408 | shr edi, 10 |
407 | add esi, page_tabs |
409 | add esi, page_tabs |
408 | add edi, page_tabs |
410 | add edi, page_tabs |
409 | .remap: |
411 | .remap: |
410 | lodsd |
412 | lodsd |
411 | or eax, ebx ; force user level r/w access |
413 | or eax, ebx ; force user level r/w access |
412 | stosd |
414 | stosd |
413 | add edx, 0x1000 |
415 | add edx, 0x1000 |
414 | dec [app_pages] |
416 | dec [app_pages] |
415 | dec ecx |
417 | dec ecx |
416 | jnz .remap |
418 | jnz .remap |
417 | 419 | ||
418 | mov ecx, [app_pages] |
420 | mov ecx, [app_pages] |
419 | test ecx, ecx |
421 | test ecx, ecx |
420 | jz .done |
422 | jz .done |
421 | 423 | ||
422 | if GREEDY_KERNEL |
424 | if GREEDY_KERNEL |
423 | mov eax, 0x02 |
425 | mov eax, 0x02 |
424 | .reserve: |
426 | .reserve: |
425 | stosd |
427 | stosd |
426 | invlpg [edx] |
428 | invlpg [edx] |
427 | add edx, 4096 |
429 | add edx, 4096 |
428 | dec ecx |
430 | dec ecx |
429 | jnz .reserve |
431 | jnz .reserve |
430 | else |
432 | else |
431 | 433 | ||
432 | .alloc: |
434 | .alloc: |
433 | call alloc_page |
435 | call alloc_page |
434 | test eax, eax |
436 | test eax, eax |
435 | jz .fail |
437 | jz .fail |
436 | 438 | ||
437 | stdcall map_page,edx,eax,dword PG_UW |
439 | stdcall map_page,edx,eax,dword PG_UW |
438 | add edx, 0x1000 |
440 | add edx, 0x1000 |
439 | dec [app_pages] |
441 | dec [app_pages] |
440 | jnz .alloc |
442 | jnz .alloc |
441 | end if |
443 | end if |
442 | 444 | ||
443 | .done: |
445 | .done: |
444 | stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP |
446 | stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP |
445 | 447 | ||
446 | dec [pg_data.pg_mutex] |
448 | dec [pg_data.pg_mutex] |
447 | mov eax, [dir_addr] |
449 | mov eax, [dir_addr] |
448 | ret |
450 | ret |
449 | .fail: |
451 | .fail: |
450 | dec [pg_data.pg_mutex] |
452 | dec [pg_data.pg_mutex] |
451 | cmp [dir_addr], 0 |
453 | cmp [dir_addr], 0 |
452 | je @f |
454 | je @f |
453 | stdcall destroy_app_space, [dir_addr] |
455 | stdcall destroy_app_space, [dir_addr] |
454 | @@: |
456 | @@: |
455 | xor eax, eax |
457 | xor eax, eax |
456 | ret |
458 | ret |
457 | endp |
459 | endp |
458 | 460 | ||
459 | align 4 |
461 | align 4 |
460 | set_cr3: |
462 | set_cr3: |
461 | 463 | ||
462 | mov ebx, [current_slot] |
464 | mov ebx, [current_slot] |
463 | mov [ebx+APPDATA.dir_table], eax |
465 | mov [ebx+APPDATA.dir_table], eax |
464 | mov cr3, eax |
466 | mov cr3, eax |
465 | ret |
467 | ret |
466 | 468 | ||
467 | align 4 |
469 | align 4 |
468 | proc destroy_page_table stdcall, pg_tab:dword |
470 | proc destroy_page_table stdcall, pg_tab:dword |
469 | 471 | ||
470 | push esi |
472 | push esi |
471 | 473 | ||
472 | mov esi, [pg_tab] |
474 | mov esi, [pg_tab] |
473 | mov ecx, 1024 |
475 | mov ecx, 1024 |
474 | .free: |
476 | .free: |
475 | mov eax, [esi] |
477 | mov eax, [esi] |
476 | test eax, 1 |
478 | test eax, 1 |
477 | jz .next |
479 | jz .next |
478 | call free_page |
480 | call free_page |
479 | .next: |
481 | .next: |
480 | add esi, 4 |
482 | add esi, 4 |
481 | dec ecx |
483 | dec ecx |
482 | jnz .free |
484 | jnz .free |
483 | pop esi |
485 | pop esi |
484 | ret |
486 | ret |
485 | endp |
487 | endp |
486 | 488 | ||
487 | align 4 |
489 | align 4 |
488 | proc destroy_app_space stdcall, pg_dir:dword |
490 | proc destroy_app_space stdcall, pg_dir:dword |
489 | 491 | ||
490 | mov ebx, pg_data.pg_mutex |
492 | mov ebx, pg_data.pg_mutex |
491 | call wait_mutex ;ebx |
493 | call wait_mutex ;ebx |
492 | 494 | ||
493 | xor edx,edx |
495 | xor edx,edx |
494 | mov eax,0x2 |
496 | mov eax,0x2 |
495 | mov ebx, [pg_dir] |
497 | mov ebx, [pg_dir] |
496 | .loop: |
498 | .loop: |
497 | ;eax = current slot of process |
499 | ;eax = current slot of process |
498 | mov ecx,eax |
500 | mov ecx,eax |
499 | shl ecx,5 |
501 | shl ecx,5 |
500 | cmp byte [CURRENT_TASK+ecx+0xa],9 ;if process running? |
502 | cmp byte [CURRENT_TASK+ecx+0xa],9 ;if process running? |
501 | jz @f ;skip empty slots |
503 | jz @f ;skip empty slots |
502 | shl ecx,3 |
504 | shl ecx,3 |
503 | cmp [SLOT_BASE+ecx+0xB8],ebx ;compare page directory addresses |
505 | cmp [SLOT_BASE+ecx+0xB8],ebx ;compare page directory addresses |
504 | jnz @f |
506 | jnz @f |
505 | inc edx ;thread found |
507 | inc edx ;thread found |
506 | @@: |
508 | @@: |
507 | inc eax |
509 | inc eax |
508 | cmp eax,[TASK_COUNT] ;exit loop if we look through all processes |
510 | cmp eax,[TASK_COUNT] ;exit loop if we look through all processes |
509 | jle .loop |
511 | jle .loop |
510 | 512 | ||
511 | ;edx = number of threads |
513 | ;edx = number of threads |
512 | ;our process is zombi so it isn't counted |
514 | ;our process is zombi so it isn't counted |
513 | cmp edx,1 |
515 | cmp edx,1 |
514 | jg .exit |
516 | jg .exit |
515 | ;if there isn't threads then clear memory. |
517 | ;if there isn't threads then clear memory. |
516 | 518 | ||
517 | mov eax, [pg_dir] |
519 | mov eax, [pg_dir] |
518 | and eax, not 0xFFF |
520 | and eax, not 0xFFF |
519 | stdcall map_page,[tmp_task_pdir],eax,dword PG_SW |
521 | stdcall map_page,[tmp_task_pdir],eax,dword PG_SW |
520 | mov esi, [tmp_task_pdir] |
522 | mov esi, [tmp_task_pdir] |
521 | mov edi, (OS_BASE shr 20)/4 |
523 | mov edi, (OS_BASE shr 20)/4 |
522 | .destroy: |
524 | .destroy: |
523 | mov eax, [esi] |
525 | mov eax, [esi] |
524 | test eax, 1 |
526 | test eax, 1 |
525 | jz .next |
527 | jz .next |
526 | and eax, not 0xFFF |
528 | and eax, not 0xFFF |
527 | stdcall map_page,[tmp_task_ptab],eax,dword PG_SW |
529 | stdcall map_page,[tmp_task_ptab],eax,dword PG_SW |
528 | stdcall destroy_page_table, [tmp_task_ptab] |
530 | stdcall destroy_page_table, [tmp_task_ptab] |
529 | mov eax, [esi] |
531 | mov eax, [esi] |
530 | call free_page |
532 | call free_page |
531 | .next: |
533 | .next: |
532 | add esi, 4 |
534 | add esi, 4 |
533 | dec edi |
535 | dec edi |
534 | jnz .destroy |
536 | jnz .destroy |
535 | 537 | ||
536 | mov eax, [pg_dir] |
538 | mov eax, [pg_dir] |
537 | call free_page |
539 | call free_page |
538 | .exit: |
540 | .exit: |
539 | stdcall map_page,[tmp_task_ptab],dword 0,dword PG_UNMAP |
541 | stdcall map_page,[tmp_task_ptab],dword 0,dword PG_UNMAP |
540 | stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP |
542 | stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP |
541 | dec [pg_data.pg_mutex] |
543 | dec [pg_data.pg_mutex] |
542 | ret |
544 | ret |
543 | endp |
545 | endp |
544 | 546 | ||
545 | pid_to_slot: |
547 | pid_to_slot: |
546 | ;Input: |
548 | ;Input: |
547 | ; eax - pid of process |
549 | ; eax - pid of process |
548 | ;Output: |
550 | ;Output: |
549 | ; eax - slot of process or 0 if process don't exists |
551 | ; eax - slot of process or 0 if process don't exists |
550 | ;Search process by PID. |
552 | ;Search process by PID. |
551 | push ebx |
553 | push ebx |
552 | push ecx |
554 | push ecx |
553 | mov ebx,[TASK_COUNT] |
555 | mov ebx,[TASK_COUNT] |
554 | shl ebx,5 |
556 | shl ebx,5 |
555 | mov ecx,2*32 |
557 | mov ecx,2*32 |
556 | 558 | ||
557 | .loop: |
559 | .loop: |
558 | ;ecx=offset of current process info entry |
560 | ;ecx=offset of current process info entry |
559 | ;ebx=maximum permitted offset |
561 | ;ebx=maximum permitted offset |
560 | cmp byte [CURRENT_TASK+ecx+0xa],9 |
562 | cmp byte [CURRENT_TASK+ecx+0xa],9 |
561 | jz .endloop ;skip empty slots |
563 | jz .endloop ;skip empty slots |
562 | cmp [CURRENT_TASK+ecx+0x4],eax ;check PID |
564 | cmp [CURRENT_TASK+ecx+0x4],eax ;check PID |
563 | jz .pid_found |
565 | jz .pid_found |
564 | .endloop: |
566 | .endloop: |
565 | add ecx,32 |
567 | add ecx,32 |
566 | cmp ecx,ebx |
568 | cmp ecx,ebx |
567 | jle .loop |
569 | jle .loop |
568 | 570 | ||
569 | pop ecx |
571 | pop ecx |
570 | pop ebx |
572 | pop ebx |
571 | xor eax,eax |
573 | xor eax,eax |
572 | ret |
574 | ret |
573 | 575 | ||
574 | .pid_found: |
576 | .pid_found: |
575 | shr ecx,5 |
577 | shr ecx,5 |
576 | mov eax,ecx ;convert offset to index of slot |
578 | mov eax,ecx ;convert offset to index of slot |
577 | pop ecx |
579 | pop ecx |
578 | pop ebx |
580 | pop ebx |
579 | ret |
581 | ret |
580 | 582 | ||
581 | check_region: |
583 | check_region: |
582 | ;input: |
584 | ;input: |
583 | ; ebx - start of buffer |
585 | ; ebx - start of buffer |
584 | ; ecx - size of buffer |
586 | ; ecx - size of buffer |
585 | ;result: |
587 | ;result: |
586 | ; eax = 1 region lays in app memory |
588 | ; eax = 1 region lays in app memory |
587 | ; eax = 0 region don't lays in app memory |
589 | ; eax = 0 region don't lays in app memory |
588 | mov eax,[CURRENT_TASK] |
590 | mov eax,[CURRENT_TASK] |
589 | jmp check_process_region |
591 | jmp check_process_region |
590 | ;----------------------------------------------------------------------------- |
592 | ;----------------------------------------------------------------------------- |
591 | check_process_region: |
593 | check_process_region: |
592 | ;input: |
594 | ;input: |
593 | ; eax - slot |
595 | ; eax - slot |
594 | ; ebx - start of buffer |
596 | ; ebx - start of buffer |
595 | ; ecx - size of buffer |
597 | ; ecx - size of buffer |
596 | ;result: |
598 | ;result: |
597 | ; eax = 1 region lays in app memory |
599 | ; eax = 1 region lays in app memory |
598 | ; eax = 0 region don't lays in app memory |
600 | ; eax = 0 region don't lays in app memory |
599 | 601 | ||
600 | test ecx,ecx |
602 | test ecx,ecx |
601 | jle .ok |
603 | jle .ok |
602 | shl eax,5 |
604 | shl eax,5 |
603 | cmp word [CURRENT_TASK+eax+0xa],0 |
605 | cmp word [CURRENT_TASK+eax+0xa],0 |
604 | jnz .failed |
606 | jnz .failed |
605 | shl eax,3 |
607 | shl eax,3 |
606 | mov eax,[SLOT_BASE+eax+0xb8] |
608 | mov eax,[SLOT_BASE+eax+0xb8] |
607 | test eax,eax |
609 | test eax,eax |
608 | jz .failed |
610 | jz .failed |
609 | 611 | ||
610 | mov eax,1 |
612 | mov eax,1 |
611 | ret |
613 | ret |
612 | 614 | ||
613 | 615 | ||
614 | ; call MEM_Get_Linear_Address |
616 | ; call MEM_Get_Linear_Address |
615 | ; push ebx |
617 | ; push ebx |
616 | ; push ecx |
618 | ; push ecx |
617 | ; push edx |
619 | ; push edx |
618 | ; mov edx,ebx |
620 | ; mov edx,ebx |
619 | ; and edx,not (4096-1) |
621 | ; and edx,not (4096-1) |
620 | ; sub ebx,edx |
622 | ; sub ebx,edx |
621 | ; add ecx,ebx |
623 | ; add ecx,ebx |
622 | ; mov ebx,edx |
624 | ; mov ebx,edx |
623 | ; add ecx,(4096-1) |
625 | ; add ecx,(4096-1) |
624 | ; and ecx,not (4096-1) |
626 | ; and ecx,not (4096-1) |
625 | ;.loop: |
627 | ;.loop: |
626 | ;;eax - linear address of page directory |
628 | ;;eax - linear address of page directory |
627 | ;;ebx - current page |
629 | ;;ebx - current page |
628 | ;;ecx - current size |
630 | ;;ecx - current size |
629 | ; mov edx,ebx |
631 | ; mov edx,ebx |
630 | ; shr edx,22 |
632 | ; shr edx,22 |
631 | ; mov edx,[eax+4*edx] |
633 | ; mov edx,[eax+4*edx] |
632 | ; and edx,not (4096-1) |
634 | ; and edx,not (4096-1) |
633 | ; test edx,edx |
635 | ; test edx,edx |
634 | ; jz .failed1 |
636 | ; jz .failed1 |
635 | ; push eax |
637 | ; push eax |
636 | ; mov eax,edx |
638 | ; mov eax,edx |
637 | ; call MEM_Get_Linear_Address |
639 | ; call MEM_Get_Linear_Address |
638 | ; mov edx,ebx |
640 | ; mov edx,ebx |
639 | ; shr edx,12 |
641 | ; shr edx,12 |
640 | ; and edx,(1024-1) |
642 | ; and edx,(1024-1) |
641 | ; mov eax,[eax+4*edx] |
643 | ; mov eax,[eax+4*edx] |
642 | ; and eax,not (4096-1) |
644 | ; and eax,not (4096-1) |
643 | ; test eax,eax |
645 | ; test eax,eax |
644 | ; pop eax |
646 | ; pop eax |
645 | ; jz .failed1 |
647 | ; jz .failed1 |
646 | ; add ebx,4096 |
648 | ; add ebx,4096 |
647 | ; sub ecx,4096 |
649 | ; sub ecx,4096 |
648 | ; jg .loop |
650 | ; jg .loop |
649 | ; pop edx |
651 | ; pop edx |
650 | ; pop ecx |
652 | ; pop ecx |
651 | ; pop ebx |
653 | ; pop ebx |
652 | .ok: |
654 | .ok: |
653 | mov eax,1 |
655 | mov eax,1 |
654 | ret |
656 | ret |
655 | ; |
657 | ; |
656 | ;.failed1: |
658 | ;.failed1: |
657 | ; pop edx |
659 | ; pop edx |
658 | ; pop ecx |
660 | ; pop ecx |
659 | ; pop ebx |
661 | ; pop ebx |
660 | .failed: |
662 | .failed: |
661 | xor eax,eax |
663 | xor eax,eax |
662 | ret |
664 | ret |
663 | 665 | ||
664 | align 4 |
666 | align 4 |
665 | proc read_process_memory |
667 | proc read_process_memory |
666 | ;Input: |
668 | ;Input: |
667 | ; eax - process slot |
669 | ; eax - process slot |
668 | ; ebx - buffer address |
670 | ; ebx - buffer address |
669 | ; ecx - buffer size |
671 | ; ecx - buffer size |
670 | ; edx - start address in other process |
672 | ; edx - start address in other process |
671 | ;Output: |
673 | ;Output: |
672 | ; eax - number of bytes read. |
674 | ; eax - number of bytes read. |
673 | locals |
675 | locals |
674 | slot dd ? |
676 | slot dd ? |
675 | buff dd ? |
677 | buff dd ? |
676 | r_count dd ? |
678 | r_count dd ? |
677 | offset dd ? |
679 | offset dd ? |
678 | tmp_r_cnt dd ? |
680 | tmp_r_cnt dd ? |
679 | endl |
681 | endl |
680 | 682 | ||
681 | mov [slot], eax |
683 | mov [slot], eax |
682 | mov [buff], ebx |
684 | mov [buff], ebx |
683 | mov [r_count], ecx |
685 | mov [r_count], ecx |
684 | mov [tmp_r_cnt], ecx |
686 | mov [tmp_r_cnt], ecx |
685 | mov [offset], edx |
687 | mov [offset], edx |
686 | 688 | ||
687 | pushad |
689 | pushad |
688 | .read_mem: |
690 | .read_mem: |
689 | mov edx, [offset] |
691 | mov edx, [offset] |
690 | mov ebx, [tmp_r_cnt] |
692 | mov ebx, [tmp_r_cnt] |
691 | 693 | ||
692 | mov ecx, 0x400000 |
694 | mov ecx, 0x400000 |
693 | and edx, 0x3FFFFF |
695 | and edx, 0x3FFFFF |
694 | sub ecx, edx |
696 | sub ecx, edx |
695 | cmp ecx, ebx |
697 | cmp ecx, ebx |
696 | jbe @f |
698 | jbe @f |
697 | mov ecx, ebx |
699 | mov ecx, ebx |
698 | @@: |
700 | @@: |
699 | cmp ecx, 0x8000 |
701 | cmp ecx, 0x8000 |
700 | jna @F |
702 | jna @F |
701 | mov ecx, 0x8000 |
703 | mov ecx, 0x8000 |
702 | @@: |
704 | @@: |
703 | mov eax, [slot] |
705 | mov eax, [slot] |
704 | shl eax,8 |
706 | shl eax,8 |
705 | mov ebx, [offset] |
707 | mov ebx, [offset] |
706 | ; add ebx, new_app_base |
708 | ; add ebx, new_app_base |
707 | push ecx |
709 | push ecx |
708 | stdcall map_memEx, [proc_mem_map],\ |
710 | stdcall map_memEx, [proc_mem_map],\ |
709 | [SLOT_BASE+eax+0xB8],\ |
711 | [SLOT_BASE+eax+0xB8],\ |
710 | ebx, ecx |
712 | ebx, ecx |
711 | pop ecx |
713 | pop ecx |
712 | 714 | ||
713 | mov esi, [offset] |
715 | mov esi, [offset] |
714 | and esi, 0xfff |
716 | and esi, 0xfff |
715 | add esi, [proc_mem_map] |
717 | add esi, [proc_mem_map] |
716 | mov edi, [buff] |
718 | mov edi, [buff] |
717 | mov edx, ecx |
719 | mov edx, ecx |
718 | rep movsb |
720 | rep movsb |
719 | 721 | ||
720 | add [offset], edx |
722 | add [offset], edx |
721 | sub [tmp_r_cnt], edx |
723 | sub [tmp_r_cnt], edx |
722 | jnz .read_mem |
724 | jnz .read_mem |
723 | 725 | ||
724 | popad |
726 | popad |
725 | mov eax, [r_count] |
727 | mov eax, [r_count] |
726 | ret |
728 | ret |
727 | endp |
729 | endp |
728 | 730 | ||
729 | align 4 |
731 | align 4 |
730 | proc write_process_memory |
732 | proc write_process_memory |
731 | ;Input: |
733 | ;Input: |
732 | ; eax - process slot |
734 | ; eax - process slot |
733 | ; ebx - buffer address |
735 | ; ebx - buffer address |
734 | ; ecx - buffer size |
736 | ; ecx - buffer size |
735 | ; edx - start address in other process |
737 | ; edx - start address in other process |
736 | ;Output: |
738 | ;Output: |
737 | ; eax - number of bytes written |
739 | ; eax - number of bytes written |
738 | 740 | ||
739 | locals |
741 | locals |
740 | slot dd ? |
742 | slot dd ? |
741 | buff dd ? |
743 | buff dd ? |
742 | w_count dd ? |
744 | w_count dd ? |
743 | offset dd ? |
745 | offset dd ? |
744 | tmp_w_cnt dd ? |
746 | tmp_w_cnt dd ? |
745 | endl |
747 | endl |
746 | 748 | ||
747 | mov [slot], eax |
749 | mov [slot], eax |
748 | mov [buff], ebx |
750 | mov [buff], ebx |
749 | mov [w_count], ecx |
751 | mov [w_count], ecx |
750 | mov [tmp_w_cnt], ecx |
752 | mov [tmp_w_cnt], ecx |
751 | mov [offset], edx |
753 | mov [offset], edx |
752 | 754 | ||
753 | pushad |
755 | pushad |
754 | .read_mem: |
756 | .read_mem: |
755 | mov edx, [offset] |
757 | mov edx, [offset] |
756 | mov ebx, [tmp_w_cnt] |
758 | mov ebx, [tmp_w_cnt] |
757 | 759 | ||
758 | mov ecx, 0x400000 |
760 | mov ecx, 0x400000 |
759 | and edx, 0x3FFFFF |
761 | and edx, 0x3FFFFF |
760 | sub ecx, edx |
762 | sub ecx, edx |
761 | cmp ecx, ebx |
763 | cmp ecx, ebx |
762 | jbe @f |
764 | jbe @f |
763 | mov ecx, ebx |
765 | mov ecx, ebx |
764 | @@: |
766 | @@: |
765 | cmp ecx, 0x8000 |
767 | cmp ecx, 0x8000 |
766 | jna @F |
768 | jna @F |
767 | mov ecx, 0x8000 |
769 | mov ecx, 0x8000 |
768 | @@: |
770 | @@: |
769 | mov eax, [slot] |
771 | mov eax, [slot] |
770 | shl eax,8 |
772 | shl eax,8 |
771 | mov ebx, [offset] |
773 | mov ebx, [offset] |
772 | ; add ebx, new_app_base |
774 | ; add ebx, new_app_base |
773 | push ecx |
775 | push ecx |
774 | stdcall map_memEx, [proc_mem_map],\ |
776 | stdcall map_memEx, [proc_mem_map],\ |
775 | [SLOT_BASE+eax+0xB8],\ |
777 | [SLOT_BASE+eax+0xB8],\ |
776 | ebx, ecx |
778 | ebx, ecx |
777 | pop ecx |
779 | pop ecx |
778 | 780 | ||
779 | mov edi, [offset] |
781 | mov edi, [offset] |
780 | and edi, 0xfff |
782 | and edi, 0xfff |
781 | add edi, [proc_mem_map] |
783 | add edi, [proc_mem_map] |
782 | mov esi, [buff] |
784 | mov esi, [buff] |
783 | mov edx, ecx |
785 | mov edx, ecx |
784 | rep movsb |
786 | rep movsb |
785 | 787 | ||
786 | add [offset], edx |
788 | add [offset], edx |
787 | sub [tmp_w_cnt], edx |
789 | sub [tmp_w_cnt], edx |
788 | jnz .read_mem |
790 | jnz .read_mem |
789 | 791 | ||
790 | popad |
792 | popad |
791 | mov eax, [w_count] |
793 | mov eax, [w_count] |
792 | ret |
794 | ret |
793 | endp |
795 | endp |
794 | 796 | ||
795 | align 4 |
797 | align 4 |
796 | proc new_sys_threads |
798 | proc new_sys_threads |
797 | locals |
799 | locals |
798 | slot dd ? |
800 | slot dd ? |
799 | app_cmdline dd ? ;0x00 |
801 | app_cmdline dd ? ;0x00 |
800 | app_path dd ? ;0x04 |
802 | app_path dd ? ;0x04 |
801 | app_eip dd ? ;0x08 |
803 | app_eip dd ? ;0x08 |
802 | app_esp dd ? ;0x0C |
804 | app_esp dd ? ;0x0C |
803 | app_mem dd ? ;0x10 |
805 | app_mem dd ? ;0x10 |
804 | endl |
806 | endl |
805 | 807 | ||
806 | cmp eax,1 |
808 | cmp eax,1 |
807 | jne .failed ;other subfunctions |
809 | jne .failed ;other subfunctions |
808 | 810 | ||
809 | xor eax,eax |
811 | xor eax,eax |
810 | mov [app_cmdline], eax |
812 | mov [app_cmdline], eax |
811 | mov [app_path], eax |
813 | mov [app_path], eax |
812 | mov [app_eip], ebx |
814 | mov [app_eip], ebx |
813 | mov [app_esp], ecx |
815 | mov [app_esp], ecx |
814 | 816 | ||
815 | ;mov esi,new_process_loading |
817 | ;mov esi,new_process_loading |
816 | ;call sys_msg_board_str |
818 | ;call sys_msg_board_str |
817 | DEBUGF 1,"%s",new_process_loading |
819 | DEBUGF 1,"%s",new_process_loading |
818 | .wait_lock: |
820 | .wait_lock: |
819 | cmp [application_table_status],0 |
821 | cmp [application_table_status],0 |
820 | je .get_lock |
822 | je .get_lock |
821 | call change_task |
823 | call change_task |
822 | jmp .wait_lock |
824 | jmp .wait_lock |
823 | 825 | ||
824 | .get_lock: |
826 | .get_lock: |
825 | mov eax, 1 |
827 | mov eax, 1 |
826 | xchg eax, [application_table_status] |
828 | xchg eax, [application_table_status] |
827 | cmp eax, 0 |
829 | cmp eax, 0 |
828 | jne .wait_lock |
830 | jne .wait_lock |
829 | 831 | ||
830 | call set_application_table_status |
832 | call set_application_table_status |
831 | 833 | ||
832 | call get_new_process_place |
834 | call get_new_process_place |
833 | test eax, eax |
835 | test eax, eax |
834 | jz .failed |
836 | jz .failed |
835 | 837 | ||
836 | mov [slot], eax |
838 | mov [slot], eax |
837 | 839 | ||
838 | mov esi,[current_slot] |
840 | mov esi,[current_slot] |
839 | mov ebx,esi ;ebx=esi - pointer to extended information about current thread |
841 | mov ebx,esi ;ebx=esi - pointer to extended information about current thread |
840 | 842 | ||
841 | mov edi, eax |
843 | mov edi, eax |
842 | shl edi,8 |
844 | shl edi,8 |
843 | add edi,SLOT_BASE |
845 | add edi,SLOT_BASE |
844 | mov edx,edi ;edx=edi - pointer to extended infomation about new thread |
846 | mov edx,edi ;edx=edi - pointer to extended infomation about new thread |
845 | mov ecx,256/4 |
847 | mov ecx,256/4 |
846 | xor eax, eax |
848 | xor eax, eax |
847 | cld |
849 | cld |
848 | rep stosd ;clean extended information about new thread |
850 | rep stosd ;clean extended information about new thread |
849 | mov esi,ebx |
851 | mov esi,ebx |
850 | mov edi,edx |
852 | mov edi,edx |
851 | mov ecx,11 |
853 | mov ecx,11 |
852 | rep movsb ;copy process name |
854 | rep movsb ;copy process name |
853 | 855 | ||
854 | mov eax,[ebx+APPDATA.heap_base] |
856 | mov eax,[ebx+APPDATA.heap_base] |
855 | mov [edx+APPDATA.heap_base], eax |
857 | mov [edx+APPDATA.heap_base], eax |
856 | 858 | ||
857 | mov ecx,[ebx+APPDATA.heap_top] |
859 | mov ecx,[ebx+APPDATA.heap_top] |
858 | mov [edx+APPDATA.heap_top], ecx |
860 | mov [edx+APPDATA.heap_top], ecx |
859 | 861 | ||
860 | mov eax,[ebx+APPDATA.mem_size] |
862 | mov eax,[ebx+APPDATA.mem_size] |
861 | mov [edx+APPDATA.mem_size], eax |
863 | mov [edx+APPDATA.mem_size], eax |
862 | 864 | ||
863 | mov ecx,[ebx+APPDATA.dir_table] |
865 | mov ecx,[ebx+APPDATA.dir_table] |
864 | mov [edx+APPDATA.dir_table],ecx ;copy page directory |
866 | mov [edx+APPDATA.dir_table],ecx ;copy page directory |
865 | 867 | ||
866 | lea eax, [app_cmdline] |
868 | lea eax, [app_cmdline] |
867 | stdcall set_app_params ,[slot],eax,dword 0,\ |
869 | stdcall set_app_params ,[slot],eax,dword 0,\ |
868 | dword 0,dword 0 |
870 | dword 0,dword 0 |
869 | 871 | ||
870 | ;mov esi,new_process_running |
872 | ;mov esi,new_process_running |
871 | ;call sys_msg_board_str ;output information about succefull startup |
873 | ;call sys_msg_board_str ;output information about succefull startup |
872 | DEBUGF 1,"%s",new_process_running |
874 | DEBUGF 1,"%s",new_process_running |
873 | 875 | ||
874 | mov [application_table_status],0 ;unlock application_table_status mutex |
876 | mov [application_table_status],0 ;unlock application_table_status mutex |
875 | mov eax,[process_number] ;set result |
877 | mov eax,[process_number] ;set result |
876 | ret |
878 | ret |
877 | .failed: |
879 | .failed: |
878 | mov [application_table_status],0 |
880 | mov [application_table_status],0 |
879 | mov eax,-1 |
881 | mov eax,-1 |
880 | ret |
882 | ret |
881 | endp |
883 | endp |
882 | 884 | ||
883 | ; param |
885 | ; param |
884 | ; ebx=mutex |
886 | ; ebx=mutex |
885 | 887 | ||
886 | align 4 |
888 | align 4 |
887 | wait_mutex: |
889 | wait_mutex: |
888 | push eax |
890 | push eax |
889 | push ebx |
891 | push ebx |
890 | .do_wait: |
892 | .do_wait: |
891 | cmp dword [ebx],0 |
893 | cmp dword [ebx],0 |
892 | je .get_lock |
894 | je .get_lock |
893 | call change_task |
895 | call change_task |
894 | jmp .do_wait |
896 | jmp .do_wait |
895 | .get_lock: |
897 | .get_lock: |
896 | mov eax, 1 |
898 | mov eax, 1 |
897 | xchg eax, [ebx] |
899 | xchg eax, [ebx] |
898 | test eax, eax |
900 | test eax, eax |
899 | jnz .do_wait |
901 | jnz .do_wait |
900 | pop ebx |
902 | pop ebx |
901 | pop eax |
903 | pop eax |
902 | ret |
904 | ret |
903 | 905 | ||
904 | EFL_IF equ 0x0200 |
906 | EFL_IF equ 0x0200 |
905 | EFL_IOPL1 equ 0x1000 |
907 | EFL_IOPL1 equ 0x1000 |
906 | EFL_IOPL2 equ 0x2000 |
908 | EFL_IOPL2 equ 0x2000 |
907 | EFL_IOPL3 equ 0x3000 |
909 | EFL_IOPL3 equ 0x3000 |
908 | 910 | ||
909 | 911 | ||
910 | align 4 |
912 | align 4 |
911 | proc set_app_params stdcall,slot:dword, params:dword,\ |
913 | proc set_app_params stdcall,slot:dword, params:dword,\ |
912 | cmd_line:dword, app_path:dword, flags:dword |
914 | cmd_line:dword, app_path:dword, flags:dword |
913 | 915 | ||
914 | locals |
916 | locals |
915 | pl0_stack dd ? |
917 | pl0_stack dd ? |
916 | endl |
918 | endl |
917 | 919 | ||
918 | stdcall kernel_alloc, RING0_STACK_SIZE+512 |
920 | stdcall kernel_alloc, RING0_STACK_SIZE+512 |
919 | mov [pl0_stack], eax |
921 | mov [pl0_stack], eax |
920 | 922 | ||
921 | lea edi, [eax+RING0_STACK_SIZE] |
923 | lea edi, [eax+RING0_STACK_SIZE] |
922 | 924 | ||
923 | mov eax, [slot] |
925 | mov eax, [slot] |
924 | mov ebx, eax |
926 | mov ebx, eax |
925 | 927 | ||
926 | shl eax, 8 |
928 | shl eax, 8 |
927 | mov [eax+SLOT_BASE+APPDATA.fpu_state], edi |
929 | mov [eax+SLOT_BASE+APPDATA.fpu_state], edi |
928 | mov [eax+SLOT_BASE+APPDATA.fpu_handler], 0 |
930 | mov [eax+SLOT_BASE+APPDATA.fpu_handler], 0 |
929 | mov [eax+SLOT_BASE+APPDATA.sse_handler], 0 |
931 | mov [eax+SLOT_BASE+APPDATA.sse_handler], 0 |
930 | 932 | ||
931 | ;set default io permission map |
933 | ;set default io permission map |
932 | mov [eax+SLOT_BASE+APPDATA.io_map],\ |
934 | mov [eax+SLOT_BASE+APPDATA.io_map],\ |
933 | (tss._io_map_0-OS_BASE+PG_MAP) |
935 | (tss._io_map_0-OS_BASE+PG_MAP) |
934 | mov [eax+SLOT_BASE+APPDATA.io_map+4],\ |
936 | mov [eax+SLOT_BASE+APPDATA.io_map+4],\ |
935 | (tss._io_map_1-OS_BASE+PG_MAP) |
937 | (tss._io_map_1-OS_BASE+PG_MAP) |
936 | 938 | ||
937 | mov esi, fpu_data |
939 | mov esi, fpu_data |
938 | mov ecx, 512/4 |
940 | mov ecx, 512/4 |
939 | rep movsd |
941 | rep movsd |
940 | 942 | ||
941 | cmp ebx,[TASK_COUNT] |
943 | cmp ebx,[TASK_COUNT] |
942 | jle .noinc |
944 | jle .noinc |
943 | inc dword [TASK_COUNT] ;update number of processes |
945 | inc dword [TASK_COUNT] ;update number of processes |
944 | .noinc: |
946 | .noinc: |
945 | shl ebx,8 |
947 | shl ebx,8 |
946 | lea edx, [ebx+SLOT_BASE+APP_EV_OFFSET] |
948 | lea edx, [ebx+SLOT_BASE+APP_EV_OFFSET] |
947 | mov [SLOT_BASE+APPDATA.fd_ev+ebx],edx |
949 | mov [SLOT_BASE+APPDATA.fd_ev+ebx],edx |
948 | mov [SLOT_BASE+APPDATA.bk_ev+ebx],edx |
950 | mov [SLOT_BASE+APPDATA.bk_ev+ebx],edx |
949 | 951 | ||
950 | add edx, APP_OBJ_OFFSET-APP_EV_OFFSET |
952 | add edx, APP_OBJ_OFFSET-APP_EV_OFFSET |
951 | mov [SLOT_BASE+APPDATA.fd_obj+ebx],edx |
953 | mov [SLOT_BASE+APPDATA.fd_obj+ebx],edx |
952 | mov [SLOT_BASE+APPDATA.bk_obj+ebx],edx |
954 | mov [SLOT_BASE+APPDATA.bk_obj+ebx],edx |
953 | 955 | ||
954 | mov ecx, [def_cursor] |
956 | mov ecx, [def_cursor] |
955 | mov [SLOT_BASE+APPDATA.cursor+ebx],ecx |
957 | mov [SLOT_BASE+APPDATA.cursor+ebx],ecx |
956 | mov eax, [pl0_stack] |
958 | mov eax, [pl0_stack] |
957 | mov [SLOT_BASE+APPDATA.pl0_stack+ebx],eax |
959 | mov [SLOT_BASE+APPDATA.pl0_stack+ebx],eax |
958 | 960 | ||
959 | shr ebx,3 |
961 | shr ebx,3 |
960 | mov eax, new_app_base |
962 | mov eax, new_app_base |
961 | mov dword [CURRENT_TASK+ebx+0x10],eax |
963 | mov dword [CURRENT_TASK+ebx+0x10],eax |
962 | 964 | ||
963 | .add_command_line: |
965 | .add_command_line: |
964 | mov edx,[params] |
966 | mov edx,[params] |
965 | mov edx,[edx] ;app_cmdline |
967 | mov edx,[edx] ;app_cmdline |
966 | test edx,edx |
968 | test edx, [cmd_line] ;check both src & dst |
967 | jz @F ;application don't need parameters |
969 | jz @F ;application don't need parameters |
968 | 970 | ||
969 | mov eax, edx |
971 | mov eax, edx |
970 | add eax, 256 |
972 | add eax, 256 |
971 | jc @f |
973 | jc @f |
972 | 974 | ||
973 | cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] |
975 | cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] |
974 | ja @f |
976 | ja @f |
975 | 977 | ||
976 | stdcall k_strncpy, edx, [cmd_line], 256 |
978 | stdcall strncpy, edx, [cmd_line], 256 |
977 | @@: |
979 | @@: |
978 | mov edx,[params] |
980 | mov edx,[params] |
979 | mov edx, [edx+4] ;app_path |
981 | mov edx, [edx+4] ;app_path |
980 | test edx,edx |
982 | test edx,edx |
981 | jz @F ;application don't need path of file |
983 | jz @F ;application don't need path of file |
982 | mov eax, edx |
984 | mov eax, edx |
983 | add eax, 1024 |
985 | add eax, 1024 |
984 | jc @f |
986 | jc @f |
985 | cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] |
987 | cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8] |
986 | ja @f |
988 | ja @f |
987 | stdcall k_strncpy, edx, [app_path], 1024 |
989 | stdcall strncpy, edx, [app_path], 1024 |
988 | @@: |
990 | @@: |
989 | mov ebx,[slot] |
991 | mov ebx,[slot] |
990 | mov eax,ebx |
992 | mov eax,ebx |
991 | shl ebx,5 |
993 | shl ebx,5 |
992 | lea ecx,[draw_data+ebx] ;ecx - pointer to draw data |
994 | lea ecx,[draw_data+ebx] ;ecx - pointer to draw data |
993 | 995 | ||
994 | ; set window state to 'normal' (non-minimized/maximized/rolled-up) state |
996 | ; set window state to 'normal' (non-minimized/maximized/rolled-up) state |
995 | mov [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL |
997 | mov [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL |
996 | mov [ebx+window_data+WDATA.fl_redraw], 1 |
998 | mov [ebx+window_data+WDATA.fl_redraw], 1 |
997 | add ebx,CURRENT_TASK ;ebx - pointer to information about process |
999 | add ebx,CURRENT_TASK ;ebx - pointer to information about process |
998 | mov [ebx+TASKDATA.wnd_number],al;set window number on screen = process slot |
1000 | mov [ebx+TASKDATA.wnd_number],al;set window number on screen = process slot |
999 | 1001 | ||
1000 | mov [ebx+TASKDATA.event_mask],dword 1+2+4 ;set default event flags (see 40 function) |
1002 | mov [ebx+TASKDATA.event_mask],dword 1+2+4 ;set default event flags (see 40 function) |
1001 | 1003 | ||
1002 | inc dword [process_number] |
1004 | inc dword [process_number] |
1003 | mov eax,[process_number] |
1005 | mov eax,[process_number] |
1004 | mov [ebx+4],eax ;set PID |
1006 | mov [ebx+4],eax ;set PID |
1005 | 1007 | ||
1006 | ;set draw data to full screen |
1008 | ;set draw data to full screen |
1007 | 1009 | ||
1008 | mov [ecx+0],dword 0 |
1010 | mov [ecx+0],dword 0 |
1009 | mov [ecx+4],dword 0 |
1011 | mov [ecx+4],dword 0 |
1010 | mov eax,[ScreenWidth] |
1012 | mov eax,[ScreenWidth] |
1011 | mov [ecx+8],eax |
1013 | mov [ecx+8],eax |
1012 | mov eax,[ScreenHeight] |
1014 | mov eax,[ScreenHeight] |
1013 | mov [ecx+12],eax |
1015 | mov [ecx+12],eax |
1014 | 1016 | ||
1015 | mov ebx, [pl0_stack] |
1017 | mov ebx, [pl0_stack] |
1016 | mov esi,[params] |
1018 | mov esi,[params] |
1017 | lea ecx, [ebx+REG_EIP] |
1019 | lea ecx, [ebx+REG_EIP] |
1018 | xor eax, eax |
1020 | xor eax, eax |
1019 | 1021 | ||
1020 | mov [ebx+REG_RET], dword irq0.return |
1022 | mov [ebx+REG_RET], dword irq0.return |
1021 | mov [ebx+REG_EDI], eax |
1023 | mov [ebx+REG_EDI], eax |
1022 | mov [ebx+REG_ESI], eax |
1024 | mov [ebx+REG_ESI], eax |
1023 | mov [ebx+REG_EBP], eax |
1025 | mov [ebx+REG_EBP], eax |
1024 | mov [ebx+REG_ESP], ecx ;ebx+REG_EIP |
1026 | mov [ebx+REG_ESP], ecx ;ebx+REG_EIP |
1025 | mov [ebx+REG_EBX], eax |
1027 | mov [ebx+REG_EBX], eax |
1026 | mov [ebx+REG_EDX], eax |
1028 | mov [ebx+REG_EDX], eax |
1027 | mov [ebx+REG_ECX], eax |
1029 | mov [ebx+REG_ECX], eax |
1028 | mov [ebx+REG_EAX], eax |
1030 | mov [ebx+REG_EAX], eax |
1029 | 1031 | ||
1030 | mov eax, [esi+0x08] ;app_eip |
1032 | mov eax, [esi+0x08] ;app_eip |
1031 | mov [ebx+REG_EIP], eax ;app_entry |
1033 | mov [ebx+REG_EIP], eax ;app_entry |
1032 | mov [ebx+REG_CS], dword app_code |
1034 | mov [ebx+REG_CS], dword app_code |
1033 | mov [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF |
1035 | mov [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF |
1034 | 1036 | ||
1035 | mov eax, [esi+0x0C] ;app_esp |
1037 | mov eax, [esi+0x0C] ;app_esp |
1036 | mov [ebx+REG_APP_ESP], eax ;app_stack |
1038 | mov [ebx+REG_APP_ESP], eax ;app_stack |
1037 | mov [ebx+REG_SS], dword app_data |
1039 | mov [ebx+REG_SS], dword app_data |
1038 | 1040 | ||
1039 | lea ecx, [ebx+REG_RET] |
1041 | lea ecx, [ebx+REG_RET] |
1040 | mov ebx, [slot] |
1042 | mov ebx, [slot] |
1041 | shl ebx, 8 |
1043 | shl ebx, 8 |
1042 | mov [ebx+SLOT_BASE+APPDATA.saved_esp], ecx |
1044 | mov [ebx+SLOT_BASE+APPDATA.saved_esp], ecx |
1043 | 1045 | ||
1044 | ;flush keyboard and buttons queue |
1046 | ;flush keyboard and buttons queue |
1045 | mov [KEY_COUNT],byte 0 |
1047 | mov [KEY_COUNT],byte 0 |
1046 | mov [BTN_COUNT],byte 0 |
1048 | mov [BTN_COUNT],byte 0 |
1047 | 1049 | ||
1048 | mov edi,[slot] |
1050 | mov edi,[slot] |
1049 | shl edi,5 |
1051 | shl edi,5 |
1050 | add edi,window_data |
1052 | add edi,window_data |
1051 | mov ebx,[slot] |
1053 | mov ebx,[slot] |
1052 | movzx esi,word [WIN_STACK+ebx*2] |
1054 | movzx esi,word [WIN_STACK+ebx*2] |
1053 | lea esi,[WIN_POS+esi*2] |
1055 | lea esi,[WIN_POS+esi*2] |
1054 | call windowactivate ;gui initialization |
1056 | call windowactivate ;gui initialization |
1055 | 1057 | ||
1056 | mov ebx,[slot] |
1058 | mov ebx,[slot] |
1057 | shl ebx,5 |
1059 | shl ebx,5 |
1058 | mov [CURRENT_TASK+ebx+0xa],byte 0 ;set process state - running |
1060 | mov [CURRENT_TASK+ebx+0xa],byte 0 ;set process state - running |
1059 | ; set if debuggee |
1061 | ; set if debuggee |
1060 | mov eax, [flags] |
1062 | mov eax, [flags] |
1061 | test byte [flags], 1 |
1063 | test byte [flags], 1 |
1062 | jz .no_debug |
1064 | jz .no_debug |
1063 | mov [CURRENT_TASK+ebx+0xa],byte 1 ;set process state - suspended |
1065 | mov [CURRENT_TASK+ebx+0xa],byte 1 ;set process state - suspended |
1064 | mov eax,[CURRENT_TASK] |
1066 | mov eax,[CURRENT_TASK] |
1065 | mov [SLOT_BASE+ebx*8+0xac],eax ;set debugger PID - current |
1067 | mov [SLOT_BASE+ebx*8+0xac],eax ;set debugger PID - current |
1066 | .no_debug: |
1068 | .no_debug: |
1067 | ;mov esi,new_process_running |
1069 | ;mov esi,new_process_running |
1068 | ;call sys_msg_board_str ;output information about succefull startup |
1070 | ;call sys_msg_board_str ;output information about succefull startup |
1069 | DEBUGF 1,"%s",new_process_running |
1071 | DEBUGF 1,"%s",new_process_running |
1070 | ret |
1072 | ret |
1071 | endp |
1073 | endp |
1072 | 1074 | ||
1073 | include "debug.inc"256 |
1075 | include "debug.inc"256 |
1074 | >> |
1076 | >> |