Code: Select all
local int i;
local uint totalFiles;
uint numGroup;
typedef struct {
char ext[4];
uint numFiles;
uint offset<format=hex>;
} GROUP;
typedef struct {
char filename[9]; // 0 terminated
uint size;
uint offset<format=hex>;
local int64 curPos = FTell();
FSeek(offset);
uchar data[size];
FSeek(curPos);
} FILE;
for(i = 0; i < numGroup; i++ ) {
GROUP groups;
totalFiles += groups.numFiles;
}
for(i = 0; i < totalFiles; i++ ) {
FILE files;
}
Code: Select all
program extract_arc;
{$APPTYPE CONSOLE}
uses
SysUtils, Classes;
procedure SaveFileFromStream(SaveFileName: String; FileStream: TFileStream; FileOffset, FileSize: Cardinal);
var
SaveFile: TFileStream;
SaveCurrentPosition: Int64;
begin
SaveCurrentPosition := FileStream.Position;
SaveFile := TFileStream.Create(SaveFileName, fmCreate);
try
FileStream.Position := FileOffset;
SaveFile.CopyFrom(FileStream, FileSize);
finally
FileStream.Position := SaveCurrentPosition;
SaveFile.Free;
end;
end;
procedure ReadArchive(filename: String);
type
TGroup = packed record
Ext: array [0..3] of Char;
numFiles,
offset: Cardinal;
end;
TFile = packed record
Filename: array [0..8] of Char;
Size,
Offset: Cardinal;
end;
var
Group: TGroup;
currentFile: TFile;
f: TFileStream;
numGroup, i, k: Cardinal;
dir, s: string;
tmp_pos: Int64;
begin
dir := ChangeFileExt(filename, '');
if not (DirectoryExists(dir) or CreateDir(dir)) then exit;
f := TFileStream.Create(filename, fmOpenRead);
try
f.Read(numGroup, SizeOf(numGroup));
for i := 0 to numGroup - 1 do begin
f.Read(Group, SizeOf(Group));
tmp_pos := f.Position;
f.Position := Group.offset;
for k := 0 to Group.numFiles - 1 do begin
f.Read(currentFile, SizeOf(currentFile));
s := dir + '\' + currentFile.Filename + '.' + Group.Ext;
writeln(s);
SaveFileFromStream(s, f, currentFile.Offset, currentFile.Size);
end;
f.Position := tmp_pos;
end;
finally
f.Free;
end;
end;
begin
ReadArchive(ParamStr(1));
end.
Code: Select all
char Magic[4]; // WIPF
ushort tflag; // ? for *.MSK = 01, for *.WIP = {01, 03, 04, 07, ...}
ushort Bit; // ? for *.MSK = 08, for *.WIP = 24
uint Width;
uint Height;
uint t[3]; // always = null
if (Bit == 8) {
uint Size; // in bytes
struct {
byte R<format=hex>;
byte G<format=hex>;
byte B<format=hex>;
byte E<format=hex>;
} RGB[256];
uchar RawData[Size];
// EOF
};
//local uint calcSize = Bit / 8 * Width * Height;
//local uint calcBit = Size * 8 / (Width * Height);
//uchar Pallete[1024];