Rev 90 | Rev 95 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 90 | Rev 94 | ||
---|---|---|---|
- | 1 | uglobal |
|
1 | uglobal |
2 | cd_current_pointer_of_input dd 0 |
2 | cd_current_pointer_of_input dd 0 |
3 | cd_current_pointer_of_input_2 dd 0 |
3 | cd_current_pointer_of_input_2 dd 0 |
4 | cd_mem_location dd 0 |
4 | cd_mem_location dd 0 |
5 | cd_counter_block dd 0 |
5 | cd_counter_block dd 0 |
6 | endg |
6 | endg |
7 | |
7 | 8 | CDDataBuf equ 0x7000 |
|
8 | CDDataBuf equ 0x7000 |
9 | |
9 | 10 | reserve_cd: |
|
10 | reserve_cd: |
11 | |
11 | 12 | cli |
|
12 | cli |
13 | cmp [cd_status],0 |
13 | cmp [cd_status],0 |
14 | je reserve_ok2 |
14 | je reserve_ok2 |
15 | |
15 | 16 | sti |
|
16 | sti |
17 | call change_task |
17 | call change_task |
18 | jmp reserve_hd1 |
18 | jmp reserve_hd1 |
19 | |
19 | 20 | reserve_ok2: |
|
20 | reserve_ok2: |
21 | |
21 | 22 | push eax |
|
22 | push eax |
23 | mov eax,[0x3000] |
23 | mov eax,[0x3000] |
24 | shl eax,5 |
24 | shl eax,5 |
25 | mov eax,[eax+0x3000+4] |
25 | mov eax,[eax+0x3000+4] |
26 | mov [cd_status],eax |
26 | mov [cd_status],eax |
27 | pop eax |
27 | pop eax |
28 | sti |
28 | sti |
29 | ret |
29 | ret |
30 | |
30 | 31 | cd_status dd 0 |
|
31 | cd_status dd 0 |
32 | |
32 | 33 | ;---------------------------------------------------------------- |
|
33 | ;---------------------------------------------------------------- |
34 | ; |
34 | ; |
35 | ; fs_CdRead - LFN variant for reading CD disk |
35 | ; fs_CdRead - LFN variant for reading CD disk |
36 | ; |
36 | ; |
37 | ; esi points to filename /dir1/dir2/.../dirn/file,0 |
37 | ; esi points to filename /dir1/dir2/.../dirn/file,0 |
38 | ; ebx pointer to 64-bit number = first wanted byte, 0+ |
38 | ; ebx pointer to 64-bit number = first wanted byte, 0+ |
39 | ; may be ebx=0 - start from first byte |
39 | ; may be ebx=0 - start from first byte |
40 | ; ecx number of bytes to read, 0+ |
40 | ; ecx number of bytes to read, 0+ |
41 | ; edx mem location to return data |
41 | ; edx mem location to return data |
42 | ; |
42 | ; |
43 | ; ret ebx = bytes read or 0xffffffff file not found |
43 | ; ret ebx = bytes read or 0xffffffff file not found |
44 | ; eax = 0 ok read or other = errormsg |
44 | ; eax = 0 ok read or other = errormsg |
45 | ; |
45 | ; |
46 | ;-------------------------------------------------------------- |
46 | ;-------------------------------------------------------------- |
47 | fs_CdRead: |
47 | fs_CdRead: |
48 | push edi |
48 | push edi |
49 | cmp byte [esi], 0 |
49 | cmp byte [esi], 0 |
50 | jnz @f |
50 | jnz @f |
51 | .noaccess: |
51 | .noaccess: |
52 | pop edi |
52 | pop edi |
53 | .noaccess_2: |
53 | .noaccess_2: |
54 | or ebx, -1 |
54 | or ebx, -1 |
55 | mov eax, ERROR_ACCESS_DENIED |
55 | mov eax, ERROR_ACCESS_DENIED |
56 | ret |
56 | ret |
57 | |
57 | 58 | .noaccess_3: |
|
58 | .noaccess_3: |
59 | pop eax edx ecx edi |
59 | pop eax edx ecx edi |
60 | jmp .noaccess_2 |
60 | jmp .noaccess_2 |
61 | |
61 | 62 | @@: |
|
62 | @@: |
63 | call cd_find_lfn |
63 | call cd_find_lfn |
64 | jnc .found |
64 | jnc .found |
65 | pop edi |
65 | pop edi |
66 | cmp [DevErrorCode],0 |
66 | cmp [DevErrorCode],0 |
67 | jne .noaccess_2 |
67 | jne .noaccess_2 |
68 | or ebx, -1 |
68 | or ebx, -1 |
69 | mov eax, ERROR_FILE_NOT_FOUND |
69 | mov eax, ERROR_FILE_NOT_FOUND |
70 | ret |
70 | ret |
71 | |
71 | 72 | .found: |
|
72 | .found: |
73 | mov edi,[cd_current_pointer_of_input] |
73 | mov edi,[cd_current_pointer_of_input] |
74 | test byte [edi+25],10b ; do not allow read directories |
74 | test byte [edi+25],10b ; do not allow read directories |
75 | jnz .noaccess |
75 | jnz .noaccess |
76 | test ebx, ebx |
76 | test ebx, ebx |
77 | jz .l1 |
77 | jz .l1 |
78 | cmp dword [ebx+4], 0 |
78 | cmp dword [ebx+4], 0 |
79 | jz @f |
79 | jz @f |
80 | xor ebx, ebx |
80 | xor ebx, ebx |
81 | .reteof: |
81 | .reteof: |
82 | mov eax, 6 ; end of file |
82 | mov eax, 6 ; end of file |
83 | pop edi |
83 | pop edi |
84 | ret |
84 | ret |
85 | @@: |
85 | @@: |
86 | mov ebx, [ebx] |
86 | mov ebx, [ebx] |
87 | .l1: |
87 | .l1: |
88 | push ecx edx |
88 | push ecx edx |
89 | push 0 |
89 | push 0 |
90 | mov eax, [edi+10] ; ðåàëüíûé ðàçìåð ôàéëîâîé ñåêöèè |
90 | mov eax, [edi+10] ; ðåàëüíûé ðàçìåð ôàéëîâîé ñåêöèè |
91 | sub eax, ebx |
91 | sub eax, ebx |
92 | jb .eof |
92 | jb .eof |
93 | cmp eax, ecx |
93 | cmp eax, ecx |
94 | jae @f |
94 | jae @f |
95 | mov ecx, eax |
95 | mov ecx, eax |
96 | mov byte [esp], 6 |
96 | mov byte [esp], 6 |
97 | @@: |
97 | @@: |
98 | mov eax,[edi+2] |
98 | mov eax,[edi+2] |
99 | mov [CDSectorAddress],eax |
99 | mov [CDSectorAddress],eax |
100 | ; now eax=cluster, ebx=position, ecx=count, edx=buffer for data |
100 | ; now eax=cluster, ebx=position, ecx=count, edx=buffer for data |
101 | .new_sector: |
101 | .new_sector: |
102 | test ecx, ecx |
102 | test ecx, ecx |
103 | jz .done |
103 | jz .done |
104 | sub ebx, 2048 |
104 | sub ebx, 2048 |
105 | jae .new_sector |
105 | jae .new_sector |
106 | add ebx, 2048 |
106 | add ebx, 2048 |
107 | jnz .incomplete_sector |
107 | jnz .incomplete_sector |
108 | cmp ecx, 2048 |
108 | cmp ecx, 2048 |
109 | jb .incomplete_sector |
109 | jb .incomplete_sector |
110 | ; we may read and memmove complete sector |
110 | ; we may read and memmove complete sector |
111 | mov [CDDataBuf_pointer],edx |
111 | mov [CDDataBuf_pointer],edx |
112 | call ReadCDWRetr ; ÷èòàåì ñåêòîð ôàéëà |
112 | call ReadCDWRetr ; ÷èòàåì ñåêòîð ôàéëà |
113 | cmp [DevErrorCode],0 |
113 | cmp [DevErrorCode],0 |
114 | jne .noaccess_3 |
114 | jne .noaccess_3 |
115 | inc dword [CDSectorAddress] |
115 | inc dword [CDSectorAddress] |
116 | add edx, 2048 |
116 | add edx, 2048 |
117 | sub ecx, 2048 |
117 | sub ecx, 2048 |
118 | jmp .new_sector |
118 | jmp .new_sector |
119 | .incomplete_sector: |
119 | .incomplete_sector: |
120 | ; we must read and memmove incomplete sector |
120 | ; we must read and memmove incomplete sector |
121 | mov [CDDataBuf_pointer],CDDataBuf |
121 | mov [CDDataBuf_pointer],CDDataBuf |
122 | call ReadCDWRetr ; ÷èòàåì ñåêòîð ôàéëà |
122 | call ReadCDWRetr ; ÷èòàåì ñåêòîð ôàéëà |
123 | cmp [DevErrorCode],0 |
123 | cmp [DevErrorCode],0 |
124 | jne .noaccess_3 |
124 | jne .noaccess_3 |
125 | inc dword [CDSectorAddress] |
125 | inc dword [CDSectorAddress] |
126 | mov eax,CDDataBuf |
126 | mov eax,CDDataBuf |
127 | add eax, ebx |
127 | add eax, ebx |
128 | push ecx |
128 | push ecx |
129 | add ecx, ebx |
129 | add ecx, ebx |
130 | cmp ecx, 2048 |
130 | cmp ecx, 2048 |
131 | jbe @f |
131 | jbe @f |
132 | mov ecx, 2048 |
132 | mov ecx, 2048 |
133 | @@: |
133 | @@: |
134 | sub ecx, ebx |
134 | sub ecx, ebx |
135 | push edi esi ecx |
135 | push edi esi ecx |
136 | mov edi,edx |
136 | mov edi,edx |
137 | mov esi,eax ;0x7000 ; CD data buffer |
137 | mov esi,eax ;0x7000 ; CD data buffer |
138 | cld |
138 | cld |
139 | rep movsb |
139 | rep movsb |
140 | pop ecx esi edi |
140 | pop ecx esi edi |
141 | add edx, ecx |
141 | add edx, ecx |
142 | sub [esp], ecx |
142 | sub [esp], ecx |
143 | pop ecx |
143 | pop ecx |
144 | xor ebx, ebx |
144 | xor ebx, ebx |
145 | jmp .new_sector |
145 | jmp .new_sector |
146 | |
146 | 147 | .done: |
|
147 | .done: |
148 | mov ebx, edx |
148 | mov ebx, edx |
149 | pop eax edx ecx edi |
149 | pop eax edx ecx edi |
150 | sub ebx, edx |
150 | sub ebx, edx |
151 | ret |
151 | ret |
152 | .eof: |
152 | .eof: |
153 | mov ebx, edx |
153 | mov ebx, edx |
154 | pop eax edx ecx |
154 | pop eax edx ecx |
155 | sub ebx, edx |
155 | sub ebx, edx |
156 | jmp .reteof |
156 | jmp .reteof |
157 | |
157 | 158 | ;---------------------------------------------------------------- |
|
158 | ;---------------------------------------------------------------- |
159 | ; |
159 | ; |
160 | ; fs_CdReadFolder - LFN variant for reading CD disk folder |
160 | ; fs_CdReadFolder - LFN variant for reading CD disk folder |
161 | ; |
161 | ; |
162 | ; esi points to filename /dir1/dir2/.../dirn/file,0 |
162 | ; esi points to filename /dir1/dir2/.../dirn/file,0 |
163 | ; ebx pointer to structure 32-bit number = first wanted block, 0+ |
163 | ; ebx pointer to structure 32-bit number = first wanted block, 0+ |
164 | ; & flags (bitfields) |
164 | ; & flags (bitfields) |
165 | ; flags: bit 0: 0=ANSI names, 1=UNICODE names |
165 | ; flags: bit 0: 0=ANSI names, 1=UNICODE names |
166 | ; ecx number of blocks to read, 0+ |
166 | ; ecx number of blocks to read, 0+ |
167 | ; edx mem location to return data |
167 | ; edx mem location to return data |
168 | ; |
168 | ; |
169 | ; ret ebx = blocks read or 0xffffffff folder not found |
169 | ; ret ebx = blocks read or 0xffffffff folder not found |
170 | ; eax = 0 ok read or other = errormsg |
170 | ; eax = 0 ok read or other = errormsg |
171 | ; |
171 | ; |
172 | ;-------------------------------------------------------------- |
172 | ;-------------------------------------------------------------- |
173 | fs_CdReadFolder: |
173 | fs_CdReadFolder: |
174 | push edi |
174 | push edi |
175 | call cd_find_lfn |
175 | call cd_find_lfn |
176 | jnc .found |
176 | jnc .found |
177 | pop edi |
177 | pop edi |
178 | cmp [DevErrorCode],0 |
178 | cmp [DevErrorCode],0 |
179 | jne .noaccess_1 |
179 | jne .noaccess_1 |
180 | or ebx, -1 |
180 | or ebx, -1 |
181 | mov eax, ERROR_FILE_NOT_FOUND |
181 | mov eax, ERROR_FILE_NOT_FOUND |
182 | ret |
182 | ret |
183 | .found: |
183 | .found: |
184 | mov edi,[cd_current_pointer_of_input] |
184 | mov edi,[cd_current_pointer_of_input] |
185 | test byte [edi+25],10b ; do not allow read directories |
185 | test byte [edi+25],10b ; do not allow read directories |
186 | jnz .found_dir |
186 | jnz .found_dir |
187 | pop edi |
187 | pop edi |
188 | .noaccess_1: |
188 | .noaccess_1: |
189 | or ebx, -1 |
189 | or ebx, -1 |
190 | mov eax, ERROR_ACCESS_DENIED |
190 | mov eax, ERROR_ACCESS_DENIED |
191 | ret |
191 | ret |
192 | .found_dir: |
192 | .found_dir: |
193 | mov eax,[edi+2] ; eax=cluster |
193 | mov eax,[edi+2] ; eax=cluster |
194 | mov [CDSectorAddress],eax |
194 | mov [CDSectorAddress],eax |
195 | mov eax,[edi+10] ; ðàçìåð äèðåêòðîðèè |
195 | mov eax,[edi+10] ; ðàçìåð äèðåêòðîðèè |
196 | .doit: |
196 | .doit: |
197 | ; init header |
197 | ; init header |
198 | push eax ecx |
198 | push eax ecx |
199 | mov edi, edx |
199 | mov edi, edx |
200 | mov ecx, 32/4 |
200 | mov ecx, 32/4 |
201 | xor eax, eax |
201 | xor eax, eax |
202 | rep stosd |
202 | rep stosd |
203 | pop ecx eax |
203 | pop ecx eax |
204 | mov byte [edx], 1 ; version |
204 | mov byte [edx], 1 ; version |
205 | mov [cd_mem_location],edx |
205 | mov [cd_mem_location],edx |
206 | add [cd_mem_location],32 |
206 | add [cd_mem_location],32 |
207 | ; íà÷èíàåì ïåðåáðîñêó ÁÄÂÊ â ÓÑÂÊ |
207 | ; íà÷èíàåì ïåðåáðîñêó ÁÄÂÊ â ÓÑÂÊ |
208 | ;.mainloop: |
208 | ;.mainloop: |
209 | mov [cd_counter_block],dword 0 |
209 | mov [cd_counter_block],dword 0 |
210 | dec dword [CDSectorAddress] |
210 | dec dword [CDSectorAddress] |
211 | push ecx |
211 | push ecx |
212 | .read_to_buffer: |
212 | .read_to_buffer: |
213 | inc dword [CDSectorAddress] |
213 | inc dword [CDSectorAddress] |
214 | mov [CDDataBuf_pointer],CDDataBuf |
214 | mov [CDDataBuf_pointer],CDDataBuf |
215 | call ReadCDWRetr ; ÷èòàåì ñåêòîð äèðåêòîðèè |
215 | call ReadCDWRetr ; ÷èòàåì ñåêòîð äèðåêòîðèè |
216 | cmp [DevErrorCode],0 |
216 | cmp [DevErrorCode],0 |
217 | jne .noaccess_1 |
217 | jne .noaccess_1 |
218 | call .get_names_from_buffer |
218 | call .get_names_from_buffer |
219 | sub eax,2048 |
219 | sub eax,2048 |
220 | ; äèðåêòîðèÿ çàêîí÷èëàñü? |
220 | ; äèðåêòîðèÿ çàêîí÷èëàñü? |
221 | cmp eax,0 |
221 | cmp eax,0 |
222 | jg .read_to_buffer |
222 | jg .read_to_buffer |
223 | mov edi,[cd_counter_block] |
223 | mov edi,[cd_counter_block] |
224 | mov [edx+8],edi |
224 | mov [edx+8],edi |
225 | mov edi,[ebx] |
225 | mov edi,[ebx] |
226 | sub [edx+4],edi |
226 | sub [edx+4],edi |
227 | pop ecx edi |
227 | pop ecx edi |
228 | mov ebx, [edx+4] |
228 | mov ebx, [edx+4] |
229 | mov eax,ERROR_SUCCESS |
229 | mov eax,ERROR_SUCCESS |
230 | ret |
230 | ret |
231 | |
231 | 232 | .get_names_from_buffer: |
|
232 | .get_names_from_buffer: |
233 | mov [cd_current_pointer_of_input_2],CDDataBuf |
233 | mov [cd_current_pointer_of_input_2],CDDataBuf |
234 | push eax esi edi edx |
234 | push eax esi edi edx |
235 | .get_names_from_buffer_1: |
235 | .get_names_from_buffer_1: |
236 | call cd_get_name |
236 | call cd_get_name |
237 | jc .end_buffer |
237 | jc .end_buffer |
238 | inc dword [cd_counter_block] |
238 | inc dword [cd_counter_block] |
239 | mov eax,[cd_counter_block] |
239 | mov eax,[cd_counter_block] |
240 | cmp [ebx],eax |
240 | cmp [ebx],eax |
241 | jae .get_names_from_buffer_1 |
241 | jae .get_names_from_buffer_1 |
242 | test ecx, ecx |
242 | test ecx, ecx |
243 | jz .get_names_from_buffer_1 |
243 | jz .get_names_from_buffer_1 |
244 | mov edi,[cd_counter_block] |
244 | mov edi,[cd_counter_block] |
245 | mov [edx+4],edi |
245 | mov [edx+4],edi |
246 | dec ecx |
246 | dec ecx |
247 | mov esi,ebp |
247 | mov esi,ebp |
248 | mov edi,[cd_mem_location] |
248 | mov edi,[cd_mem_location] |
249 | add edi,40 |
249 | add edi,40 |
250 | test dword [ebx+4], 1 ; 0=ANSI, 1=UNICODE |
250 | test dword [ebx+4], 1 ; 0=ANSI, 1=UNICODE |
251 | jnz .unicode |
251 | jnz .unicode |
252 | ; jmp .unicode |
252 | ; jmp .unicode |
253 | .ansi: |
253 | .ansi: |
254 | cmp [cd_counter_block],2 |
254 | cmp [cd_counter_block],2 |
255 | jbe .ansi_parent_directory |
255 | jbe .ansi_parent_directory |
256 | cld |
256 | cld |
257 | lodsw |
257 | lodsw |
258 | xchg ah,al |
258 | xchg ah,al |
259 | call uni2ansi_char |
259 | call uni2ansi_char |
260 | cld |
260 | cld |
261 | stosb |
261 | stosb |
262 | ; ïðîâåðêà êîíöà ôàéëà |
262 | ; ïðîâåðêà êîíöà ôàéëà |
263 | mov al,[esi+1] |
263 | mov al,[esi+1] |
264 | cmp al,byte 3Bh ; ñåïàðàòîð êîíöà ôàéëà ';' |
264 | cmp al,byte 3Bh ; ñåïàðàòîð êîíöà ôàéëà ';' |
265 | je .cd_get_parameters_of_file_1 |
265 | je .cd_get_parameters_of_file_1 |
266 | ; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì |
266 | ; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì |
267 | movzx eax,byte [ebp-33] |
267 | movzx eax,byte [ebp-33] |
268 | add eax,ebp |
268 | add eax,ebp |
269 | sub eax,34 |
269 | sub eax,34 |
270 | cmp esi,eax |
270 | cmp esi,eax |
271 | je .cd_get_parameters_of_file_1 |
271 | je .cd_get_parameters_of_file_1 |
272 | ; ïðîâåðêà êîíöà ïàïêè |
272 | ; ïðîâåðêà êîíöà ïàïêè |
273 | movzx eax,byte [ebp-1] |
273 | movzx eax,byte [ebp-1] |
274 | add eax,ebp |
274 | add eax,ebp |
275 | cmp esi,eax |
275 | cmp esi,eax |
276 | jb .ansi |
276 | jb .ansi |
277 | .cd_get_parameters_of_file_1: |
277 | .cd_get_parameters_of_file_1: |
278 | mov [edi],byte 0 |
278 | mov [edi],byte 0 |
279 | call cd_get_parameters_of_file |
279 | call cd_get_parameters_of_file |
280 | add [cd_mem_location],304 |
280 | add [cd_mem_location],304 |
281 | jmp .get_names_from_buffer_1 |
281 | jmp .get_names_from_buffer_1 |
282 | |
282 | 283 | .ansi_parent_directory: |
|
283 | .ansi_parent_directory: |
284 | cmp [cd_counter_block],2 |
284 | cmp [cd_counter_block],2 |
285 | je @f |
285 | je @f |
286 | mov [edi],byte '.' |
286 | mov [edi],byte '.' |
287 | inc edi |
287 | inc edi |
288 | jmp .cd_get_parameters_of_file_1 |
288 | jmp .cd_get_parameters_of_file_1 |
289 | @@: |
289 | @@: |
290 | mov [edi],word '..' |
290 | mov [edi],word '..' |
291 | add edi,2 |
291 | add edi,2 |
292 | jmp .cd_get_parameters_of_file_1 |
292 | jmp .cd_get_parameters_of_file_1 |
293 | |
293 | 294 | .unicode: |
|
294 | .unicode: |
295 | cmp [cd_counter_block],2 |
295 | cmp [cd_counter_block],2 |
296 | jbe .unicode_parent_directory |
296 | jbe .unicode_parent_directory |
297 | cld |
297 | cld |
298 | movsw |
298 | movsw |
299 | ; ïðîâåðêà êîíöà ôàéëà |
299 | ; ïðîâåðêà êîíöà ôàéëà |
300 | mov ax,[esi] |
300 | mov ax,[esi] |
301 | cmp ax,word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';' |
301 | cmp ax,word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';' |
302 | je .cd_get_parameters_of_file_2 |
302 | je .cd_get_parameters_of_file_2 |
303 | ; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì |
303 | ; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì |
304 | movzx eax,byte [ebp-33] |
304 | movzx eax,byte [ebp-33] |
305 | add eax,ebp |
305 | add eax,ebp |
306 | sub eax,34 |
306 | sub eax,34 |
307 | cmp esi,eax |
307 | cmp esi,eax |
308 | je .cd_get_parameters_of_file_2 |
308 | je .cd_get_parameters_of_file_2 |
309 | ; ïðîâåðêà êîíöà ïàïêè |
309 | ; ïðîâåðêà êîíöà ïàïêè |
310 | movzx eax,byte [ebp-1] |
310 | movzx eax,byte [ebp-1] |
311 | add eax,ebp |
311 | add eax,ebp |
312 | cmp esi,eax |
312 | cmp esi,eax |
313 | jb .unicode |
313 | jb .unicode |
314 | .cd_get_parameters_of_file_2: |
314 | .cd_get_parameters_of_file_2: |
315 | mov [edi],word 0 |
315 | mov [edi],word 0 |
316 | call cd_get_parameters_of_file |
316 | call cd_get_parameters_of_file |
317 | add [cd_mem_location],560 |
317 | add [cd_mem_location],560 |
318 | jmp .get_names_from_buffer_1 |
318 | jmp .get_names_from_buffer_1 |
319 | |
319 | 320 | .unicode_parent_directory: |
|
320 | .unicode_parent_directory: |
321 | cmp [cd_counter_block],2 |
321 | cmp [cd_counter_block],2 |
322 | je @f |
322 | je @f |
323 | mov [edi],word 2E00h ; '.' |
323 | mov [edi],word 2E00h ; '.' |
324 | add edi,2 |
324 | add edi,2 |
325 | jmp .cd_get_parameters_of_file_2 |
325 | jmp .cd_get_parameters_of_file_2 |
326 | @@: |
326 | @@: |
327 | mov [edi],dword 2E002E00h ; '..' |
327 | mov [edi],dword 2E002E00h ; '..' |
328 | add edi,4 |
328 | add edi,4 |
329 | jmp .cd_get_parameters_of_file_2 |
329 | jmp .cd_get_parameters_of_file_2 |
330 | |
330 | 331 | .end_buffer: |
|
331 | .end_buffer: |
332 | pop edx edi esi eax |
332 | pop edx edi esi eax |
333 | ret |
333 | ret |
334 | |
334 | 335 | cd_get_parameters_of_file: |
|
335 | cd_get_parameters_of_file: |
336 | mov edi,[cd_mem_location] |
336 | mov edi,[cd_mem_location] |
337 | cd_get_parameters_of_file_1: |
337 | cd_get_parameters_of_file_1: |
338 | ; ïîëó÷àåì àòðèáóòû ôàéëà |
338 | ; ïîëó÷àåì àòðèáóòû ôàéëà |
339 | xor eax,eax |
339 | xor eax,eax |
340 | ; ôàéë íå àðõèâèðîâàëñÿ |
340 | ; ôàéë íå àðõèâèðîâàëñÿ |
341 | inc al |
341 | inc al |
342 | shl eax,1 |
342 | shl eax,1 |
343 | ; ýòî êàòàëîã? |
343 | ; ýòî êàòàëîã? |
344 | test [ebp-8],byte 2 |
344 | test [ebp-8],byte 2 |
345 | jz .file |
345 | jz .file |
346 | inc al |
346 | inc al |
347 | .file: |
347 | .file: |
348 | ; ìåòêà òîìà íå êàê â FAT, â ýòîì âèäå îòñóòñâóåò |
348 | ; ìåòêà òîìà íå êàê â FAT, â ýòîì âèäå îòñóòñâóåò |
349 | ; ôàéë íå ÿâëÿåòñÿ ñèñòåìíûì |
349 | ; ôàéë íå ÿâëÿåòñÿ ñèñòåìíûì |
350 | shl eax,3 |
350 | shl eax,3 |
351 | ; ôàéë ÿâëÿåòñÿ ñêðûòûì? (àòðèáóò ñóùåñòâîâàíèå) |
351 | ; ôàéë ÿâëÿåòñÿ ñêðûòûì? (àòðèáóò ñóùåñòâîâàíèå) |
352 | test [ebp-8],byte 1 |
352 | test [ebp-8],byte 1 |
353 | jz .hidden |
353 | jz .hidden |
354 | inc al |
354 | inc al |
355 | .hidden: |
355 | .hidden: |
356 | shl eax,1 |
356 | shl eax,1 |
357 | ; ôàéë âñåãäà òîëüêî äëÿ ÷òåíèÿ, òàê êàê ýòî CD |
357 | ; ôàéë âñåãäà òîëüêî äëÿ ÷òåíèÿ, òàê êàê ýòî CD |
358 | inc al |
358 | inc al |
359 | mov [edi],eax |
359 | mov [edi],eax |
360 | ; ïîëó÷àåì âðåìÿ äëÿ ôàéëà |
360 | ; ïîëó÷àåì âðåìÿ äëÿ ôàéëà |
361 | ;÷àñ |
361 | ;÷àñ |
362 | movzx eax,byte [ebp-12] |
362 | movzx eax,byte [ebp-12] |
363 | shl eax,8 |
363 | shl eax,8 |
364 | ;ìèíóòà |
364 | ;ìèíóòà |
365 | mov al,[ebp-11] |
365 | mov al,[ebp-11] |
366 | shl eax,8 |
366 | shl eax,8 |
367 | ;ñåêóíäà |
367 | ;ñåêóíäà |
368 | mov al,[ebp-10] |
368 | mov al,[ebp-10] |
369 | ;âðåìÿ ñîçäàíèÿ ôàéëà |
369 | ;âðåìÿ ñîçäàíèÿ ôàéëà |
370 | mov [edi+8],eax |
370 | mov [edi+8],eax |
371 | ;âðåìÿ ïîñëåäíåãî äîñòóïà |
371 | ;âðåìÿ ïîñëåäíåãî äîñòóïà |
372 | mov [edi+16],eax |
372 | mov [edi+16],eax |
373 | ;âðåìÿ ïîñëåäíåé çàïèñè |
373 | ;âðåìÿ ïîñëåäíåé çàïèñè |
374 | mov [edi+24],eax |
374 | mov [edi+24],eax |
375 | ; ïîëó÷àåì äàòó äëÿ ôàéëà |
375 | ; ïîëó÷àåì äàòó äëÿ ôàéëà |
376 | ;ãîä |
376 | ;ãîä |
377 | movzx eax,byte [ebp-15] |
377 | movzx eax,byte [ebp-15] |
378 | add eax,1900 |
378 | add eax,1900 |
379 | shl eax,8 |
379 | shl eax,8 |
380 | ;ìåñÿö |
380 | ;ìåñÿö |
381 | mov al,[ebp-14] |
381 | mov al,[ebp-14] |
382 | shl eax,8 |
382 | shl eax,8 |
383 | ;äåíü |
383 | ;äåíü |
384 | mov al,[ebp-13] |
384 | mov al,[ebp-13] |
385 | ;äàòà ñîçäàíèÿ ôàéëà |
385 | ;äàòà ñîçäàíèÿ ôàéëà |
386 | mov [edi+12],eax |
386 | mov [edi+12],eax |
387 | ;âðåìÿ ïîñëåäíåãî äîñòóïà |
387 | ;âðåìÿ ïîñëåäíåãî äîñòóïà |
388 | mov [edi+20],eax |
388 | mov [edi+20],eax |
389 | ;âðåìÿ ïîñëåäíåé çàïèñè |
389 | ;âðåìÿ ïîñëåäíåé çàïèñè |
390 | mov [edi+28],eax |
390 | mov [edi+28],eax |
391 | ; ïîëó÷àåì òèï äàííûõ èìåíè |
391 | ; ïîëó÷àåì òèï äàííûõ èìåíè |
392 | xor eax,eax |
392 | xor eax,eax |
393 | test dword [ebx+4], 1 ; 0=ANSI, 1=UNICODE |
393 | test dword [ebx+4], 1 ; 0=ANSI, 1=UNICODE |
394 | jnz .unicode_1 |
394 | jnz .unicode_1 |
395 | mov [edi+4],eax |
395 | mov [edi+4],eax |
396 | jmp @f |
396 | jmp @f |
397 | .unicode_1: |
397 | .unicode_1: |
398 | inc eax |
398 | inc eax |
399 | mov [edi+4],eax |
399 | mov [edi+4],eax |
400 | @@: |
400 | @@: |
401 | ; ïîëó÷àåì ðàçìåð ôàéëà â áàéòàõ |
401 | ; ïîëó÷àåì ðàçìåð ôàéëà â áàéòàõ |
402 | xor eax,eax |
402 | xor eax,eax |
403 | mov [edi+32+4],eax |
403 | mov [edi+32+4],eax |
404 | mov eax,[ebp-23] |
404 | mov eax,[ebp-23] |
405 | mov [edi+32],eax |
405 | mov [edi+32],eax |
406 | ret |
406 | ret |
407 | |
407 | 408 | ;---------------------------------------------------------------- |
|
408 | ;---------------------------------------------------------------- |
409 | ; |
409 | ; |
410 | ; fs_CdGetFileInfo - LFN variant for CD |
410 | ; fs_CdGetFileInfo - LFN variant for CD |
411 | ; get file/directory attributes structure |
411 | ; get file/directory attributes structure |
412 | ; |
412 | ; |
413 | ;---------------------------------------------------------------- |
413 | ;---------------------------------------------------------------- |
414 | fs_CdGetFileInfo: |
414 | fs_CdGetFileInfo: |
415 | cmp byte [esi], 0 |
415 | cmp byte [esi], 0 |
416 | jnz @f |
416 | jnz @f |
417 | mov eax, 2 |
417 | mov eax, 2 |
418 | ret |
418 | ret |
419 | @@: |
419 | @@: |
420 | push edi ebp |
420 | push edi ebp |
421 | call cd_find_lfn |
421 | call cd_find_lfn |
422 | pushfd |
422 | pushfd |
423 | cmp [DevErrorCode], 0 |
423 | cmp [DevErrorCode], 0 |
424 | jz @f |
424 | jz @f |
425 | popfd |
425 | popfd |
426 | pop ebp edi |
426 | pop ebp edi |
427 | mov eax, 11 |
427 | mov eax, 11 |
428 | ret |
428 | ret |
429 | @@: |
429 | @@: |
430 | popfd |
430 | popfd |
431 | jnc @f |
431 | jnc @f |
432 | pop ebp edi |
432 | pop ebp edi |
433 | mov eax, ERROR_FILE_NOT_FOUND |
433 | mov eax, ERROR_FILE_NOT_FOUND |
434 | ret |
434 | ret |
435 | @@: |
435 | @@: |
436 | |
436 | 437 | mov edi, edx |
|
437 | mov edi, edx |
438 | call cd_get_parameters_of_file_1 |
438 | call cd_get_parameters_of_file_1 |
439 | and dword [edi+4], 0 |
439 | and dword [edi+4], 0 |
440 | pop ebp |
440 | pop ebp |
441 | pop ebp edi |
441 | pop ebp edi |
442 | xor eax, eax |
442 | xor eax, eax |
443 | ret |
443 | ret |
444 | |
- | 445 | ;---------------------------------------------------------------- |
|
- | 446 | ; |
|
- | 447 | ; fs_CdExecute - LFN variant for executing from CD |
|
- | 448 | ; |
|
- | 449 | ; esi points to hd filename (e.g. 'dir1/name') |
|
- | 450 | ; ebp points to full filename (e.g. '/hd0/1/dir1/name') |
|
- | 451 | ; dword [ebx] = flags |
|
- | 452 | ; dword [ebx+4] = cmdline |
|
- | 453 | ; |
|
- | 454 | ; ret ebx,edx destroyed |
|
- | 455 | ; eax > 0 - PID, < 0 - error |
|
- | 456 | ; |
|
- | 457 | ;-------------------------------------------------------------- |
|
- | 458 | fs_CdExecute: |
|
- | 459 | mov edx, [ebx] |
|
- | 460 | mov ebx, [ebx+4] |
|
- | 461 | test ebx, ebx |
|
- | 462 | jz @f |
|
- | 463 | add ebx, std_application_base_address |
|
- | 464 | @@: |
|
- | 465 | ||
- | 466 | ;---------------------------------------------------------------- |
|
- | 467 | ; |
|
- | 468 | ; fs_CdExecute.flags - second entry |
|
- | 469 | ; |
|
- | 470 | ; esi points to floppy filename (kernel address) |
|
- | 471 | ; ebp points to full filename |
|
- | 472 | ; edx flags |
|
- | 473 | ; ebx cmdline (kernel address) |
|
- | 474 | ; |
|
- | 475 | ; ret eax > 0 - PID, < 0 - error |
|
- | 476 | ; |
|
- | 477 | ;-------------------------------------------------------------- |
|
- | 478 | ||
- | 479 | .flags: |
|
- | 480 | cmp byte [esi], 0 |
|
- | 481 | jnz @f |
|
- | 482 | ; cannot execute root! |
|
- | 483 | mov eax, -ERROR_ACCESS_DENIED |
|
- | 484 | ret |
|
- | 485 | @@: |
|
- | 486 | push edi |
|
- | 487 | call cd_find_lfn |
|
- | 488 | jnc .found |
|
- | 489 | pop edi |
|
- | 490 | mov eax, -ERROR_FILE_NOT_FOUND |
|
- | 491 | cmp [DevErrorCode], 0 |
|
- | 492 | jz @f |
|
- | 493 | mov al, -11 |
|
- | 494 | @@: |
|
- | 495 | ret |
|
- | 496 | .found: |
|
- | 497 | mov edi,[cd_current_pointer_of_input] |
|
- | 498 | mov eax,[edi+2] |
|
- | 499 | push 0 |
|
- | 500 | push eax |
|
- | 501 | push dword [edi+10] ; size |
|
- | 502 | push .DoRead |
|
- | 503 | call fs_execute |
|
- | 504 | add esp, 16 |
|
- | 505 | pop edi |
|
- | 506 | ret |
|
- | 507 | ||
- | 508 | .DoRead: |
|
- | 509 | ; read next block |
|
- | 510 | ; in: eax->parameters, edi->buffer |
|
- | 511 | ; out: eax = error code |
|
- | 512 | pushad |
|
- | 513 | cmp dword [eax], 0 ; file size |
|
- | 514 | jz .eof |
|
- | 515 | cmp [eax+8],dword 0 |
|
- | 516 | jne @f |
|
- | 517 | mov ecx,[eax+4] |
|
- | 518 | inc dword [eax+4] |
|
- | 519 | mov [CDSectorAddress],ecx |
|
- | 520 | mov [CDDataBuf_pointer],CDDataBuf ;edi |
|
- | 521 | call ReadCDWRetr |
|
- | 522 | cmp [DevErrorCode], 0 |
|
- | 523 | jnz .err |
|
- | 524 | @@: |
|
- | 525 | push esi edi ecx |
|
- | 526 | mov esi,512 |
|
- | 527 | imul esi,[eax+8] |
|
- | 528 | add esi,CDDataBuf |
|
- | 529 | mov ecx,512/4 |
|
- | 530 | cld |
|
- | 531 | rep movsd |
|
- | 532 | pop ecx edi esi |
|
- | 533 | ||
- | 534 | mov eax, [esp+28] |
|
- | 535 | mov ecx, [eax] |
|
- | 536 | sub ecx, 512 |
|
- | 537 | jae @f |
|
- | 538 | lea edi, [edi+ecx+512] |
|
- | 539 | neg ecx |
|
- | 540 | push eax |
|
- | 541 | xor eax, eax |
|
- | 542 | rep stosb |
|
- | 543 | pop eax |
|
- | 544 | @@: |
|
- | 545 | mov [eax], ecx |
|
- | 546 | mov edx, [eax+8] |
|
- | 547 | inc edx |
|
- | 548 | cmp edx, 4 ; 2048/512=4 |
|
- | 549 | jb @f |
|
- | 550 | xor edx, edx |
|
- | 551 | @@: |
|
- | 552 | mov [eax+8], edx |
|
- | 553 | popad |
|
- | 554 | xor eax, eax |
|
- | 555 | ret |
|
- | 556 | .eof: |
|
- | 557 | popad |
|
- | 558 | mov eax, 6 |
|
- | 559 | ret |
|
- | 560 | .err: |
|
- | 561 | popad |
|
- | 562 | mov eax, 11 |
|
- | 563 | ret |
|
- | 564 | ||
444 | 565 | cd_find_lfn: |
|
445 | cd_find_lfn: |
566 | ; in: esi->name |
446 | ; in: esi->name |
567 | ; out: CF=1 - file not found |
447 | ; out: CF=1 - file not found |
568 | ; else CF=0 and [cd_current_pointer_of_input] direntry |
448 | ; else CF=0 and [cd_current_pointer_of_input] direntry |
569 | push eax esi |
449 | push eax esi |
570 | ; 16 ñåêòîð íà÷àëî íàáîðà äåñêðèïòîðîâ òîìîâ |
450 | ; 16 ñåêòîð íà÷àëî íàáîðà äåñêðèïòîðîâ òîìîâ |
571 | mov [CDSectorAddress],dword 15 |
451 | mov [CDSectorAddress],dword 15 |
572 | .start: |
452 | .start: |
573 | inc dword [CDSectorAddress] |
453 | inc dword [CDSectorAddress] |
574 | mov [CDDataBuf_pointer],CDDataBuf |
454 | mov [CDDataBuf_pointer],CDDataBuf |
575 | call ReadCDWRetr |
455 | call ReadCDWRetr |
576 | cmp [DevErrorCode],0 |
456 | cmp [DevErrorCode],0 |
577 | jne .access_denied |
457 | jne .access_denied |
578 | ; ïðîâåðêà íà âøèâîñòü |
458 | ; ïðîâåðêà íà âøèâîñòü |
579 | cmp [CDDataBuf+1],dword 'CD00' |
459 | cmp [CDDataBuf+1],dword 'CD00' |
580 | jne .access_denied |
460 | jne .access_denied |
581 | cmp [CDDataBuf+5],byte '1' |
461 | cmp [CDDataBuf+5],byte '1' |
582 | jne .access_denied |
462 | jne .access_denied |
583 | ; ñåêòîð ÿâëÿåòñÿ òåðìèíàòîðîì íàáîð äåñêðèïòîðîâ òîìîâ? |
463 | ; ñåêòîð ÿâëÿåòñÿ òåðìèíàòîðîì íàáîð äåñêðèïòîðîâ òîìîâ? |
584 | cmp [CDDataBuf],byte 0xff |
464 | cmp [CDDataBuf],byte 0xff |
585 | je .access_denied |
465 | je .access_denied |
586 | ; ñåêòîð ÿâëÿåòñÿ äîïîëíèòåëüíûì è óëó÷øåííûì äåñêðèïòîðîì òîìà? |
466 | ; ñåêòîð ÿâëÿåòñÿ äîïîëíèòåëüíûì è óëó÷øåííûì äåñêðèïòîðîì òîìà? |
587 | cmp [CDDataBuf],byte 0x2 |
467 | cmp [CDDataBuf],byte 0x2 |
588 | jne .start |
468 | jne .start |
589 | ; ñåêòîð ÿâëÿåòñÿ äîïîëíèòåëüíûì äåñêðèïòîðîì òîìà? |
469 | ; ñåêòîð ÿâëÿåòñÿ äîïîëíèòåëüíûì äåñêðèïòîðîì òîìà? |
590 | cmp [CDDataBuf+6],byte 0x1 |
470 | cmp [CDDataBuf+6],byte 0x1 |
591 | jne .start |
471 | jne .start |
592 | ; ïàðàìåòðû root äèðåêòðîðèè |
472 | ; ïàðàìåòðû root äèðåêòðîðèè |
593 | mov eax,[CDDataBuf+0x9c+2] ; íà÷àëî root äèðåêòðîðèè |
473 | mov eax,[CDDataBuf+0x9c+2] ; íà÷àëî root äèðåêòðîðèè |
594 | mov [CDSectorAddress],eax |
474 | mov [CDSectorAddress],eax |
595 | mov eax,[CDDataBuf+0x9c+10] ; ðàçìåð root äèðåêòðîðèè |
475 | mov eax,[CDDataBuf+0x9c+10] ; ðàçìåð root äèðåêòðîðèè |
596 | cmp byte [esi], 0 |
476 | cmp byte [esi], 0 |
597 | jnz @f |
477 | jnz @f |
598 | mov [cd_current_pointer_of_input],CDDataBuf+0x9c |
478 | mov [cd_current_pointer_of_input],CDDataBuf+0x9c |
599 | jmp .done |
479 | jmp .done |
600 | @@: |
480 | @@: |
601 | ; íà÷èíàåì ïîèñê |
481 | ; íà÷èíàåì ïîèñê |
602 | .mainloop: |
482 | .mainloop: |
603 | dec dword [CDSectorAddress] |
483 | dec dword [CDSectorAddress] |
604 | .read_to_buffer: |
484 | .read_to_buffer: |
605 | inc dword [CDSectorAddress] |
485 | inc dword [CDSectorAddress] |
606 | mov [CDDataBuf_pointer],CDDataBuf |
486 | mov [CDDataBuf_pointer],CDDataBuf |
607 | call ReadCDWRetr ; ÷èòàåì ñåêòîð äèðåêòîðèè |
487 | call ReadCDWRetr ; ÷èòàåì ñåêòîð äèðåêòîðèè |
608 | cmp [DevErrorCode],0 |
488 | cmp [DevErrorCode],0 |
609 | jne .access_denied |
489 | jne .access_denied |
610 | call cd_find_name_in_buffer |
490 | call cd_find_name_in_buffer |
611 | jnc .found |
491 | jnc .found |
612 | sub eax,2048 |
492 | sub eax,2048 |
613 | ; äèðåêòîðèÿ çàêîí÷èëàñü? |
493 | ; äèðåêòîðèÿ çàêîí÷èëàñü? |
614 | cmp eax,0 |
494 | cmp eax,0 |
615 | jg .read_to_buffer |
495 | jg .read_to_buffer |
616 | ; íåò èñêîìîãî ýëåìåíòà öåïî÷êè |
496 | ; íåò èñêîìîãî ýëåìåíòà öåïî÷êè |
617 | .access_denied: |
497 | .access_denied: |
618 | pop esi eax |
498 | pop esi eax |
619 | stc |
499 | stc |
620 | ret |
500 | ret |
621 | ; èñêîìûé ýëåìåíò öåïî÷êè íàéäåí |
501 | ; èñêîìûé ýëåìåíò öåïî÷êè íàéäåí |
622 | .found: |
502 | .found: |
623 | ; êîíåö ïóòè ôàéëà |
503 | ; êîíåö ïóòè ôàéëà |
624 | cmp byte [esi-1], 0 |
504 | cmp byte [esi], 0 |
625 | jz .done |
505 | jz .done |
626 | mov eax,[cd_current_pointer_of_input] |
506 | mov eax,[cd_current_pointer_of_input] |
627 | add eax,2 |
507 | add eax,2 |
628 | mov eax,[eax] |
508 | mov eax,[eax] |
629 | mov [CDSectorAddress],eax ; íà÷àëî äèðåêòîðèè |
509 | mov [CDSectorAddress],eax ; íà÷àëî äèðåêòîðèè |
630 | add eax,8 |
510 | add eax,8 |
631 | mov eax,[eax] ; ðàçìåð äèðåêòîðèè |
511 | mov eax,[eax] ; ðàçìåð äèðåêòîðèè |
632 | jmp .mainloop |
512 | jmp .mainloop |
633 | ; óêàçàòåëü ôàéëà íàéäåí |
513 | ; óêàçàòåëü ôàéëà íàéäåí |
634 | .done: |
514 | .done: |
635 | pop esi eax |
515 | pop esi eax |
636 | clc |
516 | clc |
637 | ret |
517 | ret |
638 | |
518 | 639 | cd_find_name_in_buffer: |
|
519 | cd_find_name_in_buffer: |
640 | mov [cd_current_pointer_of_input_2],CDDataBuf |
520 | mov [cd_current_pointer_of_input_2],CDDataBuf |
641 | .start: |
521 | .start: |
642 | call cd_get_name |
522 | call cd_get_name |
643 | jc .not_found |
523 | jc .not_found |
644 | call cd_compare_name |
524 | call cd_compare_name |
645 | jc .start |
525 | jc .start |
646 | .found: |
526 | .found: |
647 | clc |
527 | clc |
648 | ret |
528 | ret |
649 | .not_found: |
529 | .not_found: |
650 | stc |
530 | stc |
651 | ret |
531 | ret |
652 | |
532 | 653 | cd_get_name: |
|
533 | cd_get_name: |
654 | push eax |
534 | push eax |
655 | mov ebp,[cd_current_pointer_of_input_2] |
535 | mov ebp,[cd_current_pointer_of_input_2] |
656 | mov [cd_current_pointer_of_input],ebp |
536 | mov [cd_current_pointer_of_input],ebp |
657 | mov eax,[ebp] |
537 | mov eax,[ebp] |
658 | cmp eax,0 ; âõîäû çàêîí÷èëèñü? |
538 | cmp eax,0 ; âõîäû çàêîí÷èëèñü? |
659 | je .next_sector |
539 | je .next_sector |
660 | cmp ebp,CDDataBuf+2048 ; áóôåð çàêîí÷èëñÿ? |
540 | cmp ebp,CDDataBuf+2048 ; áóôåð çàêîí÷èëñÿ? |
661 | jae .next_sector |
541 | jae .next_sector |
662 | movzx eax, byte [ebp] |
542 | movzx eax, byte [ebp] |
663 | add [cd_current_pointer_of_input_2],eax ; ñëåäóþùèé âõîä êàòàëîãà |
543 | add [cd_current_pointer_of_input_2],eax ; ñëåäóþùèé âõîä êàòàëîãà |
664 | add ebp,33 ; óêàçàòåëü óñòàíîâëåí íà íà÷àëî èìåíè |
544 | add ebp,33 ; óêàçàòåëü óñòàíîâëåí íà íà÷àëî èìåíè |
665 | pop eax |
545 | pop eax |
666 | clc |
546 | clc |
667 | ret |
547 | ret |
668 | .next_sector: |
548 | .next_sector: |
669 | pop eax |
549 | pop eax |
670 | stc |
550 | stc |
671 | ret |
551 | ret |
672 | |
552 | 673 | cd_compare_name: |
|
553 | cd_compare_name: |
674 | ; compares ASCIIZ-names, case-insensitive (cp866 encoding) |
554 | ; compares ASCIIZ-names, case-insensitive (cp866 encoding) |
675 | ; in: esi->name, ebp->name |
555 | ; in: esi->name, ebp->name |
676 | ; out: if names match: ZF=1 and esi->next component of name |
556 | ; out: if names match: ZF=1 and esi->next component of name |
677 | ; else: ZF=0, esi is not changed |
557 | ; else: ZF=0, esi is not changed |
678 | ; destroys eax |
558 | ; destroys eax |
679 | push esi eax edi |
559 | push esi eax edi |
680 | mov edi,ebp |
560 | mov edi,ebp |
681 | .loop: |
561 | .loop: |
682 | cld |
562 | cld |
683 | lodsb |
563 | lodsb |
684 | push ax |
564 | push ax |
685 | call char_toupper |
565 | call char_toupper |
686 | call ansi2uni_char |
566 | call ansi2uni_char |
687 | xchg ah,al |
567 | xchg ah,al |
688 | cld |
568 | cld |
689 | scasw |
569 | scasw |
690 | pop ax |
570 | pop ax |
691 | je .coincides |
571 | je .coincides |
692 | call char_todown |
572 | call char_todown |
693 | call ansi2uni_char |
573 | call ansi2uni_char |
694 | xchg ah,al |
574 | xchg ah,al |
695 | cld |
575 | cld |
696 | sub edi,2 |
576 | sub edi,2 |
697 | scasw |
577 | scasw |
698 | jne .name_not_coincide |
578 | jne .name_not_coincide |
699 | .coincides: |
579 | .coincides: |
700 | cmp [esi],byte '/' ; ðàçäåëèòåëü ïóòè, êîíåö èìåíè òåêóùåãî ýëåìåíòà |
580 | cmp [esi],byte '/' ; ðàçäåëèòåëü ïóòè, êîíåö èìåíè òåêóùåãî ýëåìåíòà |
701 | je .done |
581 | je .done |
702 | cmp [esi],byte 0 ; ðàçäåëèòåëü ïóòè, êîíåö èìåíè òåêóùåãî ýëåìåíòà |
582 | cmp [esi],byte 0 ; ðàçäåëèòåëü ïóòè, êîíåö èìåíè òåêóùåãî ýëåìåíòà |
703 | je .done |
583 | je .done |
704 | jmp .loop |
584 | jmp .loop |
705 | .name_not_coincide: |
585 | .name_not_coincide: |
706 | pop edi eax esi |
586 | pop edi eax esi |
707 | stc |
587 | stc |
708 | ret |
588 | ret |
709 | .done: |
589 | .done: |
710 | ; ïðîâåðêà êîíöà ôàéëà |
590 | ; ïðîâåðêà êîíöà ôàéëà |
711 | cmp [edi],word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';' |
591 | cmp [edi],word 3B00h ; ñåïàðàòîð êîíöà ôàéëà ';' |
712 | je .done_1 |
592 | je .done_1 |
713 | ; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì |
593 | ; ïðîâåðêà äëÿ ôàéëîâ íå çàêàí÷èâàþùèõñÿ ñåïàðàòîðîì |
714 | movzx eax,byte [ebp-33] |
594 | movzx eax,byte [ebp-33] |
715 | add eax,ebp |
595 | add eax,ebp |
716 | sub eax,34 |
596 | sub eax,34 |
717 | cmp edi,eax |
597 | cmp edi,eax |
718 | je .done_1 |
598 | je .done_1 |
719 | ; ïðîâåðêà êîíöà ïàïêè |
599 | ; ïðîâåðêà êîíöà ïàïêè |
720 | movzx eax,byte [ebp-1] |
600 | movzx eax,byte [ebp-1] |
721 | add eax,ebp |
601 | add eax,ebp |
722 | cmp edi,eax |
602 | cmp edi,eax |
723 | jne .name_not_coincide |
603 | jne .name_not_coincide |
724 | .done_1: |
604 | .done_1: |
725 | pop edi eax |
605 | pop edi eax |
726 | add esp,4 |
606 | add esp,4 |
727 | inc esi |
607 | inc esi |
728 | clc |
608 | clc |
729 | ret |
609 | ret |
730 | |
610 | 731 | char_todown: |
|
611 | char_todown: |
732 | ; convert character to uppercase, using cp866 encoding |
612 | ; convert character to uppercase, using cp866 encoding |
733 | ; in: al=symbol |
613 | ; in: al=symbol |
734 | ; out: al=converted symbol |
614 | ; out: al=converted symbol |
735 | cmp al, 'A' |
615 | cmp al, 'A' |
736 | jb .ret |
616 | jb .ret |
737 | cmp al, 'Z' |
617 | cmp al, 'Z' |
738 | jbe .az |
618 | jbe .az |
739 | cmp al, '' |
619 | cmp al, '' |
740 | jb .ret |
620 | jb .ret |
741 | cmp al, '' |
621 | cmp al, '' |
742 | jb .rus1 |
622 | jb .rus1 |
743 | cmp al, '' |
623 | cmp al, '' |
744 | ja .ret |
624 | ja .ret |
745 | ; 0x90-0x9F -> 0xE0-0xEF |
625 | ; 0x90-0x9F -> 0xE0-0xEF |
746 | add al, 'à'-'' |
626 | add al, 'à'-'' |
747 | .ret: |
627 | .ret: |
748 | ret |
628 | ret |
749 | .rus1: |
629 | .rus1: |
750 | ; 0x80-0x8F -> 0xA0-0xAF |
630 | ; 0x80-0x8F -> 0xA0-0xAF |
751 | .az: |
631 | .az: |
752 | add al, 0x20 |
632 | add al, 0x20 |
753 | ret |
633 | ret |
754 | |
634 | 755 | uni2ansi_char: |
|
635 | uni2ansi_char: |
756 | ; convert UNICODE character in al to ANSI character in ax, using cp866 encoding |
636 | ; convert UNICODE character in al to ANSI character in ax, using cp866 encoding |
757 | ; in: ax=UNICODE character |
637 | ; in: ax=UNICODE character |
758 | ; out: al=converted ANSI character |
638 | ; out: al=converted ANSI character |
759 | cmp ax, 0x80 |
639 | cmp ax, 0x80 |
760 | jb .ascii |
640 | jb .ascii |
761 | cmp ax, 0x401 |
641 | cmp ax, 0x401 |
762 | jz .yo1 |
642 | jz .yo1 |
763 | cmp ax, 0x451 |
643 | cmp ax, 0x451 |
764 | jz .yo2 |
644 | jz .yo2 |
765 | cmp ax, 0x410 |
645 | cmp ax, 0x410 |
766 | jb .unk |
646 | jb .unk |
767 | cmp ax, 0x440 |
647 | cmp ax, 0x440 |
768 | jb .rus1 |
648 | jb .rus1 |
769 | cmp ax, 0x450 |
649 | cmp ax, 0x450 |
770 | jb .rus2 |
650 | jb .rus2 |
771 | .unk: |
651 | .unk: |
772 | mov al, '_' |
652 | mov al, '_' |
773 | jmp .doit |
653 | jmp .doit |
774 | .yo1: |
654 | .yo1: |
775 | mov al, 'ð' |
655 | mov al, 'ð' |
776 | jmp .doit |
656 | jmp .doit |
777 | .yo2: |
657 | .yo2: |
778 | mov al, 'ñ' |
658 | mov al, 'ñ' |
779 | jmp .doit |
659 | jmp .doit |
780 | .rus1: |
660 | .rus1: |
781 | ; 0x410-0x43F -> 0x80-0xAF |
661 | ; 0x410-0x43F -> 0x80-0xAF |
782 | add al, 0x70 |
662 | add al, 0x70 |
783 | jmp .doit |
663 | jmp .doit |
784 | .rus2: |
664 | .rus2: |
785 | ; 0x440-0x44F -> 0xE0-0xEF |
665 | ; 0x440-0x44F -> 0xE0-0xEF |
786 | add al, 0xA0 |
666 | add al, 0xA0 |
787 | .ascii: |
667 | .ascii: |
788 | .doit: |
668 | .doit: |
789 | ret>> |
669 | ret |
- |