Subversion Repositories Kolibri OS

Rev

Rev 3742 | Rev 5363 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3742 Rev 4700
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2011. 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: 3742 $
-
 
-
 
8
$Revision: 4700 $
9
 
9
 
10
 
10
;-----------------------------------------------------------------------------
11
uglobal
11
uglobal
12
cd_current_pointer_of_input    dd  0
12
cd_current_pointer_of_input    dd  0
13
cd_current_pointer_of_input_2  dd  0
13
cd_current_pointer_of_input_2  dd  0
14
cd_mem_location                dd  0
14
cd_mem_location                dd  0
15
cd_counter_block               dd  0
15
cd_counter_block               dd  0
16
IDE_Channel_1                  db  0
-
 
17
IDE_Channel_2                  db  0
-
 
18
endg
16
endg
19
 
-
 
-
 
17
;-----------------------------------------------------------------------------
20
reserve_cd:
18
reserve_cd:
21
 
-
 
22
        cli
19
        cli
23
        cmp     [cd_status], 0
20
        cmp     [cd_status], 0
24
        je      reserve_ok2
21
        je      reserve_ok2
25
 
22
 
26
        sti
23
        sti
27
        call    change_task
24
        call    change_task
28
        jmp     reserve_cd
25
        jmp     reserve_cd
29
 
-
 
-
 
26
;-----------------------------------------------------------------------------
30
  reserve_ok2:
27
reserve_ok2:
31
 
-
 
32
        push    eax
28
        push    eax
33
        mov     eax, [CURRENT_TASK]
29
        mov     eax, [CURRENT_TASK]
34
        shl     eax, 5
30
        shl     eax, 5
35
        mov     eax, [eax+CURRENT_TASK+TASKDATA.pid]
31
        mov     eax, [eax+CURRENT_TASK+TASKDATA.pid]
36
        mov     [cd_status], eax
32
        mov     [cd_status], eax
37
        pop     eax
33
        pop     eax
38
        sti
34
        sti
39
        ret
35
        ret
40
 
-
 
-
 
36
;-----------------------------------------------------------------------------
41
reserve_cd_channel:
37
reserve_cd_channel:
42
        cmp     [ChannelNumber], 1
-
 
43
        jne     .IDE_Channel_2
-
 
44
.IDE_Channel_1:
-
 
45
        pushad
38
        pushad
-
 
39
        mov     eax, [cdpos]
-
 
40
        dec     eax
-
 
41
        shr     eax, 2
-
 
42
 
-
 
43
        test    eax, eax
-
 
44
        jnz     .1
-
 
45
 
-
 
46
        cmp     [ChannelNumber], 1
-
 
47
        jne     @f
-
 
48
 
46
        mov     ecx, ide_channel1_mutex
49
        mov     ecx, ide_channel1_mutex
47
        call    mutex_lock
50
        jmp     .mutex_lock
48
        mov     [IDE_Channel_1], 1
51
;--------------------------------------
49
        popad
-
 
50
        ret
52
@@:
51
.IDE_Channel_2:
-
 
52
        pushad
-
 
53
        mov     ecx, ide_channel2_mutex
53
        mov     ecx, ide_channel2_mutex
-
 
54
        jmp     .mutex_lock
-
 
55
;--------------------------------------
-
 
56
.1:
-
 
57
        dec     eax
-
 
58
        jnz     .2
-
 
59
 
-
 
60
        cmp     [ChannelNumber], 1
-
 
61
        jne     @f
-
 
62
 
-
 
63
        mov     ecx, ide_channel3_mutex
-
 
64
        jmp     .mutex_lock
-
 
65
;--------------------------------------
-
 
66
@@:
-
 
67
        mov     ecx, ide_channel4_mutex
-
 
68
        jmp     .mutex_lock
-
 
69
;--------------------------------------
-
 
70
.2:
-
 
71
        cmp     [ChannelNumber], 1
-
 
72
        jne     @f
-
 
73
 
-
 
74
        mov     ecx, ide_channel5_mutex
-
 
75
        jmp     .mutex_lock
-
 
76
;--------------------------------------
-
 
77
@@:
-
 
78
        mov     ecx, ide_channel6_mutex
-
 
79
.mutex_lock:
54
        call    mutex_lock
80
        call    mutex_lock
55
        mov     [IDE_Channel_2], 1
-
 
56
        popad
81
        popad
57
        ret
82
        ret
58
 
-
 
-
 
83
;-----------------------------------------------------------------------------
59
free_cd_channel:
84
free_cd_channel:
60
        cmp     [ChannelNumber], 1
-
 
61
        jne     .IDE_Channel_2
-
 
62
.IDE_Channel_1:
-
 
63
        mov     [IDE_Channel_1], 0
-
 
64
        pushad
85
        pushad
-
 
86
        mov     eax, [cdpos]
-
 
87
        dec     eax
-
 
88
        shr     eax, 2
-
 
89
 
-
 
90
        test    eax, eax
-
 
91
        jnz     .1
-
 
92
 
-
 
93
        cmp     [ChannelNumber], 1
-
 
94
        jne     @f
-
 
95
 
65
        mov     ecx, ide_channel1_mutex
96
        mov     ecx, ide_channel1_mutex
66
        call    mutex_unlock
97
        jmp     .mutex_unlock
67
        popad
-
 
68
        ret
-
 
69
.IDE_Channel_2:
-
 
70
        mov     [IDE_Channel_2], 0
98
;--------------------------------------
71
        pushad
99
@@:
72
        mov     ecx, ide_channel2_mutex
100
        mov     ecx, ide_channel2_mutex
-
 
101
        jmp     .mutex_unlock
-
 
102
;--------------------------------------
-
 
103
.1:
-
 
104
        dec     eax
-
 
105
        jnz     .2
-
 
106
 
-
 
107
        cmp     [ChannelNumber], 1
-
 
108
        jne     @f
-
 
109
 
-
 
110
        mov     ecx, ide_channel3_mutex
-
 
111
        jmp     .mutex_unlock
-
 
112
;--------------------------------------
-
 
113
@@:
-
 
114
        mov     ecx, ide_channel4_mutex
-
 
115
        jmp     .mutex_unlock
-
 
116
;--------------------------------------
-
 
117
.2:
-
 
118
        cmp     [ChannelNumber], 1
-
 
119
        jne     @f
-
 
120
 
-
 
121
        mov     ecx, ide_channel5_mutex
-
 
122
        jmp     .mutex_unlock
-
 
123
;--------------------------------------
-
 
124
@@:
-
 
125
        mov     ecx, ide_channel6_mutex
-
 
126
.mutex_unlock:
73
        call    mutex_unlock
127
        call    mutex_unlock
74
        popad
128
        popad
75
        ret
129
        ret
76
 
-
 
-
 
130
;-----------------------------------------------------------------------------
77
uglobal
131
uglobal
78
cd_status dd 0
132
cd_status dd 0
79
endg
133
endg
80
 
-
 
