Rev 71 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 71 | Rev 75 | ||
---|---|---|---|
Line 1089... | Line 1089... | ||
1089 | ; out: CF=1 - file not found |
1089 | ; out: CF=1 - file not found |
1090 | ; else CF=0 and edi->direntry |
1090 | ; else CF=0 and edi->direntry |
1091 | pusha |
1091 | pusha |
1092 | sub esp, 262*2 ; reserve place for LFN |
1092 | sub esp, 262*2 ; reserve place for LFN |
1093 | mov ebp, esp |
1093 | mov ebp, esp |
- | 1094 | push 0 ; for fat_get_name: read ASCII name |
|
1094 | call read_flp_fat |
1095 | call read_flp_fat |
1095 | cmp [FDC_Status], 0 |
1096 | cmp [FDC_Status], 0 |
1096 | jnz .error |
1097 | jnz .error |
1097 | mov eax, 19 |
1098 | mov eax, 19 |
1098 | mov dh, 14 |
1099 | mov dh, 14 |
Line 1119... | Line 1120... | ||
1119 | inc eax |
1120 | inc eax |
1120 | dec dh |
1121 | dec dh |
1121 | js @f |
1122 | js @f |
1122 | jnz .20_1 |
1123 | jnz .20_1 |
1123 | .error: |
1124 | .error: |
1124 | add esp, 262*2 |
1125 | add esp, 262*2+4 |
1125 | popa |
1126 | popa |
1126 | stc |
1127 | stc |
1127 | ret |
1128 | ret |
1128 | @@: |
1129 | @@: |
1129 | ; read next sector from FAT |
1130 | ; read next sector from FAT |
1130 | mov eax, [(eax-31)*2+0x282000] |
1131 | mov eax, [(eax-31-1)*2+0x282000] |
1131 | and eax, 0xFFF |
1132 | and eax, 0xFFF |
1132 | cmp eax, 0xFF8 |
1133 | cmp eax, 0xFF8 |
1133 | jae .error |
1134 | jae .error |
1134 | add eax, 31 |
1135 | add eax, 31 |
1135 | jmp .main_loop |
1136 | jmp .main_loop |
Line 1156... | Line 1157... | ||
1156 | movzx eax, word [edi+26] |
1157 | movzx eax, word [edi+26] |
1157 | add eax, 31 |
1158 | add eax, 31 |
1158 | mov dh, 0 |
1159 | mov dh, 0 |
1159 | jmp .main_loop |
1160 | jmp .main_loop |
1160 | .done: |
1161 | .done: |
1161 | add esp, 262*2+4 |
1162 | add esp, 262*2+4+4 |
1162 | push edi |
1163 | push edi |
1163 | popad |
1164 | popad |
1164 | ret |
1165 | ret |
Line 1165... | Line 1166... | ||
1165 | 1166 | ||
Line 1176... | Line 1177... | ||
1176 | ; ret ebx = size or 0xffffffff file not found |
1177 | ; ret ebx = size or 0xffffffff file not found |
1177 | ; eax = 0 ok read or other = errormsg |
1178 | ; eax = 0 ok read or other = errormsg |
1178 | ; |
1179 | ; |
1179 | ;-------------------------------------------------------------- |
1180 | ;-------------------------------------------------------------- |
1180 | fs_FloppyRead: |
1181 | fs_FloppyRead: |
1181 | mov [save_flag], 0 |
1182 | call read_flp_fat |
1182 | cmp byte [esi], 0 |
1183 | cmp byte [esi], 0 |
1183 | jnz @f |
1184 | jnz @f |
1184 | or ebx, -1 |
1185 | or ebx, -1 |
1185 | mov eax, 10 ; access denied |
1186 | mov eax, 10 ; access denied |
1186 | ret |
1187 | ret |
Line 1259... | Line 1260... | ||
1259 | jmp .reteof |
1260 | jmp .reteof |
1260 | .err: |
1261 | .err: |
1261 | mov eax, 5 ; may be other error code? |
1262 | mov eax, 5 ; may be other error code? |
1262 | pop edx ecx ebx ebx edi |
1263 | pop edx ecx ebx ebx edi |
1263 | ret |
1264 | ret |
- | 1265 | ||
- | 1266 | ;---------------------------------------------------------------- |
|
- | 1267 | ; |
|
- | 1268 | ; fs_FloppyReadFolder - LFN variant for reading floppy folders |
|
- | 1269 | ; |
|
- | 1270 | ; esi points to filename |
|
- | 1271 | ; ebx pointer to 32-bit number = first wanted block, 0+ |
|
- | 1272 | ; ecx number of blocks to read, 0+ |
|
- | 1273 | ; edx mem location to return data |
|
- | 1274 | ; |
|
- | 1275 | ; ret ebx = size or 0xffffffff folder not found |
|
- | 1276 | ; eax = 0 ok read or other = errormsg |
|
- | 1277 | ; |
|
- | 1278 | ;-------------------------------------------------------------- |
|
- | 1279 | fs_FloppyReadFolder: |
|
- | 1280 | call read_flp_fat |
|
- | 1281 | mov ebx, [ebx] |
|
- | 1282 | push edi |
|
- | 1283 | cmp byte [esi], 0 |
|
- | 1284 | jz .root |
|
- | 1285 | call fd_find_lfn |
|
- | 1286 | jnc .found |
|
- | 1287 | pop edi |
|
- | 1288 | or ebx, -1 |
|
- | 1289 | mov eax, ERROR_FILE_NOT_FOUND |
|
- | 1290 | ret |
|
- | 1291 | .found: |
|
- | 1292 | test byte [edi+11], 0x10 ; do not allow read files |
|
- | 1293 | jnz .found_dir |
|
- | 1294 | pop edi |
|
- | 1295 | or ebx, -1 |
|
- | 1296 | mov eax, ERROR_ACCESS_DENIED |
|
- | 1297 | ret |
|
- | 1298 | .found_dir: |
|
- | 1299 | movzx eax, word [edi+26] |
|
- | 1300 | add eax, 31 |
|
- | 1301 | push 0 |
|
- | 1302 | jmp .doit |
|
- | 1303 | .root: |
|
- | 1304 | mov eax, 19 |
|
- | 1305 | push 14 |
|
- | 1306 | .doit: |
|
- | 1307 | push ecx ebp |
|
- | 1308 | sub esp, 262*2 ; reserve space for LFN |
|
- | 1309 | mov ebp, esp |
|
- | 1310 | push 1 ; for fat_get_name: read UNICODE names |
|
- | 1311 | ; init header |
|
- | 1312 | push eax ecx |
|
- | 1313 | mov edi, edx |
|
- | 1314 | mov ecx, 32/4 |
|
- | 1315 | xor eax, eax |
|
- | 1316 | rep stosd |
|
- | 1317 | pop ecx eax |
|
- | 1318 | mov byte [edx], 1 ; version |
|
- | 1319 | mov esi, edi ; esi points to BDFE |
|
- | 1320 | .main_loop: |
|
- | 1321 | pusha |
|
- | 1322 | call read_chs_sector |
|
- | 1323 | popa |
|
- | 1324 | cmp [FDC_Status], 0 |
|
- | 1325 | jnz .error |
|
- | 1326 | mov edi, 0xD000 |
|
- | 1327 | push eax |
|
- | 1328 | .l1: |
|
- | 1329 | call fat_get_name |
|
- | 1330 | jc .l2 |
|
- | 1331 | cmp byte [edi+11], 0xF |
|
- | 1332 | jnz .do_bdfe |
|
- | 1333 | add edi, 0x20 |
|
- | 1334 | cmp edi, 0xD200 |
|
- | 1335 | jb .do_bdfe |
|
- | 1336 | pop eax |
|
- | 1337 | inc eax |
|
- | 1338 | dec byte [esp+262*2+12] |
|
- | 1339 | jz .done |
|
- | 1340 | jns @f |
|
- | 1341 | ; read next sector from FAT |
|
- | 1342 | mov eax, [(eax-31-1)*2+0x282000] |
|
- | 1343 | and eax, 0xFFF |
|
- | 1344 | cmp eax, 0xFF8 |
|
- | 1345 | jae .done |
|
- | 1346 | add eax, 31 |
|
- | 1347 | mov byte [esp+262*2+12], 0 |
|
- | 1348 | @@: |
|
- | 1349 | pusha |
|
- | 1350 | call read_chs_sector |
|
- | 1351 | popa |
|
- | 1352 | cmp [FDC_Status], 0 |
|
- | 1353 | jnz .error |
|
- | 1354 | mov edi, 0xD000 |
|
- | 1355 | push eax |
|
- | 1356 | .do_bdfe: |
|
- | 1357 | inc dword [edx+8] ; new file found |
|
- | 1358 | dec ebx |
|
- | 1359 | jns .l2 |
|
- | 1360 | dec ecx |
|
- | 1361 | js .l2 |
|
- | 1362 | inc dword [edx+4] ; new file block copied |
|
- | 1363 | call fat_entry_to_bdfe |
|
- | 1364 | .l2: |
|
- | 1365 | add edi, 0x20 |
|
- | 1366 | cmp edi, 0xD200 |
|
- | 1367 | jb .l1 |
|
- | 1368 | pop eax |
|
- | 1369 | inc eax |
|
- | 1370 | dec byte [esp+262*2+12] |
|
- | 1371 | jz .done |
|
- | 1372 | jns @f |
|
- | 1373 | ; read next sector from FAT |
|
- | 1374 | mov eax, [(eax-31-1)*2+0x282000] |
|
- | 1375 | and eax, 0xFFF |
|
- | 1376 | cmp eax, 0xFF8 |
|
- | 1377 | jae .done |
|
- | 1378 | add eax, 31 |
|
- | 1379 | mov byte [esp+262*2+12], 0 |
|
- | 1380 | @@: |
|
- | 1381 | jmp .main_loop |
|
- | 1382 | .error: |
|
- | 1383 | add esp, 262*2+4 |
|
- | 1384 | pop ebp ecx edi edi |
|
- | 1385 | or ebx, -1 |
|
- | 1386 | mov eax, ERROR_FILE_NOT_FOUND |
|
- | 1387 | ret |
|
- | 1388 | .done: |
|
- | 1389 | add esp, 262*2+4 |
|
- | 1390 | pop ebp |
|
- | 1391 | mov ebx, [edx+8] |
|
- | 1392 | xor eax, eax |
|
- | 1393 | dec ecx |
|
- | 1394 | js @f |
|
- | 1395 | mov al, ERROR_END_OF_FILE |
|
- | 1396 | @@: |
|
- | 1397 | pop ecx edi edi |
|
- | 1398 | ret |
|
- | 1399 | ||
1264 | ; \end{diamond}->->->-> |
1400 | ; \end{diamond}->->->-> |
1265 | 1401 |