Rev 9734 | Rev 10016 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9734 | Rev 9894 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
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 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
7 | 7 | ||
8 | $Revision: 9734 $ |
8 | $Revision: 9894 $ |
9 | 9 | ||
10 | ERROR_SUCCESS = 0 |
10 | ERROR_SUCCESS = 0 |
11 | ERROR_DISK_BASE = 1 |
11 | ERROR_DISK_BASE = 1 |
12 | ERROR_UNSUPPORTED_FS = 2 |
12 | ERROR_UNSUPPORTED_FS = 2 |
13 | ERROR_UNKNOWN_FS = 3 |
13 | ERROR_UNKNOWN_FS = 3 |
14 | ERROR_PARTITION = 4 |
14 | ERROR_PARTITION = 4 |
15 | ERROR_FILE_NOT_FOUND = 5 |
15 | ERROR_FILE_NOT_FOUND = 5 |
16 | ERROR_END_OF_FILE = 6 |
16 | ERROR_END_OF_FILE = 6 |
17 | ERROR_MEMORY_POINTER = 7 |
17 | ERROR_MEMORY_POINTER = 7 |
18 | ERROR_DISK_FULL = 8 |
18 | ERROR_DISK_FULL = 8 |
19 | ERROR_FS_FAIL = 9 |
19 | ERROR_FS_FAIL = 9 |
20 | ERROR_ACCESS_DENIED = 10 |
20 | ERROR_ACCESS_DENIED = 10 |
21 | ERROR_DEVICE = 11 |
21 | ERROR_DEVICE = 11 |
22 | 22 | ||
23 | maxPathLength = 1000h |
23 | maxPathLength = 1000h |
24 | 24 | ||
25 | image_of_eax EQU esp+32 |
25 | image_of_eax EQU esp+32 |
26 | image_of_ebx EQU esp+20 |
26 | image_of_ebx EQU esp+20 |
- | 27 | ||
- | 28 | ; fs api for drivers |
|
- | 29 | struct FileSystem |
|
- | 30 | Next dd ? |
|
- | 31 | Prev dd ? |
|
- | 32 | Creat_part dd ? ; %FSNAME%_create_partition |
|
- | 33 | UserFuncs dd ? ; for fs_del |
|
- | 34 | Name rd 16 ;ascii string + \n |
|
- | 35 | ends |
|
- | 36 | ||
- | 37 | ||
- | 38 | fs_list: |
|
- | 39 | dd fs_list |
|
- | 40 | dd fs_list |
|
- | 41 | ;.look: dd 0 |
|
- | 42 | ||
- | 43 | ; IN: ecx = %FSNAME%_create_partition |
|
- | 44 | ; edx = ptr to UserFuncs |
|
- | 45 | ; [esp] = fs name |
|
- | 46 | ;OUT: eax = list item |
|
- | 47 | fs_add: |
|
- | 48 | push ecx edx |
|
- | 49 | ; add in fs_list |
|
- | 50 | mov eax, sizeof.FileSystem |
|
- | 51 | call malloc |
|
- | 52 | pop edx ecx |
|
- | 53 | test eax, eax |
|
- | 54 | jz .err |
|
- | 55 | ||
- | 56 | mov [eax + FileSystem.Creat_part], ecx |
|
- | 57 | mov [eax + FileSystem.UserFuncs], edx |
|
- | 58 | mov edx, [esp + 4] |
|
- | 59 | mov [eax + FileSystem.Name], edx |
|
- | 60 | mov edx, eax |
|
- | 61 | ||
- | 62 | cli ; DELETE |
|
- | 63 | list_add_tail edx, fs_list |
|
- | 64 | sti ; DELETE |
|
- | 65 | mov edx, ecx ; save function |
|
- | 66 | ||
- | 67 | ;DEBUGF 1, 'K : FS: find partition\n' |
|
- | 68 | ; check all disks |
|
- | 69 | mov esi, [disk_list] |
|
- | 70 | .new_disk: |
|
- | 71 | cmp dword[esi], disk_list |
|
- | 72 | jz .end |
|
- | 73 | ||
- | 74 | push edx |
|
- | 75 | mov eax, [esi + DISK.MediaInfo.SectorSize] |
|
- | 76 | shl eax, 2 |
|
- | 77 | stdcall kernel_alloc, eax ;get buffer |
|
- | 78 | test eax, eax |
|
- | 79 | pop edx |
|
- | 80 | jz .end ; no memory |
|
- | 81 | mov ebx, eax |
|
- | 82 | ||
- | 83 | mov ecx, [esi + DISK.NumPartitions] |
|
- | 84 | dec ecx |
|
- | 85 | shl ecx, 2 ; to dword |
|
- | 86 | add ecx, [esi + DISK.Partitions] |
|
- | 87 | @@: |
|
- | 88 | mov ebp, [ecx] |
|
- | 89 | cmp [ebp + PARTITION.FSUserFunctions], default_fs_functions |
|
- | 90 | jnz .no_fs |
|
- | 91 | ||
- | 92 | ;DEBUGF 1, 'K : FS: found partition\n' |
|
- | 93 | push ecx edx |
|
- | 94 | ||
- | 95 | xor eax, eax ; first sector of the partition |
|
- | 96 | call fs_read32_sys |
|
- | 97 | push eax |
|
- | 98 | ;DEBUGF 1, 'K : FS: call driver func = %x\n', edx |
|
- | 99 | ||
- | 100 | call edx ; creat_partition |
|
- | 101 | add esp, 4 |
|
- | 102 | ;DEBUGF 1, 'K : FS: end call\n' |
|
- | 103 | pop edx ecx |
|
- | 104 | ||
- | 105 | test eax, eax |
|
- | 106 | jz .no_fs |
|
- | 107 | ; save and delete old struct |
|
- | 108 | xchg [ecx], eax |
|
- | 109 | push ecx edx |
|
- | 110 | call free |
|
- | 111 | pop edx ecx |
|
- | 112 | ;DEBUGF 1, 'K : FS: set fs for partition\n' |
|
- | 113 | .no_fs: |
|
- | 114 | ;sub ecx, 4 |
|
- | 115 | cmp ecx, [esi + DISK.Partitions] |
|
- | 116 | lea ecx, [ecx - 4] |
|
- | 117 | jnz @b |
|
- | 118 | ||
- | 119 | push edx |
|
- | 120 | stdcall kernel_free, ebx |
|
- | 121 | pop edx |
|
- | 122 | ||
- | 123 | mov esi, [esi] |
|
- | 124 | jmp .new_disk |
|
- | 125 | .end: |
|
- | 126 | .err: |
|
- | 127 | ret |
|
- | 128 | ; IN: ecx = list item |
|
- | 129 | ;OUT: - |
|
- | 130 | ;fs_del: |
|
- | 131 | ; |
|
- | 132 | ; ret |
|
- | 133 | ||
- | 134 | ||
27 | 135 | ||
28 | ; System function 70 security check |
136 | ; System function 70 security check |
29 | align 4 |
137 | align 4 |
30 | proc file_system_is_operation_safe stdcall, inf_struct_ptr: dword |
138 | proc file_system_is_operation_safe stdcall, inf_struct_ptr: dword |
31 | ; in: |
139 | ; in: |
32 | ; inf_struct_ptr = pointer to information structure was given to sysfn70 |
140 | ; inf_struct_ptr = pointer to information structure was given to sysfn70 |
33 | ; out: ZF = 1 if operation is safe |
141 | ; out: ZF = 1 if operation is safe |
34 | ; ZF = 0 if operation can cause kernel crash |
142 | ; ZF = 0 if operation can cause kernel crash |
35 | push ebx ecx edx |
143 | push ebx ecx edx |
36 | xor ecx, ecx ; ecx - length of target buffer |
144 | xor ecx, ecx ; ecx - length of target buffer |
37 | 145 | ||
38 | mov ebx, [inf_struct_ptr] |
146 | mov ebx, [inf_struct_ptr] |
39 | mov edx, [ebx + 16] ; base of target buffer |
147 | mov edx, [ebx + 16] ; base of target buffer |
40 | 148 | ||
41 | cmp dword [ebx], 0 ; if 70.0 |
149 | cmp dword [ebx], 0 ; if 70.0 |
42 | jnz .case1 |
150 | jnz .case1 |
43 | mov ecx, dword [ebx + 12] |
151 | mov ecx, dword [ebx + 12] |
44 | jmp .end_switch |
152 | jmp .end_switch |
45 | 153 | ||
46 | .case1: |
154 | .case1: |
47 | cmp dword [ebx], 1 ; if 70.1 |
155 | cmp dword [ebx], 1 ; if 70.1 |
48 | jnz .case2_3 |
156 | jnz .case2_3 |
49 | ;mov ecx, 32 |
157 | ;mov ecx, 32 |
50 | cmp dword [ebx + 8], 1 ; check encoding |
158 | cmp dword [ebx + 8], 1 ; check encoding |
51 | jbe .case1_304 ; if encdoing <= 1 i.e cpp866 |
159 | jbe .case1_304 ; if encdoing <= 1 i.e cpp866 |
52 | mov ecx, 560 ; if unicode then bdvk block len is 560 bytes |
160 | mov ecx, 560 ; if unicode then bdvk block len is 560 bytes |
53 | jmp .case1_end |
161 | jmp .case1_end |
54 | .case1_304: |
162 | .case1_304: |
55 | mov ecx, 304 ; if cp866 then bdvk block len is 304 bytes |
163 | mov ecx, 304 ; if cp866 then bdvk block len is 304 bytes |
56 | .case1_end: |
164 | .case1_end: |
57 | imul ecx, dword [ebx + 12] ; multiply bdvk length by their count |
165 | imul ecx, dword [ebx + 12] ; multiply bdvk length by their count |
58 | add ecx, 32 ; add result header len |
166 | add ecx, 32 ; add result header len |
59 | jmp .end_switch |
167 | jmp .end_switch |
60 | 168 | ||
61 | .case2_3: |
169 | .case2_3: |
62 | cmp dword [ebx], 3 |
170 | cmp dword [ebx], 3 |
63 | ja .case5 ; if subfn > 3 |
171 | ja .case5 ; if subfn > 3 |
64 | mov ecx, dword [ebx + 12] |
172 | mov ecx, dword [ebx + 12] |
65 | jmp .end_switch |
173 | jmp .end_switch |
66 | 174 | ||
67 | .case5: |
175 | .case5: |
68 | cmp dword [ebx], 5 |
176 | cmp dword [ebx], 5 |
69 | jnz .case6 |
177 | jnz .case6 |
70 | mov ecx, 40 |
178 | mov ecx, 40 |
71 | jmp .end_switch |
179 | jmp .end_switch |
72 | 180 | ||
73 | .case6: |
181 | .case6: |
74 | cmp dword [ebx], 6 |
182 | cmp dword [ebx], 6 |
75 | jnz .switch_none |
183 | jnz .switch_none |
76 | mov ecx, 32 |
184 | mov ecx, 32 |
77 | jmp .end_switch |
185 | jmp .end_switch |
78 | 186 | ||
79 | .switch_none: |
187 | .switch_none: |
80 | cmp ecx, ecx |
188 | cmp ecx, ecx |
81 | jmp .ret |
189 | jmp .ret |
82 | 190 | ||
83 | .end_switch: |
191 | .end_switch: |
84 | stdcall is_region_userspace, edx, ecx |
192 | stdcall is_region_userspace, edx, ecx |
85 | .ret: |
193 | .ret: |
86 | pop edx ecx ebx |
194 | pop edx ecx ebx |
87 | ret |
195 | ret |
88 | endp |
196 | endp |
89 | 197 | ||
90 | sys_fileSystemUnicode: ; with user pointer correctness checking |
198 | sys_fileSystemUnicode: ; with user pointer correctness checking |
91 | ; in: ebx -> f.80 parameter structure |
199 | ; in: ebx -> f.80 parameter structure |
92 | stdcall file_system_is_operation_safe, ebx |
200 | stdcall file_system_is_operation_safe, ebx |
93 | jz @f |
201 | jz @f |
94 | 202 | ||
95 | DEBUGF 1, "sysfn80 addr error\n" |
203 | DEBUGF 1, "sysfn80 addr error\n" |
96 | mov dword [image_of_eax], ERROR_MEMORY_POINTER |
204 | mov dword [image_of_eax], ERROR_MEMORY_POINTER |
97 | ret |
205 | ret |
98 | @@: |
206 | @@: |
99 | jmp fileSystemUnicode |
207 | jmp fileSystemUnicode |
100 | 208 | ||
101 | ;System function 70 |
209 | ;System function 70 |
102 | sys_file_system_lfn: ; with user pointer correctness checking |
210 | sys_file_system_lfn: ; with user pointer correctness checking |
103 | ; in: ebx -> f.70 parameter structure |
211 | ; in: ebx -> f.70 parameter structure |
104 | stdcall file_system_is_operation_safe, ebx |
212 | stdcall file_system_is_operation_safe, ebx |
105 | jz @f |
213 | jz @f |
106 | 214 | ||
107 | DEBUGF 1, "sysfn70 addr error\n" |
215 | DEBUGF 1, "sysfn70 addr error\n" |
108 | mov dword [image_of_eax], ERROR_MEMORY_POINTER |
216 | mov dword [image_of_eax], ERROR_MEMORY_POINTER |
109 | ret |
217 | ret |
110 | @@: |
218 | @@: |
111 | jmp file_system_lfn |
219 | jmp file_system_lfn |
112 | 220 | ||
113 | ;file_system_lfn_protected returns values not in registers, but in their images |
221 | ;file_system_lfn_protected returns values not in registers, but in their images |
114 | ;on stack. Make a short wrapper to actually return values in registers. |
222 | ;on stack. Make a short wrapper to actually return values in registers. |
115 | file_system_lfn_protected_registers: |
223 | file_system_lfn_protected_registers: |
116 | pushad |
224 | pushad |
117 | call file_system_lfn_protected |
225 | call file_system_lfn_protected |
118 | popad |
226 | popad |
119 | ret |
227 | ret |
120 | 228 | ||
121 | file_system_lfn_protected: |
229 | file_system_lfn_protected: |
122 | pushad |
230 | pushad |
123 | call protect_from_terminate |
231 | call protect_from_terminate |
124 | call file_system_lfn |
232 | call file_system_lfn |
125 | call unprotect_from_terminate |
233 | call unprotect_from_terminate |
126 | popad |
234 | popad |
127 | mov [image_of_eax], eax |
235 | mov [image_of_eax], eax |
128 | mov [image_of_ebx], ebx |
236 | mov [image_of_ebx], ebx |
129 | ret |
237 | ret |
130 | 238 | ||
131 | fileSystemUnicode: |
239 | fileSystemUnicode: |
132 | ; in: ebx -> f.80 parameter structure |
240 | ; in: ebx -> f.80 parameter structure |
133 | mov edi, [ebx+20] |
241 | mov edi, [ebx+20] |
134 | mov esi, [ebx+24] |
242 | mov esi, [ebx+24] |
135 | jmp @f |
243 | jmp @f |
136 | 244 | ||
137 | file_system_lfn: |
245 | file_system_lfn: |
138 | ; in: ebx -> f.70 parameter structure |
246 | ; in: ebx -> f.70 parameter structure |
139 | xor edi, edi |
247 | xor edi, edi |
140 | lea esi, [ebx+20] |
248 | lea esi, [ebx+20] |
141 | cmp byte [esi], 0 |
249 | cmp byte [esi], 0 |
142 | jnz @f |
250 | jnz @f |
143 | mov esi, [ebx+21] |
251 | mov esi, [ebx+21] |
144 | @@: |
252 | @@: |
145 | cmp word [esi], '/' |
253 | cmp word [esi], '/' |
146 | jnz @f |
254 | jnz @f |
147 | cmp edi, 2 |
255 | cmp edi, 2 |
148 | jnz .rootdir |
256 | jnz .rootdir |
149 | cmp dword[esi], '/' |
257 | cmp dword[esi], '/' |
150 | jz .rootdir |
258 | jz .rootdir |
151 | @@: |
259 | @@: |
152 | stdcall kernel_alloc, maxPathLength |
260 | stdcall kernel_alloc, maxPathLength |
153 | push eax ebx |
261 | push eax ebx |
154 | xchg eax, edi |
262 | xchg eax, edi |
155 | call getFullPath |
263 | call getFullPath |
156 | pop ebx ebp |
264 | pop ebx ebp |
157 | test eax, eax |
265 | test eax, eax |
158 | jz .notfound |
266 | jz .notfound |
159 | cmp dword[ebx], 7 ; start application |
267 | cmp dword[ebx], 7 ; start application |
160 | jnz @f |
268 | jnz @f |
161 | mov edx, [ebx+4] |
269 | mov edx, [ebx+4] |
162 | mov ecx, [ebx+8] |
270 | mov ecx, [ebx+8] |
163 | mov ebx, ebp |
271 | mov ebx, ebp |
164 | call fs_execute |
272 | call fs_execute |
165 | mov [image_of_eax], eax |
273 | mov [image_of_eax], eax |
166 | ret |
274 | ret |
167 | 275 | ||
168 | @@: |
276 | @@: |
169 | lea esi, [ebp+2] |
277 | lea esi, [ebp+2] |
170 | mov ax, [esi] |
278 | mov ax, [esi] |
171 | or ax, 2020h |
279 | or ax, 2020h |
172 | cmp ax, 'cd' |
280 | cmp ax, 'cd' |
173 | jz .CD |
281 | jz .CD |
174 | call dyndisk_handler ; not returns if success |
282 | call dyndisk_handler ; not returns if success |
175 | .notfound: |
283 | .notfound: |
176 | stdcall kernel_free, ebp |
284 | stdcall kernel_free, ebp |
177 | mov dword[image_of_eax], ERROR_FILE_NOT_FOUND |
285 | mov dword[image_of_eax], ERROR_FILE_NOT_FOUND |
178 | ret |
286 | ret |
179 | 287 | ||
180 | .CD: |
288 | .CD: |
181 | add esi, 2 |
289 | add esi, 2 |
182 | xor eax, eax |
290 | xor eax, eax |
183 | lodsb ; disk number |
291 | lodsb ; disk number |
184 | sub eax, '0' |
292 | sub eax, '0' |
185 | cmp eax, 10 |
293 | cmp eax, 10 |
186 | jnc .notfound |
294 | jnc .notfound |
187 | mov edi, eax |
295 | mov edi, eax |
188 | lodsb |
296 | lodsb |
189 | test eax, eax |
297 | test eax, eax |
190 | jz .maindir |
298 | jz .maindir |
191 | cmp al, '/' |
299 | cmp al, '/' |
192 | jnz .notfound |
300 | jnz .notfound |
193 | lodsb ; partition number |
301 | lodsb ; partition number |
194 | test eax, eax |
302 | test eax, eax |
195 | jz .maindir |
303 | jz .maindir |
196 | cmp al, '1' |
304 | cmp al, '1' |
197 | jnz .notfound |
305 | jnz .notfound |
198 | cmp byte [esi], '/' |
306 | cmp byte [esi], '/' |
199 | jnz @f |
307 | jnz @f |
200 | inc esi |
308 | inc esi |
201 | @@: |
309 | @@: |
202 | call reserve_cd |
310 | call reserve_cd |
203 | mov eax, edi |
311 | mov eax, edi |
204 | bt eax, 0 |
312 | bt eax, 0 |
205 | setc [DiskNumber] |
313 | setc [DiskNumber] |
206 | bt eax, 1 |
314 | bt eax, 1 |
207 | setc [ChannelNumber] |
315 | setc [ChannelNumber] |
208 | inc [ChannelNumber] |
316 | inc [ChannelNumber] |
209 | inc eax |
317 | inc eax |
210 | mov [cdpos], eax |
318 | mov [cdpos], eax |
211 | call reserve_cd_channel |
319 | call reserve_cd_channel |
212 | mov eax, edi |
320 | mov eax, edi |
213 | not eax |
321 | not eax |
214 | and eax, 3 |
322 | and eax, 3 |
215 | shl eax, 1 |
323 | shl eax, 1 |
216 | inc eax |
324 | inc eax |
217 | shr edi, 2 |
325 | shr edi, 2 |
218 | mov dword[image_of_eax], ERROR_FILE_NOT_FOUND |
326 | mov dword[image_of_eax], ERROR_FILE_NOT_FOUND |
219 | bt [edi*5+DRIVE_DATA+1], ax |
327 | bt [edi*5+DRIVE_DATA+1], ax |
220 | jnc @f |
328 | jnc @f |
221 | mov ecx, [ebx+12] |
329 | mov ecx, [ebx+12] |
222 | mov edx, [ebx+16] |
330 | mov edx, [ebx+16] |
223 | mov eax, [ebx] |
331 | mov eax, [ebx] |
224 | mov dword[image_of_eax], ERROR_UNSUPPORTED_FS |
332 | mov dword[image_of_eax], ERROR_UNSUPPORTED_FS |
225 | cmp eax, fs_NumCdServices |
333 | cmp eax, fs_NumCdServices |
226 | jae @f |
334 | jae @f |
227 | add ebx, 4 |
335 | add ebx, 4 |
228 | push ebp |
336 | push ebp |
229 | call dword[fs_CdServices + eax*4] |
337 | call dword[fs_CdServices + eax*4] |
230 | pop ebp |
338 | pop ebp |
231 | mov [image_of_eax], eax |
339 | mov [image_of_eax], eax |
232 | mov [image_of_ebx], ebx |
340 | mov [image_of_ebx], ebx |
233 | @@: |
341 | @@: |
234 | call free_cd_channel |
342 | call free_cd_channel |
235 | and [cd_status], 0 |
343 | and [cd_status], 0 |
236 | stdcall kernel_free, ebp |
344 | stdcall kernel_free, ebp |
237 | ret |
345 | ret |
238 | 346 | ||
239 | .nextCD: |
347 | .nextCD: |
240 | test eax, eax ; partition number |
348 | test eax, eax ; partition number |
241 | jnz @f |
349 | jnz @f |
242 | inc eax ; /cdX/1 |
350 | inc eax ; /cdX/1 |
243 | ret |
351 | ret |
244 | 352 | ||
245 | @@: |
353 | @@: |
246 | stc |
354 | stc |
247 | ret |
355 | ret |
248 | 356 | ||
249 | .maindir: ; list partitions |
357 | .maindir: ; list partitions |
250 | mov esi, .nextCD |
358 | mov esi, .nextCD |
251 | xor ecx, ecx |
359 | xor ecx, ecx |
252 | .maindir_noesi: ; backjump from dyndisk_handler |
360 | .maindir_noesi: ; backjump from dyndisk_handler |
253 | push ebp |
361 | push ebp |
254 | mov ebp, ecx |
362 | mov ebp, ecx |
255 | call kernel_free |
363 | call kernel_free |
256 | mov edi, [ebx+16] ; buffer |
364 | mov edi, [ebx+16] ; buffer |
257 | cmp byte [ebx], 5 |
365 | cmp byte [ebx], 5 |
258 | jz .deviceInfo |
366 | jz .deviceInfo |
259 | cmp byte [ebx], 1 ; read folder? |
367 | cmp byte [ebx], 1 ; read folder? |
260 | jnz .access_denied |
368 | jnz .access_denied |
261 | push ebp |
369 | push ebp |
262 | pushd [ebx+4] ; first block |
370 | pushd [ebx+4] ; first block |
263 | mov ebp, [ebx+12] ; the number of blocks to read |
371 | mov ebp, [ebx+12] ; the number of blocks to read |
264 | mov ebx, [ebx+8] ; flags |
372 | mov ebx, [ebx+8] ; flags |
265 | mov ecx, 32/4 |
373 | mov ecx, 32/4 |
266 | mov edx, edi |
374 | mov edx, edi |
267 | xor eax, eax |
375 | xor eax, eax |
268 | rep stosd |
376 | rep stosd |
269 | mov byte [edx], 1 ; version |
377 | mov byte [edx], 1 ; version |
270 | .maindir_loop: |
378 | .maindir_loop: |
271 | call esi |
379 | call esi |
272 | jc .maindir_done |
380 | jc .maindir_done |
273 | inc dword[edx+8] |
381 | inc dword[edx+8] |
274 | dec dword[esp] |
382 | dec dword[esp] |
275 | jns .maindir_loop |
383 | jns .maindir_loop |
276 | dec ebp |
384 | dec ebp |
277 | js .maindir_loop |
385 | js .maindir_loop |
278 | inc dword[edx+4] |
386 | inc dword[edx+4] |
279 | mov dword[edi], 16 ; attributes: folder |
387 | mov dword[edi], 16 ; attributes: folder |
280 | mov dword[edi+4], ebx ; name encoding |
388 | mov dword[edi+4], ebx ; name encoding |
281 | push eax |
389 | push eax |
282 | mov ecx, 32/4 |
390 | mov ecx, 32/4 |
283 | add edi, 8 |
391 | add edi, 8 |
284 | xor eax, eax |
392 | xor eax, eax |
285 | rep stosd |
393 | rep stosd |
286 | pop eax |
394 | pop eax |
287 | push eax edx edi |
395 | push eax edx edi |
288 | ; convert number in eax to decimal string |
396 | ; convert number in eax to decimal string |
289 | push -'0' |
397 | push -'0' |
290 | mov ecx, 10 |
398 | mov ecx, 10 |
291 | @@: |
399 | @@: |
292 | xor edx, edx |
400 | xor edx, edx |
293 | div ecx |
401 | div ecx |
294 | push edx |
402 | push edx |
295 | test eax, eax |
403 | test eax, eax |
296 | jnz @b |
404 | jnz @b |
297 | cmp ebx, 2 |
405 | cmp ebx, 2 |
298 | jz .uni |
406 | jz .uni |
299 | @@: |
407 | @@: |
300 | pop eax |
408 | pop eax |
301 | add eax, '0' |
409 | add eax, '0' |
302 | stosb |
410 | stosb |
303 | test eax, eax |
411 | test eax, eax |
304 | jnz @b |
412 | jnz @b |
305 | pop edi edx eax |
413 | pop edi edx eax |
306 | cmp ebx, 3 |
414 | cmp ebx, 3 |
307 | jz @f |
415 | jz @f |
308 | add edi, 264 |
416 | add edi, 264 |
309 | jmp .maindir_loop |
417 | jmp .maindir_loop |
310 | 418 | ||
311 | .uni: |
419 | .uni: |
312 | pop eax |
420 | pop eax |
313 | add eax, '0' |
421 | add eax, '0' |
314 | stosw |
422 | stosw |
315 | test eax, eax |
423 | test eax, eax |
316 | jnz .uni |
424 | jnz .uni |
317 | pop edi edx eax |
425 | pop edi edx eax |
318 | @@: |
426 | @@: |
319 | add edi, 520 |
427 | add edi, 520 |
320 | jmp .maindir_loop |
428 | jmp .maindir_loop |
321 | 429 | ||
322 | .maindir_done: |
430 | .maindir_done: |
323 | pop eax eax |
431 | pop eax eax |
324 | mov ebx, [edx+4] |
432 | mov ebx, [edx+4] |
325 | xor eax, eax |
433 | xor eax, eax |
326 | dec ebp |
434 | dec ebp |
327 | js @f |
435 | js @f |
328 | mov al, ERROR_END_OF_FILE |
436 | mov al, ERROR_END_OF_FILE |
329 | @@: |
437 | @@: |
330 | mov [image_of_eax], eax |
438 | mov [image_of_eax], eax |
331 | mov [image_of_ebx], ebx |
439 | mov [image_of_ebx], ebx |
332 | ret |
440 | ret |
333 | 441 | ||
334 | .access_denied: |
442 | .access_denied: |
335 | mov dword[image_of_eax], ERROR_ACCESS_DENIED |
443 | mov dword[image_of_eax], ERROR_ACCESS_DENIED |
336 | ret |
444 | ret |
337 | 445 | ||
338 | .deviceInfo: |
446 | .deviceInfo: |
339 | test ebp, ebp |
447 | test ebp, ebp |
340 | jz @f |
448 | jz @f |
341 | mov eax, dword[ebp+DISK.MediaInfo.Capacity] |
449 | mov eax, dword[ebp+DISK.MediaInfo.Capacity] |
342 | mov edx, dword[ebp+DISK.MediaInfo.Capacity+4] |
450 | mov edx, dword[ebp+DISK.MediaInfo.Capacity+4] |
343 | shld edx, eax, 9 |
451 | shld edx, eax, 9 |
344 | shl eax, 9 |
452 | shl eax, 9 |
345 | mov [edi+36], edx |
453 | mov [edi+36], edx |
346 | mov [edi+32], eax |
454 | mov [edi+32], eax |
347 | @@: |
455 | @@: |
348 | and dword[image_of_eax], 0 |
456 | and dword[image_of_eax], 0 |
349 | ret |
457 | ret |
350 | 458 | ||
351 | .rootdir: ; / - virtual root folder |
459 | .rootdir: ; / - virtual root folder |
352 | cmp byte [ebx], 5 |
460 | cmp byte [ebx], 5 |
353 | jz @b |
461 | jz @b |
354 | cmp byte [ebx], 1 ; read folder? |
462 | cmp byte [ebx], 1 ; read folder? |
355 | jnz .access_denied |
463 | jnz .access_denied |
356 | mov ebp, [ebx+12] ; number of blocks |
464 | mov ebp, [ebx+12] ; number of blocks |
357 | mov edx, [ebx+16] ; return area |
465 | mov edx, [ebx+16] ; return area |
358 | push dword[ebx+4] ; first block |
466 | push dword[ebx+4] ; first block |
359 | mov ebx, [ebx+8] ; flags |
467 | mov ebx, [ebx+8] ; flags |
360 | mov ecx, 32/4 |
468 | mov ecx, 32/4 |
361 | mov edi, edx |
469 | mov edi, edx |
362 | xor eax, eax |
470 | xor eax, eax |
363 | rep stosd |
471 | rep stosd |
364 | mov byte [edx], 1 ; version |
472 | mov byte [edx], 1 ; version |
365 | sub esp, 16 |
473 | sub esp, 16 |
366 | .rootdir_loop: |
474 | .rootdir_loop: |
367 | push edi |
475 | push edi |
368 | lea edi, [esp+4] |
476 | lea edi, [esp+4] |
369 | call dyndisk_enum_root |
477 | call dyndisk_enum_root |
370 | pop edi |
478 | pop edi |
371 | test eax, eax |
479 | test eax, eax |
372 | jz .rootdirCD |
480 | jz .rootdirCD |
373 | inc dword[edx+8] |
481 | inc dword[edx+8] |
374 | dec dword[esp+16] |
482 | dec dword[esp+16] |
375 | jns .rootdir_loop |
483 | jns .rootdir_loop |
376 | dec ebp |
484 | dec ebp |
377 | js .rootdir_loop |
485 | js .rootdir_loop |
378 | inc dword[edx+4] |
486 | inc dword[edx+4] |
379 | mov dword[edi], 16 ; attributes: folder |
487 | mov dword[edi], 16 ; attributes: folder |
380 | mov dword[edi+4], ebx ; name encoding |
488 | mov dword[edi+4], ebx ; name encoding |
381 | push eax |
489 | push eax |
382 | mov ecx, 32/4 |
490 | mov ecx, 32/4 |
383 | add edi, 8 |
491 | add edi, 8 |
384 | xor eax, eax |
492 | xor eax, eax |
385 | rep stosd |
493 | rep stosd |
386 | push edi |
494 | push edi |
387 | lea esi, [esp+8] |
495 | lea esi, [esp+8] |
388 | cmp ebx, 2 |
496 | cmp ebx, 2 |
389 | jz .uni2 |
497 | jz .uni2 |
390 | @@: |
498 | @@: |
391 | lodsb |
499 | lodsb |
392 | stosb |
500 | stosb |
393 | test eax, eax |
501 | test eax, eax |
394 | jnz @b |
502 | jnz @b |
395 | pop edi eax |
503 | pop edi eax |
396 | cmp ebx, 3 |
504 | cmp ebx, 3 |
397 | jz @f |
505 | jz @f |
398 | add edi, 264 |
506 | add edi, 264 |
399 | jmp .rootdir_loop |
507 | jmp .rootdir_loop |
400 | 508 | ||
401 | .uni2: |
509 | .uni2: |
402 | lodsb |
510 | lodsb |
403 | stosw |
511 | stosw |
404 | test eax, eax |
512 | test eax, eax |
405 | jnz .uni2 |
513 | jnz .uni2 |
406 | pop edi eax |
514 | pop edi eax |
407 | @@: |
515 | @@: |
408 | add edi, 520 |
516 | add edi, 520 |
409 | jmp .rootdir_loop |
517 | jmp .rootdir_loop |
410 | 518 | ||
411 | .rootdirCD: |
519 | .rootdirCD: |
412 | add esp, 16 |
520 | add esp, 16 |
413 | or esi, -1 |
521 | or esi, -1 |
414 | .rootdirCD_loop: |
522 | .rootdirCD_loop: |
415 | inc esi |
523 | inc esi |
416 | cmp esi, 10 |
524 | cmp esi, 10 |
417 | jnc .rootdir_done |
525 | jnc .rootdir_done |
418 | mov eax, esi |
526 | mov eax, esi |
419 | not eax |
527 | not eax |
420 | and eax, 3 |
528 | and eax, 3 |
421 | shl eax, 1 |
529 | shl eax, 1 |
422 | inc eax |
530 | inc eax |
423 | mov ecx, esi |
531 | mov ecx, esi |
424 | shr ecx, 2 |
532 | shr ecx, 2 |
425 | bt [ecx*5+DRIVE_DATA+1], ax |
533 | bt [ecx*5+DRIVE_DATA+1], ax |
426 | jnc .rootdirCD_loop |
534 | jnc .rootdirCD_loop |
427 | inc dword[edx+8] |
535 | inc dword[edx+8] |
428 | dec dword[esp] |
536 | dec dword[esp] |
429 | jns .rootdirCD_loop |
537 | jns .rootdirCD_loop |
430 | dec ebp |
538 | dec ebp |
431 | js .rootdirCD_loop |
539 | js .rootdirCD_loop |
432 | inc dword[edx+4] |
540 | inc dword[edx+4] |
433 | mov dword[edi], 16 ; attributes: folder |
541 | mov dword[edi], 16 ; attributes: folder |
434 | mov dword[edi+4], ebx ; name encoding |
542 | mov dword[edi+4], ebx ; name encoding |
435 | mov ecx, 32/4 |
543 | mov ecx, 32/4 |
436 | add edi, 8 |
544 | add edi, 8 |
437 | xor eax, eax |
545 | xor eax, eax |
438 | rep stosd |
546 | rep stosd |
439 | mov eax, esi |
547 | mov eax, esi |
440 | add eax, '0' |
548 | add eax, '0' |
441 | cmp ebx, 1 |
549 | cmp ebx, 1 |
442 | jz @f |
550 | jz @f |
443 | mov word [edi], 'cd' |
551 | mov word [edi], 'cd' |
444 | mov [edi+2], ax |
552 | mov [edi+2], ax |
445 | add edi, 264 |
553 | add edi, 264 |
446 | jmp .rootdirCD_loop |
554 | jmp .rootdirCD_loop |
447 | 555 | ||
448 | @@: |
556 | @@: |
449 | mov dword[edi], 640063h |
557 | mov dword[edi], 640063h |
450 | mov [edi+4], eax |
558 | mov [edi+4], eax |
451 | add edi, 520 |
559 | add edi, 520 |
452 | jmp .rootdirCD_loop |
560 | jmp .rootdirCD_loop |
453 | 561 | ||
454 | .rootdir_done: |
562 | .rootdir_done: |
455 | pop eax |
563 | pop eax |
456 | mov ebx, [edx+4] |
564 | mov ebx, [edx+4] |
457 | xor eax, eax |
565 | xor eax, eax |
458 | dec ebp |
566 | dec ebp |
459 | js @f |
567 | js @f |
460 | mov al, ERROR_END_OF_FILE |
568 | mov al, ERROR_END_OF_FILE |
461 | @@: |
569 | @@: |
462 | mov [image_of_eax], eax |
570 | mov [image_of_eax], eax |
463 | mov [image_of_ebx], ebx |
571 | mov [image_of_ebx], ebx |
464 | ret |
572 | ret |
465 | 573 | ||
466 | ;----------------------------------------------------------------------------- |
574 | ;----------------------------------------------------------------------------- |
467 | process_replace_file_name: |
575 | process_replace_file_name: |
468 | ; in: [esi] = virtual path |
576 | ; in: [esi] = virtual path |
469 | ; out: [esi]+[ebp] = physical path |
577 | ; out: [esi]+[ebp] = physical path |
470 | xor edi, edi |
578 | xor edi, edi |
471 | xor ebp, ebp |
579 | xor ebp, ebp |
472 | .loop: |
580 | .loop: |
473 | cmp edi, [full_file_name_table.size] |
581 | cmp edi, [full_file_name_table.size] |
474 | jae .notfound |
582 | jae .notfound |
475 | push esi edi |
583 | push esi edi |
476 | shl edi, 7 |
584 | shl edi, 7 |
477 | add edi, [full_file_name_table] |
585 | add edi, [full_file_name_table] |
478 | @@: |
586 | @@: |
479 | cmp byte [edi], 0 |
587 | cmp byte [edi], 0 |
480 | jz .dest_done |
588 | jz .dest_done |
481 | lodsb |
589 | lodsb |
482 | test al, al |
590 | test al, al |
483 | jz .cont |
591 | jz .cont |
484 | scasb |
592 | scasb |
485 | jz @b |
593 | jz @b |
486 | or al, 20h |
594 | or al, 20h |
487 | cmp [edi-1], al |
595 | cmp [edi-1], al |
488 | jz @b |
596 | jz @b |
489 | .cont: |
597 | .cont: |
490 | pop edi esi |
598 | pop edi esi |
491 | inc edi |
599 | inc edi |
492 | jmp .loop |
600 | jmp .loop |
493 | 601 | ||
494 | .dest_done: |
602 | .dest_done: |
495 | cmp byte [esi], 0 |
603 | cmp byte [esi], 0 |
496 | jz .found |
604 | jz .found |
497 | cmp byte [esi], '/' |
605 | cmp byte [esi], '/' |
498 | jnz .cont |
606 | jnz .cont |
499 | .found: |
607 | .found: |
500 | pop edi eax |
608 | pop edi eax |
501 | shl edi, 7 |
609 | shl edi, 7 |
502 | add edi, [full_file_name_table] |
610 | add edi, [full_file_name_table] |
503 | mov ebp, esi |
611 | mov ebp, esi |
504 | lea esi, [edi+64] |
612 | lea esi, [edi+64] |
505 | .notfound: |
613 | .notfound: |
506 | ret |
614 | ret |
507 | 615 | ||
508 | ;----------------------------------------------------------------------------- |
616 | ;----------------------------------------------------------------------------- |
509 | uglobal |
617 | uglobal |
510 | addDirSeal db ? |
618 | addDirSeal db ? |
511 | endg |
619 | endg |
512 | 620 | ||
513 | sys_current_directory: ; sysfunction 30 |
621 | sys_current_directory: ; sysfunction 30 |
514 | mov eax, [current_slot] |
622 | mov eax, [current_slot] |
515 | mov edi, [eax+APPDATA.cur_dir] |
623 | mov edi, [eax+APPDATA.cur_dir] |
516 | xor eax, eax |
624 | xor eax, eax |
517 | dec ebx |
625 | dec ebx |
518 | jz .set |
626 | jz .set |
519 | dec ebx |
627 | dec ebx |
520 | jz .get |
628 | jz .get |
521 | dec ebx |
629 | dec ebx |
522 | jz .mount_additional_directory |
630 | jz .mount_additional_directory |
523 | mov eax, edx |
631 | mov eax, edx |
524 | dec ebx |
632 | dec ebx |
525 | jz .set |
633 | jz .set |
526 | mov eax, esi |
634 | mov eax, esi |
527 | dec ebx |
635 | dec ebx |
528 | jz .get |
636 | jz .get |
529 | @@: |
637 | @@: |
530 | ret |
638 | ret |
531 | 639 | ||
532 | .mount_additional_directory: |
640 | .mount_additional_directory: |
533 | ; in: ecx -> dir name+dir path (128) |
641 | ; in: ecx -> dir name+dir path (128) |
534 | mov al, 1 |
642 | mov al, 1 |
535 | xchg [addDirSeal], al |
643 | xchg [addDirSeal], al |
536 | test al, al |
644 | test al, al |
537 | jnz @b |
645 | jnz @b |
538 | mov esi, ecx |
646 | mov esi, ecx |
539 | mov edi, sysdir_name1 |
647 | mov edi, sysdir_name1 |
540 | mov ecx, 64 |
648 | mov ecx, 64 |
541 | rep movsb ; copying fake directory name |
649 | rep movsb ; copying fake directory name |
542 | mov byte [edi-1], 0 |
650 | mov byte [edi-1], 0 |
543 | mov cl, 63 |
651 | mov cl, 63 |
544 | call cp866toUTF8_string |
652 | call cp866toUTF8_string |
545 | mov byte [edi], 0 |
653 | mov byte [edi], 0 |
546 | mov [full_file_name_table.size], 2 |
654 | mov [full_file_name_table.size], 2 |
547 | ret |
655 | ret |
548 | 656 | ||
549 | .get: |
657 | .get: |
550 | ; in: ecx -> buffer, edx = length, eax = encoding |
658 | ; in: ecx -> buffer, edx = length, eax = encoding |
551 | stdcall is_region_userspace, ecx, edx |
659 | stdcall is_region_userspace, ecx, edx |
552 | jz @f |
660 | jz @f |
553 | 661 | ||
554 | ; if illegal buffer given |
662 | ; if illegal buffer given |
555 | xor edx, edx |
663 | xor edx, edx |
556 | jmp .ret |
664 | jmp .ret |
557 | @@: |
665 | @@: |
558 | 666 | ||
559 | mov esi, edi |
667 | mov esi, edi |
560 | inc esi |
668 | inc esi |
561 | mov edi, ecx |
669 | mov edi, ecx |
562 | cmp edx, maxPathLength |
670 | cmp edx, maxPathLength |
563 | jc @f |
671 | jc @f |
564 | mov edx, maxPathLength |
672 | mov edx, maxPathLength |
565 | @@: |
673 | @@: |
566 | mov ecx, edx |
674 | mov ecx, edx |
567 | jecxz .ret |
675 | jecxz .ret |
568 | cmp eax, 2 |
676 | cmp eax, 2 |
569 | jz .get16 |
677 | jz .get16 |
570 | cmp eax, 3 |
678 | cmp eax, 3 |
571 | jz .get8 |
679 | jz .get8 |
572 | @@: |
680 | @@: |
573 | dec ecx |
681 | dec ecx |
574 | js @f |
682 | js @f |
575 | call utf8to16 |
683 | call utf8to16 |
576 | call uni2ansi_char |
684 | call uni2ansi_char |
577 | stosb |
685 | stosb |
578 | test al, al |
686 | test al, al |
579 | jnz @b |
687 | jnz @b |
580 | sub edx, ecx |
688 | sub edx, ecx |
581 | @@: |
689 | @@: |
582 | mov byte [edi-1], 0 |
690 | mov byte [edi-1], 0 |
583 | .ret: |
691 | .ret: |
584 | mov [esp+32], edx |
692 | mov [esp+32], edx |
585 | ret |
693 | ret |
586 | 694 | ||
587 | .get8: |
695 | .get8: |
588 | push edi |
696 | push edi |
589 | mov edi, esi |
697 | mov edi, esi |
590 | xor eax, eax |
698 | xor eax, eax |
591 | repnz scasb |
699 | repnz scasb |
592 | sub edx, ecx |
700 | sub edx, ecx |
593 | mov ecx, edx |
701 | mov ecx, edx |
594 | pop edi |
702 | pop edi |
595 | rep movsb |
703 | rep movsb |
596 | jmp @b |
704 | jmp @b |
597 | 705 | ||
598 | .get16: |
706 | .get16: |
599 | shr ecx, 1 |
707 | shr ecx, 1 |
600 | shr edx, 1 |
708 | shr edx, 1 |
601 | @@: |
709 | @@: |
602 | dec ecx |
710 | dec ecx |
603 | js @f |
711 | js @f |
604 | call utf8to16 |
712 | call utf8to16 |
605 | stosw |
713 | stosw |
606 | test ax, ax |
714 | test ax, ax |
607 | jnz @b |
715 | jnz @b |
608 | sub edx, ecx |
716 | sub edx, ecx |
609 | @@: |
717 | @@: |
610 | shl edx, 1 |
718 | shl edx, 1 |
611 | mov word [edi-2], 0 |
719 | mov word [edi-2], 0 |
612 | jmp .ret |
720 | jmp .ret |
613 | 721 | ||
614 | .set: |
722 | .set: |
615 | mov esi, ecx |
723 | mov esi, ecx |
616 | getFullPath: |
724 | getFullPath: |
617 | ; in: esi -> file path, eax = string encoding, edi -> destination |
725 | ; in: esi -> file path, eax = string encoding, edi -> destination |
618 | ; out: UTF-8 string (with marker), eax = length, 0 -> error |
726 | ; out: UTF-8 string (with marker), eax = length, 0 -> error |
619 | test eax, eax |
727 | test eax, eax |
620 | jnz @f |
728 | jnz @f |
621 | cmp byte [esi], 4 |
729 | cmp byte [esi], 4 |
622 | jnc @f |
730 | jnc @f |
623 | cmp byte [esi], 0 |
731 | cmp byte [esi], 0 |
624 | jz @f |
732 | jz @f |
625 | lodsb |
733 | lodsb |
626 | @@: |
734 | @@: |
627 | cmp byte [esi], '/' |
735 | cmp byte [esi], '/' |
628 | jnz .relative |
736 | jnz .relative |
629 | cmp eax, 2 |
737 | cmp eax, 2 |
630 | jnz @f |
738 | jnz @f |
631 | cmp word [esi], '/' |
739 | cmp word [esi], '/' |
632 | jnz .relative |
740 | jnz .relative |
633 | inc esi |
741 | inc esi |
634 | inc esi |
742 | inc esi |
635 | jmp .start |
743 | jmp .start |
636 | 744 | ||
637 | @@: |
745 | @@: |
638 | inc esi |
746 | inc esi |
639 | cmp byte [esi], 4 |
747 | cmp byte [esi], 4 |
640 | jnc .start |
748 | jnc .start |
641 | lodsb |
749 | lodsb |
642 | cmp byte [esi], '/' |
750 | cmp byte [esi], '/' |
643 | jnz .start |
751 | jnz .start |
644 | inc esi |
752 | inc esi |
645 | .start: |
753 | .start: |
646 | push eax edi |
754 | push eax edi |
647 | call process_replace_file_name |
755 | call process_replace_file_name |
648 | mov edi, [esp] |
756 | mov edi, [esp] |
649 | mov ecx, maxPathLength |
757 | mov ecx, maxPathLength |
650 | mov al, 3 |
758 | mov al, 3 |
651 | mov ah, '/' |
759 | mov ah, '/' |
652 | stosw |
760 | stosw |
653 | sub ecx, 2 |
761 | sub ecx, 2 |
654 | test ebp, ebp |
762 | test ebp, ebp |
655 | jz .absolute |
763 | jz .absolute |
656 | @@: |
764 | @@: |
657 | lodsb |
765 | lodsb |
658 | stosb |
766 | stosb |
659 | dec ecx |
767 | dec ecx |
660 | test al, al |
768 | test al, al |
661 | jnz @b |
769 | jnz @b |
662 | mov esi, ebp |
770 | mov esi, ebp |
663 | dec edi |
771 | dec edi |
664 | .absolute: |
772 | .absolute: |
665 | cmp byte [esp+4], 2 |
773 | cmp byte [esp+4], 2 |
666 | jz .utf16 |
774 | jz .utf16 |
667 | cmp byte [esp+4], 3 |
775 | cmp byte [esp+4], 3 |
668 | jz .utf8 |
776 | jz .utf8 |
669 | call cp866toUTF8_string |
777 | call cp866toUTF8_string |
670 | jns .end |
778 | jns .end |
671 | jmp .fail |
779 | jmp .fail |
672 | 780 | ||
673 | .utf8: |
781 | .utf8: |
674 | dec ecx |
782 | dec ecx |
675 | js .fail |
783 | js .fail |
676 | lodsb |
784 | lodsb |
677 | stosb |
785 | stosb |
678 | test al, al |
786 | test al, al |
679 | jz .end |
787 | jz .end |
680 | jmp .utf8 |
788 | jmp .utf8 |
681 | 789 | ||
682 | .utf16: |
790 | .utf16: |
683 | call UTF16to8_string |
791 | call UTF16to8_string |
684 | jns .end |
792 | jns .end |
685 | .fail: |
793 | .fail: |
686 | mov byte [edi], 0 |
794 | mov byte [edi], 0 |
687 | pop eax eax |
795 | pop eax eax |
688 | xor eax, eax |
796 | xor eax, eax |
689 | ret |
797 | ret |
690 | 798 | ||
691 | .relative: |
799 | .relative: |
692 | push eax edi |
800 | push eax edi |
693 | mov ebx, esi |
801 | mov ebx, esi |
694 | mov edi, [current_slot] |
802 | mov edi, [current_slot] |
695 | mov edi, [edi+APPDATA.cur_dir] |
803 | mov edi, [edi+APPDATA.cur_dir] |
696 | mov edx, edi |
804 | mov edx, edi |
697 | mov ecx, maxPathLength |
805 | mov ecx, maxPathLength |
698 | xor eax, eax |
806 | xor eax, eax |
699 | repnz scasb |
807 | repnz scasb |
700 | mov esi, edi |
808 | mov esi, edi |
701 | mov edi, [esp] |
809 | mov edi, [esp] |
702 | jecxz .fail |
810 | jecxz .fail |
703 | cmp byte [ebx], 0 |
811 | cmp byte [ebx], 0 |
704 | jz .set_ok |
812 | jz .set_ok |
705 | dec esi |
813 | dec esi |
706 | cmp edx, edi ; is destination equal to cur_dir? |
814 | cmp edx, edi ; is destination equal to cur_dir? |
707 | mov edi, esi |
815 | mov edi, esi |
708 | jz @f |
816 | jz @f |
709 | mov edi, [esp] |
817 | mov edi, [esp] |
710 | mov ecx, esi |
818 | mov ecx, esi |
711 | sub ecx, edx |
819 | sub ecx, edx |
712 | mov esi, edx |
820 | mov esi, edx |
713 | mov edx, edi |
821 | mov edx, edi |
714 | rep movsb |
822 | rep movsb |
715 | @@: |
823 | @@: |
716 | mov byte [edi], '/' |
824 | mov byte [edi], '/' |
717 | inc edi |
825 | inc edi |
718 | mov esi, ebx |
826 | mov esi, ebx |
719 | mov ecx, edx |
827 | mov ecx, edx |
720 | add ecx, maxPathLength |
828 | add ecx, maxPathLength |
721 | sub ecx, edi |
829 | sub ecx, edi |
722 | jmp .absolute |
830 | jmp .absolute |
723 | 831 | ||
724 | .set_ok: |
832 | .set_ok: |
725 | cmp edx, edi ; is destination equal to cur_dir? |
833 | cmp edx, edi ; is destination equal to cur_dir? |
726 | jz @f |
834 | jz @f |
727 | mov ecx, esi |
835 | mov ecx, esi |
728 | sub ecx, edx |
836 | sub ecx, edx |
729 | mov esi, edx |
837 | mov esi, edx |
730 | rep movsb |
838 | rep movsb |
731 | @@: |
839 | @@: |
732 | pop eax |
840 | pop eax |
733 | sub edi, eax |
841 | sub edi, eax |
734 | pop eax |
842 | pop eax |
735 | mov eax, edi |
843 | mov eax, edi |
736 | ret |
844 | ret |
737 | 845 | ||
738 | .end: |
846 | .end: |
739 | or ecx, -1 |
847 | or ecx, -1 |
740 | mov edi, [esp] |
848 | mov edi, [esp] |
741 | xor eax, eax |
849 | xor eax, eax |
742 | push edi |
850 | push edi |
743 | repnz scasb |
851 | repnz scasb |
744 | not ecx |
852 | not ecx |
745 | pop edi |
853 | pop edi |
746 | .parse: |
854 | .parse: |
747 | mov al, '/' |
855 | mov al, '/' |
748 | repnz scasb |
856 | repnz scasb |
749 | jecxz @b |
857 | jecxz @b |
750 | cmp byte [edi], '.' |
858 | cmp byte [edi], '.' |
751 | jnz .parse |
859 | jnz .parse |
752 | mov esi, edi |
860 | mov esi, edi |
753 | @@: |
861 | @@: |
754 | lodsw |
862 | lodsw |
755 | sub ecx, 2 |
863 | sub ecx, 2 |
756 | cmp ax, './' |
864 | cmp ax, './' |
757 | jz @b |
865 | jz @b |
758 | cmp ax, '..' |
866 | cmp ax, '..' |
759 | jnz @f |
867 | jnz @f |
760 | cmp byte [esi], '/' |
868 | cmp byte [esi], '/' |
761 | jnz @f |
869 | jnz @f |
762 | mov edx, ecx |
870 | mov edx, ecx |
763 | mov ecx, edi |
871 | mov ecx, edi |
764 | sub ecx, [esp] |
872 | sub ecx, [esp] |
765 | sub ecx, 2 |
873 | sub ecx, 2 |
766 | jc .fail |
874 | jc .fail |
767 | sub edi, 2 |
875 | sub edi, 2 |
768 | lodsb |
876 | lodsb |
769 | dec edx |
877 | dec edx |
770 | std |
878 | std |
771 | repnz scasb |
879 | repnz scasb |
772 | cld |
880 | cld |
773 | add edi, 2 |
881 | add edi, 2 |
774 | mov ecx, edx |
882 | mov ecx, edx |
775 | jmp @b |
883 | jmp @b |
776 | 884 | ||
777 | @@: |
885 | @@: |
778 | sub esi, 2 |
886 | sub esi, 2 |
779 | add ecx, 2 |
887 | add ecx, 2 |
780 | cmp esi, edi |
888 | cmp esi, edi |
781 | jz .parse |
889 | jz .parse |
782 | push edi ecx |
890 | push edi ecx |
783 | rep movsb |
891 | rep movsb |
784 | pop ecx edi |
892 | pop ecx edi |
785 | jmp .parse |
893 | jmp .parse |
786 | 894 | ||
787 | include "parse_fn.inc" |
895 | include "parse_fn.inc" |
788 | include "fs_common.inc" |
896 | include "fs_common.inc" |
789 | include "iso9660.inc" ; read for CD filesystem |
897 | include "iso9660.inc" ; read for CD filesystem |
790 | include "fat.inc" |
898 | include "fat.inc" |
791 | include "exfat.inc" |
899 | include "exfat.inc" |
792 | include "ntfs.inc" |
900 | include "ntfs.inc" |
793 | include "ext.inc" |
901 | include "ext.inc" |
794 | include "xfs.asm"=> |
902 | include "xfs.asm"=> |