81
;----------------------------------------------------------------
134
;-----------------------------------------------------------------------------
82
;
135
;
83
;  fs_CdRead - LFN variant for reading CD disk
136
;  fs_CdRead - LFN variant for reading CD disk
84
;
137
;
85
;  esi  points to filename /dir1/dir2/.../dirn/file,0
138
;  esi  points to filename /dir1/dir2/.../dirn/file,0
86
;  ebx  pointer to 64-bit number = first wanted byte, 0+
139
;  ebx  pointer to 64-bit number = first wanted byte, 0+
87
;       may be ebx=0 - start from first byte
140
;       may be ebx=0 - start from first byte
88
;  ecx  number of bytes to read, 0+
141
;  ecx  number of bytes to read, 0+
89
;  edx  mem location to return data
142
;  edx  mem location to return data
90
;
143
;
91
;  ret ebx = bytes read or 0xffffffff file not found
144
;  ret ebx = bytes read or 0xffffffff file not found
92
;      eax = 0 ok read or other = errormsg
145
;      eax = 0 ok read or other = errormsg
93
;
146
;
94
;--------------------------------------------------------------
147
;-----------------------------------------------------------------------------
95
fs_CdRead:
148
fs_CdRead:
96
        push    edi
149
        push    edi
97
        cmp     byte [esi], 0
150
        cmp     byte [esi], 0
98
        jnz     @f
151
        jnz     @f
-
 
152
;--------------------------------------
99
.noaccess:
153
.noaccess:
100
        pop     edi
154
        pop     edi
-
 
155
;--------------------------------------
101
.noaccess_2:
156
.noaccess_2:
102
        or      ebx, -1
157
        or      ebx, -1
103
        mov     eax, ERROR_ACCESS_DENIED
158
        mov     eax, ERROR_ACCESS_DENIED
104
        ret
159
        ret
105
 
-
 
-
 
160
;--------------------------------------
106
.noaccess_3:
161
.noaccess_3:
107
        pop     eax edx ecx edi
162
        pop     eax edx ecx edi
108
        jmp     .noaccess_2
163
        jmp     .noaccess_2
109
 
-
 
-
 
164
;--------------------------------------
110
@@:
165
@@:
111
        call    cd_find_lfn
166
        call    cd_find_lfn
112
        jnc     .found
167
        jnc     .found
-
 
168
 
113
        pop     edi
169
        pop     edi
114
        cmp     [DevErrorCode], 0
170
        cmp     [DevErrorCode], 0
115
        jne     .noaccess_2
171
        jne     .noaccess_2
-
 
172
 
116
        or      ebx, -1
173
        or      ebx, -1
117
        mov     eax, ERROR_FILE_NOT_FOUND
174
        mov     eax, ERROR_FILE_NOT_FOUND
118
        ret
175
        ret
119
 
-
 
-
 
176
;--------------------------------------
120
.found:
177
.found:
121
        mov     edi, [cd_current_pointer_of_input]
178
        mov     edi, [cd_current_pointer_of_input]
122
        test    byte [edi+25], 10b; do not allow read directories
179
        test    byte [edi+25], 10b; do not allow read directories
123
        jnz     .noaccess
180
        jnz     .noaccess
-
 
181
 
124
        test    ebx, ebx
182
        test    ebx, ebx
125
        jz      .l1
183
        jz      .l1
-
 
184
 
126
        cmp     dword [ebx+4], 0
185
        cmp     dword [ebx+4], 0
127
        jz      @f
186
        jz      @f
-
 
187
 
128
        xor     ebx, ebx
188
        xor     ebx, ebx
-
 
189
;--------------------------------------
129
.reteof:
190
.reteof:
130
        mov     eax, 6; end of file
191
        mov     eax, 6; end of file
131
        pop     edi
192
        pop     edi
132
        ret
193
        ret
-
 
194
;--------------------------------------
133
@@:
195
@@:
134
        mov     ebx, [ebx]
196
        mov     ebx, [ebx]
-
 
197
;--------------------------------------
135
.l1:
198
.l1:
136
        push    ecx edx
199
        push    ecx edx
137
        push    0
200
        push    0
138
        mov     eax, [edi+10] ; реальный размер файловой секции
201
        mov     eax, [edi+10] ; real size of the file section
139
        sub     eax, ebx
202
        sub     eax, ebx
140
        jb      .eof
203
        jb      .eof
-
 
204
 
141
        cmp     eax, ecx
205
        cmp     eax, ecx
142
        jae     @f
206
        jae     @f
-
 
207
 
143
        mov     ecx, eax
208
        mov     ecx, eax
144
        mov     byte [esp], 6
209
        mov     byte [esp], 6
-
 
210
;--------------------------------------
145
@@:
211
@@:
146
        mov     eax, [edi+2]
212
        mov     eax, [edi+2]
147
        mov     [CDSectorAddress], eax
213
        mov     [CDSectorAddress], eax
-
 
214
;--------------------------------------
148
; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
215
; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
149
.new_sector:
216
.new_sector:
150
        test    ecx, ecx
217
        test    ecx, ecx
151
        jz      .done
218
        jz      .done
-
 
219
 
152
        sub     ebx, 2048
220
        sub     ebx, 2048
153
        jae     .next
221
        jae     .next
-
 
222
 
154
        add     ebx, 2048
223
        add     ebx, 2048
155
        jnz     .incomplete_sector
224
        jnz     .incomplete_sector
-
 
225
 
156
        cmp     ecx, 2048
226
        cmp     ecx, 2048
157
        jb      .incomplete_sector
227
        jb      .incomplete_sector
158
; we may read and memmove complete sector
228
; we may read and memmove complete sector
159
        mov     [CDDataBuf_pointer], edx
229
        mov     [CDDataBuf_pointer], edx
160
        call    ReadCDWRetr; читаем сектор файла
230
        call    ReadCDWRetr ; read sector of file
161
        cmp     [DevErrorCode], 0
231
        cmp     [DevErrorCode], 0
162
        jne     .noaccess_3
232
        jne     .noaccess_3
-
 
233
 
163
        add     edx, 2048
234
        add     edx, 2048
164
        sub     ecx, 2048
235
        sub     ecx, 2048
-
 
236
;--------------------------------------
165
.next:
237
.next:
166
        inc     dword [CDSectorAddress]
238
        inc     dword [CDSectorAddress]
167
        jmp     .new_sector
239
        jmp     .new_sector
-
 
240
;--------------------------------------
168
.incomplete_sector:
241
.incomplete_sector:
169
; we must read and memmove incomplete sector
242
; we must read and memmove incomplete sector
170
        mov     [CDDataBuf_pointer], CDDataBuf
243
        mov     [CDDataBuf_pointer], CDDataBuf
171
        call    ReadCDWRetr; читаем сектор файла
244
        call    ReadCDWRetr ; read sector of file
172
        cmp     [DevErrorCode], 0
245
        cmp     [DevErrorCode], 0
173
        jne     .noaccess_3
246
        jne     .noaccess_3
-
 
247
 
174
        push    ecx
248
        push    ecx
175
        add     ecx, ebx
249
        add     ecx, ebx
176
        cmp     ecx, 2048
250
        cmp     ecx, 2048
