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