mirror of https://github.com/x64dbg/btparser
initial commit (lexer working for very very simple files)
This commit is contained in:
commit
7c18c0238f
|
@ -0,0 +1,5 @@
|
|||
*.sdf
|
||||
*.opensdf
|
||||
*.suo
|
||||
Release/
|
||||
Debug/
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.40629.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cparser", "cparser\cparser.vcxproj", "{B0411C78-2F06-49E0-8DE9-5C52A466F5DE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B0411C78-2F06-49E0-8DE9-5C52A466F5DE}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{B0411C78-2F06-49E0-8DE9-5C52A466F5DE}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B0411C78-2F06-49E0-8DE9-5C52A466F5DE}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B0411C78-2F06-49E0-8DE9-5C52A466F5DE}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,2 @@
|
|||
Debug/
|
||||
Release/
|
|
@ -0,0 +1,306 @@
|
|||
//------------------------------------
|
||||
//--- 010 Editor v1.2 Binary Template
|
||||
//
|
||||
// Name: AVITemplate.bt
|
||||
// Original Author: Blaine Lefebvre [bl]
|
||||
// Contributor: Elias Bachaalany [eb]
|
||||
// Purpose: Parse an AVI file
|
||||
//
|
||||
// Last Updated: 10/02/2006, 04:40 PM
|
||||
//
|
||||
// History
|
||||
// -----------
|
||||
// [bl] original version: Blaine Lefevre
|
||||
// 10/02/2006:
|
||||
// - [eb] Added BITMAPINFO and WAVEFORMATEX proper strfHEADER recognition
|
||||
// - [eb] Fixed 'idx1' parsing
|
||||
//------------------------------------
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD wFormatTag;
|
||||
WORD nChannels;
|
||||
DWORD nSamplesPerSec;
|
||||
DWORD nAvgBytesPerSec;
|
||||
WORD nBlockAlign;
|
||||
WORD wBitsPerSample;
|
||||
WORD cbSize;
|
||||
} WAVEFORMATEX;
|
||||
|
||||
// head structure info
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwMicroSecPerFrame;
|
||||
DWORD dwMaxBytesPerSec;
|
||||
DWORD dwReserved1;
|
||||
DWORD dwFlags;
|
||||
DWORD dwTotalFrames;
|
||||
DWORD dwInitialFrames;
|
||||
DWORD dwStreams;
|
||||
DWORD dwSuggestedBufferSize;
|
||||
DWORD dwWidth;
|
||||
DWORD dwHeight;
|
||||
DWORD dwScale;
|
||||
DWORD dwRate;
|
||||
DWORD dwStart;
|
||||
DWORD dwLength;
|
||||
} MainAVIHeader;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 biSize;
|
||||
uint32 biWidth;
|
||||
uint32 biHeight;
|
||||
uint16 biPlanes;
|
||||
uint16 biBitCount;
|
||||
uint32 biCompression;
|
||||
uint32 biSizeImage;
|
||||
uint32 biXPelsPerMeter;
|
||||
uint32 biYPelsPerMeter;
|
||||
uint32 biClrUsed;
|
||||
uint32 biClrImportant;
|
||||
} BITMAPINFOHEADER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char rgbBlue;
|
||||
unsigned char rgbGreen;
|
||||
unsigned char rgbRed;
|
||||
unsigned char rgbReserved;
|
||||
} RGBQUAD;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BITMAPINFOHEADER bmiHeader;
|
||||
RGBQUAD bmiColors;
|
||||
} BITMAPINFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char id[4];
|
||||
uint32 datalen;
|
||||
MainAVIHeader data;
|
||||
} avihHEADER;
|
||||
|
||||
|
||||
// header stream structure info
|
||||
typedef struct
|
||||
{
|
||||
char fccType[4];
|
||||
char fccHandler[4];
|
||||
DWORD dwFlags;
|
||||
DWORD dwReserved1;
|
||||
DWORD dwInitialFrames;
|
||||
DWORD dwScale;
|
||||
DWORD dwRate;
|
||||
DWORD dwStart;
|
||||
DWORD dwLength;
|
||||
DWORD dwSuggestedBufferSize;
|
||||
DWORD dwQuality;
|
||||
DWORD dwSampleSize;
|
||||
DWORD xdwQuality;
|
||||
DWORD xdwSampleSize;
|
||||
} AVIStreamHeader;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char id[4];
|
||||
uint32 datalen;
|
||||
AVIStreamHeader data;
|
||||
}strhHEADER;
|
||||
|
||||
|
||||
// Generic strfHEADER
|
||||
typedef struct
|
||||
{
|
||||
char id[4];
|
||||
uint32 datalen;
|
||||
if (datalen % 2)
|
||||
char data[datalen+1];
|
||||
else
|
||||
char data[datalen];
|
||||
} strfHEADER;
|
||||
|
||||
// strfHEADER with BITMAPINFOHEADER
|
||||
typedef struct
|
||||
{
|
||||
char id[4];
|
||||
uint32 datalen;
|
||||
BITMAPINFOHEADER bmiHeader;
|
||||
local int sz = sizeof(bmiHeader);
|
||||
if (datalen == (sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)))
|
||||
{
|
||||
RGBQUAD bmiColors;
|
||||
sz += sizeof(RGBQUAD);
|
||||
}
|
||||
Printf("left: %d\n", sz);
|
||||
char exData[datalen - sz];
|
||||
} strfHEADER_BIH;
|
||||
|
||||
|
||||
// strfHEADER with WAVEFORMAT
|
||||
typedef struct
|
||||
{
|
||||
char id[4];
|
||||
uint32 datalen;
|
||||
WAVEFORMATEX wave;
|
||||
char exData[datalen - sizeof(WAVEFORMATEX)];
|
||||
} strfHEADER_WAVE;
|
||||
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
char id[4];
|
||||
uint32 datalen;
|
||||
if ( datalen % 2 )
|
||||
char data[datalen+1];
|
||||
else
|
||||
char data[datalen];
|
||||
} strnHEADER;
|
||||
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
char id[4];
|
||||
uint32 datalen;
|
||||
if ( datalen % 2 )
|
||||
char data[datalen+1];
|
||||
else
|
||||
char data[datalen];
|
||||
} genericblock;
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char id[4];
|
||||
uint32 datalen;
|
||||
char type[4];
|
||||
|
||||
if (!Memcmp(type,"hdrl",4))
|
||||
{
|
||||
avihHEADER avhi;
|
||||
}
|
||||
else if (!Memcmp(type,"strl",4))
|
||||
{
|
||||
strhHEADER strh;
|
||||
|
||||
// Printf("->%c%c%c%c\n", strh.data.fccHandler[0], strh.data.fccHandler[1],strh.data.fccHandler[2],strh.data.fccHandler[3]);
|
||||
if (Memcmp(strh.data.fccType, "vids", 4) == 0)
|
||||
{
|
||||
strfHEADER_BIH strf;
|
||||
}
|
||||
else if (Memcmp(strh.data.fccType, "auds", 4) == 0)
|
||||
{
|
||||
strfHEADER_WAVE strf;
|
||||
}
|
||||
else
|
||||
{
|
||||
strfHEADER strf;
|
||||
}
|
||||
strnHEADER strn;
|
||||
}
|
||||
else if (Memcmp(type,"movi",4) == 0)
|
||||
{
|
||||
local int32 pointer = 0;
|
||||
local int32 stop = datalen - 4;
|
||||
|
||||
//Printf("stop=%d\n", stop);
|
||||
|
||||
do
|
||||
{
|
||||
genericblock gb;
|
||||
pointer += sizeof(gb);
|
||||
//Printf("+%x = %d\n", gb.datalen, pointer);
|
||||
} while (pointer != stop);
|
||||
}
|
||||
else
|
||||
{
|
||||
char data[datalen-4];
|
||||
}
|
||||
} LISTHEADER;
|
||||
|
||||
|
||||
// junk structure info
|
||||
typedef struct
|
||||
{
|
||||
char id[4];
|
||||
uint32 datalen;
|
||||
if ( datalen % 2 )
|
||||
char data[datalen+1];
|
||||
else
|
||||
char data[datalen];
|
||||
} JUNKHEADER;
|
||||
|
||||
|
||||
// aviindex structure info
|
||||
typedef struct
|
||||
{
|
||||
DWORD ckid;
|
||||
DWORD dwFlags;
|
||||
DWORD dwChunkOffset;
|
||||
DWORD dwChunkLength;
|
||||
} AVIINDEXENTRY;
|
||||
|
||||
const DWORD AVIINDEXENTRYLEN = 16;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char id[4];
|
||||
uint32 datalen;
|
||||
AVIINDEXENTRY data[datalen/AVIINDEXENTRYLEN];
|
||||
} idx1HEADER;
|
||||
|
||||
// root structure info
|
||||
typedef struct xroot
|
||||
{
|
||||
char id[4]; // RIFF
|
||||
if (root.id[3] == 'X')
|
||||
{
|
||||
Printf("Motorola format\n");
|
||||
BigEndian();
|
||||
}
|
||||
else
|
||||
{
|
||||
Printf("Intel format\n");
|
||||
LittleEndian();
|
||||
}
|
||||
|
||||
uint32 datalen;
|
||||
char form[4];
|
||||
|
||||
if (Strcmp(form, "AVI "))
|
||||
{
|
||||
Warning("Not a valid AVI file");
|
||||
return -1;
|
||||
}
|
||||
} ROOT;
|
||||
|
||||
local char nheader[4];
|
||||
|
||||
ROOT root;
|
||||
|
||||
while (!FEof())
|
||||
{
|
||||
ReadBytes(nheader,FTell(), 4);
|
||||
|
||||
if (Memcmp(nheader,"LIST",4) == 0)
|
||||
{
|
||||
LISTHEADER list;
|
||||
}
|
||||
else if (Memcmp(nheader, "JUNK",4) == 0)
|
||||
{
|
||||
JUNKHEADER junk;
|
||||
}
|
||||
else if (Memcmp(nheader, "idx1",4) == 0)
|
||||
{
|
||||
idx1HEADER idx1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!FEof())
|
||||
Printf("unknown chunk: %c%c%c%c", nheader[0],nheader[1],nheader[2],nheader[3]);
|
||||
return -1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,188 @@
|
|||
//--------------------------------------
|
||||
//--- 010 Editor v5.0.2 Binary Template
|
||||
//
|
||||
// File: AndroidManifestTemplate.bt
|
||||
// Author: dongmu
|
||||
// Revision: 1.0
|
||||
// Purpose: Define a template for parsing
|
||||
// AndroidManifest.xml binary files.
|
||||
//--------------------------------------
|
||||
|
||||
// Define the structures used in a
|
||||
// AndroidManifest.xml binary file
|
||||
|
||||
// Define Header
|
||||
typedef struct {
|
||||
uint magicnumber;
|
||||
uint filesize;
|
||||
} HEADER;
|
||||
|
||||
// Define the string format
|
||||
typedef struct {
|
||||
ushort sfSize;
|
||||
if (sfSize > 0)
|
||||
{
|
||||
struct {
|
||||
char c1;
|
||||
char c2;
|
||||
} ONECHAR[ sfSize ];
|
||||
}
|
||||
ushort sfEnd;
|
||||
} STRING_ITEM;
|
||||
|
||||
|
||||
// Define the string chunk
|
||||
typedef struct {
|
||||
uint scSignature;
|
||||
uint scSize;
|
||||
uint scStringCount;
|
||||
uint scStyleCount;
|
||||
uint scUNKNOWN;
|
||||
uint scStringPoolOffset;
|
||||
uint scStylePoolOffset;
|
||||
uint scStringOffsets[ scStringCount ] <comment="Relative to the 0x8+scStringPoolOffset">;
|
||||
|
||||
if (scStyleCount > 0)
|
||||
uint scStyleOffset[ scStylePoolOffset ];
|
||||
|
||||
// The Strings
|
||||
local int i;
|
||||
for (i = 0; i < scStringCount; i++)
|
||||
{
|
||||
if ((0x8+scStringPoolOffset + scStringOffsets[ i ]) < (0x8+scSize))
|
||||
{
|
||||
FSeek(0x8+scStringPoolOffset + scStringOffsets[ i ]);
|
||||
STRING_ITEM strItem;
|
||||
}
|
||||
}
|
||||
|
||||
} STRINGCHUNK;
|
||||
|
||||
// Define the Resource chunk
|
||||
typedef struct {
|
||||
|
||||
local int pos = FTell();
|
||||
|
||||
uint rcSignature;
|
||||
uint rcSize;
|
||||
uint rcItem[ rcSize/4 - 2 ];
|
||||
|
||||
} RESOURCEIDCHUNK;
|
||||
|
||||
// Define the Start Namespace Chunk
|
||||
typedef struct {
|
||||
uint sncSignature;
|
||||
uint sncSize;
|
||||
uint sncLineNumber;
|
||||
uint sncUNKNOWN;
|
||||
uint sncPrefix;
|
||||
uint sncUri;
|
||||
} SNCHUNK;
|
||||
|
||||
// Define the End Namespace Chunk
|
||||
typedef struct {
|
||||
uint encSignature;
|
||||
uint encSize;
|
||||
uint encLineNumber;
|
||||
uint encUNKNOWN;
|
||||
uint encPrefix;
|
||||
uint encUri;
|
||||
} ENCHUNK;
|
||||
|
||||
// Define the Attribute Chunk
|
||||
typedef struct {
|
||||
uint acNamespaceUri;
|
||||
uint acName;
|
||||
uint acValueStr;
|
||||
uint acType <comment="right shift 24bit">;
|
||||
uint acData;
|
||||
} ATTRIBUTECHUNK;
|
||||
|
||||
|
||||
// Define the Start Tag Chunk
|
||||
typedef struct {
|
||||
local int pos = FTell();
|
||||
uint stcSignature;
|
||||
uint stcSize;
|
||||
uint stcLineNumber;
|
||||
uint stcUNKNOWN;
|
||||
uint stcNamespaceUri;
|
||||
uint stcName;
|
||||
uint stcFlags;
|
||||
uint stcAttributeCount;
|
||||
uint stcClassAttribute;
|
||||
|
||||
while (FTell() != pos + stcSize)
|
||||
ATTRIBUTECHUNK attributeChunk;
|
||||
} STCHUNK;
|
||||
|
||||
// Define the End Tag Chunk
|
||||
typedef struct {
|
||||
uint etcSignature;
|
||||
uint etcSize;
|
||||
uint etcLineNumber;
|
||||
uint etcUNKNOWN;
|
||||
uint etcNamespaceUri;
|
||||
uint etcName;
|
||||
} ETCHUNK;
|
||||
|
||||
// Define the Text Chunk
|
||||
typedef struct {
|
||||
uint tcSignature;
|
||||
uint tcSize;
|
||||
uint tcLineNumber;
|
||||
uint tcUNKNOWN;
|
||||
uint tcName;
|
||||
uint tcUNKNOWN;
|
||||
uint tcUNNNOWN;
|
||||
} TEXTCHUNK;
|
||||
|
||||
//--------------------------------------
|
||||
// Define the file
|
||||
|
||||
local uint tag;
|
||||
|
||||
LittleEndian();
|
||||
HEADER header;
|
||||
|
||||
SetBackColor( cLtGreen );
|
||||
STRINGCHUNK stringChunk;
|
||||
// Sometimes there are some zeros padding after the string chunk
|
||||
FSeek(0x8+stringChunk.scSize);
|
||||
|
||||
SetBackColor( cLtBlue );
|
||||
RESOURCEIDCHUNK resourceChunk;
|
||||
FSeek(resourceChunk.pos+resourceChunk.rcSize);
|
||||
|
||||
while( !FEof() )
|
||||
{
|
||||
// Read a tag
|
||||
tag = ReadUInt( FTell() );
|
||||
|
||||
// Read data depending upon tag
|
||||
if (tag == 0x00100100)
|
||||
{
|
||||
SetBackColor( cLtPurple );
|
||||
SNCHUNK startNamespaceChunk;
|
||||
}
|
||||
else if (tag == 0x00100101)
|
||||
{
|
||||
SetBackColor( cLtPurple );
|
||||
ENCHUNK endNamespaceChunk;
|
||||
}
|
||||
else if (tag == 0x00100102)
|
||||
{
|
||||
SetBackColor( cLtGreen );
|
||||
STCHUNK startTagChunk;
|
||||
}
|
||||
else if (tag == 0x00100103)
|
||||
{
|
||||
SetBackColor( cLtGreen );
|
||||
ETCHUNK endTagChunk;
|
||||
}
|
||||
else if (tag == 0x00100104)
|
||||
{
|
||||
SetBackColor( cLtBlue );
|
||||
TEXTCHUNK TextChunk;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
//-----------------------------------
|
||||
//--- 010 Editor v2.0 Binary Template
|
||||
//
|
||||
// File: BMPTemplate.bt
|
||||
// Author: SweetScape Software
|
||||
// Revision: 2.2
|
||||
// Purpose: Defines a template for
|
||||
// parsing BMP image files.
|
||||
//-----------------------------------
|
||||
|
||||
// Define structures used in BMP files
|
||||
|
||||
typedef struct { // bmfh
|
||||
CHAR bfType[2];
|
||||
DWORD bfSize;
|
||||
WORD bfReserved1;
|
||||
WORD bfReserved2;
|
||||
DWORD bfOffBits;
|
||||
} BITMAPFILEHEADER;
|
||||
|
||||
typedef struct { // bmih
|
||||
DWORD biSize;
|
||||
LONG biWidth;
|
||||
LONG biHeight;
|
||||
WORD biPlanes;
|
||||
WORD biBitCount;
|
||||
DWORD biCompression;
|
||||
DWORD biSizeImage;
|
||||
LONG biXPelsPerMeter;
|
||||
LONG biYPelsPerMeter;
|
||||
DWORD biClrUsed;
|
||||
DWORD biClrImportant;
|
||||
} BITMAPINFOHEADER;
|
||||
|
||||
typedef struct { // rgbq
|
||||
UBYTE rgbBlue;
|
||||
UBYTE rgbGreen;
|
||||
UBYTE rgbRed;
|
||||
UBYTE rgbReserved;
|
||||
} RGBQUAD <read=ReadRGBQUAD>;
|
||||
|
||||
typedef struct { // rgbt
|
||||
UBYTE rgbBlue;
|
||||
UBYTE rgbGreen;
|
||||
UBYTE rgbRed;
|
||||
} RGBTRIPLE <read=ReadRGBTRIPLE>;
|
||||
|
||||
//---------------------------------------------
|
||||
// Custom read functions for color types - this allows the
|
||||
// color to be displayed without having to open up the structure.
|
||||
|
||||
string ReadRGBQUAD( RGBQUAD &a )
|
||||
{
|
||||
string s;
|
||||
SPrintf( s, "#%02X%02X%02X%02X", (int)a.rgbReserved, (int)a.rgbRed, (int)a.rgbGreen, (int)a.rgbBlue );
|
||||
return s;
|
||||
}
|
||||
|
||||
string ReadRGBTRIPLE( RGBTRIPLE &a )
|
||||
{
|
||||
string s;
|
||||
SPrintf( s, "#%02X%02X%02X", (int)a.rgbRed, (int)a.rgbGreen, (int)a.rgbBlue );
|
||||
return s;
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
|
||||
// Define the headers
|
||||
LittleEndian();
|
||||
SetBackColor( cLtGray );
|
||||
BITMAPFILEHEADER bmfh;
|
||||
BITMAPINFOHEADER bmih;
|
||||
|
||||
// Check for header
|
||||
if( bmfh.bfType != "BM" )
|
||||
{
|
||||
Warning( "File is not a bitmap. Template stopped." );
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Define the color table
|
||||
if( (bmih.biBitCount != 24) && (bmih.biBitCount != 32) )
|
||||
{
|
||||
SetBackColor( cLtAqua );
|
||||
if( bmih.biClrUsed > 0 )
|
||||
RGBQUAD aColors[ bmih.biClrUsed ];
|
||||
else
|
||||
RGBQUAD aColors[ 1 << bmih.biBitCount ];
|
||||
}
|
||||
|
||||
// Define the bytes of the data
|
||||
SetBackColor( cNone );
|
||||
if( bmih.biCompression > 0 )
|
||||
{
|
||||
// Bytes are compressed
|
||||
if( bmih.biSizeImage > 0 )
|
||||
UBYTE rleData[ bmih.biSizeImage ];
|
||||
else
|
||||
UBYTE rleData[ bmfh.bfSize - FTell() ];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Calculate bytes per line and padding required
|
||||
local int bytesPerLine = (int)Ceil( bmih.biWidth * bmih.biBitCount / 8.0 );
|
||||
local int padding = 4 - (bytesPerLine % 4);
|
||||
if( padding == 4 )
|
||||
padding = 0;
|
||||
|
||||
// Define each line of the image
|
||||
struct BITMAPLINE {
|
||||
|
||||
// Define color data
|
||||
if( bmih.biBitCount < 8 )
|
||||
UBYTE imageData[ bytesPerLine ];
|
||||
else if( bmih.biBitCount == 8 )
|
||||
UBYTE colorIndex[ bmih.biWidth ];
|
||||
else if( bmih.biBitCount == 24 )
|
||||
RGBTRIPLE colors[ bmih.biWidth ];
|
||||
else if( bmih.biBitCount == 32 )
|
||||
RGBQUAD colors[ bmih.biWidth ];
|
||||
|
||||
// Pad if necessary
|
||||
if( padding != 0 )
|
||||
UBYTE padBytes[ padding ];
|
||||
|
||||
} lines[ bmih.biHeight ] <optimize=true>;
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
//--------------------------------------
|
||||
//--- 010 Editor v3.2.2 Binary Template
|
||||
//
|
||||
// File: cabtemplate.bt
|
||||
// Author: Alex McDonnell
|
||||
// Revision: 0.1
|
||||
// Purpose: Parse Microsoft CAB files
|
||||
// Changes:
|
||||
// 0.2 (SweetScape):
|
||||
// - Allow for multiple flags to be set at the same time
|
||||
//--------------------------------------
|
||||
|
||||
// Define structures used in CAB files
|
||||
|
||||
typedef struct {
|
||||
//header
|
||||
char signature[4]; /* 'MSCF' */
|
||||
uint reserved1; /* 0x00000000 */
|
||||
uint cbCabinet; /* size of this cabinet file in bytes */
|
||||
uint reserved2; /* 0x00000000 */
|
||||
uint coffFiles; /* offset of the first CFFILE entry */
|
||||
uint reserved3; /* 0x00000000 */
|
||||
ubyte versionMinor; /* cabinet file format version, minor 0x03 */
|
||||
ubyte versionMajor; /* cabinet file format version, major 0x01 */
|
||||
ushort cFolders; /* number of CFFOLDER entries in this cabinet */
|
||||
ushort cFiles; /* number of CFFILE entries in this cabinet */
|
||||
ushort flags; /* cabinet file option indicators 0x0001 0x0002 0x0004 only*/
|
||||
ushort setID; /* must be the same for all cabinets in a set */
|
||||
ushort iCabinet; /* number of this cabinet file in a set */
|
||||
|
||||
if(flags & 4){
|
||||
|
||||
ushort cbCFHeader; /* (optional) size of per-cabinet reserved area */
|
||||
ubyte cbCFFolder; /* (optional) size of per-folder reserved area */
|
||||
ubyte cbCFData; /* (optional) size of per-datablock reserved area */
|
||||
|
||||
if(cbCFHeader > 0)
|
||||
char abReserve[cbCFHeader]; /* (optional) per-cabinet reserved area */
|
||||
|
||||
}
|
||||
if(flags & 1){
|
||||
|
||||
char szCabinetPrev[];/* (optional) name of previous cabinet file */
|
||||
char szDiskPrev[]; /* (optional) name of previous disk */
|
||||
|
||||
}
|
||||
if(flags & 2){
|
||||
|
||||
char szCabinetNext[]; /* (optional) name of next cabinet file */
|
||||
char szDiskNext[]; /* (optional) name of next disk */
|
||||
|
||||
}
|
||||
|
||||
} CFHEADER;
|
||||
|
||||
LittleEndian();
|
||||
CFHEADER header;
|
||||
local uint counter = 0;
|
||||
|
||||
typedef struct {
|
||||
//folder
|
||||
uint coffCabStart; /* offset of the first CFDATA block in this folder */
|
||||
ushort cCFData; /* number of CFDATA blocks in this folder */
|
||||
ushort typeCompress; /* compression type indicator */
|
||||
|
||||
if( exists(header.cbCFFolder))
|
||||
char abReserve[header.cbCFFolder]; /* (optional) per-folder reserved area */
|
||||
|
||||
} CFFOLDER;
|
||||
|
||||
typedef struct {
|
||||
//file
|
||||
uint cbFile; /* uncompressed size of this file in bytes */
|
||||
uint uoffFolderStart; /* uncompressed offset of this file in the folder */
|
||||
ushort iFolder; /* index into the CFFOLDER area */
|
||||
DOSDATE date; /* date stamp for this file */
|
||||
DOSTIME time; /* time stamp for this file */
|
||||
ushort attribs; /* attribute flags for this file */
|
||||
char szName[]; /* name of this file */
|
||||
} CFFILE;
|
||||
|
||||
typedef struct {
|
||||
//data
|
||||
uint csum; /* checksum of this CFDATA entry */
|
||||
ushort cbData; /* number of compressed bytes in this block */
|
||||
ushort cbUncomp; /* number of uncompressed bytes in this block */
|
||||
|
||||
if( exists(header.cbCFData))
|
||||
char abReserve[header.cbCFData]; /* (optional) per-datablock reserved area */
|
||||
|
||||
char ab[cbData]; /* compressed data bytes */
|
||||
} CFDATA;
|
||||
|
||||
while(header.cFolders > counter){
|
||||
|
||||
counter++;
|
||||
CFFOLDER folder;
|
||||
|
||||
}
|
||||
|
||||
counter = 0;
|
||||
|
||||
while(header.cFiles > counter){
|
||||
|
||||
counter++;
|
||||
CFFILE file;
|
||||
|
||||
}
|
||||
|
||||
counter = 0;
|
||||
|
||||
while(folder.cCFData > counter){
|
||||
|
||||
counter++;
|
||||
CFDATA data;
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,31 @@
|
|||
//------------------------------------
|
||||
//--- 010 Editor v1.0 Binary Template
|
||||
//
|
||||
// Name: CDATemplate.bt
|
||||
// Author: Szabolcs Dávid
|
||||
// Purpose: CDA template for Audio CD
|
||||
// header Information
|
||||
//------------------------------------
|
||||
typedef struct
|
||||
{
|
||||
char szHeader[8];
|
||||
char szFormat[8];
|
||||
DWORD dwEOLn;
|
||||
} CDAFILEHEADER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD wTrackFirst;
|
||||
WORD wTrackCount;
|
||||
DWORD dwVolumeSerialNumber;
|
||||
DWORD dwStartFrame;
|
||||
DWORD dwLengthFrame;
|
||||
DWORD dwStartMS;
|
||||
DWORD dwLengthMS;
|
||||
} CDAINFORMATION;
|
||||
|
||||
LittleEndian();
|
||||
CDAFILEHEADER Header;
|
||||
CDAINFORMATION Information;
|
||||
|
||||
|
|
@ -0,0 +1,253 @@
|
|||
//-------------------------------------------------------------------------
|
||||
//--- 010 Editor v2.1 Binary Template
|
||||
//
|
||||
// File: CLASSTemplate.bt
|
||||
// Author: Kevin O. Grover <kevin@kevingrover.net>
|
||||
// Purpose: A template for parsing Java Class (JVM) Files
|
||||
// Version: 1.1 2014-08-13
|
||||
// History:
|
||||
// 2007-02-26 kog Original Version
|
||||
// 2014-08-13 kog Updated for Java 7/8 Version number (and future)
|
||||
//
|
||||
// This template was written to the "The Java Virtual Machine
|
||||
// Specification", Second Edition, by Tim Lindholm, Frank Yellin.
|
||||
// It was later updated to include the provisio in that spec (and future
|
||||
// specs).
|
||||
//
|
||||
// The details used to write this Template came mainly from Chapter 4:
|
||||
// "The <code>class</code> File Format".
|
||||
//
|
||||
// You can get the document from the Oracle Java Pages or Wikipedia:
|
||||
// http://docs.oracle.com/javase/specs/
|
||||
// http://docs.oracle.com/javase/specs/jvms/se7/jvms7.pdf
|
||||
// http://docs.oracle.com/javase/specs/jvms/se8/jvms8.pdf
|
||||
// http://en.wikipedia.org/wiki/Class_file
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
BigEndian();
|
||||
|
||||
// Types used in the JVM Spec.
|
||||
// (To make this code as close to the text in the spec as possible.)
|
||||
typedef uint32 u4;
|
||||
typedef uint16 u2;
|
||||
typedef ubyte u1;
|
||||
|
||||
typedef enum <u2> eACCESS_FLAGS {
|
||||
ACC_PUBLIC = 0x0001, // Declared public; may be accessed from outside its package.
|
||||
ACC_PRIVATE = 0x0002, // Declared private; usable only within the defining class.
|
||||
ACC_PROTECTED = 0x0004, // Declared protected; may be accessed within subclasses.
|
||||
ACC_STATIC = 0x0008, // Declared static.
|
||||
ACC_FINAL = 0x0010, // Declared final; no subclasses allowed.
|
||||
ACC_SUPER = 0x0020, // Treat superclass methods specially when invoked by the invokespecial instruction.
|
||||
ACC_VOLATILE = 0x0040, // Declared volatile; cannot be cached.
|
||||
ACC_TRANSIENT = 0x0080, // Declared transient; not written or read by a persistent object manager.
|
||||
ACC_NATIVE = 0x0100, // Declared native; implemented in a language other than Java.
|
||||
ACC_INTERFACE = 0x0200, // Is an interface, not a class.
|
||||
ACC_ABSTRACT = 0x0400, // Declared abstract; may not be instantiated.
|
||||
ACC_STRICT = 0x0800 // Declared strictfp; floating-point mode is FP-strict
|
||||
} AF <read=read_AF>;
|
||||
|
||||
string read_AF (local AF &af) {
|
||||
local string s = "";
|
||||
local int commaNeeded = 0;
|
||||
local AF i = 1;
|
||||
|
||||
SPrintf (s, "%d: ", af);
|
||||
|
||||
// Iterate over all possible values the flags
|
||||
// if the given bit is set, add it's text representation to the
|
||||
// return string.
|
||||
// NOTE: There's probably a better way to do this. (More portable?)
|
||||
while (i < ACC_STRICT) {
|
||||
if (af && i) {
|
||||
if (commaNeeded) {
|
||||
s += ", ";
|
||||
}
|
||||
s += EnumToString(i);
|
||||
commaNeeded = 1;
|
||||
}
|
||||
i = i << 1;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
// Constants for cp_info.tag ...
|
||||
typedef enum <u1> eCP_CONST {
|
||||
CONSTANT_Utf8 = 1,
|
||||
CONSTANT_Integer = 3,
|
||||
CONSTANT_Float = 4,
|
||||
CONSTANT_Long = 5,
|
||||
CONSTANT_Double = 6,
|
||||
CONSTANT_Class = 7,
|
||||
CONSTANT_String = 8,
|
||||
CONSTANT_Fieldref = 9,
|
||||
CONSTANT_Methodref = 10,
|
||||
CONSTANT_InterfaceMethodref = 11,
|
||||
CONSTANT_NameAndType = 12,
|
||||
} CP_CONST;
|
||||
|
||||
// Constant Pool Table Structure
|
||||
// NOTE: These are NOT constant sized items. Although referenced
|
||||
// like an array in the main structure, you can not use position
|
||||
// to directly infer a byte offset because you do not know the
|
||||
// sizes of the items preceeding it.
|
||||
typedef struct {
|
||||
CP_CONST tag;
|
||||
switch(tag)
|
||||
{
|
||||
case CONSTANT_Class:
|
||||
u2 name_index;
|
||||
break;
|
||||
case CONSTANT_Methodref:
|
||||
case CONSTANT_Fieldref:
|
||||
case CONSTANT_InterfaceMethodref:
|
||||
u2 class_index;
|
||||
u2 name_and_type_index;
|
||||
break;
|
||||
case CONSTANT_Utf8:
|
||||
u2 length;
|
||||
char bytes[length];
|
||||
break;
|
||||
case CONSTANT_Integer:
|
||||
case CONSTANT_Float:
|
||||
u4 bytes;
|
||||
break;
|
||||
case CONSTANT_Long:
|
||||
case CONSTANT_Double:
|
||||
u4 high_bytes;
|
||||
u4 low_bytes;
|
||||
break;
|
||||
case CONSTANT_String:
|
||||
u2 string_index;
|
||||
break;
|
||||
case CONSTANT_NameAndType:
|
||||
u2 name_index;
|
||||
u2 descriptor_index;
|
||||
break;
|
||||
default:
|
||||
local string s;
|
||||
SPrintf(s, "Unknown 'constant_pool' tag: %d", tag);
|
||||
Warning(s);
|
||||
return -3;
|
||||
}
|
||||
} cp_info <read=read_cp_info, optimize=false>;
|
||||
|
||||
/**
|
||||
* Reader for 'cp_info'
|
||||
* @param cp_info Constant Pool info structure
|
||||
*/
|
||||
string read_cp_info (local cp_info &i)
|
||||
{
|
||||
local string s = "";
|
||||
s = EnumToString(i.tag);
|
||||
if (i.tag == CONSTANT_Utf8) {
|
||||
s += ": " + i.bytes;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
u2 attribute_name_index;
|
||||
u4 attribute_length;
|
||||
u1 info[attribute_length];
|
||||
} attribute_info <optimize=false>;
|
||||
|
||||
typedef struct {
|
||||
AF access_flags;
|
||||
u2 name_index;
|
||||
u2 descriptor_index;
|
||||
u2 attributes_count;
|
||||
attribute_info attributes[attributes_count];
|
||||
} field_info <optimize=false>;
|
||||
|
||||
typedef struct {
|
||||
AF access_flags;
|
||||
u2 name_index;
|
||||
u2 descriptor_index;
|
||||
u2 attributes_count;
|
||||
attribute_info attributes[attributes_count];
|
||||
} method_info <optimize=false>;
|
||||
|
||||
// MAIN Structure
|
||||
|
||||
typedef struct {
|
||||
u4 magic <format=hex>;
|
||||
if (magic != 0xCAFEBABE) { // Check that 'magic' is correct
|
||||
Warning("Incorrect Magic Number. This is not a JVM Class. Template Terminated.");
|
||||
return -1;
|
||||
}
|
||||
u2 minor_version;
|
||||
u2 major_version;
|
||||
u2 constant_pool_count;
|
||||
cp_info constant_pool[constant_pool_count-1];
|
||||
AF access_flags;
|
||||
u2 this_class; // Reference into constant_pool table
|
||||
if (this_class < 1 || this_class > constant_pool_count-1) {
|
||||
local string s;
|
||||
SPrintf(s,"Bad 'this_class' reference (%d). It should be in the range [1..%d]", this_class, constant_pool_count-1);
|
||||
Warning(s);
|
||||
return -2;
|
||||
}
|
||||
u2 super_class; // Reference into constant_pool table
|
||||
if (super_class < 1 || super_class > constant_pool_count-1) {
|
||||
local string s;
|
||||
SPrintf(s,"Bad 'super_class' reference (%d). It should be in the range [1..%d]", super_class, constant_pool_count-1);
|
||||
Warning(s);
|
||||
return -2;
|
||||
}
|
||||
u2 interfaces_count;
|
||||
u2 interfaces[interfaces_count];
|
||||
u2 fields_count;
|
||||
field_info fields[fields_count];
|
||||
u2 methods_count;
|
||||
method_info methods[methods_count];
|
||||
u2 attributes_count;
|
||||
attribute_info attributes[attributes_count];
|
||||
} JVMClass <read=read_JVMClass, optimize=false>;
|
||||
|
||||
/**
|
||||
* Reader for 'JVMClass'
|
||||
* Returns the JVM Version: major.minor and the Java version (if it can
|
||||
* calculate it from the JVM Version.
|
||||
* @param j JVMClass The JVM Class Structure
|
||||
* @return string The version information
|
||||
*/
|
||||
string read_JVMClass (local JVMClass &j)
|
||||
{
|
||||
// JVM Version (as stored in the class file)
|
||||
local string s;
|
||||
SPrintf (s, "JVM class v%d.%d", j.major_version, j.minor_version);
|
||||
|
||||
// Java Runtime Version. From the JVM Spec for class files
|
||||
local int major = 1;
|
||||
local int minor = 0;
|
||||
|
||||
if (j.major_version == 45) {
|
||||
if (j.minor_version >= 3) minor = 1;
|
||||
} else {
|
||||
if (j.major_version >= 46) {
|
||||
minor = j.major_version - 44;
|
||||
} else {
|
||||
// Unknown: it's either newer or older than expected
|
||||
major = 0;
|
||||
minor = 0;
|
||||
Warning("Unexpected JVM major version number.");
|
||||
}
|
||||
}
|
||||
|
||||
if (major || minor) {
|
||||
local string jre_v;
|
||||
SPrintf(jre_v, " (Java %d.%d)", major, minor);
|
||||
s += jre_v;
|
||||
} else {
|
||||
s += " (Unknown Java Version)";
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// *****************************************
|
||||
// MAIN - Allocate data here...
|
||||
// *****************************************
|
||||
|
||||
struct JVMClass jc;
|
|
@ -0,0 +1,121 @@
|
|||
BigEndian();
|
||||
|
||||
typedef struct {
|
||||
enum <ubyte> {
|
||||
CONSTANT_Class = 7,
|
||||
CONSTANT_Fieldref = 9,
|
||||
CONSTANT_Methodref = 10,
|
||||
CONSTANT_InterfaceMethodref = 11,
|
||||
CONSTANT_String = 8,
|
||||
CONSTANT_Integer = 3,
|
||||
CONSTANT_Float = 4,
|
||||
CONSTANT_Long = 5,
|
||||
CONSTANT_Double = 6,
|
||||
CONSTANT_NameAndType = 12,
|
||||
CONSTANT_Utf8 = 1
|
||||
} tag;
|
||||
switch (tag) {
|
||||
case 7:
|
||||
uint16 name_index;
|
||||
break;
|
||||
case 9:
|
||||
uint16 class_index;
|
||||
uint16 name_and_type_index;
|
||||
break;
|
||||
case 10:
|
||||
uint16 class_index;
|
||||
uint16 name_and_type_index;
|
||||
break;
|
||||
case 11:
|
||||
uint16 class_index;
|
||||
uint16 name_and_type_index;
|
||||
break;
|
||||
case 8:
|
||||
uint16 string_index;
|
||||
break;
|
||||
case 3:
|
||||
int32 int_value;
|
||||
break;
|
||||
case 4:
|
||||
float float_value;
|
||||
break;
|
||||
case 5:
|
||||
int64 long_value;
|
||||
break;
|
||||
case 6:
|
||||
double double_value;
|
||||
break;
|
||||
case 12:
|
||||
uint16 name_index;
|
||||
uint16 descriptor_index;
|
||||
break;
|
||||
case 1:
|
||||
uint16 length;
|
||||
char utf8_value[length];
|
||||
break;
|
||||
}
|
||||
} cp_info;
|
||||
|
||||
typedef struct {
|
||||
uint16 attribute_name_index;
|
||||
uint32 attribute_length;
|
||||
char info[attribute_length];
|
||||
} attribute_info;
|
||||
|
||||
typedef struct {
|
||||
uint16 access_flags <format = binary>;
|
||||
uint16 name_index;
|
||||
uint16 descriptor_index;
|
||||
uint16 attributes_count;
|
||||
local int i_att2 = 0;
|
||||
for ( i_att2 = 0; i_att2 < attributes_count; i_att2++) {
|
||||
attribute_info attributes;
|
||||
};
|
||||
} field_info, method_info;
|
||||
|
||||
typedef struct {
|
||||
uint32 magic <format = hex>;
|
||||
if (magic != 0xCAFEBABE) {
|
||||
Warning ("Invalid Class File.");
|
||||
return -1;
|
||||
}
|
||||
uint16 minor_version;
|
||||
uint16 major_version;
|
||||
uint16 constant_pool_count;
|
||||
local int i_cp = 0;
|
||||
for ( i_cp = 1; i_cp < constant_pool_count; i_cp++) {
|
||||
cp_info constant_pool;
|
||||
if ( constant_pool.tag == 5 || constant_pool.tag == 6 ){
|
||||
i_cp++;
|
||||
}
|
||||
};
|
||||
uint16 access_flags <format = binary>;
|
||||
uint16 this_class;
|
||||
uint16 super_class;
|
||||
uint16 interfaces_count;
|
||||
local int i_if = 0;
|
||||
for ( i_if = 0; i_if < interfaces_count; i_if++) {
|
||||
uint16 interfaces;
|
||||
};
|
||||
uint16 fields_count;
|
||||
local int i_fld = 0;
|
||||
for ( i_fld = 0; i_fld < fields_count; i_fld++) {
|
||||
field_info fields;
|
||||
};
|
||||
uint16 methods_count;
|
||||
local int i_m = 0;
|
||||
for ( i_m = 0; i_m < methods_count; i_m++) {
|
||||
method_info methods;
|
||||
};
|
||||
uint16 attributes_count;
|
||||
local int i_att = 0;
|
||||
for ( i_att = 0; i_att < attributes_count; i_att++) {
|
||||
attribute_info attributes;
|
||||
};
|
||||
} class_file;
|
||||
|
||||
class_file file;
|
||||
|
||||
if (!FEof()) {
|
||||
Warning("File is not properly ended.");
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,209 @@
|
|||
//-----------------------------------
|
||||
//--- 010 Editor v2.0 Binary Template
|
||||
//
|
||||
// File: CRXTemplate.bt
|
||||
// Author: SweetScape Software
|
||||
// Revision: 1.0
|
||||
// Purpose: Copy of ZIPTemplate.bt
|
||||
// with extra bits for Google Chrome
|
||||
// extensions.
|
||||
//-----------------------------------
|
||||
|
||||
// Define structures used in ZIP files
|
||||
|
||||
//enum used for compression format
|
||||
typedef enum <short> {
|
||||
COMP_STORED = 0,
|
||||
COMP_SHRUNK = 1,
|
||||
COMP_REDUCED1 = 2,
|
||||
COMP_REDUCED2 = 3,
|
||||
COMP_REDUCED3 = 4,
|
||||
COMP_REDUCED4 = 5,
|
||||
COMP_IMPLODED = 6,
|
||||
COMP_TOKEN = 7,
|
||||
COMP_DEFLATE = 8,
|
||||
COMP_DEFLATE64 = 9
|
||||
} COMPTYPE;
|
||||
|
||||
// Defines a file record
|
||||
typedef struct {
|
||||
// Header for the file
|
||||
char frSignature[4]; //0x04034b50
|
||||
ushort frVersion;
|
||||
ushort frFlags;
|
||||
COMPTYPE frCompression;
|
||||
DOSTIME frFileTime;
|
||||
DOSDATE frFileDate;
|
||||
uint frCrc <format=hex>;
|
||||
uint frCompressedSize;
|
||||
uint frUncompressedSize;
|
||||
ushort frFileNameLength;
|
||||
ushort frExtraFieldLength;
|
||||
if( frFileNameLength > 0 )
|
||||
char frFileName[ frFileNameLength ];
|
||||
if( frExtraFieldLength > 0 )
|
||||
uchar frExtraField[ frExtraFieldLength ];
|
||||
|
||||
// Compressed data
|
||||
SetBackColor( cNone );
|
||||
if( frCompressedSize > 0 )
|
||||
uchar frData[ frCompressedSize ];
|
||||
|
||||
} ZIPFILERECORD <read=ReadZIPFILERECORD, write=WriteZIPFILERECORD>;
|
||||
|
||||
// Defines an entry in the directory table
|
||||
typedef struct {
|
||||
char deSignature[4]; //0x02014b50
|
||||
ushort deVersionMadeBy;
|
||||
ushort deVersionToExtract;
|
||||
ushort deFlags;
|
||||
COMPTYPE deCompression;
|
||||
DOSTIME deFileTime;
|
||||
DOSDATE deFileDate;
|
||||
uint deCrc <format=hex>;
|
||||
uint deCompressedSize;
|
||||
uint deUncompressedSize;
|
||||
ushort deFileNameLength;
|
||||
ushort deExtraFieldLength;
|
||||
ushort deFileCommentLength;
|
||||
ushort deDiskNumberStart;
|
||||
ushort deInternalAttributes;
|
||||
uint deExternalAttributes;
|
||||
uint deHeaderOffset;
|
||||
if( deFileNameLength > 0 )
|
||||
char deFileName[ deFileNameLength ];
|
||||
if( deExtraFieldLength > 0 )
|
||||
uchar deExtraField[ deExtraFieldLength ];
|
||||
if( deFileCommentLength > 0 )
|
||||
uchar deFileComment[ deFileCommentLength ];
|
||||
} ZIPDIRENTRY <read=ReadZIPDIRENTRY>;
|
||||
|
||||
// Defines the digital signature
|
||||
typedef struct {
|
||||
char dsSignature[4]; //0x05054b50
|
||||
ushort dsDataLength;
|
||||
if( dsDataLength > 0 )
|
||||
uchar dsData[ dsDataLength ];
|
||||
} ZIPDIGITALSIG;
|
||||
|
||||
// Defintes the Data descriptor
|
||||
typedef struct {
|
||||
char ddSignature[4]; //0x08074b50
|
||||
uint ddCRC <format=hex>;
|
||||
uint ddCompressedSize;
|
||||
uint ddUncompressedSize;
|
||||
} ZIPDATADESCR;
|
||||
|
||||
// Defines the end of central directory locator
|
||||
typedef struct {
|
||||
char elSignature[4]; //0x06054b50
|
||||
ushort elDiskNumber;
|
||||
ushort elStartDiskNumber;
|
||||
ushort elEntriesOnDisk;
|
||||
ushort elEntriesInDirectory;
|
||||
uint elDirectorySize;
|
||||
uint elDirectoryOffset;
|
||||
ushort elCommentLength;
|
||||
if( elCommentLength > 0 )
|
||||
char elComment[ elCommentLength ];
|
||||
} ZIPENDLOCATOR;
|
||||
|
||||
//--------------------------------------------
|
||||
|
||||
// Custom read functions that allows the name of the
|
||||
// of the file to appear in the Template Results.
|
||||
|
||||
string ReadZIPFILERECORD( ZIPFILERECORD &file )
|
||||
{
|
||||
if( exists( file.frFileName ) )
|
||||
return file.frFileName;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
string ReadZIPDIRENTRY( ZIPDIRENTRY &entry )
|
||||
{
|
||||
if( exists( entry.deFileName ) )
|
||||
return entry.deFileName;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
// Custom write function that allows changing
|
||||
// the name of the file - note that the file
|
||||
// name size cannot be increased
|
||||
|
||||
void WriteZIPFILERECORD( ZIPFILERECORD &file, string s )
|
||||
{
|
||||
local int len = Strlen( s );
|
||||
if( exists( file.frFileName ) )
|
||||
{
|
||||
Strncpy( file.frFileName, s, file.frFileNameLength );
|
||||
if( len < file.frFileNameLength )
|
||||
file.frFileName[len] = 0; //null terminate
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
SetBackColor(0xd8e5ed);
|
||||
char magicNumber[4];
|
||||
SetBackColor(0xd8edd8);
|
||||
uint32 version;
|
||||
SetBackColor(0xd8e5ed);
|
||||
uint32 pkLength;
|
||||
SetBackColor(0xd8edd8);
|
||||
uint32 sigLength;
|
||||
SetBackColor(0xf7d6c3);
|
||||
byte pubKey[pkLength];
|
||||
SetBackColor(0xd8edd8);
|
||||
byte sig[sigLength];
|
||||
} CRXHEADER;
|
||||
|
||||
//--------------------------------------------
|
||||
|
||||
// Define the file
|
||||
SetBackColor(0xe8e8e8);
|
||||
CRXHEADER crxHeader;
|
||||
SetBackColor(cNone);
|
||||
local uint tag;
|
||||
LittleEndian();
|
||||
while( !FEof() )
|
||||
{
|
||||
// Read a tag
|
||||
tag = ReadUInt( FTell() );
|
||||
|
||||
// Read data depending upon tag - should start with 'PK'.
|
||||
// Note that when duplicate variables are defined, they
|
||||
// are made into an array (see 'Using Templates and Structs'
|
||||
// in the help file).
|
||||
if( tag == 0x04034b50 )
|
||||
{
|
||||
SetBackColor( cLtGray );
|
||||
ZIPFILERECORD record;
|
||||
}
|
||||
else if( tag == 0x08074b50 )
|
||||
{
|
||||
SetBackColor( cLtGreen );
|
||||
ZIPDATADESCR dataDescr;
|
||||
}
|
||||
else if( tag == 0x02014b50 )
|
||||
{
|
||||
SetBackColor( cLtPurple );
|
||||
ZIPDIRENTRY dirEntry;
|
||||
}
|
||||
else if( tag == 0x05054b50 )
|
||||
{
|
||||
SetBackColor( cLtBlue );
|
||||
ZIPDIGITALSIG digitalSig;
|
||||
}
|
||||
else if( tag == 0x06054b50 )
|
||||
{
|
||||
SetBackColor( cLtYellow );
|
||||
ZIPENDLOCATOR endLocator;
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning( "Unknown ZIP tag encountered. Template stopped." );
|
||||
return -1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
//--------------------------------------
|
||||
//--- 010 Editor v2.1.3 Binary Template
|
||||
//
|
||||
// File:
|
||||
// Author:
|
||||
// Revision:
|
||||
// Purpose:
|
||||
//--------------------------------------
|
||||
|
||||
string yearFrom1900 (char yy)
|
||||
{
|
||||
string s;
|
||||
SPrintf(s, "%d", 1900 + yy);
|
||||
return s;
|
||||
}
|
||||
|
||||
struct DBF {
|
||||
struct HEADER {
|
||||
char version;
|
||||
struct DATE_OF_LAST_UPDATE {
|
||||
char yy <read=yearFrom1900,format=decimal>;
|
||||
char mm <format=decimal>;
|
||||
char dd <format=decimal>;
|
||||
} DateOfLastUpdate;
|
||||
int numberOfRecords;
|
||||
short lengthOfHeaderStructure;
|
||||
short lengthOfEachRecord;
|
||||
char reserved[2];
|
||||
char incompleteTrasaction <format=decimal>;
|
||||
char encryptionFlag <format=decimal>;
|
||||
int freeRecordThread;
|
||||
int reserved1[2];
|
||||
char mdxFlag <format=decimal>;
|
||||
char languageDriver <format=decimal>;
|
||||
short reserved2;
|
||||
} header;
|
||||
struct FIELD {
|
||||
char fieldName[11];
|
||||
char fieldType;
|
||||
int fieldDataAddress;
|
||||
char fieldLength <format=decimal>;
|
||||
char decimalCount <format=decimal>;
|
||||
short reserved;
|
||||
char workAreaId <format=decimal>;
|
||||
short reserved1;
|
||||
char flags <format=hex>;
|
||||
char reserved2[7];
|
||||
char indexFieldFlag <format=decimal>;
|
||||
} field[(header.lengthOfHeaderStructure-33)/sizeof(struct FIELD)];
|
||||
char Terminator <format=hex>;
|
||||
struct RECORD {
|
||||
char deletedFlag;
|
||||
char fields[header.lengthOfEachRecord-1];
|
||||
} record [ header.numberOfRecords ] <optimize=false>;
|
||||
} dbf <optimize=false>;
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,82 @@
|
|||
//--------------------------------------
|
||||
//--- 010 Editor v2.0.2 Binary Template
|
||||
//
|
||||
// File: DMPTemplate.bt
|
||||
// Author: <a.schuster@yendor.net>
|
||||
// Revision: 1.0 - 20060320
|
||||
// Purpose: This template merely serves as documentation of the
|
||||
// memory dump format used by Microsoft's debuggers and
|
||||
// the NT kernel crashdump facility. Detailed and
|
||||
// authorative information about a DMP file can be
|
||||
// obtained by processing the file with the "dumpchk"
|
||||
// utility which ships whith Microsoft's free debugging
|
||||
// tools package.
|
||||
//--------------------------------------
|
||||
|
||||
|
||||
typedef enum <uint32> {
|
||||
FULL = 1,
|
||||
KERNEL,
|
||||
SMALL
|
||||
} e_DumpType;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32 BasePage <format=hex>;
|
||||
uint32 PageCount <format=hex>;
|
||||
} _PHYSICAL_MEMORY_RUN32;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32 NumberOfRuns;
|
||||
uint32 NumberOfPages <format=hex>;
|
||||
_PHYSICAL_MEMORY_RUN32 Run[NumberOfRuns];
|
||||
} _PHYSICAL_MEMORY_DESCRIPTOR32;
|
||||
|
||||
|
||||
typedef struct {
|
||||
int32 ExceptionCode <format=hex>;
|
||||
uint32 ExceptionFlags;
|
||||
uint32 ExceptionRecord;
|
||||
uint32 ExceptionAddress <format=hex>;
|
||||
uint32 NumberParameters;
|
||||
uint32 ExceptionInformation[15] <format=hex>;
|
||||
} _EXCEPTION_RECORD32;
|
||||
|
||||
|
||||
FSeek(0);
|
||||
|
||||
char Signature[4];
|
||||
char ValidDump[4];
|
||||
uint32 MajorVersion;
|
||||
uint32 MinorVersion;
|
||||
uint32 DirectoryTableBase <format=hex>;
|
||||
uint32 PfnDataBase <format=hex>;
|
||||
uint32 PsLoadedModuleList <format=hex>;
|
||||
uint32 PsActiveProcessHead <format=hex>;
|
||||
uint32 MachineImageType <format=hex>;
|
||||
uint32 NumberProcessors;
|
||||
uint32 BugCheckCode <format=hex>;
|
||||
uint32 BugCheckParameter[4] <format=hex>;
|
||||
char VersionUser[32];
|
||||
uchar PaeEnabled;
|
||||
uchar KdSecondaryVersion;
|
||||
uchar Spare3[2];
|
||||
uint32 KdDebuggerDataBlock <format=hex>;
|
||||
_PHYSICAL_MEMORY_DESCRIPTOR32 PhysicalMemoryBlock;
|
||||
FSeek(800);
|
||||
uchar ContextRecord[1200];
|
||||
_EXCEPTION_RECORD32 Exception;
|
||||
char Comment[128];
|
||||
uchar _reserved0[1768];
|
||||
e_DumpType DumpType;
|
||||
uint32 MiniDumpFields;
|
||||
uint32 SecondaryDataState;
|
||||
uint32 ProductType;
|
||||
uint32 SuiteMask;
|
||||
uint32 WriterStatus;
|
||||
int64 RequiredDumpSpace;
|
||||
uchar _reserved2[16];
|
||||
FILETIME SystemUpTime;
|
||||
FILETIME SystemTime;
|
||||
uchar _reserved3[56];
|
|
@ -0,0 +1,730 @@
|
|||
//--------------------------------------
|
||||
//--- 010 Editor v3.2.2 Binary Template
|
||||
//
|
||||
// File: EDIDTemplate.bt
|
||||
// Author: Rafael Vuijk
|
||||
// Revision: 2012-03-02
|
||||
// Purpose: EDID structure parser
|
||||
//--------------------------------------
|
||||
//
|
||||
// NOTE: This template uses variable-size/unoptimized structure arrays.
|
||||
// Information source: https://en.wikipedia.org/wiki/Extended_display_identification_data
|
||||
// Modeline calculator: http://www.epanorama.net/faq/vga2rgb/calc.html
|
||||
//
|
||||
//--------------------------------------
|
||||
|
||||
typedef uint16 EISAId <read=EISAIdToString, write=StringToEISAId>;
|
||||
|
||||
string EISAIdToString(EISAId x)
|
||||
{
|
||||
uint16 sw = SwapBytes(x);
|
||||
string s;
|
||||
SPrintf(s, "%c%c%c", '@' + (sw>>10 & 0x1F), '@' + (sw>>5 & 0x1F), '@' + (sw>>0 & 0x1F));
|
||||
return s;
|
||||
}
|
||||
|
||||
void StringToEISAId(EISAId &x, string s)
|
||||
{
|
||||
char c[3];
|
||||
SScan(s, "%c%c%c", c[0], c[1], c2[2]);
|
||||
x = (c[0] - '@')<<10 | (c[1] - '@')<<5 | (c[2] - '@')<<0;
|
||||
x = SwapBytes(x);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ubyte x_resolution;
|
||||
ubyte vFrequency : 6;
|
||||
ubyte pixelRatio : 2;
|
||||
} Timing <read=TimingToString>;
|
||||
|
||||
string TimingToString(Timing &t)
|
||||
{
|
||||
if (t.x_resolution == 1 && t.vFrequency == 1 && t.pixelRatio == 0) return "-";
|
||||
int x = (t.x_resolution + 31) * 8;
|
||||
int y;
|
||||
switch (t.pixelRatio)
|
||||
{
|
||||
case 0: y = x*10/16; break;
|
||||
case 1: y = x*3/4; break;
|
||||
case 2: y = x*4/5; break;
|
||||
case 3: y = x*9/16; break;
|
||||
}
|
||||
string s;
|
||||
SPrintf(s, "%ux%u, %uHz", x, y, t.vFrequency + 60);
|
||||
return s;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
enum <ubyte> DescriptorType
|
||||
{
|
||||
TIMINGS = 0xFA, // Additional standard timing identifiers. 6- 2-byte descriptors, padded with 0A.
|
||||
WHITE_POINT = 0xFB, // Additional white point data. 2- 5-byte descriptors, padded with 0A 20 20.
|
||||
MONITOR_NAME = 0xFC, // Monitor name (text)
|
||||
RANGE_LIMITS = 0xFD, // Monitor range limits. 6- or 13-byte binary descriptor.
|
||||
UNSPECIFIED_TEXT = 0xFE, // Unspecified text (text)
|
||||
SERIAL_NUMBER = 0xFF, // Monitor serial number (text)
|
||||
};
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
enum <ubyte> FormatCode
|
||||
{
|
||||
RESERVED = 0,
|
||||
LPCM = 1,
|
||||
AC_3 = 2,
|
||||
MPEG1 = 3,
|
||||
MP3 = 4,
|
||||
MPEG2 = 5,
|
||||
AAC = 6,
|
||||
DTS = 7,
|
||||
ATRAC = 8,
|
||||
SACD = 9,
|
||||
DD_PLUS = 10,
|
||||
DTS_HD = 11,
|
||||
MLP_TRUEHD = 12,
|
||||
DST = 13,
|
||||
WMA_PRO = 14,
|
||||
RESERVED2 = 15,
|
||||
};
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
enum <ubyte> BlockType
|
||||
{
|
||||
AUDIO = 1,
|
||||
VIDEO = 2,
|
||||
VENDOR_SPECIFIC = 3,
|
||||
SPEAKER = 4,
|
||||
};
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
enum <ubyte> SVDIndex
|
||||
{
|
||||
_DMT0659 = 1, // 4:3 640x480p @ 59.94/60Hz
|
||||
_480p = 2, // 4:3 720x480p @ 59.94/60Hz
|
||||
_480pH = 3, // 16:9 720x480p @ 59.94/60Hz
|
||||
_720p = 4, // 16:9 1280x720p @ 59.94/60Hz
|
||||
_1080i = 5, // 16:9 1920x1080i @ 59.94/60Hz
|
||||
_480i = 6, // 4:3 720(1440)x480i @ 59.94/60Hz
|
||||
_480iH = 7, // 16:9 720(1440)x480i @ 59.94/60Hz
|
||||
_240p = 8, // 4:3 720(1440)x240p @ 59.94/60Hz
|
||||
_240pH = 9, // 16:9 720(1440)x240p @ 59.94/60Hz
|
||||
_480i4x = 10, // 4:3 (2880)x480i @ 59.94/60Hz
|
||||
_480i4xH = 11, // 16:9 (2880)x480i @ 59.94/60Hz
|
||||
_240p4x = 12, // 4:3 (2880)x240p @ 59.94/60Hz
|
||||
_240p4xH = 13, // 16:9 (2880)x240p @ 59.94/60Hz
|
||||
_480p2x = 14, // 4:3 1440x480p @ 59.94/60Hz
|
||||
_480p2xH = 15, // 16:9 1440x480p @ 59.94/60Hz
|
||||
_1080p = 16, // 16:9 1920x1080p @ 59.94/60Hz
|
||||
_576p = 17, // 4:3 720x576p @ 50Hz
|
||||
_576pH = 18, // 16:9 720x576p @ 50Hz
|
||||
_720p50 = 19, // 16:9 1280x720p @ 50Hz
|
||||
_1080i25 = 20, // 16:9 1920x1080i @ 50Hz*
|
||||
_576i = 21, // 4:3 720(1440)x576i @ 50Hz
|
||||
_576iH = 22, // 16:9 720(1440)x576i @ 50Hz
|
||||
_288p = 23, // 4:3 720(1440)x288p @ 50Hz
|
||||
_288pH = 24, // 16:9 720(1440)x288p @ 50Hz
|
||||
_576i4x = 25, // 4:3 (2880)x576i @ 50Hz
|
||||
_576i4xH = 26, // 16:9 (2880)x576i @ 50Hz
|
||||
_288p4x = 27, // 4:3 (2880)x288p @ 50Hz
|
||||
_288p4xH = 28, // 16:9 (2880)x288p @ 50Hz
|
||||
_576p2x = 29, // 4:3 1440x576p @ 50Hz
|
||||
_576p2xH = 30, // 16:9 1440x576p @ 50Hz
|
||||
_1080p50 = 31, // 16:9 1920x1080p @ 50Hz
|
||||
_1080p24 = 32, // 16:9 1920x1080p @ 23.98/24Hz
|
||||
_1080p25 = 33, // 16:9 1920x1080p @ 25Hz
|
||||
_1080p30 = 34, // 16:9 1920x1080p @ 29.97/30Hz
|
||||
_480p4x = 35, // 4:3 (2880)x480p @ 59.94/60Hz
|
||||
_480p4xH = 36, // 16:9 (2880)x480p @ 59.94/60Hz
|
||||
_576p4x = 37, // 4:3 (2880)x576p @ 50Hz
|
||||
_576p4xH = 38, // 16:9 (2880)x576p @ 50Hz
|
||||
_1080i25b = 39, // 16:9 1920x1080i(1250 Total) @ 50Hz*
|
||||
_1080i50 = 40, // 16:9 1920x1080i @ 100Hz
|
||||
_720p100 = 41, // 16:9 1280x720p @ 100Hz
|
||||
_576p100 = 42, // 4:3 720x576p @ 100Hz
|
||||
_576p100H = 43, // 16:9 720x576p @ 100Hz
|
||||
_576i50 = 44, // 4:3 720(1440)x576i @ 100Hz
|
||||
_576i50H = 45, // 16:9 720(1440)x576i @ 100Hz
|
||||
_1080i60 = 46, // 16:9 1920x1080i @ 119.88/120Hz
|
||||
_720p120 = 47, // 16:9 1280x720p @ 119.88/120Hz
|
||||
_480p119 = 48, // 4:3 720x480p @ 119.88/120Hz
|
||||
_480p119H = 49, // 16:9 720x480p @ 119.88/120Hz
|
||||
_480i59 = 50, // 4:3 720(1440)x480i @ 119.88/120Hz
|
||||
_480i59H = 51, // 16:9 720(1440)x480i @ 119.88/120Hz
|
||||
_576p200 = 52, // 4:3 720x576p @ 200Hz
|
||||
_576p200H = 53, // 16:9 720x576p @ 200Hz
|
||||
_576i100 = 54, // 4:3 720(1440)x576i @ 200Hz
|
||||
_576i100H = 55, // 16:9 720(1440)x576i @ 200Hz
|
||||
_480p239 = 56, // 4:3 720x480p @ 239.76/240Hz
|
||||
_480p239H = 57, // 16:9 720x480p @ 239.76/240Hz
|
||||
_480i119 = 58, // 4:3 720(1440)x480i @ 239.76/240Hz
|
||||
_480i119H = 59, // 16:9 720(1440)x480i @ 239.76/240Hz
|
||||
_720p24 = 60, // 16:9 1280x720p @ 23.98/24Hz
|
||||
_720p25 = 61, // 16:9 1280x720p @ 25Hz
|
||||
_720p30 = 62, // 16:9 1280x720p @ 29.97/30Hz
|
||||
_1080p120 = 63, // 16:9 1920x1080p @ 119.88/120Hz
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SVDIndex index : 7 <comment="index value to a table of standard resolutions/timings from CEA/EIA-861E">;
|
||||
ubyte native : 1 <comment="1 to designate that this should be considered a \"native\" resolution, 0 for non-native">;
|
||||
} SVD <read=SVDToString, comment="Short Video Descriptor">;
|
||||
|
||||
string SVDToString(SVD &svd)
|
||||
{
|
||||
string s;
|
||||
SPrintf(s, "%s%s (%u)", (svd.native ? "*" : ""), EnumToString(svd.index), svd.index);
|
||||
return s;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
string SPAToString(uint16 spa)
|
||||
{
|
||||
string s;
|
||||
SPrintf(s, "%u.%u.%u.%u", spa>>4&15, spa>>0&15, spa>>12&15, spa>>8&15);
|
||||
return s;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
string TDMSFreqToString(ubyte f)
|
||||
{
|
||||
string s;
|
||||
SPrintf(s, "%u MHz", (uint)f * 5);
|
||||
return s;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
string PixelClockToString(uint16 f)
|
||||
{
|
||||
string s;
|
||||
SPrintf(s, "%.2lf MHz", (double)f / 100);
|
||||
return s;
|
||||
}
|
||||
|
||||
void StringToPixelClock(uint16 &f, string s)
|
||||
{
|
||||
f = Atof(s) * 100;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
typedef ubyte PixelRate <read=PixelRateToString, write=StringToPixelRate>;
|
||||
|
||||
string PixelRateToString(PixelRate f)
|
||||
{
|
||||
string s;
|
||||
SPrintf(s, "%u MHz", (uint)f * 10);
|
||||
return s;
|
||||
}
|
||||
|
||||
void StringToPixelRate(PixelRate &f, string s)
|
||||
{
|
||||
f = Atof(s) / 10;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
typedef ubyte BitRate <read=BitRateToString, write=StringToBitRate, comment="maximum supported bitrate divided by 8 kbit/s">;
|
||||
|
||||
string BitRateToString(BitRate b)
|
||||
{
|
||||
string s;
|
||||
SPrintf(s, "%u kHz", (uint)b * 8);
|
||||
return s;
|
||||
}
|
||||
|
||||
void StringToBitRate(BitRate &b, string s)
|
||||
{
|
||||
b = Atof(s) / 8;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
typedef ubyte Latency <read=LatencyToString, write=StringToLatency, comment="Latency (value=1+ms/2 with a max of 251 meaning 500ms)">;
|
||||
|
||||
string LatencyToString(Latency l)
|
||||
{
|
||||
if (l == 0) return "-";
|
||||
string s;
|
||||
SPrintf(s, "%u ms", ((uint)l - 1) * 2);
|
||||
return s;
|
||||
}
|
||||
|
||||
void StringToLatency(Latency &l, string s)
|
||||
{
|
||||
if (s == "-") l = 0; else l = (uint)(Atof(s) / 2) + 1;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ubyte size : 5 <comment="Total number of bytes in this block following this byte">;
|
||||
BlockType typeTag : 3 <comment="Block Type Tag (1 is audio, 2 is video, 3 is vendor specific, 4 is speaker allocation, all other values Reserved)">;
|
||||
|
||||
// local int64 dataStart <hidden=true> = FTell();
|
||||
switch (typeTag)
|
||||
{
|
||||
case AUDIO:
|
||||
{
|
||||
ubyte channelCount : 3 <comment="number of channels minus 1">;
|
||||
FormatCode formatCode : 4 <comment="Audio format code">;
|
||||
ubyte reserved1 : 1;
|
||||
struct SampleRates
|
||||
{
|
||||
ubyte _32kHz : 1;
|
||||
ubyte _44kHz : 1;
|
||||
ubyte _48kHz : 1;
|
||||
ubyte _88kHz : 1;
|
||||
ubyte _96kHz : 1;
|
||||
ubyte _176kHz : 1;
|
||||
ubyte _192kHz : 1;
|
||||
ubyte reserved : 1;
|
||||
} sampleRates <comment="sampling frequencies supported">;
|
||||
if (formatCode == 1) // LPCM
|
||||
{
|
||||
ubyte _16bits : 1;
|
||||
ubyte _20bits : 1;
|
||||
ubyte _24bits : 1;
|
||||
ubyte reserved : 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
BitRate bitrate;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case VIDEO:
|
||||
{
|
||||
SVD svds[size] <bgcolor=cLtGreen, comment="Short Video Descriptors">;
|
||||
break;
|
||||
}
|
||||
|
||||
case VENDOR_SPECIFIC:
|
||||
{
|
||||
ubyte oui[3] <format=hex, comment="IEEE Registration Identifier">;
|
||||
uint16 spa <read=SPAToString, comment="Source Physical Address">;
|
||||
if (size >= 3)
|
||||
{
|
||||
ubyte DVI_Dual : 1 <comment="sink supports DVI Dual Link Operation">;
|
||||
ubyte reserved : 1;
|
||||
ubyte reserved : 1;
|
||||
ubyte dc_Y444 : 1 <comment="sink supports 4:4:4 in deep color modes">;
|
||||
ubyte dc_30bit : 1 <comment="sink supports 10-bit-per-channel deep color">;
|
||||
ubyte dc_36bit : 1 <comment="sink supports 12-bit-per-channel deep color">;
|
||||
ubyte dc_48bit : 1 <comment="sink supports 16-bit-per-channel deep color">;
|
||||
ubyte supports_AI : 1 <comment="sink supports a function that needs info from ACP or ISRC packets">;
|
||||
}
|
||||
if (size >= 4)
|
||||
ubyte max_TMDS_Frequency <read=TDMSFreqToString, comment="Maximum TMDS frequency">;
|
||||
if (size >= 5)
|
||||
{
|
||||
ubyte reserved : 6;
|
||||
ubyte i_latency_fields : 1 <comment="set if interlaced latency fields are present; if set four latency fields will be present">;
|
||||
ubyte latency_fields : 1 <comment="set if latency fields are present">;
|
||||
if (latency_fields)
|
||||
{
|
||||
Latency videoLatency <comment="Video Latency (value=1+ms/2 with a max of 251 meaning 500ms)">;
|
||||
Latency audioLatency <comment="Audio Latency (value=1+ms/2 with a max of 251 meaning 500ms)">;
|
||||
}
|
||||
if (i_latency_fields)
|
||||
{
|
||||
Latency interlacedVideoLatency <comment="Interlaced Video Latency (value=1+ms/2 with a max of 251 meaning 500ms)">;
|
||||
Latency interlacedAudioLatency <comment="Interlaced Audio Latency (value=1+ms/2 with a max of 251 meaning 500ms)">;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SPEAKER:
|
||||
{
|
||||
ubyte frontLeftRight : 1 <comment="Front Left / Front Right present for 1, absent for 0">;
|
||||
ubyte LFE : 1 <comment="LFE present for 1, absent for 0">;
|
||||
ubyte frontCenter : 1 <comment="Front Center present for 1, absent for 0">;
|
||||
ubyte rearLeftRight : 1 <comment="Rear Left / Rear Right present for 1, absent for 0">;
|
||||
ubyte rearCenter : 1 <comment="Rear Center present for 1, absent for 0">;
|
||||
ubyte frontLeftRightCenter : 1 <comment="Front Left Center / Front Right Center present for 1, absent for 0">;
|
||||
ubyte rearLeftRightCenter : 1 <comment="Rear Left Center / Rear Right Center present for 1, absent for 0">;
|
||||
ubyte reserved : 1;
|
||||
ubyte reserved[2];
|
||||
break;
|
||||
}
|
||||
} // switch
|
||||
|
||||
// local int64 dataEnd <hidden=true> = FTell();
|
||||
// Printf("block size: %u %lu\n", size, dataEnd - dataStart);
|
||||
|
||||
/* Assert(dataEnd - dataStart <= size, "Data block size error");
|
||||
if (dataEnd - dataStart < size)
|
||||
{
|
||||
ubyte extraData[size - (dataEnd - dataStart)];
|
||||
}*/
|
||||
} DataBlock <size=DataBlockSize, optimize=false, open=true, comment="Data block">;
|
||||
|
||||
int DataBlockSize(DataBlock &b)
|
||||
{
|
||||
return (ReadUByte(startof(b)) & 0x1F);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16 pixelClock <read=PixelClockToString, write=StringToPixelClock, comment="Pixel clock in 10 kHz units. (0.01-655.35 MHz, little-endian)">;
|
||||
|
||||
ubyte hActive_lsb <comment="Horizontal active pixels 8 lsbits (0-4095)">;
|
||||
ubyte hBlanking_lsb <comment="Horizontal blanking pixels 8 lsbits (0-4095) End of active to start of next active.">;
|
||||
ubyte hBlanking_msb : 4 <comment="Horizontal blanking pixels 4 msbits">;
|
||||
ubyte hActive_msb : 4 <comment="Horizontal active pixels 4 msbits">;
|
||||
ubyte vActive_lsb <comment="Vertical active lines 8 lsbits (0-4095)">;
|
||||
ubyte vBlanking_lsb <comment="Vertical blanking lines 8 lsbits (0-4095)">;
|
||||
ubyte vBlanking_msb : 4 <comment="Vertical blanking lines 4 msbits">;
|
||||
ubyte vActive_msb : 4 <comment="Vertical active lines 4 msbits">;
|
||||
ubyte hSyncOffset_lsb <comment="Horizontal sync offset pixels 8 lsbits (0-1023) From blanking start">;
|
||||
ubyte hSync_lsb <comment="Horizontal sync pulse width pixels 8 lsbits (0-1023)">;
|
||||
ubyte vSync_lsb : 4 <comment="Vertical sync pulse width lines 4 lsbits (0-63)">;
|
||||
ubyte vSyncOffset_lsb : 4 <comment="Vertical sync offset lines 4 lsbits (0-63)">;
|
||||
ubyte vSync_msb : 2 <comment="Vertical sync pulse width lines 2 msbits">;
|
||||
ubyte vSyncOffset_msb : 2 <comment="Vertical sync offset lines 2 msbits">;
|
||||
ubyte hSync_msb : 2 <comment="Horizontal sync pulse width pixels 2 msbits">;
|
||||
ubyte hSyncOffset_msb : 2 <comment="Horizontal sync offset pixels 2 msbits">;
|
||||
ubyte hSize_lsb <comment="Horizontal display size, mm, 8 lsbits (0-4095 mm, 161 in)">;
|
||||
ubyte vSize_lsb <comment="Vertical display size, mm, 8 lsbits (0-4095 mm, 161 in)">;
|
||||
ubyte vSize_msb : 4 <comment="Vertical display size, mm, 4 msbits">;
|
||||
ubyte hSize_msb : 4 <comment="Horizontal display size, mm, 4 msbits">;
|
||||
ubyte hBorder <comment="Horizontal border pixels (each side; total is twice this)">;
|
||||
ubyte vBorder <comment="Vertical border lines (each side; total is twice this)">;
|
||||
|
||||
ubyte _f0 : 1 <comment="2-way line-interleaved stereo, if bits 4-3 are not 00.">;
|
||||
ubyte _f1 : 1 <comment="If analog sync: Sync on all 3 RGB lines (else green only). Digital: HSync polarity (1=positive)">;
|
||||
ubyte _f2 : 1 <comment="If digital separate: Vertical sync polarity (1=positive). Other types: VSync serrated (HSync during VSync)">;
|
||||
ubyte _f34 : 2 <comment="Sync type: 00=Analog composite; 01=Bipolar analog composite; 10=Digital composite (on HSync); 11=Digital separate">;
|
||||
ubyte _f56 : 2 <comment="Stereo mode: 00=No stereo; other values depend on bit 0: Bit 0=0: 01=Field sequential, sync=1 during right; 10=similar, sync=1 during left; 11=4-way interleaved stereo. Bit 0=1 2-way interleaved stereo: 01=Right image on even lines; 10=Left image on even lines; 11=side-by-side">;
|
||||
ubyte interlaced : 1 <comment="Interlaced">;
|
||||
|
||||
//if (_f34 >> 1 & 1) Printf("Digital sync: "); else Printf("Analog sync: ");
|
||||
//if (_f34 >> 0 & 1) Printf("Bipolar/separate\n"); else Printf("Composite\n");
|
||||
} ModeLine <read=ModeLineToString, write=StringToModeLine, comment="Xfree86 modeline">;
|
||||
|
||||
string ModeLineToString(ModeLine &n)
|
||||
{
|
||||
uint hActive = (uint)n.hActive_msb<<8 | n.hActive_lsb;
|
||||
uint hSyncOffset = (uint)n.hSyncOffset_msb<<8 | n.hSyncOffset_lsb;
|
||||
uint hSync = (uint)n.hSync_msb<<8 | n.hSync_lsb;
|
||||
uint hBlanking = (uint)n.hBlanking_msb<<8 | n.hBlanking_lsb;
|
||||
|
||||
uint vActive = (uint)n.vActive_msb<<8 | n.vActive_lsb;
|
||||
uint vSyncOffset = (uint)n.vSyncOffset_msb<<8 | n.vSyncOffset_lsb;
|
||||
uint vSync = (uint)n.vSync_msb<<8 | n.vSync_lsb;
|
||||
uint vBlanking = (uint)n.vBlanking_msb<<8 | n.vBlanking_lsb;
|
||||
|
||||
uint im = n.interlaced ? 2 : 1;
|
||||
string s;
|
||||
SPrintf(s, "Modeline \"%ux%u\" %.2lf %4u %4u %4u %4u %4u %4u %4u %4u %chsync %cvsync %s ; %u %u", // relative to absolute
|
||||
hActive, vActive*im, (double)n.pixelClock / 100,
|
||||
hActive, hActive + hSyncOffset, hActive + hSyncOffset + hSync, hActive + hBlanking,
|
||||
vActive*im, (vActive + vSyncOffset)*im, (vActive + vSyncOffset + vSync)*im, (vActive + vBlanking)*im,
|
||||
n._f1 ? '+' : '-', n._f2 ? '+' : '-',
|
||||
n.interlaced ? "Interlace" : "",
|
||||
n.hBorder, n.vBorder
|
||||
);
|
||||
return s;
|
||||
}
|
||||
|
||||
void StringToModeLine(ModeLine &n, string s)
|
||||
{
|
||||
uint dummy;
|
||||
uint hActive, hActive_hSyncOffset, hActive_hSyncOffset_hSync, hActive_hBlanking;
|
||||
uint vActive, vActive_vSyncOffset, vActive_vSyncOffset_vSync, vActive_vBlanking;
|
||||
char hsync, vsync;
|
||||
string interlaced;
|
||||
double f;
|
||||
SScanf(s, "Modeline \"%ux%u\" %lf %u %u %u %u %u %u %u %u %chsync %cvsync %[^0-9;]",
|
||||
dummy, dummy, f,
|
||||
hActive, hActive_hSyncOffset, hActive_hSyncOffset_hSync, hActive_hBlanking,
|
||||
vActive, vActive_vSyncOffset, vActive_vSyncOffset_vSync, vActive_vBlanking,
|
||||
hsync, vsync,
|
||||
interlaced
|
||||
);
|
||||
int p = Strchr(s, ';');
|
||||
if (p >= 0) SScanf(SubStr(s, p), "; %u %u", n.hBorder, n.vBorder);
|
||||
|
||||
n.interlaced = (interlaced[0] == 'I');
|
||||
uint im = n.interlaced ? 2 : 1;
|
||||
|
||||
uint hBlanking = hActive_hBlanking - hActive;
|
||||
uint hSync = hActive_hSyncOffset_hSync - hActive_hSyncOffset;
|
||||
uint hSyncOffset = hActive_hSyncOffset - hActive;
|
||||
n.hActive_msb = hActive>>8; n.hActive_lsb = (ubyte)hActive;
|
||||
n.hSyncOffset_msb = hSyncOffset>>8; n.hSyncOffset_lsb = (ubyte)hSyncOffset;
|
||||
n.hSync_msb = hSync>>8; n.hSync_lsb = (ubyte)hSync;
|
||||
n.hBlanking_msb = hBlanking>>8; n.hBlanking_lsb = (ubyte)hBlanking;
|
||||
|
||||
uint vBlanking = (vActive_vBlanking - vActive)/im;
|
||||
uint vSync = (vActive_vSyncOffset_vSync - vActive_vSyncOffset)/im;
|
||||
uint vSyncOffset = (vActive_vSyncOffset - vActive)/im;
|
||||
vActive /= im;
|
||||
n.vActive_msb = vActive>>8; n.vActive_lsb = (ubyte)vActive;
|
||||
n.vSyncOffset_msb = vSyncOffset>>8; n.vSyncOffset_lsb = (ubyte)vSyncOffset;
|
||||
n.vSync_msb = vSync>>8; n.vSync_lsb = (ubyte)vSync;
|
||||
n.vBlanking_msb = vBlanking>>8; n.vBlanking_lsb = (ubyte)vBlanking;
|
||||
|
||||
n._f1 = hsync == '+' ? 1 : 0;
|
||||
n._f2 = vsync == '+' ? 1 : 0;
|
||||
n.pixelClock = f * 100;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
struct File
|
||||
{
|
||||
struct Header
|
||||
{
|
||||
ubyte pattern[8] <format=hex, comment="Fixed header pattern: 00 FF FF FF FF FF FF 00">;
|
||||
EISAId eisaId <comment="EISA ID. Encoded as 3 5-bit letters (1=A, 26=Z), big-endian, with msbit reserved.">;
|
||||
uint16 mfgProductId <comment="Manufacturer product code. 16-bit number, little-endian.">;
|
||||
uint32 serial <comment="Serial number. 32 bits, little endian.">;
|
||||
ubyte mfgWeek <comment="Week of manufacture. Week numbering is not consistent between manufacturers.">;
|
||||
ubyte mfgYear <comment="Year of manufacture, less 1990. (1990-2245). If week=255, it is the model year instead.">;
|
||||
ubyte edidVersion <comment="EDID version, usually 1 (for 1.3)">;
|
||||
ubyte edidRevision <comment="EDID revision, usually 3 (for 1.3)">;
|
||||
} header <open=false, comment="Header information">;
|
||||
|
||||
struct Basic
|
||||
{
|
||||
union Bitmap
|
||||
{
|
||||
ubyte hmz;
|
||||
if (hmz & 0x80)
|
||||
{
|
||||
struct Digital
|
||||
{
|
||||
ubyte vesa : 1 <comment="Signal is compatible with VESA DFP 1.x TMDS CRGB, 1 pixel per clock, up to 8 bits per color, MSB aligned,">;
|
||||
ubyte reserved : 6 <comment="Reserved, must be 0">;
|
||||
ubyte digital : 1 <comment="1=Digital input">;
|
||||
} digital;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct Analog
|
||||
{
|
||||
ubyte vSeparate : 1 <comment="VSync pulse must be separated when composite or sync-on-green is used">;
|
||||
ubyte syncOnGreen : 1 <comment="Sync on green supported">;
|
||||
|
||||
ubyte compositeSync : 1 <comment="Composite sync (on HSync) supported">;
|
||||
ubyte separateSync : 1 <comment="Separate sync supported">;
|
||||
ubyte blankToBlack : 1 <comment="Blank-to-black setup (pedestal) expected">;
|
||||
ubyte level : 2 <comment="Video white and sync levels, relative to blank: 00=+0.7/ |