177
        jbe     @f
251
        jbe     @f
-
 
252
 
178
        mov     ecx, 2048
253
        mov     ecx, 2048
-
 
254
;--------------------------------------
179
@@:
255
@@:
180
        sub     ecx, ebx
256
        sub     ecx, ebx
181
        push    edi esi ecx
257
        push    edi esi ecx
182
        mov     edi, edx
258
        mov     edi, edx
183
        lea     esi, [CDDataBuf + ebx]
259
        lea     esi, [CDDataBuf + ebx]
184
        cld
260
        cld
185
        rep movsb
261
        rep movsb
186
        pop     ecx esi edi
262
        pop     ecx esi edi
187
        add     edx, ecx
263
        add     edx, ecx
188
        sub     [esp], ecx
264
        sub     [esp], ecx
189
        pop     ecx
265
        pop     ecx
190
        xor     ebx, ebx
266
        xor     ebx, ebx
191
        jmp     .next
267
        jmp     .next
192
 
-
 
-
 
268
;--------------------------------------
193
.done:
269
.done:
194
        mov     ebx, edx
270
        mov     ebx, edx
195
        pop     eax edx ecx edi
271
        pop     eax edx ecx edi
196
        sub     ebx, edx
272
        sub     ebx, edx
197
        ret
273
        ret
-
 
274
;--------------------------------------
198
.eof:
275
.eof:
199
        mov     ebx, edx
276
        mov     ebx, edx
200
        pop     eax edx ecx
277
        pop     eax edx ecx
201
        sub     ebx, edx
278
        sub     ebx, edx
202
        jmp     .reteof
279
        jmp     .reteof
203
 
-
 
204
;----------------------------------------------------------------
280
;-----------------------------------------------------------------------------
205
;
281
;
206
;  fs_CdReadFolder - LFN variant for reading CD disk folder
282
;  fs_CdReadFolder - LFN variant for reading CD disk folder
207
;
283
;
208
;  esi  points to filename  /dir1/dir2/.../dirn/file,0
284
;  esi  points to filename  /dir1/dir2/.../dirn/file,0
209
;  ebx  pointer to structure 32-bit number = first wanted block, 0+
285
;  ebx  pointer to structure 32-bit number = first wanted block, 0+
210
;                          & flags (bitfields)
286
;                          & flags (bitfields)
211
; flags: bit 0: 0=ANSI names, 1=UNICODE names
287
; flags: bit 0: 0=ANSI names, 1=UNICODE names
212
;  ecx  number of blocks to read, 0+
288
;  ecx  number of blocks to read, 0+
213
;  edx  mem location to return data
289
;  edx  mem location to return data
214
;
290
;
215
;  ret ebx = blocks read or 0xffffffff folder not found
291
;  ret ebx = blocks read or 0xffffffff folder not found
216
;      eax = 0 ok read or other = errormsg
292
;      eax = 0 ok read or other = errormsg
217
;
293
;
218
;--------------------------------------------------------------
294
;-----------------------------------------------------------------------------
219
fs_CdReadFolder:
295
fs_CdReadFolder:
220
        push    edi
296
        push    edi
221
        call    cd_find_lfn
297
        call    cd_find_lfn
222
        jnc     .found
298
        jnc     .found
-
 
299
 
223
        pop     edi
300
        pop     edi
224
        cmp     [DevErrorCode], 0
301
        cmp     [DevErrorCode], 0
225
        jne     .noaccess_1
302
        jne     .noaccess_1
-
 
303
 
226
        or      ebx, -1
304
        or      ebx, -1
227
        mov     eax, ERROR_FILE_NOT_FOUND
305
        mov     eax, ERROR_FILE_NOT_FOUND
228
        ret
306
        ret
-
 
307
;--------------------------------------
229
.found:
308
.found:
230
        mov     edi, [cd_current_pointer_of_input]
309
        mov     edi, [cd_current_pointer_of_input]
231
        test    byte [edi+25], 10b    ; do not allow read directories
310
        test    byte [edi+25], 10b    ; do not allow read directories
232
        jnz     .found_dir
311
        jnz     .found_dir
-
 
312
 
233
        pop     edi
313
        pop     edi
-
 
314
;--------------------------------------
234
.noaccess_1:
315
.noaccess_1:
235
        or      ebx, -1
316
        or      ebx, -1
236
        mov     eax, ERROR_ACCESS_DENIED
317
        mov     eax, ERROR_ACCESS_DENIED
237
        ret
318
        ret
-
 
319
;--------------------------------------
238
.found_dir:
320
.found_dir:
239
        mov     eax, [edi+2]    ; eax=cluster
321
        mov     eax, [edi+2]    ; eax=cluster
240
        mov     [CDSectorAddress], eax
322
        mov     [CDSectorAddress], eax
241
        mov     eax, [edi+10]   ; размер директрории
323
        mov     eax, [edi+10]   ; directory size
-
 
324
;--------------------------------------
242
.doit:
325
.doit:
243
; init header
326
; init header
244
        push    eax ecx
327
        push    eax ecx
245
        mov     edi, edx
328
        mov     edi, edx
246
        mov     ecx, 32/4
329
        mov     ecx, 32/4
247
        xor     eax, eax
330
        xor     eax, eax
248
        rep stosd
331
        rep stosd
249
        pop     ecx eax
332
        pop     ecx eax
250
        mov     byte [edx], 1   ; version
333
        mov     byte [edx], 1   ; version
251
        mov     [cd_mem_location], edx
334
        mov     [cd_mem_location], edx
252
        add     [cd_mem_location], 32
335
        add     [cd_mem_location], 32
253
; начинаем переброску БДВК в УСВК
-
 
254
;.mainloop:
336
;.mainloop:
255
        mov     [cd_counter_block], dword 0
337
        mov     [cd_counter_block], dword 0
256
        dec     dword [CDSectorAddress]
338
        dec     dword [CDSectorAddress]
257
        push    ecx
339
        push    ecx
-
 
340
;--------------------------------------
258
.read_to_buffer:
341
.read_to_buffer:
259
        inc     dword [CDSectorAddress]
342
        inc     dword [CDSectorAddress]
260
        mov     [CDDataBuf_pointer], CDDataBuf
343
        mov     [CDDataBuf_pointer], CDDataBuf
261
        call    ReadCDWRetr         ; читаем сектор директории
344
        call    ReadCDWRetr         ; read sector of directory
262
        cmp     [DevErrorCode], 0
345
        cmp     [DevErrorCode], 0
263
        jne     .noaccess_1
346
        jne     .noaccess_1
-
 
347
 
264
        call    .get_names_from_buffer
348
        call    .get_names_from_buffer
265
        sub     eax, 2048
349
        sub     eax, 2048
266
; директория закончилась?
350
; directory is over?
267
        ja      .read_to_buffer
351
        ja      .read_to_buffer
-
 
352
 
268
        mov     edi, [cd_counter_block]
353
        mov     edi, [cd_counter_block]
269
        mov     [edx+8], edi
354
        mov     [edx+8], edi
270
        mov     edi, [ebx]
