-
Notifications
You must be signed in to change notification settings - Fork 15
/
sai.bt
96 lines (87 loc) · 2.16 KB
/
sai.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//------------------------------------------------
//--- 010 Editor v10.0 Binary Template
//
// File:
// Authors: Wunkolo
// Version: 0.01
// Purpose: Parsing decrypted .sai files
// Category:
// File Mask:
// ID Bytes:
// History:
//------------------------------------------------
const uint32 PageSize = 0x1000;
const uint32 TableSpan = PageSize / 8;
uint NearestTableIndex(uint PageIndex)
{
return (PageIndex / TableSpan) * TableSpan;
}
uint IsTableIndex(uint PageIndex)
{
return (PageIndex % TableSpan) ? false : true;
}
uint IsDataIndex(uint PageIndex)
{
return (PageIndex % TableSpan) ? true : false;
}
struct FATEntry
{
enum <uchar> EntryType
{
Folder = 0x10,
File = 0x80
};
uint32 Flags;
char Name[32];
uchar Pad1;
uchar Pad2;
EntryType Type;
uchar Pad4;
uint32 PageIndex;
uint32 Size;
FILETIME TimeStamp; // Windows FILETIME
uint64 UnknownB;
};
union VirtualPage
{
uchar u8[PageSize];
uint32 u32[PageSize / sizeof(uint32)];
struct PageEntry
{
uint32 Checksum<format=hex>;
uint32 NextPageIndex;
} PageEntries[PageSize / sizeof(PageEntry)];
FATEntry FATEntries[64];
};
//FileSize()
//int FSeek( int64 pos )
void ParseTable(int64 Offset)
{
FSeek(Offset);
VirtualPage CurTable<bgcolor=cLtBlue>;
local uint i;
local uint CurBlockIndex;
local uint SpanStart;
local uint SpanEnd;
local uint NextPageIndex;
local uint CurTableIndex;
for( i = 0; i < PageSize / sizeof(PageEntry); ++i )
{
SpanStart = Offset + i * PageSize;
SpanEnd = SpanStart + PageSize;
FSeek(SpanStart);
VirtualPage DataBlock<comment="SpanStart">;
NextPageIndex = CurTable.PageEntries[i].NextPageIndex;
if(CurTable.PageEntries[i].Checksum == 0) break;
while( NextPageIndex != 0 )
{
CurTableIndex = NearestTableIndex(NextPageIndex);
NextPageIndex = ReadUInt( CurTableIndex + NextPageIndex * 8 + 4);
FSeek(NextPageIndex * PageSize);
VirtualPage DataSegment;
}
//CurBlockIndex = CurPage.PageEntries[i].NextPageIndex;
//DefinePages(i * PageSize);
}
}
ParseTable(0);