如何使用WinHex脚本自动修复FAT32文件系统DBR

        此脚本不是去复制备份的DBR,而是通过文件系统计算BPB参数,来达到修复文件系统的目的,下面是脚本:

 

Assign ParSize GetSize
Assign SecSize 512

Goto 0x000
Write 0xEB5890
Write 0x4D53444F53352E30
Write SecSize
Write 0x00
Write 0x0000
Write 0x02
Write 0x0000
Write 0x0000
Write 0xF8
Write 0x0000
Write 0x3F00
Write 0xFF00
Write 0x00000000
Write 0x0000000000000000
Write 0x0000
Write 0x0000
Write 0x02000000
Write 0x0100
Write 0x0600
Write 0x000000000000000000000000
Write 0x80
Write 0x00
Write 0x29
Write 0x9E3A76F0
Write 0x48424E2052657061697220
Write 0x4641543332202020
{
Write 0x00
}[420]
Write 0x55AA

Goto 0x020
Write (ParSize/SecSize)

Goto 0x000
Find 0xF8FFFF0FFFFFFF Down
IfFound
Assign FAT1 CurrentPos
Move SecSize
EndIF

Find 0xF8FFFF0FFFFFFF Down
IfFound
Assign FAT2 CurrentPos
Move SecSize
EndIF

Goto 0x024
Write ((FAT2/SecSize)-(FAT1/SecSize))

Goto 0x00E
Write (FAT1/SecSize)

Goto ((FAT2-FAT1)+FAT2)
Find 0x2E20202020202020202020 Down
IfFound
Assign SEC1 CurrentPos
Move 26
Read CDX1 2
EndIF

Find 0x2E20202020202020202020 Down
IfFound
Assign SEC2 CurrentPos
Move 26
Read CDX2 2
EndIF

Goto 0x00D
Write (((SEC1/SecSize)-(SEC2/SecSize))/((CDX1)-(CDX2)))

MessageBox "DBR修复完成!"