355
        mov     edi, [ebx]
271
        sub     [edx+4], edi
356
        sub     [edx+4], edi
272
        xor     eax, eax
357
        xor     eax, eax
273
        dec     ecx
358
        dec     ecx
274
        js      @f
359
        js      @f
-
 
360
 
275
        mov     al, ERROR_END_OF_FILE
361
        mov     al, ERROR_END_OF_FILE
-
 
362
;--------------------------------------
276
@@:
363
@@:
277
        pop     ecx edi
364
        pop     ecx edi
278
        mov     ebx, [edx+4]
365
        mov     ebx, [edx+4]
279
        ret
366
        ret
280
 
-
 
-
 
367
;--------------------------------------
281
.get_names_from_buffer:
368
.get_names_from_buffer:
282
        mov     [cd_current_pointer_of_input_2], CDDataBuf
369
        mov     [cd_current_pointer_of_input_2], CDDataBuf
283
        push    eax esi edi edx
370
        push    eax esi edi edx
-
 
371
;--------------------------------------
284
.get_names_from_buffer_1:
372
.get_names_from_buffer_1:
285
        call    cd_get_name
373
        call    cd_get_name
286
        jc      .end_buffer
374
        jc      .end_buffer
-
 
375
 
287
        inc     dword [cd_counter_block]
376
        inc     dword [cd_counter_block]
288
        mov     eax, [cd_counter_block]
377
        mov     eax, [cd_counter_block]
289
        cmp     [ebx], eax
378
        cmp     [ebx], eax
290
        jae     .get_names_from_buffer_1
379
        jae     .get_names_from_buffer_1
-
 
380
 
291
        test    ecx, ecx
381
        test    ecx, ecx
292
        jz      .get_names_from_buffer_1
382
        jz      .get_names_from_buffer_1
-
 
383
 
293
        mov     edi, [cd_counter_block]
384
        mov     edi, [cd_counter_block]
294
        mov     [edx+4], edi
385
        mov     [edx+4], edi
295
        dec     ecx
386
        dec     ecx
296
        mov     esi, ebp
387
        mov     esi, ebp
297
        mov     edi, [cd_mem_location]
388
        mov     edi, [cd_mem_location]
298
        add     edi, 40
389
        add     edi, 40
299
        test    dword [ebx+4], 1; 0=ANSI, 1=UNICODE
390
        test    dword [ebx+4], 1; 0=ANSI, 1=UNICODE
300
        jnz     .unicode
391
        jnz     .unicode
301
;    jmp  .unicode
392
;--------------------------------------
302
.ansi:
393
.ansi:
303
        cmp     [cd_counter_block], 2
394
        cmp     [cd_counter_block], 2
304
        jbe     .ansi_parent_directory
395
        jbe     .ansi_parent_directory
-
 
396
 
305
        cld
397
        cld
306
        lodsw
398
        lodsw
307
        xchg    ah, al
399
        xchg    ah, al
308
        call    uni2ansi_char
400
        call    uni2ansi_char
309
        cld
401
        cld
310
        stosb
402
        stosb
311
; проверка конца файла
403
; check end of file
312
        mov     ax, [esi]
404
        mov     ax, [esi]
313
        cmp     ax, word 3B00h; сепаратор конца файла ';'
405
        cmp     ax, word 3B00h ; separator end of file ';'
314
        je      .cd_get_parameters_of_file_1
406
        je      .cd_get_parameters_of_file_1
315
; проверка для файлов не заканчивающихся сепаратором
407
; check for files not ending with separator
316
        movzx   eax, byte [ebp-33]
408
        movzx   eax, byte [ebp-33]
317
        add     eax, ebp
409
        add     eax, ebp
318
        sub     eax, 34
410
        sub     eax, 34
319
        cmp     esi, eax
411
        cmp     esi, eax
320
        je      .cd_get_parameters_of_file_1
412
        je      .cd_get_parameters_of_file_1
321
; проверка конца папки
413
; check the end of the directory
322
        movzx   eax, byte [ebp-1]
414
        movzx   eax, byte [ebp-1]
323
        add     eax, ebp
415
        add     eax, ebp
324
        cmp     esi, eax
416
        cmp     esi, eax
325
        jb      .ansi
417
        jb      .ansi
-
 
418
;--------------------------------------
326
.cd_get_parameters_of_file_1:
419
.cd_get_parameters_of_file_1:
327
        mov     [edi], byte 0
420
        mov     [edi], byte 0
328
        call    cd_get_parameters_of_file
421
        call    cd_get_parameters_of_file
329
        add     [cd_mem_location], 304
422
        add     [cd_mem_location], 304
330
        jmp     .get_names_from_buffer_1
423
        jmp     .get_names_from_buffer_1
331
 
-
 
-
 
424
;--------------------------------------
332
.ansi_parent_directory:
425
.ansi_parent_directory:
333
        cmp     [cd_counter_block], 2
426
        cmp     [cd_counter_block], 2
334
        je      @f
427
        je      @f
-
 
428
 
335
        mov     [edi], byte '.'
429
        mov     [edi], byte '.'
336
        inc     edi
430
        inc     edi
337
        jmp     .cd_get_parameters_of_file_1
431
        jmp     .cd_get_parameters_of_file_1
-
 
432
;--------------------------------------
338
@@:
433
@@:
339
        mov     [edi], word '..'
434
        mov     [edi], word '..'
340
        add     edi, 2
435
        add     edi, 2
341
        jmp     .cd_get_parameters_of_file_1
436
        jmp     .cd_get_parameters_of_file_1
342
 
-
 
-
 
437
;--------------------------------------
343
.unicode:
438
.unicode:
344
        cmp     [cd_counter_block], 2
439
        cmp     [cd_counter_block], 2
345
        jbe     .unicode_parent_directory
440
        jbe     .unicode_parent_directory
-
 
441
 
346
        cld
442
        cld
347
        movsw
443
        movsw
348
; проверка конца файла
444
; check end of file
349
        mov     ax, [esi]
445
        mov     ax, [esi]
350
        cmp     ax, word 3B00h; сепаратор конца файла ';'
446
        cmp     ax, word 3B00h; separator end of file ';'
351
        je      .cd_get_parameters_of_file_2
447
        je      .cd_get_parameters_of_file_2
352
; проверка для файлов не заканчивающихся сепаратором
448
; check for files not ending with separator
353
        movzx   eax, byte [ebp-33]
449
        movzx   eax, byte [ebp-33]
354
        add     eax, ebp
450
        add     eax, ebp
355
        sub     eax, 34
451
        sub     eax, 34
356
        cmp     esi, eax
452
        cmp     esi, eax
357
        je      .cd_get_parameters_of_file_2
453
        je      .cd_get_parameters_of_file_2
358
; проверка конца папки
454
; check the end of the directory
359
        movzx   eax, byte [ebp-1]
455
        movzx   eax, byte [ebp-1]
360
        add     eax, ebp
456
        add     eax, ebp
361
        cmp     esi, eax
457
        cmp     esi, eax
362
        jb      .unicode
458
        jb      .unicode
-
 
