📄 fat.cod
字号:
001cc e59d1010 ldr r1, [sp, #0x10]
001d0 eb000000 bl __rt_udiv
001d4 e58d1004 str r1, [sp, #4]
; 306 : Sector /= g_FATParms.BytesPerSect;
001d8 e59f1220 ldr r1, [pc, #0x220]
001dc e5d13020 ldrb r3, [r1, #0x20]
001e0 e1a03403 mov r3, r3, lsl #8
001e4 e1a02803 mov r2, r3, lsl #16
001e8 e1a02822 mov r2, r2, lsr #16
001ec e5d1301f ldrb r3, [r1, #0x1F]
001f0 e1830002 orr r0, r3, r2
001f4 e59d1010 ldr r1, [sp, #0x10]
001f8 eb000000 bl __rt_udiv
001fc e58d0010 str r0, [sp, #0x10]
; 307 : Sector += g_FATParms.FATLBA;
00200 e59d2010 ldr r2, [sp, #0x10]
00204 e59f31f4 ldr r3, [pc, #0x1F4]
00208 e5933004 ldr r3, [r3, #4]
0020c e0823003 add r3, r2, r3
00210 e58d3010 str r3, [sp, #0x10]
00214 |$L38279|
; 308 : break;
; 309 : }
; 310 :
; 311 : // If the sector we're interested in isn't in our cache, get it.
; 312 : //
; 313 : if (CurrentSector != Sector)
00214 e59f31dc ldr r3, [pc, #0x1DC]
00218 e5932000 ldr r2, [r3]
0021c e59d3010 ldr r3, [sp, #0x10]
00220 e1520003 cmp r2, r3
00224 0a00000e beq |$L38287|
; 314 : {
; 315 : if (!ReadSectors(g_FATParms.DriveId, Sector, 1, pSectorCache))
00228 e59d300c ldr r3, [sp, #0xC]
0022c e3a02001 mov r2, #1
00230 e59d1010 ldr r1, [sp, #0x10]
00234 e59f01c4 ldr r0, [pc, #0x1C4]
00238 e5d0001e ldrb r0, [r0, #0x1E]
0023c eb000000 bl ReadSectors
00240 e5cd0028 strb r0, [sp, #0x28]
00244 e5dd3028 ldrb r3, [sp, #0x28]
00248 e3530000 cmp r3, #0
0024c 1a000001 bne |$L38288|
; 316 : {
; 317 : SERPRINT("ERROR: GetNextCluster - unable to read sector.\r\n");
00250 e59f01a4 ldr r0, [pc, #0x1A4]
00254 eb000000 bl EdbgOutputDebugString
00258 |$L38288|
; 318 : }
; 319 :
; 320 : CurrentSector = Sector;
00258 e59d2010 ldr r2, [sp, #0x10]
0025c e59f3194 ldr r3, [pc, #0x194]
00260 e5832000 str r2, [r3]
00264 |$L38287|
; 321 : }
; 322 :
; 323 : // Locate next cluster number...
; 324 : //
; 325 : switch(g_FATParms.FATType)
00264 e59f3194 ldr r3, [pc, #0x194]
00268 e5933000 ldr r3, [r3]
0026c e58d302c str r3, [sp, #0x2C]
00270 e59d302c ldr r3, [sp, #0x2C]
00274 e3530000 cmp r3, #0
00278 0a000003 beq |$L38294|
0027c e59d302c ldr r3, [sp, #0x2C]
00280 e3530002 cmp r3, #2
00284 0a00004a beq |$L38304|
00288 ea00004f b |$L38307|
0028c |$L38294|
; 326 : {
; 327 : case FAT_12:
; 328 : #if !defined( NDEF_DWF_NEW_FAT_12_CODE )
; 329 : // Every FAT-12 entry requires 3 bytes, so we must watch
; 330 : // for sector boundry crossings and access the correct
; 331 : // bytes...
; 332 : uShort1 = *((PUCHAR) (pSectorCache + ByteOffset));
0028c e59d200c ldr r2, [sp, #0xC]
00290 e59d3004 ldr r3, [sp, #4]
00294 e0823003 add r3, r2, r3
00298 e5d33000 ldrb r3, [r3]
0029c e1cd30b0 strh r3, [sp]
; 333 : // Need to worry about cluster number crossing a sector boundary.
; 334 : if (ByteOffset == ((ULONG)g_FATParms.BytesPerSect - 1))
002a0 e59f1158 ldr r1, [pc, #0x158]
002a4 e5d13020 ldrb r3, [r1, #0x20]
002a8 e1a03403 mov r3, r3, lsl #8
002ac e1a02803 mov r2, r3, lsl #16
002b0 e1a02822 mov r2, r2, lsr #16
002b4 e5d1301f ldrb r3, [r1, #0x1F]
002b8 e1833002 orr r3, r3, r2
002bc e2432001 sub r2, r3, #1
002c0 e59d3004 ldr r3, [sp, #4]
002c4 e1530002 cmp r3, r2
002c8 1a000015 bne |$L38297|
; 335 : {
; 336 : // We must read the next sector to get the 2nd byte of the
; 337 : // FAT entry for this cluster!
; 338 : ++Sector;
002cc e59d3010 ldr r3, [sp, #0x10]
002d0 e2833001 add r3, r3, #1
002d4 e58d3010 str r3, [sp, #0x10]
; 339 : if (!ReadSectors(g_FATParms.DriveId, Sector, 1, pSectorCache))
002d8 e59d300c ldr r3, [sp, #0xC]
002dc e3a02001 mov r2, #1
002e0 e59d1010 ldr r1, [sp, #0x10]
002e4 e59f0114 ldr r0, [pc, #0x114]
002e8 e5d0001e ldrb r0, [r0, #0x1E]
002ec eb000000 bl ReadSectors
002f0 e5cd0030 strb r0, [sp, #0x30]
002f4 e5dd3030 ldrb r3, [sp, #0x30]
002f8 e3530000 cmp r3, #0
002fc 1a000001 bne |$L38298|
; 340 : {
; 341 : SERPRINT("ERROR: GetNextCluster - unable to read sector.\r\n");
00300 e59f00f4 ldr r0, [pc, #0xF4]
00304 eb000000 bl EdbgOutputDebugString
00308 |$L38298|
; 342 : }
; 343 : CurrentSector = Sector;
00308 e59d2010 ldr r2, [sp, #0x10]
0030c e59f30e4 ldr r3, [pc, #0xE4]
00310 e5832000 str r2, [r3]
; 344 : uShort2 = *((PUCHAR) pSectorCache); // get the 1st byte of sector...
00314 e59d300c ldr r3, [sp, #0xC]
00318 e5d33000 ldrb r3, [r3]
0031c e1cd31b4 strh r3, [sp, #0x14]
; 345 : }
; 346 : else
00320 ea000005 b |$L38300|
00324 |$L38297|
; 347 : {
; 348 : uShort2 = *((PUCHAR) (pSectorCache + ByteOffset + 1));
00324 e59d200c ldr r2, [sp, #0xC]
00328 e59d3004 ldr r3, [sp, #4]
0032c e0823003 add r3, r2, r3
00330 e2833001 add r3, r3, #1
00334 e5d33000 ldrb r3, [r3]
00338 e1cd31b4 strh r3, [sp, #0x14]
0033c |$L38300|
; 349 : }
; 350 : // decide which parts of the FAT info to use...
; 351 : if (Cluster & 0x01)
0033c e59d303c ldr r3, [sp, #0x3C]
00340 e3130001 tst r3, #1
00344 0a00000a beq |$L38302|
; 352 : {
; 353 : // how odd, an odd cluster number!
; 354 : uShort1 = (uShort1 >> 4);
00348 e1dd30b0 ldrh r3, [sp]
0034c e1a03243 mov r3, r3, asr #4
00350 e1a03803 mov r3, r3, lsl #16
00354 e1a03823 mov r3, r3, lsr #16
00358 e1cd30b0 strh r3, [sp]
; 355 : uShort2 = (uShort2 << 4);
0035c e1dd31b4 ldrh r3, [sp, #0x14]
00360 e1a03203 mov r3, r3, lsl #4
00364 e1a03803 mov r3, r3, lsl #16
00368 e1a03823 mov r3, r3, lsr #16
0036c e1cd31b4 strh r3, [sp, #0x14]
; 356 : }
; 357 : else
00370 ea000009 b |$L38303|
00374 |$L38302|
; 358 : {
; 359 : // must be an even cluster, uShort1 does not change...
; 360 : uShort2 = (uShort2 & 0x0F);
00374 e1dd31b4 ldrh r3, [sp, #0x14]
00378 e203300f and r3, r3, #0xF
0037c e1a03803 mov r3, r3, lsl #16
00380 e1a03823 mov r3, r3, lsr #16
00384 e1cd31b4 strh r3, [sp, #0x14]
; 361 : uShort2 = (uShort2 << 8);
00388 e1dd31b4 ldrh r3, [sp, #0x14]
0038c e1a03403 mov r3, r3, lsl #8
00390 e1a03803 mov r3, r3, lsl #16
00394 e1a03823 mov r3, r3, lsr #16
00398 e1cd31b4 strh r3, [sp, #0x14]
0039c |$L38303|
; 362 : }
; 363 : NextCluster = uShort1 | uShort2;
0039c e1dd30b0 ldrh r3, [sp]
003a0 e1a02003 mov r2, r3
003a4 e1dd31b4 ldrh r3, [sp, #0x14]
003a8 e1823003 orr r3, r2, r3
003ac e58d3008 str r3, [sp, #8]
; 364 :
; 365 : #else // ( NDEF_DWF_NEW_FAT_12_CODE )
; 366 :
; 367 : // Need to worry about cluster number crossing a sector boundary.
; 368 : if (ByteOffset == ((ULONG)g_FATParms.BytesPerSect - 1))
; 369 : {
; 370 : NextCluster = (ULONG)(*(PUCHAR)(pSectorCache + ByteOffset));
; 371 :
; 372 : // Now we need to read the next sector.
; 373 : //
; 374 : ++Sector;
; 375 : if (!ReadSectors(g_FATParms.DriveId, Sector, 1, pSectorCache))
; 376 : {
; 377 : SERPRINT("ERROR: GetNextCluster - unable to read sector.\r\n");
; 378 : }
; 379 : CurrentSector = Sector;
; 380 :
; 381 : NextCluster |= (ULONG)((*(PUCHAR)pSectorCache) << 8);
; 382 : }
; 383 : else
; 384 : NextCluster = (ULONG)(*(PUSHORT)(pSectorCache + ByteOffset));
; 385 :
; 386 : // Since every FAT12 entry is 1.5 bytes, we either need to shift or mask based
; 387 : // on whether the previous cluster number was odd or even.
; 388 : //
; 389 : if (Cluster & 0x1)
; 390 : NextCluster = NextCluster >> 4;
; 391 : else
; 392 : NextCluster = NextCluster & 0xfff;
; 393 :
; 394 : #endif // ( NDEF_DWF_NEW_FAT_12_CODE )
; 395 : break;
003b0 ea00000a b |$L38291|
003b4 |$L38304|
; 396 : case FAT_32:
; 397 : // FAT32 is easy - no worries about sector boundaries...
; 398 : NextCluster = (ULONG)(*(PULONG)(pSectorCache + ByteOffset));
003b4 e59d200c ldr r2, [sp, #0xC]
003b8 e59d3004 ldr r3, [sp, #4]
003bc e0823003 add r3, r2, r3
003c0 e5933000 ldr r3, [r3]
003c4 e58d3008 str r3, [sp, #8]
; 399 : break;
003c8 ea000004 b |$L38291|
003cc |$L38307|
; 400 : case FAT_16:
; 401 : default:
; 402 : // FAT16 is easy - no worries about sector boundaries...
; 403 : NextCluster = (ULONG)(*(PUSHORT)(pSectorCache + ByteOffset));
003cc e59d200c ldr r2, [sp, #0xC]
003d0 e59d3004 ldr r3, [sp, #4]
003d4 e0823003 add r3, r2, r3
003d8 e1d330b0 ldrh r3, [r3]
003dc e58d3008 str r3, [sp, #8]
003e0 |$L38291|
; 404 : }
; 405 :
; 406 : #if 0
; 407 : SERPRINT("INFO: GetNextCluster - cluster=0x%x next cluster=0x%x.\r\n", Cluster, NextCluster);
; 408 : #endif
; 409 :
; 410 : // Return the next cluster value.
; 411 : //
; 412 : return(NextCluster);
003e0 e59d3008 ldr r3, [sp, #8]
003e4 e58d3018 str r3, [sp, #0x18]
003e8 |$L38265|
; 276 : return(Cluster);
003e8 e59d0018 ldr r0, [sp, #0x18]
; 413 : }
003ec e28dd034 add sp, sp, #0x34
003f0 e89d6000 ldmia sp, {sp, lr}
003f4 e12fff1e bx lr
003f8 |$L38588|
003f8 00000000 DCD |?CurrentSector@?1??GetNextCluster@@9@9|
003fc 00000000 DCD |??_C@_0DB@JADKCOOO@ERROR?3?5GetNextCluster?5?9?5unable?5t@|
00400 00000000 DCD |g_FATParms|
00404 00000000 DCD |??_C@_0CO@EODDONOK@ERROR?3?5GetNextCluster?5?9?5bad?5clus@|
00408 |$M38584|
ENDP ; |GetNextCluster|
00000 AREA |.text| { |IsDataCluster| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 AREA |.pdata$$IsDataCluster|, PDATA, SELECTION=5, ASSOC=|.text| { |IsDataCluster| } ; comdat associative
|$T38595| DCD |$L38594|
DCD 0x40003c04
; Function compile flags: /Ods
00000 AREA |.text| { |IsDataCluster| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 |IsDataCluster| PROC
; 170 : {
00000 |$L38594|
00000 e1a0c00d mov r12, sp
00004 e92d0001 stmdb sp!, {r0}
00008 e92d5000 stmdb sp!, {r12, lr}
0000c e24dd008 sub sp, sp, #8
00010 |$M38592|
; 171 : switch(g_FATParms.FATType)
00010 e59f30d4 ldr r3, [pc, #0xD4]
00014 e5933000 ldr r3, [r3]
00018 e58d3004 str r3, [sp, #4]
0001c e59d3004 ldr r3, [sp, #4]
00020 e3530000 cmp r3, #0
00024 0a000003 beq |$L38214|
00028 e59d3004 ldr r3, [sp, #4]
0002c e3530002 cmp r3, #2
00030 0a00000c beq |$L38216|
00034 ea00001b b |$L38218|
00038 |$L38214|
; 172 : {
; 173 : case FAT_12:
; 174 : if (Cluster >= 0x002 && Cluster <= 0xfef)
00038 e59d3010 ldr r3, [sp, #0x10]
0003c e3530002 cmp r3, #2
00040 3a000007 bcc |$L38215|
00044 e59d2010 ldr r2, [sp, #0x10]
00048 e3a03efe mov r3, #0xFE, 28
0004c e383300f orr r3, r3, #0xF
00050 e1520003 cmp r2, r3
00054 8a000002 bhi |$L38215|
; 175 : return(TRUE);
00058 e3a03001 mov r3, #1
0005c e58d3000 str r3, [sp]
00060 ea00001d b |$L38209|
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -