Rev 8093 | Rev 8593 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8093 | Rev 8592 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2016. 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 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 8093 $ |
8 | $Revision: 8592 $ |
Line 9... | Line 9... | ||
9 | 9 | ||
Line 80... | Line 80... | ||
80 | ; ebx -> absolute file path |
80 | ; ebx -> absolute file path |
81 | ; eax = string length |
81 | ; eax = string length |
82 | locals |
82 | locals |
83 | cmdline rd 1 |
83 | cmdline rd 1 |
84 | flags rd 1 |
84 | flags rd 1 |
85 | slot rd 1 |
85 | slot rd 1 ; number of new thread slot |
86 | slot_base rd 1 |
86 | slot_base rd 1 ; base address of it |
87 | ; app header data |
87 | ; app header data |
88 | hdr_cmdline rd 1 |
88 | hdr_cmdline rd 1 |
89 | hdr_path rd 1 |
89 | hdr_path rd 1 |
90 | hdr_eip rd 1 |
90 | hdr_eip rd 1 |
91 | hdr_esp rd 1 |
91 | hdr_esp rd 1 |
Line 110... | Line 110... | ||
110 | jz .err_file |
110 | jz .err_file |
Line 111... | Line 111... | ||
111 | 111 | ||
112 | mov [file_base], eax |
112 | mov [file_base], eax |
113 | mov [file_size], ebx |
113 | mov [file_size], ebx |
114 | lea ebx, [hdr_cmdline] |
114 | lea ebx, [hdr_cmdline] |
115 | call test_app_header |
115 | call test_app_header ; fill our app header data locals with values from given application header (if its correct) |
116 | mov esi, -0x1F |
116 | mov esi, -0x1F |
117 | test eax, eax |
117 | test eax, eax |
Line 118... | Line 118... | ||
118 | jz .err_hdr |
118 | jz .err_hdr |
119 | 119 | ||
120 | call lock_application_table |
120 | call lock_application_table |
121 | call alloc_thread_slot |
121 | call alloc_thread_slot ; create a slot for new thread |
122 | mov esi, -0x20 ; too many processes |
122 | mov esi, -0x20 ; too many processes |
Line 123... | Line 123... | ||
123 | test eax, eax |
123 | test eax, eax |
Line 130... | Line 130... | ||
130 | ; clean extended information about process |
130 | ; clean extended information about process |
131 | mov ecx, sizeof.APPDATA/4 |
131 | mov ecx, sizeof.APPDATA/4 |
132 | xor eax, eax |
132 | xor eax, eax |
133 | cld |
133 | cld |
134 | rep stosd |
134 | rep stosd |
135 | ; write application name |
135 | ; write application name ( APPDATA.appname ) |
136 | stdcall strrchr, [path_string], '/' |
136 | stdcall strrchr, [path_string], '/' |
137 | lea esi, [eax+1] ; -> name without path |
137 | lea esi, [eax+1] ; -> name without path |
138 | mov ecx, 11 |
138 | mov ecx, 11 |
139 | mov edi, [slot_base] |
139 | mov edi, [slot_base] |
140 | @@: |
140 | @@: |
Line 153... | Line 153... | ||
153 | jz @f |
153 | jz @f |
154 | mov ecx, 65535 |
154 | mov ecx, 65535 |
155 | call _strnlen |
155 | call _strnlen |
156 | cmp eax, 256 |
156 | cmp eax, 256 |
157 | jb @f |
157 | jb @f |
- | 158 | ; if cmdline length >= 256 then increase needed memory size by this length |
|
158 | lea ebx, [eax+1] |
159 | lea ebx, [eax+1] |
159 | add [hdr_emem], ebx |
160 | add [hdr_emem], ebx |
160 | @@: |
161 | @@: |
161 | mov [cmdline_size], eax |
162 | mov [cmdline_size], eax |
162 | stdcall create_process, [hdr_emem] |
163 | stdcall create_process, [hdr_emem] ; create a new process |
163 | mov esi, -30 ; no memory |
164 | mov esi, -30 ; no memory |
164 | test eax, eax |
165 | test eax, eax |
165 | jz .err_hdr |
166 | jz .err_hdr |
Line -... | Line 167... | ||
- | 167 | ||
166 | 168 | ; add new process to the list |
|
167 | mov ebx, [sys_proc+LHEAD.prev] |
169 | mov ebx, [sys_proc+LHEAD.prev] |
- | 170 | __list_add eax, ebx, sys_proc |
|
168 | __list_add eax, ebx, sys_proc |
171 | ; fill the structure fields: |
169 | mov ebx, [hdr_emem] |
172 | mov ebx, [hdr_emem] |
- | 173 | mov [eax+PROC.mem_used], ebx |
|
- | 174 | ||
170 | mov [eax+PROC.mem_used], ebx |
175 | ; write that main thread of app belongs to new process |
171 | mov ebx, [slot_base] |
176 | mov ebx, [slot_base] |
- | 177 | mov [ebx+APPDATA.process], eax |
|
- | 178 | ||
172 | mov [ebx+APPDATA.process], eax |
179 | ; initialize the thread list of process: at this moment it consists only of one main thread |
173 | lea edx, [ebx+APPDATA.list] |
180 | lea edx, [ebx+APPDATA.list] |
174 | lea ecx, [eax+PROC.thr_list] |
181 | lea ecx, [eax+PROC.thr_list] |
- | 182 | list_add_tail edx, ecx |
|
- | 183 | ||
175 | list_add_tail edx, ecx |
184 | ; allocate space and copy app header data locals and cmdline string there, put pointer to exec_params of new thread |
176 | mov eax, [cmdline_size] |
185 | mov eax, [cmdline_size] |
177 | add eax, sizeof.APP_HDR |
186 | add eax, sizeof.APP_HDR |
178 | stdcall kernel_alloc, eax |
187 | stdcall kernel_alloc, eax |
179 | mov [ebx+APPDATA.exec_params], eax |
188 | mov [ebx+APPDATA.exec_params], eax |
Line 182... | Line 191... | ||
182 | mov ecx, sizeof.APP_HDR/4 |
191 | mov ecx, sizeof.APP_HDR/4 |
183 | rep movsd |
192 | rep movsd |
184 | mov ecx, [cmdline_size] |
193 | mov ecx, [cmdline_size] |
185 | mov esi, [cmdline] |
194 | mov esi, [cmdline] |
186 | rep movsb |
195 | rep movsb |
- | 196 | ; set other parameters of application |
|
187 | lea eax, [hdr_cmdline] |
197 | lea eax, [hdr_cmdline] |
188 | stdcall set_app_params , [slot], eax, [flags] |
198 | stdcall set_app_params , [slot], eax, [flags] |
189 | mov eax, [process_number] ;set result |
199 | mov eax, [process_number] ; return process number |
190 | call unlock_application_table |
200 | call unlock_application_table |
191 | ret |
201 | ret |
Line 192... | Line 202... | ||
192 | 202 | ||
193 | .err_0: |
203 | .err_0: |