459
;--------------------------------------
363
.cd_get_parameters_of_file_2:
460
.cd_get_parameters_of_file_2:
364
        mov     [edi], word 0
461
        mov     [edi], word 0
365
        call    cd_get_parameters_of_file
462
        call    cd_get_parameters_of_file
366
        add     [cd_mem_location], 560
463
        add     [cd_mem_location], 560
367
        jmp     .get_names_from_buffer_1
464
        jmp     .get_names_from_buffer_1
368
 
-
 
-
 
465
;--------------------------------------
369
.unicode_parent_directory:
466
.unicode_parent_directory:
370
        cmp     [cd_counter_block], 2
467
        cmp     [cd_counter_block], 2
371
        je      @f
468
        je      @f
-
 
469
 
372
        mov     [edi], word 2E00h; '.'
470
        mov     [edi], word 2E00h; '.'
373
        add     edi, 2
471
        add     edi, 2
374
        jmp     .cd_get_parameters_of_file_2
472
        jmp     .cd_get_parameters_of_file_2
-
 
473
;--------------------------------------
375
@@:
474
@@:
376
        mov     [edi], dword 2E002E00h; '..'
475
        mov     [edi], dword 2E002E00h; '..'
377
        add     edi, 4
476
        add     edi, 4
378
        jmp     .cd_get_parameters_of_file_2
477
        jmp     .cd_get_parameters_of_file_2
379
 
-
 
-
 
478
;--------------------------------------
380
.end_buffer:
479
.end_buffer:
381
        pop     edx edi esi eax
480
        pop     edx edi esi eax
382
        ret
481
        ret
383
 
-
 
-
 
482
;-----------------------------------------------------------------------------
384
cd_get_parameters_of_file:
483
cd_get_parameters_of_file:
385
        mov     edi, [cd_mem_location]
484
        mov     edi, [cd_mem_location]
386
cd_get_parameters_of_file_1:
485
cd_get_parameters_of_file_1:
387
; получаем атрибуты файла
486
; get file attributes
388
        xor     eax, eax
487
        xor     eax, eax
389
; файл не архивировался
488
; file is not archived
390
        inc     eax
489
        inc     eax
391
        shl     eax, 1
490
        shl     eax, 1
392
; это каталог?
491
; is a directory?
393
        test    [ebp-8], byte 2
492
        test    [ebp-8], byte 2
394
        jz      .file
493
        jz      .file
-
 
494
 
395
        inc     eax
495
        inc     eax
-
 
496
;--------------------------------------
396
.file:
497
.file:
397
; метка тома не как в FAT, в этом виде отсутсвует
498
; not as a volume label in the FAT, in this form not available
398
; файл не является системным
499
; file is not a system
399
        shl     eax, 3
500
        shl     eax, 3
400
; файл является скрытым? (атрибут существование)
501
; file is hidden? (attribute of existence)
401
        test    [ebp-8], byte 1
502
        test    [ebp-8], byte 1
402
        jz      .hidden
503
        jz      .hidden
-
 
504
 
403
        inc     eax
505
        inc     eax
-
 
506
;--------------------------------------
404
.hidden:
507
.hidden:
405
        shl     eax, 1
508
        shl     eax, 1
406
; файл всегда только для чтения, так как это CD
509
; file is always read-only, as this CD
407
        inc     eax
510
        inc     eax
408
        mov     [edi], eax
511
        mov     [edi], eax
409
; получаем время для файла
512
; get the time to file
410
;час
513
; hour
411
        movzx   eax, byte [ebp-12]
514
        movzx   eax, byte [ebp-12]
412
        shl     eax, 8
515
        shl     eax, 8
413
;минута
516
; minute
414
        mov     al, [ebp-11]
517
        mov     al, [ebp-11]
415
        shl     eax, 8
518
        shl     eax, 8
416
;секунда
519
; second
417
        mov     al, [ebp-10]
520
        mov     al, [ebp-10]
418
;время создания файла
521
; file creation time
419
        mov     [edi+8], eax
522
        mov     [edi+8], eax
420
;время последнего доступа
523
; last access time
421
        mov     [edi+16], eax
524
        mov     [edi+16], eax
422
;время последней записи
525
; last write time
423
        mov     [edi+24], eax
526
        mov     [edi+24], eax
424
; получаем дату для файла
527
; get date for file
425
;год
528
; year
426
        movzx   eax, byte [ebp-15]
529
        movzx   eax, byte [ebp-15]
427
        add     eax, 1900
530
        add     eax, 1900
428
        shl     eax, 8
531
        shl     eax, 8
429
;месяц
532
; month
430
        mov     al, [ebp-14]
533
        mov     al, [ebp-14]
431
        shl     eax, 8
534
        shl     eax, 8
432
;день
535
; day
433
        mov     al, [ebp-13]
536
        mov     al, [ebp-13]
434
;дата создания файла
537
; file creation date
435
        mov     [edi+12], eax
538
        mov     [edi+12], eax
436
;время последнего доступа
539
; last access date
437
        mov     [edi+20], eax
540
        mov     [edi+20], eax
438
;время последней записи
541
; last write date 
439
        mov     [edi+28], eax
542
        mov     [edi+28], eax
440
; получаем тип данных имени
543
; get the data type of name
441
        xor     eax, eax
544
        xor     eax, eax
442
        test    dword [ebx+4], 1; 0=ANSI, 1=UNICODE
545
        test    dword [ebx+4], 1; 0=ANSI, 1=UNICODE
443
        jnz     .unicode_1
546
        jnz     .unicode_1
-
 
547
 
444
        mov     [edi+4], eax
548
        mov     [edi+4], eax
445
        jmp     @f
549
        jmp     @f
-
 
550
;--------------------------------------
446
.unicode_1:
551
.unicode_1:
447
        inc     eax
552
        inc     eax
448
        mov     [edi+4], eax
553
        mov     [edi+4], eax
-
 
554
;--------------------------------------
449
@@:
555
@@:
450
; получаем размер файла в байтах
556
; get the file size in bytes
451
        xor     eax, eax
557
        xor     eax, eax
452
        mov     [edi+32+4], eax
558
        mov     [edi+32+4], eax
453
        mov     eax, [ebp-23]
559
        mov     eax, [ebp-23]
454
        mov     [edi+32], eax
560
        mov     [edi+32], eax
455
        ret
561
        ret
456
 
-
 
457
;----------------------------------------------------------------
562
;-----------------------------------------------------------------------------
458
;
563
;
459
;  fs_CdGetFileInfo - LFN variant for CD
564
;  fs_CdGetFileInfo - LFN variant for CD
460
;                     get file/directory attributes structure
565
;                     get file/directory attributes structure
461
;
566
;
462
;----------------------------------------------------------------
567
;-----------------------------------------------------------------------------
463
fs_CdGetFileInfo:
568
fs_CdGetFileInfo:
464
        cmp     byte [esi], 0
569
        cmp     byte [esi], 0
465
        jnz     @f
570
        jnz     @f
-
 
571
 
466
        mov     eax, 2
572
        mov     eax, 2
467
        ret
573
        ret
