line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::ParseBinary::FileSystem::MBR;
|
2
|
1
|
|
|
1
|
|
703
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
7
|
use Data::ParseBinary;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
660
|
|
5
|
|
|
|
|
|
|
#"""
|
6
|
|
|
|
|
|
|
#Master Boot Record
|
7
|
|
|
|
|
|
|
#The first sector on disk, contains the partition table, bootloader, et al.
|
8
|
|
|
|
|
|
|
#
|
9
|
|
|
|
|
|
|
#http://www.win.tue.nl/~aeb/partitions/partition_types-1.html
|
10
|
|
|
|
|
|
|
#"""
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $mbr_parser = Struct("mbr",
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# The first 440 (446) bytes are executable code that is loaded by the
|
15
|
|
|
|
|
|
|
# BIOS to boot the system. we use HexDump so it would print out nicely.
|
16
|
|
|
|
|
|
|
Bytes("bootloader_code", 440),
|
17
|
|
|
|
|
|
|
# Optional disk signature.
|
18
|
|
|
|
|
|
|
Array(4, UBInt8('optional_disk_signature')),
|
19
|
|
|
|
|
|
|
# Usually Nulls; 0x0000.
|
20
|
|
|
|
|
|
|
Padding(2),
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Array(4,
|
23
|
|
|
|
|
|
|
Struct("partitions",
|
24
|
|
|
|
|
|
|
Enum(Byte("state"),
|
25
|
|
|
|
|
|
|
INACTIVE => 0x00,
|
26
|
|
|
|
|
|
|
ACTIVE => 0x80,
|
27
|
|
|
|
|
|
|
),
|
28
|
|
|
|
|
|
|
BitStruct("beginning",
|
29
|
|
|
|
|
|
|
Octet("head"),
|
30
|
|
|
|
|
|
|
BitField("sect", 6),
|
31
|
|
|
|
|
|
|
BitField("cyl", 10),
|
32
|
|
|
|
|
|
|
),
|
33
|
|
|
|
|
|
|
Enum(UBInt8("type"),
|
34
|
|
|
|
|
|
|
'Unused' => 0x00,
|
35
|
|
|
|
|
|
|
'FAT12' => 0x01,
|
36
|
|
|
|
|
|
|
'XENIX root fs' => 0x02,
|
37
|
|
|
|
|
|
|
'XENIX /usr' => 0x03,
|
38
|
|
|
|
|
|
|
'FAT16 old' => 0x04,
|
39
|
|
|
|
|
|
|
'Extended_DOS' => 0x05,
|
40
|
|
|
|
|
|
|
'FAT16' => 0x06,
|
41
|
|
|
|
|
|
|
'FAT32' => 0x0b,
|
42
|
|
|
|
|
|
|
'FAT32 (LBA)' => 0x0c,
|
43
|
|
|
|
|
|
|
'NTFS' => 0x07,
|
44
|
|
|
|
|
|
|
'FAT16 (LBA)' => 0x0e,
|
45
|
|
|
|
|
|
|
'LINUX_SWAP' => 0x82,
|
46
|
|
|
|
|
|
|
'LINUX_NATIVE' => 0x83,
|
47
|
|
|
|
|
|
|
_default_ => $DefaultPass,
|
48
|
|
|
|
|
|
|
),
|
49
|
|
|
|
|
|
|
BitStruct("ending",
|
50
|
|
|
|
|
|
|
Octet("head"),
|
51
|
|
|
|
|
|
|
BitField("sect", 6),
|
52
|
|
|
|
|
|
|
BitField("cyl", 10),
|
53
|
|
|
|
|
|
|
),
|
54
|
|
|
|
|
|
|
ULInt32("sector_offset"), # offset from MBR in sectors
|
55
|
|
|
|
|
|
|
ULInt32("size"), # in sectors
|
56
|
|
|
|
|
|
|
)
|
57
|
|
|
|
|
|
|
),
|
58
|
|
|
|
|
|
|
Magic("\x55\xAA"),
|
59
|
|
|
|
|
|
|
);
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
require Exporter;
|
62
|
|
|
|
|
|
|
our @ISA = qw(Exporter);
|
63
|
|
|
|
|
|
|
our @EXPORT = qw($mbr_parser);
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1;
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__
|