-
 
574
;--------------------------------------
468
@@:
575
@@:
469
        push    edi
576
        push    edi
470
        call    cd_find_lfn
577
        call    cd_find_lfn
471
        pushfd
578
        pushfd
472
        cmp     [DevErrorCode], 0
579
        cmp     [DevErrorCode], 0
473
        jz      @f
580
        jz      @f
-
 
581
 
474
        popfd
582
        popfd
475
        pop     edi
583
        pop     edi
476
        mov     eax, 11
584
        mov     eax, 11
477
        ret
585
        ret
-
 
586
;--------------------------------------
478
@@:
587
@@:
479
        popfd
588
        popfd
480
        jnc     @f
589
        jnc     @f
-
 
590
 
481
        pop     edi
591
        pop     edi
482
        mov     eax, ERROR_FILE_NOT_FOUND
592
        mov     eax, ERROR_FILE_NOT_FOUND
483
        ret
593
        ret
-
 
594
;--------------------------------------
484
@@:
595
@@:
485
 
596
 
486
        mov     edi, edx
597
        mov     edi, edx
487
        push    ebp
598
        push    ebp
488
        mov     ebp, [cd_current_pointer_of_input]
599
        mov     ebp, [cd_current_pointer_of_input]
489
        add     ebp, 33
600
        add     ebp, 33
490
        call    cd_get_parameters_of_file_1
601
        call    cd_get_parameters_of_file_1
491
        pop     ebp
602
        pop     ebp
492
        and     dword [edi+4], 0
603
        and     dword [edi+4], 0
493
        pop     edi
604
        pop     edi
494
        xor     eax, eax
605
        xor     eax, eax
495
        ret
606
        ret
496
 
-
 
497
;----------------------------------------------------------------
607
;-----------------------------------------------------------------------------
498
cd_find_lfn:
608
cd_find_lfn:
499
        mov     [cd_appl_data], 0
609
        mov     [cd_appl_data], 0
500
; in: esi+ebp -> name
610
; in: esi+ebp -> name
501
; out: CF=1 - file not found
611
; out: CF=1 - file not found
502
; else CF=0 and [cd_current_pointer_of_input] direntry
612
; else CF=0 and [cd_current_pointer_of_input] direntry
503
        push    eax esi
613
        push    eax esi
504
; 16 сектор начало набора дескрипторов томов
614
; Sector 16 - start set of volume descriptors
505
 
-
 
506
        call    WaitUnitReady
615
        call    WaitUnitReady
507
        cmp     [DevErrorCode], 0
616
        cmp     [DevErrorCode], 0
508
        jne     .access_denied
617
        jne     .access_denied
509
 
618
 
510
        call    prevent_medium_removal
619
        call    prevent_medium_removal
511
; тестовое чтение
620
; testing of reading
512
        mov     [CDSectorAddress], dword 16
621
        mov     [CDSectorAddress], dword 16
513
        mov     [CDDataBuf_pointer], CDDataBuf
622
        mov     [CDDataBuf_pointer], CDDataBuf
514
        call    ReadCDWRetr;_1
623
        call    ReadCDWRetr;_1
515
        cmp     [DevErrorCode], 0
624
        cmp     [DevErrorCode], 0
516
        jne     .access_denied
625
        jne     .access_denied
517
 
626
 
518
; вычисление последней сессии
627
; calculation of the last session
519
        call    WaitUnitReady
628
        call    WaitUnitReady
520
        cmp     [DevErrorCode], 0
629
        cmp     [DevErrorCode], 0
521
        jne     .access_denied
630
        jne     .access_denied
-
 
631
 
522
        call    Read_TOC
632
        call    Read_TOC
523
        mov     ah, [CDDataBuf+4+4]
633
        mov     ah, [CDDataBuf+4+4]
524
        mov     al, [CDDataBuf+4+5]
634
        mov     al, [CDDataBuf+4+5]
525
        shl     eax, 16
635
        shl     eax, 16
526
        mov     ah, [CDDataBuf+4+6]
636
        mov     ah, [CDDataBuf+4+6]
527
        mov     al, [CDDataBuf+4+7]
637
        mov     al, [CDDataBuf+4+7]
528
        add     eax, 15
638
        add     eax, 15
529
        mov     [CDSectorAddress], eax
639
        mov     [CDSectorAddress], eax
530
;  mov  [CDSectorAddress],dword 15
640
;  mov  [CDSectorAddress],dword 15
531
        mov     [CDDataBuf_pointer], CDDataBuf
641
        mov     [CDDataBuf_pointer], CDDataBuf
532
 
-
 
-
 
642
;--------------------------------------
533
.start:
643
.start:
534
        inc     dword [CDSectorAddress]
644
        inc     dword [CDSectorAddress]
535
        call    ReadCDWRetr;_1
645
        call    ReadCDWRetr;_1
536
        cmp     [DevErrorCode], 0
646
        cmp     [DevErrorCode], 0
537
        jne     .access_denied
647
        jne     .access_denied
538
 
648
 
539
.start_check:
649
.start_check:
540
; проверка на вшивость
650
; checking for "lice"
541
        cmp     [CDDataBuf+1], dword 'CD00'
651
        cmp     [CDDataBuf+1], dword 'CD00'
542
        jne     .access_denied
652
        jne     .access_denied
-
 
653
 
543
        cmp     [CDDataBuf+5], byte '1'
654
        cmp     [CDDataBuf+5], byte '1'
544
        jne     .access_denied
655
        jne     .access_denied
545
; сектор является терминатором набор дескрипторов томов?
656
; sector is the terminator of set of descriptors volumes?
546
        cmp     [CDDataBuf], byte 0xff
657
        cmp     [CDDataBuf], byte 0xff
547
        je      .access_denied
658
        je      .access_denied
548
; сектор является дополнительным и улучшенным дескриптором тома?
659
; sector is an additional and improved descriptor of volume?
549
        cmp     [CDDataBuf], byte 0x2
660
        cmp     [CDDataBuf], byte 0x2
550
        jne     .start
661
        jne     .start
551
; сектор является дополнительным дескриптором тома?
662
; sector is an additional descriptor of volume?
552
        cmp     [CDDataBuf+6], byte 0x1
663
        cmp     [CDDataBuf+6], byte 0x1
553
        jne     .start
664
        jne     .start
554
 
665
 
555
; параметры root директрории
666
; parameters of root directory
556
        mov     eax, [CDDataBuf+0x9c+2]; начало root директрории
667
        mov     eax, [CDDataBuf+0x9c+2]; start of root directory
557
        mov     [CDSectorAddress], eax
668
        mov     [CDSectorAddress], eax
558
        mov     eax, [CDDataBuf+0x9c+10]; размер root директрории
669
        mov     eax, [CDDataBuf+0x9c+10]; size of root directory
559
        cmp     byte [esi], 0
670
        cmp     byte [esi], 0
-
 
671
        jnz     @f
560
        jnz     @f
672
 
561
        mov     [cd_current_pointer_of_input], CDDataBuf+0x9c
673
        mov     [cd_current_pointer_of_input], CDDataBuf+0x9c
-
 
674
        jmp     .done
562
        jmp     .done
675
;--------------------------------------
563
@@:
676
@@:
564
; начинаем поиск
677
; start the search
565
.mainloop:
678
.mainloop:
-
 
679
        dec     dword [CDSectorAddress]
566
        dec     dword [CDSectorAddress]
680
;--------------------------------------
567
.read_to_buffer:
681
.read_to_buffer:
568
        inc     dword [CDSectorAddress]
682
        inc     dword [CDSectorAddress]
569
        mov     [CDDataBuf_pointer], CDDataBuf
683
        mov     [CDDataBuf_pointer], CDDataBuf
570
        call    ReadCDWRetr      ; читаем сектор директории
684
        call    ReadCDWRetr      ; read sector of directory
571
        cmp     [DevErrorCode], 0
685
        cmp     [DevErrorCode], 0
572
        jne     .access_denied
686
        jne     .access_denied
-
 
687
 
573
        push    ebp
688
        push    ebp
574
        call    cd_find_name_in_buffer
689
        call    cd_find_name_in_buffer
575
        pop     ebp
690
        pop     ebp
576
        jnc     .found
691
        jnc     .found
-
 
692
 
577
        sub     eax, 2048
693
        sub     eax, 2048
578
; директория закончилась?
694
; directory is over?
579
        cmp     eax, 0
695
        cmp     eax, 0
580
        ja      .read_to_buffer
696
        ja      .read_to_buffer
581
; нет искомого элемента цепочки
697
; desired element of chain is not found
582
.access_denied:
698
.access_denied:
583
        pop     esi eax
699
        pop     esi eax
584
        mov     [cd_appl_data], 1
700
        mov     [cd_appl_data], 1
585
        stc
701
        stc
586
        ret
702
        ret
-
 
703
;--------------------------------------
587
; искомый элемент цепочки найден
704
; desired element of chain found
588
  .found:
705
.found:
589
; конец пути файла
706
; the end of the file path
590
        cmp     byte [esi-1], 0
707
        cmp     byte [esi-1], 0
591
        jz      .done
708
        jz      .done
592
  .nested:
709
  .nested:
593
        mov     eax, [cd_current_pointer_of_input]
710
        mov     eax, [cd_current_pointer_of_input]
594
        push    dword [eax+2]
711
        push    dword [eax+2]
595
        pop     dword [CDSectorAddress]       ; начало директории
712
        pop     dword [CDSectorAddress] ; beginning of the directory
596
        mov     eax, [eax+2+8]; размер директории
713
        mov     eax, [eax+2+8] ; size of directory
597
        jmp     .mainloop
714
        jmp     .mainloop
598
; указатель файла найден
715
;--------------------------------------
-
 
716
; file pointer found
599
   .done:
717
.done:
600
        test    ebp, ebp
718
        test    ebp, ebp
601
        jz      @f
719
        jz      @f
-
 
720
 
602
        mov     esi, ebp
721
        mov     esi, ebp
603
        xor     ebp, ebp
722
        xor     ebp, ebp
604
        jmp     .nested
723
        jmp     .nested
-
 
724
;--------------------------------------
605
@@:
725
@@:
606
        pop     esi eax
726
        pop     esi eax
607
        mov     [cd_appl_data], 1
727
        mov     [cd_appl_data], 1
608
        clc
728
        clc
609
        ret
729
        ret
610
 
-
 
-
 
730
;-----------------------------------------------------------------------------
611
cd_find_name_in_buffer:
731
cd_find_name_in_buffer:
612
        mov     [cd_current_pointer_of_input_2], CDDataBuf
732
        mov     [cd_current_pointer_of_input_2], CDDataBuf
-
 
733
;--------------------------------------
613
.start:
734
.start:
614
        call    cd_get_name
735
        call    cd_get_name
615
        jc      .not_found
736
        jc      .not_found
-
 
737
 
616
        call    cd_compare_name
738
        call    cd_compare_name
617
        jc      .start
739
        jc      .start
-
 
740
;--------------------------------------
618
.found:
741
.found:
619
        clc
742
        clc
620
        ret
743
        ret
-
 
744
;--------------------------------------
621
.not_found:
745
.not_found:
622
        stc
746
        stc
623
        ret
747
        ret
624
 
-
 
-
 
748
;-----------------------------------------------------------------------------
625
cd_get_name:
749
cd_get_name:
626
        push    eax
750
        push    eax
627
        mov     ebp, [cd_current_pointer_of_input_2]
751
        mov     ebp, [cd_current_pointer_of_input_2]
628
        mov     [cd_current_pointer_of_input], ebp
752
        mov     [cd_current_pointer_of_input], ebp
629
        mov     eax, [ebp]
753
        mov     eax, [ebp]
630
        test    eax, eax ; входы закончились?
754
        test    eax, eax ; entry's is over?
631
        jz      .next_sector
755
        jz      .next_sector
-
 
756
 
632
        cmp     ebp, CDDataBuf+2048  ; буфер закончился?
757
        cmp     ebp, CDDataBuf+2048  ; buffer is over?
633
        jae     .next_sector
758
        jae     .next_sector
-
 
759
 
634
        movzx   eax, byte [ebp]
760
        movzx   eax, byte [ebp]
635
        add     [cd_current_pointer_of_input_2], eax; следующий вход каталога
761
        add     [cd_current_pointer_of_input_2], eax ; next entry of directory
636
        add     ebp, 33; указатель установлен на начало имени
762
        add     ebp, 33; pointer is set to the beginning of the name
637
        pop     eax
763
        pop     eax
638
        clc
764
        clc
639
        ret
765
        ret
-
 
766
;--------------------------------------
640
.next_sector:
767
.next_sector:
641
        pop     eax
768
        pop     eax
642
        stc
769
        stc
643
        ret
770
        ret
644
 
-
 
-
 
771
;-----------------------------------------------------------------------------
645
cd_compare_name:
772
cd_compare_name:
646
; compares ASCIIZ-names, case-insensitive (cp866 encoding)
773
; compares ASCIIZ-names, case-insensitive (cp866 encoding)
647
; in: esi->name, ebp->name
774
; in: esi->name, ebp->name
648
; out: if names match: ZF=1 and esi->next component of name
775
; out: if names match: ZF=1 and esi->next component of name
649
;      else: ZF=0, esi is not changed
776
;      else: ZF=0, esi is not changed
650
; destroys eax
777
; destroys eax
651
        push    esi eax edi
778
        push    esi eax edi
652
        mov     edi, ebp
779
        mov     edi, ebp
-
 
780
;--------------------------------------
653
.loop:
781
.loop:
654
        cld
782
        cld
655
        lodsb
783
        lodsb
656
        push    eax
784
        push    eax
657
        call    char_todown
785
        call    char_todown
658
        call    ansi2uni_char
786
        call    ansi2uni_char
659
        xchg    ah, al
787
        xchg    ah, al
660
        scasw
788
        scasw
661
        pop     eax
789
        pop     eax
662
        je      .coincides
790
        je      .coincides
663
        call    char_toupper
791
        call    char_toupper
664
        call    ansi2uni_char
792
        call    ansi2uni_char
665
        xchg    ah, al
793
        xchg    ah, al
666
        sub     edi, 2
794
        sub     edi, 2
667
        scasw
795
        scasw
668
        jne     .name_not_coincide
796
        jne     .name_not_coincide
-
 
797
;--------------------------------------
669
.coincides:
798
.coincides:
670
        cmp     [esi], byte '/'; разделитель пути, конец имени текущего элемента
799
        cmp     [esi], byte '/' ; path separator is end of current element
671
        je      .done
800
        je      .done
-
 
801
 
672
        cmp     [esi], byte 0; разделитель пути, конец имени текущего элемента
802
        cmp     [esi], byte 0 ; path separator end of name
673
        je      .done
803
        je      .done
-
 
804
 
674
        jmp     .loop
805
        jmp     .loop
-
 
806
;--------------------------------------
675
.name_not_coincide:
807
.name_not_coincide:
676
        pop     edi eax esi
808
        pop     edi eax esi
677
        stc
809
        stc
678
        ret
810
        ret
-
 
811
;--------------------------------------
679
.done:
812
.done:
680
; проверка конца файла
813
; check end of file
681
        cmp     [edi], word 3B00h; сепаратор конца файла ';'
814
        cmp     [edi], word 3B00h; separator end of file ';'
682
        je      .done_1
815
        je      .done_1
683
; проверка для файлов не заканчивающихся сепаратором
816
; check for files not ending with separator
684
        movzx   eax, byte [ebp-33]
817
        movzx   eax, byte [ebp-33]
685
        add     eax, ebp
818
        add     eax, ebp
686
        sub     eax, 34
819
        sub     eax, 34
687
        cmp     edi, eax
820
        cmp     edi, eax
688
        je      .done_1
821
        je      .done_1
689
; проверка конца папки
822
; check the end of directory
690
        movzx   eax, byte [ebp-1]
823
        movzx   eax, byte [ebp-1]
691
        add     eax, ebp
824
        add     eax, ebp
692
        cmp     edi, eax
825
        cmp     edi, eax
693
        jne     .name_not_coincide
826
        jne     .name_not_coincide
-
 
827
;--------------------------------------
694
.done_1:
828
.done_1:
695
        pop     edi eax
829
        pop     edi eax
696
        add     esp, 4
830
        add     esp, 4
697
        inc     esi
831
        inc     esi
698
        clc
832
        clc
699
        ret
833
        ret
700
 
-
 
-
 
834
;-----------------------------------------------------------------------------
701
char_todown:
835
char_todown:
702
; convert character to uppercase, using cp866 encoding
836
; convert character to uppercase, using cp866 encoding
703
; in: al=symbol
837
; in: al=symbol
704
; out: al=converted symbol
838
; out: al=converted symbol
705
        cmp     al, 'A'
839
        cmp     al, 'A'
706
        jb      .ret
840
        jb      .ret
-
 
841
 
707
        cmp     al, 'Z'
842
        cmp     al, 'Z'
708
        jbe     .az
843
        jbe     .az
-
 
844
 
709
        cmp     al, 0x80 ; 'А'
845
        cmp     al, 0x80 ; 'А'
710
        jb      .ret
846
        jb      .ret
-
 
847
 
711
        cmp     al, 0x90 ; 'Р'
848
        cmp     al, 0x90 ; 'Р'
712
        jb      .rus1
849
        jb      .rus1
-
 
850
 
713
        cmp     al, 0x9F ; 'Я'
851
        cmp     al, 0x9F ; 'Я'
714
        ja      .ret
852
        ja      .ret
715
; 0x90-0x9F -> 0xE0-0xEF
853
; 0x90-0x9F -> 0xE0-0xEF
716
        add     al, 0xE0-0x90
854
        add     al, 0xE0-0x90
-
 
855
;--------------------------------------
717
.ret:
856
.ret:
718
        ret
857
        ret
-
 
858
;--------------------------------------
719
.rus1:
859
.rus1:
720
; 0x80-0x8F -> 0xA0-0xAF
860
; 0x80-0x8F -> 0xA0-0xAF
721
.az:
861
.az:
722
        add     al, 0x20
862
        add     al, 0x20
723
        ret
863
        ret
724
 
-
 
-
 
864
;-----------------------------------------------------------------------------
725
uni2ansi_char:
865
uni2ansi_char:
726
; convert UNICODE character in al to ANSI character in ax, using cp866 encoding
866
; convert UNICODE character in al to ANSI character in ax, using cp866 encoding
727
; in: ax=UNICODE character
867
; in: ax=UNICODE character
728
; out: al=converted ANSI character
868
; out: al=converted ANSI character
729
        cmp     ax, 0x80
869
        cmp     ax, 0x80
730
        jb      .ascii
870
        jb      .ascii
-
 
871
 
731
        cmp     ax, 0x401
872
        cmp     ax, 0x401
732
        jz      .yo1
873
        jz      .yo1
-
 
874
 
733
        cmp     ax, 0x451
875
        cmp     ax, 0x451
734
        jz      .yo2
876
        jz      .yo2
-
 
877
 
735
        cmp     ax, 0x410
878
        cmp     ax, 0x410
736
        jb      .unk
879
        jb      .unk
-
 
880
 
737
        cmp     ax, 0x440
881
        cmp     ax, 0x440
738
        jb      .rus1
882
        jb      .rus1
-
 
883
 
739
        cmp     ax, 0x450
884
        cmp     ax, 0x450
740
        jb      .rus2
885
        jb      .rus2
-
 
886
;--------------------------------------
741
.unk:
887
.unk:
742
        mov     al, '_'
888
        mov     al, '_'
743
        jmp     .doit
889
        jmp     .doit
-
 
890
;--------------------------------------
744
.yo1:
891
.yo1:
745
        mov     al, 0xF0 ; 'Ё' in cp866
892
        mov     al, 0xF0 ; 'Ё' in cp866
746
        jmp     .doit
893
        jmp     .doit
-
 
894
;--------------------------------------
747
.yo2:
895
.yo2:
748
        mov     al, 0xF1 ; 'ё' in cp866
896
        mov     al, 0xF1 ; 'ё' in cp866
749
        jmp     .doit
897
        jmp     .doit
-
 
898
;--------------------------------------
750
.rus1:
899
.rus1:
751
; 0x410-0x43F -> 0x80-0xAF
900
; 0x410-0x43F -> 0x80-0xAF
752
        add     al, 0x70
901
        add     al, 0x70
753
        jmp     .doit
902
        jmp     .doit
-
 
903
;--------------------------------------
754
.rus2:
904
.rus2:
755
; 0x440-0x44F -> 0xE0-0xEF
905
; 0x440-0x44F -> 0xE0-0xEF
756
        add     al, 0xA0
906
        add     al, 0xA0
-
 
907
;--------------------------------------
757
.ascii:
908
.ascii:
758
.doit:
909
.doit:
759
        ret
910
        ret
-
 
911
;-----------------------------------------------------------------------------