mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-27 23:37:04 -05:00
patterns/includes: Update standard library and patterns to support the new bitfields (#102)
* Add `current_bit_offset()` and `read_bits(...)` to `std::mem` * Replace deprecated BitfieldOrder enum values with new clearer names This adds new options named `MostToLeastSignificant` and `LeastToMostSignificant` to replace the old `LeftToRight` and `RightToLeft` names. These names should be much clearer about what they affect and how. * Throw errors when `std::core::(get|set)_bitfield_order()` are called * Update all patterns to work with the new bitfield behaviors
This commit is contained in:
@@ -10,11 +10,21 @@
|
|||||||
namespace std::core {
|
namespace std::core {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The default ordering of bitfield members
|
The layout order of each field after byte-endianness has been handled.
|
||||||
|
|
||||||
|
`LeftToRight` and `RightToLeft` are deprecated in favor of the clearer `MostToLeastSignificant` and `LeastToMostSignificant` names.
|
||||||
*/
|
*/
|
||||||
enum BitfieldOrder : u8 {
|
enum BitfieldOrder : u8 {
|
||||||
|
/**
|
||||||
|
@warning deprecated
|
||||||
|
*/
|
||||||
LeftToRight = 0,
|
LeftToRight = 0,
|
||||||
RightToLeft = 1
|
/**
|
||||||
|
@warning deprecated
|
||||||
|
*/
|
||||||
|
RightToLeft = 1,
|
||||||
|
MostToLeastSignificant = 0,
|
||||||
|
LeastToMostSignificant = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -56,19 +66,17 @@ namespace std::core {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the default bitfield order.
|
@warning Removed in 1.28.0
|
||||||
@param order The new default bitfield order
|
|
||||||
*/
|
*/
|
||||||
fn set_bitfield_order(BitfieldOrder order) {
|
fn set_bitfield_order(BitfieldOrder order) {
|
||||||
builtin::std::core::set_bitfield_order(u32(order));
|
builtin::std::error("Runtime default bitfield order is no longer supported.\nConsider using `be` or `le` on your bitfield variables,\nor attach attribute `bitfield_order` to the bitfield.");
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gets thee current default bitfield order
|
@warning Removed in 1.28.0
|
||||||
@return The currently set default bitfield order
|
|
||||||
*/
|
*/
|
||||||
fn get_bitfield_order() {
|
fn get_bitfield_order() {
|
||||||
return builtin::std::core::get_bitfield_order();
|
builtin::std::error("Runtime default bitfield order is no longer supported.\nConsider using `be` or `le` on your bitfield variables,\nor attach attribute `bitfield_order` to the bitfield.");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -113,6 +113,27 @@ namespace std::mem {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the current bit offset within the current byte that a bitfield will read.
|
||||||
|
*/
|
||||||
|
fn current_bit_offset() {
|
||||||
|
return builtin::std::mem::current_bit_offset();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads a number of bits from the specified bit offset within the specified byte
|
||||||
|
@param byteOffset The byte offset within the data
|
||||||
|
@param bitOffset The bit offset to start the read at within the current byte
|
||||||
|
@param bitSize The total number of bits to read
|
||||||
|
@return A u128 containing the value read
|
||||||
|
*/
|
||||||
|
fn read_bits(u128 byteOffset, u128 bitOffset, u64 bitSize) {
|
||||||
|
byteOffset += bitOffset >> 3;
|
||||||
|
bitOffset = bitOffset & 0x7;
|
||||||
|
return builtin::std::mem::read_bits(byteOffset, bitOffset, bitSize);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a new custom section with the given name
|
Creates a new custom section with the given name
|
||||||
@param name The name of the section
|
@param name The name of the section
|
||||||
|
|||||||
@@ -1,209 +1,209 @@
|
|||||||
#pragma MIME application/x-coff
|
#pragma MIME application/x-coff
|
||||||
|
|
||||||
#include <type/time.pat>
|
#include <type/time.pat>
|
||||||
#include <type/size.pat>
|
#include <type/size.pat>
|
||||||
|
|
||||||
enum Machine : u16 {
|
enum Machine : u16 {
|
||||||
Unknown = 0x0000,
|
Unknown = 0x0000,
|
||||||
AM33 = 0x01D3,
|
AM33 = 0x01D3,
|
||||||
AMD64 = 0x8664,
|
AMD64 = 0x8664,
|
||||||
ARM = 0x01C0,
|
ARM = 0x01C0,
|
||||||
ARM64 = 0xAA64,
|
ARM64 = 0xAA64,
|
||||||
ARMNT = 0x01C4,
|
ARMNT = 0x01C4,
|
||||||
EBC = 0x0EBC,
|
EBC = 0x0EBC,
|
||||||
I386 = 0x014C,
|
I386 = 0x014C,
|
||||||
IA64 = 0x0200,
|
IA64 = 0x0200,
|
||||||
LOONGARCH32 = 0x6232,
|
LOONGARCH32 = 0x6232,
|
||||||
LOONGARCH64 = 0x6264,
|
LOONGARCH64 = 0x6264,
|
||||||
M32R = 0x9041,
|
M32R = 0x9041,
|
||||||
MIPS16 = 0x0226,
|
MIPS16 = 0x0226,
|
||||||
MIPSFPU = 0x0366,
|
MIPSFPU = 0x0366,
|
||||||
MIPSFPU16 = 0x0466,
|
MIPSFPU16 = 0x0466,
|
||||||
POWERPC = 0x01F0,
|
POWERPC = 0x01F0,
|
||||||
POWERPCFP = 0x01F0,
|
POWERPCFP = 0x01F0,
|
||||||
R4000 = 0x0166,
|
R4000 = 0x0166,
|
||||||
RISCV32 = 0x5032,
|
RISCV32 = 0x5032,
|
||||||
RISCV64 = 0x5064,
|
RISCV64 = 0x5064,
|
||||||
RISCV128 = 0x5128,
|
RISCV128 = 0x5128,
|
||||||
SH3 = 0x01A2,
|
SH3 = 0x01A2,
|
||||||
SH3DSP = 0x01A3,
|
SH3DSP = 0x01A3,
|
||||||
SH4 = 0x01A6,
|
SH4 = 0x01A6,
|
||||||
SH5 = 0x01A8,
|
SH5 = 0x01A8,
|
||||||
THUMB = 0x01C2,
|
THUMB = 0x01C2,
|
||||||
WCEMIPSV2 = 0x0169
|
WCEMIPSV2 = 0x0169
|
||||||
};
|
};
|
||||||
|
|
||||||
bitfield Characteristics {
|
bitfield Characteristics {
|
||||||
relocsStripped : 1;
|
relocsStripped : 1;
|
||||||
executableImage : 1;
|
executableImage : 1;
|
||||||
lineNumsStripped : 1;
|
lineNumsStripped : 1;
|
||||||
localSymsStripped : 1;
|
localSymsStripped : 1;
|
||||||
aggressiveWsTrim : 1;
|
aggressiveWsTrim : 1;
|
||||||
largeAddressAware : 1;
|
largeAddressAware : 1;
|
||||||
padding : 1;
|
padding : 1;
|
||||||
bytesReversedLo : 1;
|
bytesReversedLo : 1;
|
||||||
_32BitMachine : 1;
|
_32BitMachine : 1;
|
||||||
debugStripped : 1;
|
debugStripped : 1;
|
||||||
removableRunFromSwap : 1;
|
removableRunFromSwap : 1;
|
||||||
netRunFromSwap : 1;
|
netRunFromSwap : 1;
|
||||||
system : 1;
|
system : 1;
|
||||||
dll : 1;
|
dll : 1;
|
||||||
upSystemOnly : 1;
|
upSystemOnly : 1;
|
||||||
bytesReversedHi : 1;
|
bytesReversedHi : 1;
|
||||||
} [[right_to_left]];
|
};
|
||||||
|
|
||||||
enum Type : u16 {
|
enum Type : u16 {
|
||||||
Null = 0,
|
Null = 0,
|
||||||
Void = 1,
|
Void = 1,
|
||||||
Char = 2,
|
Char = 2,
|
||||||
Short = 3,
|
Short = 3,
|
||||||
Int = 4,
|
Int = 4,
|
||||||
Long = 5,
|
Long = 5,
|
||||||
Float = 6,
|
Float = 6,
|
||||||
Double = 7,
|
Double = 7,
|
||||||
Struct = 8,
|
Struct = 8,
|
||||||
Union = 9,
|
Union = 9,
|
||||||
Enum = 10,
|
Enum = 10,
|
||||||
MOE = 11,
|
MOE = 11,
|
||||||
Byte = 12,
|
Byte = 12,
|
||||||
Word = 13,
|
Word = 13,
|
||||||
UInt = 14,
|
UInt = 14,
|
||||||
DWord = 15
|
DWord = 15
|
||||||
};
|
};
|
||||||
|
|
||||||
enum StorageClass : u8 {
|
enum StorageClass : u8 {
|
||||||
EndOfFunction = 0xFF,
|
EndOfFunction = 0xFF,
|
||||||
Null = 0,
|
Null = 0,
|
||||||
Automatic = 1,
|
Automatic = 1,
|
||||||
External = 2,
|
External = 2,
|
||||||
Static = 3,
|
Static = 3,
|
||||||
Register = 4,
|
Register = 4,
|
||||||
ExternalDef = 5,
|
ExternalDef = 5,
|
||||||
Label = 6,
|
Label = 6,
|
||||||
UndefinedLabel = 7,
|
UndefinedLabel = 7,
|
||||||
MemberOfStruct = 8,
|
MemberOfStruct = 8,
|
||||||
Argument = 9,
|
Argument = 9,
|
||||||
StructTag = 10,
|
StructTag = 10,
|
||||||
MemberOfUnion = 11,
|
MemberOfUnion = 11,
|
||||||
UnionTag = 12,
|
UnionTag = 12,
|
||||||
TypeDefinition = 13,
|
TypeDefinition = 13,
|
||||||
UndefinedStatic = 14,
|
UndefinedStatic = 14,
|
||||||
EnumTag = 15,
|
EnumTag = 15,
|
||||||
MemberOfEnum = 16,
|
MemberOfEnum = 16,
|
||||||
RegisterParam = 17,
|
RegisterParam = 17,
|
||||||
BitField = 18,
|
BitField = 18,
|
||||||
Block = 100,
|
Block = 100,
|
||||||
Function = 101,
|
Function = 101,
|
||||||
EndOfStruct = 102,
|
EndOfStruct = 102,
|
||||||
File = 103,
|
File = 103,
|
||||||
Section = 104,
|
Section = 104,
|
||||||
WeakExternal = 105,
|
WeakExternal = 105,
|
||||||
CLRToken = 107
|
CLRToken = 107
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AuxSymbol {
|
struct AuxSymbol {
|
||||||
u8 data[18];
|
u8 data[18];
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 countedSymbols = 0;
|
u32 countedSymbols = 0;
|
||||||
struct SymbolTable {
|
struct SymbolTable {
|
||||||
char name[8];
|
char name[8];
|
||||||
u32 value;
|
u32 value;
|
||||||
u16 sectionNumber;
|
u16 sectionNumber;
|
||||||
Type type;
|
Type type;
|
||||||
StorageClass storageClass;
|
StorageClass storageClass;
|
||||||
u8 numberOfAuxSymbols;
|
u8 numberOfAuxSymbols;
|
||||||
|
|
||||||
countedSymbols += 1 + numberOfAuxSymbols;
|
countedSymbols += 1 + numberOfAuxSymbols;
|
||||||
|
|
||||||
AuxSymbol auxSymbols[numberOfAuxSymbols];
|
AuxSymbol auxSymbols[numberOfAuxSymbols];
|
||||||
|
|
||||||
if (countedSymbols >= parent.header.numberOfSymbols)
|
if (countedSymbols >= parent.header.numberOfSymbols)
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct String {
|
struct String {
|
||||||
char value[];
|
char value[];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StringTable {
|
struct StringTable {
|
||||||
u32 size;
|
u32 size;
|
||||||
String strings[while($ < addressof(size) + size)];
|
String strings[while($ < addressof(size) + size)];
|
||||||
};
|
};
|
||||||
|
|
||||||
bitfield SectionFlags {
|
bitfield SectionFlags {
|
||||||
padding : 3;
|
padding : 3;
|
||||||
typeNoPad : 1;
|
typeNoPad : 1;
|
||||||
padding : 1;
|
padding : 1;
|
||||||
cntCode : 1;
|
cntCode : 1;
|
||||||
initializedData : 1;
|
initializedData : 1;
|
||||||
uninitializedData : 1;
|
uninitializedData : 1;
|
||||||
lnkOther : 1;
|
lnkOther : 1;
|
||||||
lnkInfo : 1;
|
lnkInfo : 1;
|
||||||
padding : 1;
|
padding : 1;
|
||||||
lnkRemove : 1;
|
lnkRemove : 1;
|
||||||
lnkCOMDAT : 1;
|
lnkCOMDAT : 1;
|
||||||
padding : 2;
|
padding : 2;
|
||||||
gprel : 1;
|
gprel : 1;
|
||||||
padding : 1;
|
padding : 1;
|
||||||
memPurgeable : 1;
|
memPurgeable : 1;
|
||||||
memLocked : 1;
|
memLocked : 1;
|
||||||
memPreload : 1;
|
memPreload : 1;
|
||||||
alignment : 4 [[format("format_alignment")]];
|
alignment : 4 [[format("format_alignment")]];
|
||||||
lnkNrelocOvfl : 1;
|
lnkNrelocOvfl : 1;
|
||||||
memDiscardable : 1;
|
memDiscardable : 1;
|
||||||
memNotCached : 1;
|
memNotCached : 1;
|
||||||
memNotPaged : 1;
|
memNotPaged : 1;
|
||||||
memShared : 1;
|
memShared : 1;
|
||||||
memExecute : 1;
|
memExecute : 1;
|
||||||
memRead : 1;
|
memRead : 1;
|
||||||
memWrite : 1;
|
memWrite : 1;
|
||||||
} [[right_to_left]];
|
};
|
||||||
|
|
||||||
fn format_alignment(u8 alignment) {
|
fn format_alignment(u8 alignment) {
|
||||||
return 1 << alignment;
|
return 1 << alignment;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Relocations {
|
struct Relocations {
|
||||||
u32 virtualAddress;
|
u32 virtualAddress;
|
||||||
u32 symbolTableIndex;
|
u32 symbolTableIndex;
|
||||||
Type type;
|
Type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Section {
|
struct Section {
|
||||||
char name[8];
|
char name[8];
|
||||||
type::Size<u32> virtualSize;
|
type::Size<u32> virtualSize;
|
||||||
u32 virtualAddress;
|
u32 virtualAddress;
|
||||||
type::Size<u32> sizeOfRawData;
|
type::Size<u32> sizeOfRawData;
|
||||||
u32 pointerToRawData;
|
u32 pointerToRawData;
|
||||||
u32 pointerToRelocations;
|
u32 pointerToRelocations;
|
||||||
u32 pointerToLineNumbers;
|
u32 pointerToLineNumbers;
|
||||||
u16 numberOfRelocations;
|
u16 numberOfRelocations;
|
||||||
u16 numberOfLineNumbers;
|
u16 numberOfLineNumbers;
|
||||||
SectionFlags characteristics;
|
SectionFlags characteristics;
|
||||||
|
|
||||||
u8 rawData[sizeOfRawData] @ pointerToRawData [[sealed]];
|
u8 rawData[sizeOfRawData] @ pointerToRawData [[sealed]];
|
||||||
Relocations relocations[numberOfRelocations] @ pointerToRelocations;
|
Relocations relocations[numberOfRelocations] @ pointerToRelocations;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Header {
|
struct Header {
|
||||||
Machine machine;
|
Machine machine;
|
||||||
u16 numberOfSections;
|
u16 numberOfSections;
|
||||||
type::time32_t timeDateStamp;
|
type::time32_t timeDateStamp;
|
||||||
u32 pointerToSymbolTable;
|
u32 pointerToSymbolTable;
|
||||||
u32 numberOfSymbols;
|
u32 numberOfSymbols;
|
||||||
u16 sizeOfOptionalHeader;
|
u16 sizeOfOptionalHeader;
|
||||||
Characteristics characteristics;
|
Characteristics characteristics;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct COFF {
|
struct COFF {
|
||||||
Header header;
|
Header header;
|
||||||
|
|
||||||
Section sectionTable[header.numberOfSections];
|
Section sectionTable[header.numberOfSections];
|
||||||
|
|
||||||
SymbolTable symbolTable[header.numberOfSymbols] @ header.pointerToSymbolTable;
|
SymbolTable symbolTable[header.numberOfSymbols] @ header.pointerToSymbolTable;
|
||||||
StringTable stringTable @ addressof(symbolTable) + sizeof(symbolTable);
|
StringTable stringTable @ addressof(symbolTable) + sizeof(symbolTable);
|
||||||
};
|
};
|
||||||
|
|
||||||
COFF coff @ 0x00;
|
COFF coff @ 0x00;
|
||||||
|
|||||||
@@ -22,14 +22,14 @@ namespace old_binary {
|
|||||||
using SwappedU32 = u32 [[transform("old_binary::swap_32bit"), format("old_binary::swap_32bit")]];
|
using SwappedU32 = u32 [[transform("old_binary::swap_32bit"), format("old_binary::swap_32bit")]];
|
||||||
|
|
||||||
bitfield Mode {
|
bitfield Mode {
|
||||||
file_type : 4;
|
|
||||||
suid : 1;
|
|
||||||
sgid : 1;
|
|
||||||
sticky : 1;
|
|
||||||
r : 3;
|
|
||||||
w : 3;
|
|
||||||
x : 3;
|
x : 3;
|
||||||
} [[left_to_right]];
|
w : 3;
|
||||||
|
r : 3;
|
||||||
|
sticky : 1;
|
||||||
|
sgid : 1;
|
||||||
|
suid : 1;
|
||||||
|
file_type : 4;
|
||||||
|
};
|
||||||
|
|
||||||
struct CpioHeader {
|
struct CpioHeader {
|
||||||
type::Oct<u16> magic;
|
type::Oct<u16> magic;
|
||||||
|
|||||||
@@ -4,10 +4,12 @@
|
|||||||
#pragma MIME application/x-object
|
#pragma MIME application/x-object
|
||||||
#pragma MIME application/x-sharedlib
|
#pragma MIME application/x-sharedlib
|
||||||
|
|
||||||
#include <std/io.pat>
|
|
||||||
#include <std/core.pat>
|
#include <std/core.pat>
|
||||||
|
#include <std/io.pat>
|
||||||
#include <std/mem.pat>
|
#include <std/mem.pat>
|
||||||
|
|
||||||
|
using BitfieldOrder = std::core::BitfieldOrder;
|
||||||
|
|
||||||
using EI_ABIVERSION = u8;
|
using EI_ABIVERSION = u8;
|
||||||
using Elf32_Addr = u32;
|
using Elf32_Addr = u32;
|
||||||
using Elf32_BaseAddr = u32;
|
using Elf32_BaseAddr = u32;
|
||||||
@@ -458,37 +460,37 @@ enum VER_NEED : Elf32_Half {
|
|||||||
};
|
};
|
||||||
|
|
||||||
bitfield SYMINFO_FLG {
|
bitfield SYMINFO_FLG {
|
||||||
padding : 10;
|
|
||||||
NOEXTDIRECT : 1;
|
|
||||||
DIRECTBIND : 1;
|
|
||||||
LAZYLOAD : 1;
|
|
||||||
COPY : 1;
|
|
||||||
RESERVED : 1;
|
|
||||||
DIRECT : 1;
|
DIRECT : 1;
|
||||||
} [[left_to_right]];
|
RESERVED : 1;
|
||||||
|
COPY : 1;
|
||||||
|
LAZYLOAD : 1;
|
||||||
|
DIRECTBIND : 1;
|
||||||
|
NOEXTDIRECT : 1;
|
||||||
|
padding : 10;
|
||||||
|
};
|
||||||
|
|
||||||
bitfield ST {
|
bitfield ST {
|
||||||
ST_BIND : 4;
|
ST_BIND : 4;
|
||||||
ST_TYPE : 4;
|
ST_TYPE : 4;
|
||||||
} [[left_to_right]];
|
} [[bitfield_order(BitfieldOrder::MostToLeastSignificant, 8)]];
|
||||||
|
|
||||||
bitfield SHF {
|
bitfield SHF {
|
||||||
MASKPROC : 4;
|
|
||||||
MASKOS : 8;
|
|
||||||
UNKNOWN : 8;
|
|
||||||
COMPRESSED : 1;
|
|
||||||
TLS : 1;
|
|
||||||
GROUP : 1;
|
|
||||||
OS_NONCONFORMING : 1;
|
|
||||||
LINK_ORDER : 1;
|
|
||||||
INFO_LINK : 1;
|
|
||||||
STRINGS : 1;
|
|
||||||
MERGE : 1;
|
|
||||||
padding : 1;
|
|
||||||
EXECINSTR : 1;
|
|
||||||
ALLOC : 1;
|
|
||||||
WRITE : 1;
|
WRITE : 1;
|
||||||
} [[left_to_right]];
|
ALLOC : 1;
|
||||||
|
EXECINSTR : 1;
|
||||||
|
padding : 1;
|
||||||
|
MERGE : 1;
|
||||||
|
STRINGS : 1;
|
||||||
|
INFO_LINK : 1;
|
||||||
|
LINK_ORDER : 1;
|
||||||
|
OS_NONCONFORMING : 1;
|
||||||
|
GROUP : 1;
|
||||||
|
TLS : 1;
|
||||||
|
COMPRESSED : 1;
|
||||||
|
UNKNOWN : 8;
|
||||||
|
MASKOS : 8;
|
||||||
|
MASKPROC : 4;
|
||||||
|
};
|
||||||
|
|
||||||
bitfield ELF32_R_INFO {
|
bitfield ELF32_R_INFO {
|
||||||
SYM : 8;
|
SYM : 8;
|
||||||
@@ -501,13 +503,13 @@ bitfield ELF64_R_INFO {
|
|||||||
} [[left_to_right]];
|
} [[left_to_right]];
|
||||||
|
|
||||||
bitfield PF {
|
bitfield PF {
|
||||||
MASKPROC : 4;
|
|
||||||
MASKOS : 4;
|
|
||||||
padding : 17;
|
|
||||||
R : 1;
|
|
||||||
W : 1;
|
|
||||||
X : 1;
|
X : 1;
|
||||||
} [[left_to_right]];
|
W : 1;
|
||||||
|
R : 1;
|
||||||
|
padding : 17;
|
||||||
|
MASKOS : 4;
|
||||||
|
MASKPROC : 4;
|
||||||
|
};
|
||||||
|
|
||||||
struct E_IDENT {
|
struct E_IDENT {
|
||||||
char EI_MAG[4];
|
char EI_MAG[4];
|
||||||
|
|||||||
@@ -1,321 +1,323 @@
|
|||||||
#include <std/sys.pat>
|
#include <std/sys.pat>
|
||||||
#include <std/core.pat>
|
#include <std/core.pat>
|
||||||
#include <std/io.pat>
|
#include <std/io.pat>
|
||||||
|
|
||||||
#pragma endian big
|
#pragma endian big
|
||||||
|
|
||||||
u32 sampleSize;
|
using BitfieldOrder = std::core::BitfieldOrder;
|
||||||
u32 bitsPerSample;
|
|
||||||
|
u32 sampleSize;
|
||||||
// METADATA
|
u32 bitsPerSample;
|
||||||
|
|
||||||
enum BLOCK_TYPE : u8 {
|
// METADATA
|
||||||
STREAMINFO = 0,
|
|
||||||
PADDING = 1,
|
enum BLOCK_TYPE : u8 {
|
||||||
APPLICATION = 2,
|
STREAMINFO = 0,
|
||||||
SEEKTABLE = 3,
|
PADDING = 1,
|
||||||
VORBIS_COMMENT = 4,
|
APPLICATION = 2,
|
||||||
CUESHEET = 5,
|
SEEKTABLE = 3,
|
||||||
PICTURE = 6,
|
VORBIS_COMMENT = 4,
|
||||||
|
CUESHEET = 5,
|
||||||
INVALID = 127
|
PICTURE = 6,
|
||||||
};
|
|
||||||
|
INVALID = 127
|
||||||
bitfield METADATA_BLOCK_HEADER {
|
};
|
||||||
lastMetadataBlock : 1;
|
|
||||||
blockType : 7;
|
bitfield METADATA_BLOCK_HEADER {
|
||||||
length : 24;
|
lastMetadataBlock : 1;
|
||||||
} [[left_to_right]];
|
blockType : 7;
|
||||||
|
length : 24;
|
||||||
bitfield STREAMINFO_FLAGS {
|
};
|
||||||
sampleRate : 20;
|
|
||||||
numChannels : 3 [[format("format_channels")]];
|
bitfield STREAMINFO_FLAGS {
|
||||||
bitsPerSample : 5;
|
sampleRate : 20;
|
||||||
numSamplesInStream : 36;
|
numChannels : 3 [[format("format_channels")]];
|
||||||
} [[inline, left_to_right]];
|
bitsPerSample : 5;
|
||||||
|
numSamplesInStream : 36;
|
||||||
fn format_channels(u8 value) {
|
} [[inline]];
|
||||||
return value + 1;
|
|
||||||
};
|
fn format_channels(u8 value) {
|
||||||
|
return value + 1;
|
||||||
struct METADATA_BLOCK_STREAMINFO {
|
};
|
||||||
u16 minBlockSize, maxBlockSize;
|
|
||||||
u24 minFrameSize, maxFrameSize;
|
struct METADATA_BLOCK_STREAMINFO {
|
||||||
STREAMINFO_FLAGS flags;
|
u16 minBlockSize, maxBlockSize;
|
||||||
u128 md5Signature;
|
u24 minFrameSize, maxFrameSize;
|
||||||
|
STREAMINFO_FLAGS flags;
|
||||||
bitsPerSample = flags.bitsPerSample;
|
u128 md5Signature;
|
||||||
};
|
|
||||||
|
bitsPerSample = flags.bitsPerSample;
|
||||||
struct METADATA_BLOCK_PADDING {
|
};
|
||||||
padding[parent.header.length];
|
|
||||||
};
|
struct METADATA_BLOCK_PADDING {
|
||||||
|
padding[parent.header.length];
|
||||||
struct METADATA_BLOCK_APPLICATION {
|
};
|
||||||
char applicationID[4];
|
|
||||||
u8 applicationData[parent.header.length - sizeof(applicationID)];
|
struct METADATA_BLOCK_APPLICATION {
|
||||||
};
|
char applicationID[4];
|
||||||
|
u8 applicationData[parent.header.length - sizeof(applicationID)];
|
||||||
struct SEEKPOINT {
|
};
|
||||||
u64 sampleNumber;
|
|
||||||
u64 byteOffset;
|
struct SEEKPOINT {
|
||||||
u16 numSamples;
|
u64 sampleNumber;
|
||||||
};
|
u64 byteOffset;
|
||||||
|
u16 numSamples;
|
||||||
struct METADATA_BLOCK_SEEKTABLE {
|
};
|
||||||
SEEKPOINT seekPoints[parent.header.length / 18];
|
|
||||||
};
|
struct METADATA_BLOCK_SEEKTABLE {
|
||||||
|
SEEKPOINT seekPoints[parent.header.length / 18];
|
||||||
struct VORBIS_USER_COMMENT {
|
};
|
||||||
le u32 length;
|
|
||||||
char comment[length];
|
struct VORBIS_USER_COMMENT {
|
||||||
};
|
le u32 length;
|
||||||
|
char comment[length];
|
||||||
struct METADATA_BLOCK_VORBIS_COMMENT {
|
};
|
||||||
le u32 vendorLength;
|
|
||||||
u8 vendor[vendorLength];
|
struct METADATA_BLOCK_VORBIS_COMMENT {
|
||||||
|
le u32 vendorLength;
|
||||||
le u32 userCommentListLength;
|
u8 vendor[vendorLength];
|
||||||
VORBIS_USER_COMMENT userCommentList[userCommentListLength];
|
|
||||||
};
|
le u32 userCommentListLength;
|
||||||
|
VORBIS_USER_COMMENT userCommentList[userCommentListLength];
|
||||||
bitfield TRACK_FLAGS {
|
};
|
||||||
audioTrack : 1;
|
|
||||||
preEmphasis : 1;
|
bitfield TRACK_FLAGS {
|
||||||
padding : 6;
|
audioTrack : 1;
|
||||||
} [[inline]];
|
preEmphasis : 1;
|
||||||
|
} [[inline,bitfield_order(BitfieldOrder::LeastToMostSignificant, 8)]];
|
||||||
struct CUESHEET_TRACK_INDEX {
|
|
||||||
u64 sampleOffset;
|
struct CUESHEET_TRACK_INDEX {
|
||||||
u8 indexPointNumber;
|
u64 sampleOffset;
|
||||||
padding[3];
|
u8 indexPointNumber;
|
||||||
};
|
padding[3];
|
||||||
|
};
|
||||||
struct CUESHEET_TRACK {
|
|
||||||
u64 trackOffset;
|
struct CUESHEET_TRACK {
|
||||||
u8 trackNumber;
|
u64 trackOffset;
|
||||||
char trackISRC[12];
|
u8 trackNumber;
|
||||||
TRACK_FLAGS flags;
|
char trackISRC[12];
|
||||||
padding[13];
|
TRACK_FLAGS flags;
|
||||||
u8 numTrackIndexPoints;
|
padding[13];
|
||||||
CUESHEET_TRACK_INDEX indexes[numTrackIndexPoints];
|
u8 numTrackIndexPoints;
|
||||||
};
|
CUESHEET_TRACK_INDEX indexes[numTrackIndexPoints];
|
||||||
|
};
|
||||||
struct METADATA_BLOCK_CUESHEET {
|
|
||||||
char mediaCatalogNumber[128];
|
struct METADATA_BLOCK_CUESHEET {
|
||||||
u64 numLeadInSamples;
|
char mediaCatalogNumber[128];
|
||||||
bool isCD;
|
u64 numLeadInSamples;
|
||||||
padding[258];
|
bool isCD;
|
||||||
u8 numTracks;
|
padding[258];
|
||||||
CUESHEET_TRACK tracks[numTracks];
|
u8 numTracks;
|
||||||
};
|
CUESHEET_TRACK tracks[numTracks];
|
||||||
|
};
|
||||||
enum PICTURE_TYPE : u32 {
|
|
||||||
Other = 0,
|
enum PICTURE_TYPE : u32 {
|
||||||
FileIcon = 1,
|
Other = 0,
|
||||||
OtherFileIcon = 2,
|
FileIcon = 1,
|
||||||
CoverFront = 3,
|
OtherFileIcon = 2,
|
||||||
CoverBack = 4,
|
CoverFront = 3,
|
||||||
LeafletPage = 5,
|
CoverBack = 4,
|
||||||
Media = 6,
|
LeafletPage = 5,
|
||||||
LeadArtist = 7,
|
Media = 6,
|
||||||
Artist = 8,
|
LeadArtist = 7,
|
||||||
Conductor = 9,
|
Artist = 8,
|
||||||
Band = 10,
|
Conductor = 9,
|
||||||
Composer = 11,
|
Band = 10,
|
||||||
Lyricist = 12,
|
Composer = 11,
|
||||||
RecordingLocation = 13,
|
Lyricist = 12,
|
||||||
DuringRecording = 14,
|
RecordingLocation = 13,
|
||||||
DuringPerformance = 15,
|
DuringRecording = 14,
|
||||||
MovieScreenCapture = 16,
|
DuringPerformance = 15,
|
||||||
ABrightColoredFish = 17,
|
MovieScreenCapture = 16,
|
||||||
Illustration = 18,
|
ABrightColoredFish = 17,
|
||||||
BandLogoType = 19,
|
Illustration = 18,
|
||||||
PublisherLogoType = 20
|
BandLogoType = 19,
|
||||||
};
|
PublisherLogoType = 20
|
||||||
|
};
|
||||||
struct METADATA_BLOCK_PICTURE {
|
|
||||||
PICTURE_TYPE pictureType;
|
struct METADATA_BLOCK_PICTURE {
|
||||||
u32 mimeTypeLength;
|
PICTURE_TYPE pictureType;
|
||||||
char mimeType[mineTypeLength];
|
u32 mimeTypeLength;
|
||||||
u32 descriptionLength;
|
char mimeType[mineTypeLength];
|
||||||
char description[descriptionLength];
|
u32 descriptionLength;
|
||||||
u32 width, height;
|
char description[descriptionLength];
|
||||||
u32 colorDepth;
|
u32 width, height;
|
||||||
u32 colorCount;
|
u32 colorDepth;
|
||||||
u32 pictureDataLength;
|
u32 colorCount;
|
||||||
u8 pictureData[pictureDataLength];
|
u32 pictureDataLength;
|
||||||
};
|
u8 pictureData[pictureDataLength];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// FRAME DATA
|
|
||||||
// TODO: THIS IS INCOMPLETE / NOT WORKING CURRENTLY
|
// FRAME DATA
|
||||||
|
// TODO: THIS IS INCOMPLETE / NOT WORKING CURRENTLY
|
||||||
bitfield FRAME_HEADER_FLAGS {
|
|
||||||
syncCode : 14;
|
bitfield FRAME_HEADER_FLAGS {
|
||||||
padding : 1;
|
syncCode : 14;
|
||||||
blockingStrategy : 1;
|
padding : 1;
|
||||||
blockSize : 4;
|
blockingStrategy : 1;
|
||||||
sampleRate : 4;
|
blockSize : 4;
|
||||||
channelAssignment : 4;
|
sampleRate : 4;
|
||||||
sampleSize : 3;
|
channelAssignment : 4;
|
||||||
padding : 1;
|
sampleSize : 3;
|
||||||
} [[inline]];
|
} [[inline,bitfield_order(BitfieldOrder::LeastToMostSignificant, 32)]];
|
||||||
|
|
||||||
struct FRAME_HEADER {
|
struct FRAME_HEADER {
|
||||||
FRAME_HEADER_FLAGS flags;
|
FRAME_HEADER_FLAGS flags;
|
||||||
|
|
||||||
sampleSize = flags.sampleSize;
|
sampleSize = flags.sampleSize;
|
||||||
|
|
||||||
if (flags.blockingStrategy)
|
if (flags.blockingStrategy)
|
||||||
char16 sampleNumber[7];
|
char16 sampleNumber[7];
|
||||||
else
|
else
|
||||||
char16 frameNumber[6];
|
char16 frameNumber[6];
|
||||||
|
|
||||||
if (flags.blockSize == 0b0110)
|
if (flags.blockSize == 0b0110)
|
||||||
u8 blockSize;
|
u8 blockSize;
|
||||||
else if (flags.blockSize == 0b0111)
|
else if (flags.blockSize == 0b0111)
|
||||||
u16 blockSize;
|
u16 blockSize;
|
||||||
|
|
||||||
if (flags.sampleRate == 0b1100)
|
if (flags.sampleRate == 0b1100)
|
||||||
u8 sampleRate;
|
u8 sampleRate;
|
||||||
else if (flags.sampleRate == 0b1101 || flags.sampleRate == 0b1110)
|
else if (flags.sampleRate == 0b1101 || flags.sampleRate == 0b1110)
|
||||||
u16 sampleRate;
|
u16 sampleRate;
|
||||||
|
|
||||||
u8 crc8;
|
u8 crc8;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FRAME_FOOTER {
|
struct FRAME_FOOTER {
|
||||||
u16 crc16;
|
u16 crc16;
|
||||||
};
|
};
|
||||||
|
|
||||||
bitfield SUBFRAME_HEADER {
|
bitfield SUBFRAME_HEADER {
|
||||||
padding : 1;
|
padding : 1;
|
||||||
type : 6;
|
type : 6;
|
||||||
wastedBits : 1;
|
wastedBits : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
fn getBitsPerSample() {
|
fn getBitsPerSample() {
|
||||||
if (sampleSize == 0b000)
|
if (sampleSize == 0b000)
|
||||||
return bitsPerSample;
|
return bitsPerSample;
|
||||||
else if (sampleSize == 0b001)
|
else if (sampleSize == 0b001)
|
||||||
return 8;
|
return 8;
|
||||||
else if (sampleSize == 0b010)
|
else if (sampleSize == 0b010)
|
||||||
return 12;
|
return 12;
|
||||||
else if (sampleSize == 0b100)
|
else if (sampleSize == 0b100)
|
||||||
return 16;
|
return 16;
|
||||||
else if (sampleSize == 0b101)
|
else if (sampleSize == 0b101)
|
||||||
return 20;
|
return 20;
|
||||||
else if (sampleSize == 0b110)
|
else if (sampleSize == 0b110)
|
||||||
return 24;
|
return 24;
|
||||||
};
|
else
|
||||||
|
std::error(std::format("Invalid sample size {}.", sampleSize));
|
||||||
bitfield SUBFRAME_CONSTANT {
|
};
|
||||||
value : getBitsPerSample();
|
|
||||||
};
|
bitfield SUBFRAME_CONSTANT {
|
||||||
|
value : getBitsPerSample();
|
||||||
bitfield SUBFRAME_VERBATIM {
|
};
|
||||||
value : getBitsPerSample() * parent.parent.header.flags.blockSize;
|
|
||||||
};
|
bitfield SUBFRAME_VERBATIM {
|
||||||
|
value : getBitsPerSample() * parent.parent.header.flags.blockSize;
|
||||||
bitfield SUBFRAME_FIXED_VALUE {
|
};
|
||||||
value : getBitsPerSample() * (parent.parent.header.type & 0b111);
|
|
||||||
codingMethod : 2;
|
bitfield SUBFRAME_FIXED_VALUE {
|
||||||
} [[inline]];
|
value : getBitsPerSample() * (parent.parent.header.type & 0b111);
|
||||||
|
codingMethod : 2;
|
||||||
bitfield RESIDUAL_CODING_METHOD_PARTITIONED_RICE {
|
} [[inline]];
|
||||||
partitionOrder : 4;
|
|
||||||
riceParameter : 4;
|
bitfield RESIDUAL_CODING_METHOD_PARTITIONED_RICE {
|
||||||
if (riceParameter == 0b1111)
|
partitionOrder : 4;
|
||||||
bitsPerSample : 5;
|
riceParameter : 4;
|
||||||
} [[right_to_left]];
|
if (riceParameter == 0b1111)
|
||||||
|
bitsPerSample : 5;
|
||||||
bitfield RESIDUAL_CODING_METHOD_PARTITIONED_RICE2 {
|
};
|
||||||
partitionOrder : 4;
|
|
||||||
riceParameter : 5;
|
bitfield RESIDUAL_CODING_METHOD_PARTITIONED_RICE2 {
|
||||||
if (riceParameter == 0b11111)
|
partitionOrder : 4;
|
||||||
bitsPerSample : 5;
|
riceParameter : 5;
|
||||||
} [[right_to_left]];
|
if (riceParameter == 0b11111)
|
||||||
|
bitsPerSample : 5;
|
||||||
struct RESIDUAL {
|
};
|
||||||
if (parent.value.codingMethod == 0b00)
|
|
||||||
RESIDUAL_CODING_METHOD_PARTITIONED_RICE rice;
|
struct RESIDUAL {
|
||||||
else if (parent.value.codingMethod == 0b01)
|
if (parent.value.codingMethod == 0b00)
|
||||||
RESIDUAL_CODING_METHOD_PARTITIONED_RICE2 rice;
|
RESIDUAL_CODING_METHOD_PARTITIONED_RICE rice;
|
||||||
|
else if (parent.value.codingMethod == 0b01)
|
||||||
|
RESIDUAL_CODING_METHOD_PARTITIONED_RICE2 rice;
|
||||||
if ((parent.parent.header.type & 0b111) == 0b000)
|
|
||||||
u8 samples[(getBitsPerSample() * (parent.parent.parent.header.flags.blockSize - (parent.parent.header.type & 0b111))) / 8];
|
|
||||||
else if (std::core::array_index() != 0)
|
if ((parent.parent.header.type & 0b111) == 0b000)
|
||||||
u8 samples[(getBitsPerSample() * (parent.parent.parent.header.flags.blockSize / (1 << rice.partitionOrder))) / 8];
|
u8 samples[(getBitsPerSample() * (parent.parent.parent.header.flags.blockSize - (parent.parent.header.type & 0b111))) / 8];
|
||||||
else
|
else if (std::core::array_index() != 0)
|
||||||
u8 samples[(getBitsPerSample() * ((parent.parent.parent.header.flags.blockSize / (1 << rice.partitionOrder)) - (parent.parent.header.type & 0b111))) / 8];
|
u8 samples[(getBitsPerSample() * (parent.parent.parent.header.flags.blockSize / (1 << rice.partitionOrder))) / 8];
|
||||||
};
|
else
|
||||||
|
u8 samples[(getBitsPerSample() * ((parent.parent.parent.header.flags.blockSize / (1 << rice.partitionOrder)) - (parent.parent.header.type & 0b111))) / 8];
|
||||||
struct SUBFRAME_FIXED {
|
};
|
||||||
SUBFRAME_FIXED_VALUE value;
|
|
||||||
RESIDUAL residual;
|
struct SUBFRAME_FIXED {
|
||||||
};
|
SUBFRAME_FIXED_VALUE value;
|
||||||
|
RESIDUAL residual;
|
||||||
bitfield SUBFRAME_LPC_VALUE {
|
};
|
||||||
warmUpSamples : getBitsPerSample() * ((parent.header.type & 0b011111) + 1);
|
|
||||||
quantizedLinearPredictorCoefficient : 4;
|
bitfield SUBFRAME_LPC_VALUE {
|
||||||
quantizedLinearPredictorCoefficientShift : 5;
|
warmUpSamples : getBitsPerSample() * ((parent.header.type & 0b011111) + 1);
|
||||||
predictorCoefficients : quantizedLinearPredictorCoefficient * ((parent.header.type & 0b011111) + 1);
|
quantizedLinearPredictorCoefficient : 4;
|
||||||
} [[inline]];
|
quantizedLinearPredictorCoefficientShift : 5;
|
||||||
|
predictorCoefficients : quantizedLinearPredictorCoefficient * ((parent.header.type & 0b011111) + 1);
|
||||||
struct SUBFRAME_LPC {
|
} [[inline]];
|
||||||
SUBFRAME_LPC_VALUE value;
|
|
||||||
RESIDUAL residual;
|
struct SUBFRAME_LPC {
|
||||||
};
|
SUBFRAME_LPC_VALUE value;
|
||||||
|
RESIDUAL residual;
|
||||||
|
};
|
||||||
struct SUBFRAME {
|
|
||||||
SUBFRAME_HEADER header;
|
|
||||||
|
struct SUBFRAME {
|
||||||
if (header.type == 0b00000)
|
SUBFRAME_HEADER header;
|
||||||
SUBFRAME_CONSTANT constant;
|
|
||||||
else if (header.type == 0b000001)
|
if (header.type == 0b00000)
|
||||||
SUBFRAME_VERBATIM verbatim;
|
SUBFRAME_CONSTANT constant;
|
||||||
else if ((header.type >> 3) == 0b001 && (header.type & 0b111) <= 4)
|
else if (header.type == 0b000001)
|
||||||
SUBFRAME_FIXED fixed;
|
SUBFRAME_VERBATIM verbatim;
|
||||||
else if (header.type == 0b100000)
|
else if ((header.type >> 3) == 0b001 && (header.type & 0b111) <= 4)
|
||||||
SUBFRAME_LPC lpc;
|
SUBFRAME_FIXED fixed;
|
||||||
};
|
else if (header.type == 0b100000)
|
||||||
|
SUBFRAME_LPC lpc;
|
||||||
struct FRAME {
|
};
|
||||||
FRAME_HEADER header;
|
|
||||||
SUBFRAME subframes[parent.metadata[0].data.flags.numChannels + 1];
|
struct FRAME {
|
||||||
FRAME_FOOTER footer;
|
FRAME_HEADER header;
|
||||||
};
|
SUBFRAME subframes[parent.metadata[0].data.flags.numChannels + 1];
|
||||||
|
FRAME_FOOTER footer;
|
||||||
|
};
|
||||||
struct METADATA_BLOCK {
|
|
||||||
METADATA_BLOCK_HEADER header;
|
|
||||||
if (header.lastMetadataBlock)
|
struct METADATA_BLOCK {
|
||||||
break;
|
METADATA_BLOCK_HEADER header;
|
||||||
|
if (header.lastMetadataBlock)
|
||||||
if (header.blockType == BLOCK_TYPE::STREAMINFO)
|
break;
|
||||||
METADATA_BLOCK_STREAMINFO data;
|
|
||||||
else if (header.blockType == BLOCK_TYPE::PADDING)
|
if (header.blockType == BLOCK_TYPE::STREAMINFO)
|
||||||
METADATA_BLOCK_PADDING data;
|
METADATA_BLOCK_STREAMINFO data;
|
||||||
else if (header.blockType == BLOCK_TYPE::APPLICATION)
|
else if (header.blockType == BLOCK_TYPE::PADDING)
|
||||||
METADATA_BLOCK_APPLICATION data;
|
METADATA_BLOCK_PADDING data;
|
||||||
else if (header.blockType == BLOCK_TYPE::VORBIS_COMMENT)
|
else if (header.blockType == BLOCK_TYPE::APPLICATION)
|
||||||
METADATA_BLOCK_VORBIS_COMMENT data;
|
METADATA_BLOCK_APPLICATION data;
|
||||||
else if (header.blockType == BLOCK_TYPE::CUESHEET)
|
else if (header.blockType == BLOCK_TYPE::VORBIS_COMMENT)
|
||||||
METADATA_BLOCK_CUESHEET data;
|
METADATA_BLOCK_VORBIS_COMMENT data;
|
||||||
else if (header.blockType == BLOCK_TYPE::PICTURE)
|
else if (header.blockType == BLOCK_TYPE::CUESHEET)
|
||||||
METADATA_BLOCK_PICTURE data;
|
METADATA_BLOCK_CUESHEET data;
|
||||||
else
|
else if (header.blockType == BLOCK_TYPE::PICTURE)
|
||||||
std::error("Invalid metadata block type!");
|
METADATA_BLOCK_PICTURE data;
|
||||||
};
|
else
|
||||||
|
std::error("Invalid metadata block type!");
|
||||||
struct STREAM {
|
};
|
||||||
char magic[4];
|
|
||||||
METADATA_BLOCK metadata[while(true)];
|
struct STREAM {
|
||||||
//FRAME frames[while(!std::mem::eof())];
|
char magic[4];
|
||||||
};
|
METADATA_BLOCK metadata[while(true)];
|
||||||
|
//FRAME frames[while(!std::mem::eof())];
|
||||||
|
};
|
||||||
|
|
||||||
STREAM stream @ 0x00;
|
STREAM stream @ 0x00;
|
||||||
@@ -13,7 +13,7 @@ bitfield CHS {
|
|||||||
h : 8;
|
h : 8;
|
||||||
s : 6;
|
s : 6;
|
||||||
c : 10;
|
c : 10;
|
||||||
} [[right_to_left, format("chs_formatter")]];
|
} [[format("chs_formatter")]];
|
||||||
|
|
||||||
fn chs_formatter(CHS chs) {
|
fn chs_formatter(CHS chs) {
|
||||||
return std::format("({:X}, {:X}, {:X}) | 0x{:X}", chs.c, chs.h, chs.s, (chs.c * 16 + chs.h) * 63 + (chs.s - 1));
|
return std::format("({:X}, {:X}, {:X}) | 0x{:X}", chs.c, chs.h, chs.s, (chs.c * 16 + chs.h) * 63 + (chs.s - 1));
|
||||||
|
|||||||
@@ -1,77 +1,79 @@
|
|||||||
#pragma MIME application/gzip
|
#pragma MIME application/gzip
|
||||||
|
|
||||||
#include <type/time.pat>
|
#include <type/time.pat>
|
||||||
#include <type/size.pat>
|
#include <type/size.pat>
|
||||||
#include <std/mem.pat>
|
#include <std/core.pat>
|
||||||
|
#include <std/mem.pat>
|
||||||
bitfield Flags {
|
|
||||||
FTEXT : 1;
|
using BitfieldOrder = std::core::BitfieldOrder;
|
||||||
FHCRC : 1;
|
|
||||||
FEXTRA : 1;
|
bitfield Flags {
|
||||||
FNAME : 1;
|
FTEXT : 1;
|
||||||
FCOMMENT : 1;
|
FHCRC : 1;
|
||||||
padding : 3;
|
FEXTRA : 1;
|
||||||
} [[right_to_left]];
|
FNAME : 1;
|
||||||
|
FCOMMENT : 1;
|
||||||
bitfield ExtraFlags {
|
} [[bitfield_order(BitfieldOrder::LeastToMostSignificant, 8)]];
|
||||||
padding : 1;
|
|
||||||
maximumCompression : 1;
|
bitfield ExtraFlags {
|
||||||
fastestCompression : 1;
|
padding : 1;
|
||||||
padding : 5;
|
maximumCompression : 1;
|
||||||
};
|
fastestCompression : 1;
|
||||||
|
padding : 5;
|
||||||
enum CompressionMethod : u8 {
|
};
|
||||||
Reserved = 0 ... 7,
|
|
||||||
Deflate = 8
|
enum CompressionMethod : u8 {
|
||||||
};
|
Reserved = 0 ... 7,
|
||||||
|
Deflate = 8
|
||||||
enum OperatingSystemID : u8 {
|
};
|
||||||
FATFileSystem = 0x00,
|
|
||||||
Amiga = 0x01,
|
enum OperatingSystemID : u8 {
|
||||||
VMS = 0x02,
|
FATFileSystem = 0x00,
|
||||||
Unix = 0x03,
|
Amiga = 0x01,
|
||||||
VM_CMS = 0x04,
|
VMS = 0x02,
|
||||||
AtariTOS = 0x05,
|
Unix = 0x03,
|
||||||
HPFSFileSystem = 0x06,
|
VM_CMS = 0x04,
|
||||||
Macintosh = 0x07,
|
AtariTOS = 0x05,
|
||||||
ZSystem = 0x08,
|
HPFSFileSystem = 0x06,
|
||||||
CP_M = 0x09,
|
Macintosh = 0x07,
|
||||||
TOPS_20 = 0x0A,
|
ZSystem = 0x08,
|
||||||
NTFSFileSystem = 0x0B,
|
CP_M = 0x09,
|
||||||
QDOS = 0x0C,
|
TOPS_20 = 0x0A,
|
||||||
AcordRISCOS = 0x0D,
|
NTFSFileSystem = 0x0B,
|
||||||
Unknown = 0xFF
|
QDOS = 0x0C,
|
||||||
};
|
AcordRISCOS = 0x0D,
|
||||||
|
Unknown = 0xFF
|
||||||
struct GZip {
|
};
|
||||||
u16 signature;
|
|
||||||
CompressionMethod compressionMethod;
|
struct GZip {
|
||||||
Flags flags;
|
u16 signature;
|
||||||
type::time32_t modificationTime;
|
CompressionMethod compressionMethod;
|
||||||
ExtraFlags extraFlags;
|
Flags flags;
|
||||||
OperatingSystemID operatingSystemId;
|
type::time32_t modificationTime;
|
||||||
|
ExtraFlags extraFlags;
|
||||||
if (flags.FEXTRA) {
|
OperatingSystemID operatingSystemId;
|
||||||
u16 extraLength;
|
|
||||||
u8 extraField[extraLength];
|
if (flags.FEXTRA) {
|
||||||
}
|
u16 extraLength;
|
||||||
|
u8 extraField[extraLength];
|
||||||
if (flags.FNAME) {
|
}
|
||||||
char originalFileName[];
|
|
||||||
}
|
if (flags.FNAME) {
|
||||||
|
char originalFileName[];
|
||||||
if (flags.FCOMMENT) {
|
}
|
||||||
char comment[];
|
|
||||||
}
|
if (flags.FCOMMENT) {
|
||||||
|
char comment[];
|
||||||
if (flags.FHCRC) {
|
}
|
||||||
u16 crc16;
|
|
||||||
}
|
if (flags.FHCRC) {
|
||||||
|
u16 crc16;
|
||||||
u8 data[while($ < std::mem::size() - 8)] [[sealed]];
|
}
|
||||||
|
|
||||||
u32 crc32;
|
u8 data[while($ < std::mem::size() - 8)] [[sealed]];
|
||||||
type::Size<u32> isize;
|
|
||||||
};
|
u32 crc32;
|
||||||
|
type::Size<u32> isize;
|
||||||
|
};
|
||||||
|
|
||||||
GZip gzip @ 0x00;
|
GZip gzip @ 0x00;
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
#pragma endian big
|
#pragma endian big
|
||||||
#pragma bitfield_order left_to_right
|
|
||||||
|
|
||||||
#include <std/sys.pat>
|
#include <std/sys.pat>
|
||||||
#include <std/io.pat>
|
#include <std/io.pat>
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
#pragma endian big
|
#pragma endian big
|
||||||
#pragma MIME application/x-java-applet
|
#pragma MIME application/x-java-applet
|
||||||
|
|
||||||
|
#include <std/core.pat>
|
||||||
#include <std/io.pat>
|
#include <std/io.pat>
|
||||||
#include <std/sys.pat>
|
#include <std/sys.pat>
|
||||||
|
|
||||||
|
using BitfieldOrder = std::core::BitfieldOrder;
|
||||||
|
|
||||||
// The Java documentations use the number of bytes instead of the number of bits for its type names
|
// The Java documentations use the number of bytes instead of the number of bits for its type names
|
||||||
using u1 = u8;
|
using u1 = u8;
|
||||||
using u2 = u16;
|
using u2 = u16;
|
||||||
@@ -206,7 +209,7 @@ bitfield access_flags_method {
|
|||||||
padding : 1; // 0x2000
|
padding : 1; // 0x2000
|
||||||
padding : 1; // 0x4000
|
padding : 1; // 0x4000
|
||||||
padding : 1; // 0x8000
|
padding : 1; // 0x8000
|
||||||
};
|
} [[bitfield_order(BitfieldOrder::LeastToMostSignificant, 16)]];
|
||||||
|
|
||||||
bitfield access_flags_field {
|
bitfield access_flags_field {
|
||||||
ACC_PUBLIC : 1; // 0x0001
|
ACC_PUBLIC : 1; // 0x0001
|
||||||
@@ -225,7 +228,7 @@ bitfield access_flags_field {
|
|||||||
padding : 1; // 0x2000
|
padding : 1; // 0x2000
|
||||||
ACC_ENUM : 1; // 0x4000
|
ACC_ENUM : 1; // 0x4000
|
||||||
padding : 1; // 0x8000
|
padding : 1; // 0x8000
|
||||||
};
|
} [[bitfield_order(BitfieldOrder::LeastToMostSignificant, 16)]];
|
||||||
|
|
||||||
bitfield access_flags_class {
|
bitfield access_flags_class {
|
||||||
ACC_PUBLIC : 1; // 0x0001
|
ACC_PUBLIC : 1; // 0x0001
|
||||||
@@ -244,7 +247,7 @@ bitfield access_flags_class {
|
|||||||
ACC_ANNOTATION : 1; // 0x2000
|
ACC_ANNOTATION : 1; // 0x2000
|
||||||
ACC_ENUM : 1; // 0x4000
|
ACC_ENUM : 1; // 0x4000
|
||||||
ACC_MODULE : 1; // 0x8000
|
ACC_MODULE : 1; // 0x8000
|
||||||
};
|
} [[bitfield_order(BitfieldOrder::LeastToMostSignificant, 16)]];
|
||||||
|
|
||||||
struct attribute_info {
|
struct attribute_info {
|
||||||
u2 attribute_name_info;
|
u2 attribute_name_info;
|
||||||
|
|||||||
@@ -1,459 +1,462 @@
|
|||||||
#pragma MIME application/x-ms-shortcut
|
#pragma MIME application/x-ms-shortcut
|
||||||
|
|
||||||
#include <type/guid.pat>
|
#include <std/core.pat>
|
||||||
#include <type/size.pat>
|
#include <type/guid.pat>
|
||||||
|
#include <type/size.pat>
|
||||||
bitfield LinkFlags {
|
|
||||||
HasLinkTargetIDList : 1;
|
using BitfieldOrder = std::core::BitfieldOrder;
|
||||||
HasLinkInfo : 1;
|
|
||||||
HasName : 1;
|
bitfield LinkFlags {
|
||||||
HasRelativePath : 1;
|
HasLinkTargetIDList : 1;
|
||||||
HasWorkingDir : 1;
|
HasLinkInfo : 1;
|
||||||
HasArguments : 1;
|
HasName : 1;
|
||||||
HasIconLocation : 1;
|
HasRelativePath : 1;
|
||||||
IsUnicode : 1;
|
HasWorkingDir : 1;
|
||||||
ForceNoLinkInfo : 1;
|
HasArguments : 1;
|
||||||
HasExpString : 1;
|
HasIconLocation : 1;
|
||||||
RunInSeparateProcess : 1;
|
IsUnicode : 1;
|
||||||
padding : 1;
|
ForceNoLinkInfo : 1;
|
||||||
HasDarwinID : 1;
|
HasExpString : 1;
|
||||||
RunAsUser : 1;
|
RunInSeparateProcess : 1;
|
||||||
HasExpIcon : 1;
|
padding : 1;
|
||||||
NoPidlAlias : 1;
|
HasDarwinID : 1;
|
||||||
padding : 1;
|
RunAsUser : 1;
|
||||||
RunWithShimLayer : 1;
|
HasExpIcon : 1;
|
||||||
ForceNoLinkTrack : 1;
|
NoPidlAlias : 1;
|
||||||
EnableTargetMetadata : 1;
|
padding : 1;
|
||||||
DisableLinkPathTracking : 1;
|
RunWithShimLayer : 1;
|
||||||
DisableKnownFolderTracking : 1;
|
ForceNoLinkTrack : 1;
|
||||||
DisableKnownFolderAlias : 1;
|
EnableTargetMetadata : 1;
|
||||||
AllowLinkToLink : 1;
|
DisableLinkPathTracking : 1;
|
||||||
UnaliasOnSave : 1;
|
DisableKnownFolderTracking : 1;
|
||||||
PreferEnvironmentPath : 1;
|
DisableKnownFolderAlias : 1;
|
||||||
KeepLocalIDListForUNCTarget : 1;
|
AllowLinkToLink : 1;
|
||||||
padding : 5;
|
UnaliasOnSave : 1;
|
||||||
} [[right_to_left]];
|
PreferEnvironmentPath : 1;
|
||||||
|
KeepLocalIDListForUNCTarget : 1;
|
||||||
bitfield FileAttributesFlags {
|
padding : 5;
|
||||||
FILE_ATTRIBUTE_READONLY : 1;
|
};
|
||||||
FILE_ATTRIBUTE_HIDDEN : 1;
|
|
||||||
FILE_ATTRIBUTE_SYSTEM : 1;
|
bitfield FileAttributesFlags {
|
||||||
padding : 1;
|
FILE_ATTRIBUTE_READONLY : 1;
|
||||||
FILE_ATTRIBUTE_DIRECTORY : 1;
|
FILE_ATTRIBUTE_HIDDEN : 1;
|
||||||
FILE_ATTRIBUTE_ARCHIVE : 1;
|
FILE_ATTRIBUTE_SYSTEM : 1;
|
||||||
padding : 1;
|
padding : 1;
|
||||||
FILE_ATTRIBUTE_NORMAL : 1;
|
FILE_ATTRIBUTE_DIRECTORY : 1;
|
||||||
FILE_ATTRIBUTE_TEMPORARY : 1;
|
FILE_ATTRIBUTE_ARCHIVE : 1;
|
||||||
FILE_ATTRIBUTE_SPARSE_FILE : 1;
|
padding : 1;
|
||||||
FILE_ATTRIBUTE_REPARSE_POINT : 1;
|
FILE_ATTRIBUTE_NORMAL : 1;
|
||||||
FILE_ATTRIBUTE_COMPRESSED : 1;
|
FILE_ATTRIBUTE_TEMPORARY : 1;
|
||||||
FILE_ATTRIBUTE_OFFLINE : 1;
|
FILE_ATTRIBUTE_SPARSE_FILE : 1;
|
||||||
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED : 1;
|
FILE_ATTRIBUTE_REPARSE_POINT : 1;
|
||||||
FILE_ATTRIBUTE_ENCRYPTED : 1;
|
FILE_ATTRIBUTE_COMPRESSED : 1;
|
||||||
padding : 17;
|
FILE_ATTRIBUTE_OFFLINE : 1;
|
||||||
} [[right_to_left]];
|
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED : 1;
|
||||||
|
FILE_ATTRIBUTE_ENCRYPTED : 1;
|
||||||
bitfield ModifierKeys {
|
padding : 17;
|
||||||
HOTKEYF_SHIFT : 1;
|
};
|
||||||
HOTKEYF_CONTROL : 1;
|
|
||||||
HOTKEYF_ALT : 1;
|
bitfield ModifierKeys {
|
||||||
padding : 5;
|
HOTKEYF_SHIFT : 1;
|
||||||
} [[right_to_left]];
|
HOTKEYF_CONTROL : 1;
|
||||||
|
HOTKEYF_ALT : 1;
|
||||||
enum Keys : u8 {
|
padding : 5;
|
||||||
KEY_NONE = 0x00,
|
};
|
||||||
KEY_0 = 0x30,
|
|
||||||
KEY_1 = 0x31,
|
enum Keys : u8 {
|
||||||
KEY_2 = 0x32,
|
KEY_NONE = 0x00,
|
||||||
KEY_3 = 0x33,
|
KEY_0 = 0x30,
|
||||||
KEY_4 = 0x34,
|
KEY_1 = 0x31,
|
||||||
KEY_5 = 0x35,
|
KEY_2 = 0x32,
|
||||||
KEY_6 = 0x36,
|
KEY_3 = 0x33,
|
||||||
KEY_7 = 0x37,
|
KEY_4 = 0x34,
|
||||||
KEY_8 = 0x38,
|
KEY_5 = 0x35,
|
||||||
KEY_9 = 0x39,
|
KEY_6 = 0x36,
|
||||||
KEY_A = 0x41,
|
KEY_7 = 0x37,
|
||||||
KEY_B = 0x42,
|
KEY_8 = 0x38,
|
||||||
KEY_C = 0x43,
|
KEY_9 = 0x39,
|
||||||
KEY_D = 0x44,
|
KEY_A = 0x41,
|
||||||
KEY_E = 0x45,
|
KEY_B = 0x42,
|
||||||
KEY_F = 0x46,
|
KEY_C = 0x43,
|
||||||
KEY_G = 0x47,
|
KEY_D = 0x44,
|
||||||
KEY_H = 0x48,
|
KEY_E = 0x45,
|
||||||
KEY_I = 0x49,
|
KEY_F = 0x46,
|
||||||
KEY_J = 0x4A,
|
KEY_G = 0x47,
|
||||||
KEY_K = 0x4B,
|
KEY_H = 0x48,
|
||||||
KEY_L = 0x4C,
|
KEY_I = 0x49,
|
||||||
KEY_M = 0x4D,
|
KEY_J = 0x4A,
|
||||||
KEY_N = 0x4E,
|
KEY_K = 0x4B,
|
||||||
KEY_O = 0x4F,
|
KEY_L = 0x4C,
|
||||||
KEY_P = 0x50,
|
KEY_M = 0x4D,
|
||||||
KEY_Q = 0x51,
|
KEY_N = 0x4E,
|
||||||
KEY_R = 0x52,
|
KEY_O = 0x4F,
|
||||||
KEY_S = 0x53,
|
KEY_P = 0x50,
|
||||||
KEY_T = 0x54,
|
KEY_Q = 0x51,
|
||||||
KEY_U = 0x55,
|
KEY_R = 0x52,
|
||||||
KEY_V = 0x56,
|
KEY_S = 0x53,
|
||||||
KEY_W = 0x57,
|
KEY_T = 0x54,
|
||||||
KEY_X = 0x58,
|
KEY_U = 0x55,
|
||||||
KEY_Y = 0x59,
|
KEY_V = 0x56,
|
||||||
KEY_Z = 0x5A,
|
KEY_W = 0x57,
|
||||||
|
KEY_X = 0x58,
|
||||||
VK_F1 = 0x70,
|
KEY_Y = 0x59,
|
||||||
VK_F2 = 0x71,
|
KEY_Z = 0x5A,
|
||||||
VK_F3 = 0x72,
|
|
||||||
VK_F4 = 0x73,
|
VK_F1 = 0x70,
|
||||||
VK_F5 = 0x74,
|
VK_F2 = 0x71,
|
||||||
VK_F6 = 0x75,
|
VK_F3 = 0x72,
|
||||||
VK_F7 = 0x76,
|
VK_F4 = 0x73,
|
||||||
VK_F8 = 0x77,
|
VK_F5 = 0x74,
|
||||||
VK_F9 = 0x78,
|
VK_F6 = 0x75,
|
||||||
VK_F10 = 0x79,
|
VK_F7 = 0x76,
|
||||||
VK_F11 = 0x7A,
|
VK_F8 = 0x77,
|
||||||
VK_F12 = 0x7B,
|
VK_F9 = 0x78,
|
||||||
VK_F13 = 0x7C,
|
VK_F10 = 0x79,
|
||||||
VK_F14 = 0x7D,
|
VK_F11 = 0x7A,
|
||||||
VK_F15 = 0x7E,
|
VK_F12 = 0x7B,
|
||||||
VK_F16 = 0x7F,
|
VK_F13 = 0x7C,
|
||||||
VK_F17 = 0x80,
|
VK_F14 = 0x7D,
|
||||||
VK_F18 = 0x81,
|
VK_F15 = 0x7E,
|
||||||
VK_F19 = 0x82,
|
VK_F16 = 0x7F,
|
||||||
VK_F20 = 0x83,
|
VK_F17 = 0x80,
|
||||||
VK_F21 = 0x84,
|
VK_F18 = 0x81,
|
||||||
VK_F22 = 0x85,
|
VK_F19 = 0x82,
|
||||||
VK_F23 = 0x86,
|
VK_F20 = 0x83,
|
||||||
VK_F24 = 0x87,
|
VK_F21 = 0x84,
|
||||||
VK_NUMLOCK = 0x90,
|
VK_F22 = 0x85,
|
||||||
VK_SCROLL = 0x91,
|
VK_F23 = 0x86,
|
||||||
};
|
VK_F24 = 0x87,
|
||||||
|
VK_NUMLOCK = 0x90,
|
||||||
struct HotKeyFlags {
|
VK_SCROLL = 0x91,
|
||||||
Keys Key;
|
};
|
||||||
ModifierKeys ModifierKeys;
|
|
||||||
};
|
struct HotKeyFlags {
|
||||||
|
Keys Key;
|
||||||
struct FILETIME {
|
ModifierKeys ModifierKeys;
|
||||||
u32 dwLowDateTime;
|
};
|
||||||
u32 dwHighDateTime;
|
|
||||||
};
|
struct FILETIME {
|
||||||
|
u32 dwLowDateTime;
|
||||||
enum SHOWWINDOW_FLAGS : u32 {
|
u32 dwHighDateTime;
|
||||||
SW_SHOWNORMAL = 0x00000001,
|
};
|
||||||
SW_SHOWMAXIMIZED = 0x00000003,
|
|
||||||
SW_SHOWMINNOACTIVE = 0x00000007
|
enum SHOWWINDOW_FLAGS : u32 {
|
||||||
};
|
SW_SHOWNORMAL = 0x00000001,
|
||||||
|
SW_SHOWMAXIMIZED = 0x00000003,
|
||||||
struct ShellLinkHeader {
|
SW_SHOWMINNOACTIVE = 0x00000007
|
||||||
type::Size32 HeaderSize;
|
};
|
||||||
type::GUID LinkCLSID;
|
|
||||||
LinkFlags LinkFlags;
|
struct ShellLinkHeader {
|
||||||
FileAttributesFlags FileAttributes;
|
type::Size32 HeaderSize;
|
||||||
FILETIME CreationTime, AccessTime, WriteTime;
|
type::GUID LinkCLSID;
|
||||||
type::Size32 FileSize;
|
LinkFlags LinkFlags;
|
||||||
u32 IconIndex;
|
FileAttributesFlags FileAttributes;
|
||||||
SHOWWINDOW_FLAGS ShowCommand;
|
FILETIME CreationTime, AccessTime, WriteTime;
|
||||||
HotKeyFlags HotKey;
|
type::Size32 FileSize;
|
||||||
padding[2];
|
u32 IconIndex;
|
||||||
padding[4];
|
SHOWWINDOW_FLAGS ShowCommand;
|
||||||
padding[4];
|
HotKeyFlags HotKey;
|
||||||
};
|
padding[2];
|
||||||
|
padding[4];
|
||||||
struct ItemID {
|
padding[4];
|
||||||
type::Size16 ItemIDSize;
|
};
|
||||||
|
|
||||||
if (ItemIDSize == 0x00)
|
struct ItemID {
|
||||||
break;
|
type::Size16 ItemIDSize;
|
||||||
else
|
|
||||||
u8 Data[ItemIDSize - sizeof(ItemIDSize)];
|
if (ItemIDSize == 0x00)
|
||||||
};
|
break;
|
||||||
|
else
|
||||||
struct IDList {
|
u8 Data[ItemIDSize - sizeof(ItemIDSize)];
|
||||||
ItemID ItemIDList[while(true)];
|
};
|
||||||
};
|
|
||||||
|
struct IDList {
|
||||||
struct LinkTargetIDList {
|
ItemID ItemIDList[while(true)];
|
||||||
type::Size16 IDListSize;
|
};
|
||||||
IDList IDList[while($ < (addressof(IDListSize) + IDListSize))];
|
|
||||||
};
|
struct LinkTargetIDList {
|
||||||
|
type::Size16 IDListSize;
|
||||||
bitfield LinkInfoFlags {
|
IDList IDList[while($ < (addressof(IDListSize) + IDListSize))];
|
||||||
VolumeIDAndLocalBasePath : 1;
|
};
|
||||||
CommonNetworkRelativeLinkAndPathSuffix : 1;
|
|
||||||
padding : 30;
|
bitfield LinkInfoFlags {
|
||||||
};
|
VolumeIDAndLocalBasePath : 1;
|
||||||
|
CommonNetworkRelativeLinkAndPathSuffix : 1;
|
||||||
enum DriveType : u32 {
|
padding : 30;
|
||||||
DRIVE_UNKNOWN = 0x00000000,
|
};
|
||||||
DRIVE_NO_ROOT_DIR = 0x00000001,
|
|
||||||
DRIVE_REMOVABLE = 0x00000002,
|
enum DriveType : u32 {
|
||||||
DRIVE_FIXED = 0x00000003,
|
DRIVE_UNKNOWN = 0x00000000,
|
||||||
DRIVE_REMOTE = 0x00000004,
|
DRIVE_NO_ROOT_DIR = 0x00000001,
|
||||||
DRIVE_CDROM = 0x00000005,
|
DRIVE_REMOVABLE = 0x00000002,
|
||||||
DRIVE_RAMDISK = 0x00000006
|
DRIVE_FIXED = 0x00000003,
|
||||||
};
|
DRIVE_REMOTE = 0x00000004,
|
||||||
|
DRIVE_CDROM = 0x00000005,
|
||||||
struct VolumeID {
|
DRIVE_RAMDISK = 0x00000006
|
||||||
type::Size32 VolumeIDSize;
|
};
|
||||||
DriveType DriveType;
|
|
||||||
u32 DriveSerialNumber;
|
struct VolumeID {
|
||||||
u32 VolumeLabelOffset;
|
type::Size32 VolumeIDSize;
|
||||||
if (VolumeLabelOffset == 0x14)
|
DriveType DriveType;
|
||||||
u32 VolumeLabelOffsetUnicode;
|
u32 DriveSerialNumber;
|
||||||
char Data[VolumeIDSize - ($ - addressof(this))];
|
u32 VolumeLabelOffset;
|
||||||
};
|
if (VolumeLabelOffset == 0x14)
|
||||||
|
u32 VolumeLabelOffsetUnicode;
|
||||||
bitfield CommonNetworkRelativeLinkFlags {
|
char Data[VolumeIDSize - ($ - addressof(this))];
|
||||||
ValidDevice : 1;
|
};
|
||||||
ValidNetType : 1;
|
|
||||||
padding : 30;
|
bitfield CommonNetworkRelativeLinkFlags {
|
||||||
} [[right_to_left]];
|
ValidDevice : 1;
|
||||||
|
ValidNetType : 1;
|
||||||
enum NetworkProviderType : u32 {
|
padding : 30;
|
||||||
WNNC_NET_AVID = 0x001A0000,
|
};
|
||||||
WNNC_NET_DOCUSPACE = 0x001B0000,
|
|
||||||
WNNC_NET_MANGOSOFT = 0x001C0000,
|
enum NetworkProviderType : u32 {
|
||||||
WNNC_NET_SERNET = 0x001D0000,
|
WNNC_NET_AVID = 0x001A0000,
|
||||||
WNNC_NET_RIVERFRONT1 = 0x001E0000,
|
WNNC_NET_DOCUSPACE = 0x001B0000,
|
||||||
WNNC_NET_RIVERFRONT2 = 0x001F0000,
|
WNNC_NET_MANGOSOFT = 0x001C0000,
|
||||||
WNNC_NET_DECORB = 0x00200000,
|
WNNC_NET_SERNET = 0x001D0000,
|
||||||
WNNC_NET_PROTSTOR = 0x00210000,
|
WNNC_NET_RIVERFRONT1 = 0x001E0000,
|
||||||
WNNC_NET_FJ_REDIR = 0x00220000,
|
WNNC_NET_RIVERFRONT2 = 0x001F0000,
|
||||||
WNNC_NET_DISTINCT = 0x00230000,
|
WNNC_NET_DECORB = 0x00200000,
|
||||||
WNNC_NET_TWINS = 0x00240000,
|
WNNC_NET_PROTSTOR = 0x00210000,
|
||||||
WNNC_NET_RDR2SAMPLE = 0x00250000,
|
WNNC_NET_FJ_REDIR = 0x00220000,
|
||||||
WNNC_NET_CSC = 0x00260000,
|
WNNC_NET_DISTINCT = 0x00230000,
|
||||||
WNNC_NET_3IN1 = 0x00270000,
|
WNNC_NET_TWINS = 0x00240000,
|
||||||
WNNC_NET_EXTENDNET = 0x00290000,
|
WNNC_NET_RDR2SAMPLE = 0x00250000,
|
||||||
WNNC_NET_STAC = 0x002A0000,
|
WNNC_NET_CSC = 0x00260000,
|
||||||
WNNC_NET_FOXBAT = 0x002B0000,
|
WNNC_NET_3IN1 = 0x00270000,
|
||||||
WNNC_NET_YAHOO = 0x002C0000,
|
WNNC_NET_EXTENDNET = 0x00290000,
|
||||||
WNNC_NET_EXIFS = 0x002D0000,
|
WNNC_NET_STAC = 0x002A0000,
|
||||||
WNNC_NET_DAV = 0x002E0000,
|
WNNC_NET_FOXBAT = 0x002B0000,
|
||||||
WNNC_NET_KNOWARE = 0x002F0000,
|
WNNC_NET_YAHOO = 0x002C0000,
|
||||||
WNNC_NET_OBJECT_DIRE = 0x00300000,
|
WNNC_NET_EXIFS = 0x002D0000,
|
||||||
WNNC_NET_MASFAX = 0x00310000,
|
WNNC_NET_DAV = 0x002E0000,
|
||||||
WNNC_NET_HOB_NFS = 0x00320000,
|
WNNC_NET_KNOWARE = 0x002F0000,
|
||||||
WNNC_NET_SHIVA = 0x00330000,
|
WNNC_NET_OBJECT_DIRE = 0x00300000,
|
||||||
WNNC_NET_IBMAL = 0x00340000,
|
WNNC_NET_MASFAX = 0x00310000,
|
||||||
WNNC_NET_LOCK = 0x00350000,
|
WNNC_NET_HOB_NFS = 0x00320000,
|
||||||
WNNC_NET_TERMSRV = 0x00360000,
|
WNNC_NET_SHIVA = 0x00330000,
|
||||||
WNNC_NET_SRT = 0x00370000,
|
WNNC_NET_IBMAL = 0x00340000,
|
||||||
WNNC_NET_QUINCY = 0x00380000,
|
WNNC_NET_LOCK = 0x00350000,
|
||||||
WNNC_NET_OPENAFS = 0x00390000,
|
WNNC_NET_TERMSRV = 0x00360000,
|
||||||
WNNC_NET_AVID1 = 0x003A0000,
|
WNNC_NET_SRT = 0x00370000,
|
||||||
WNNC_NET_DFS = 0x003B0000,
|
WNNC_NET_QUINCY = 0x00380000,
|
||||||
WNNC_NET_KWNP = 0x003C0000,
|
WNNC_NET_OPENAFS = 0x00390000,
|
||||||
WNNC_NET_ZENWORKS = 0x003D0000,
|
WNNC_NET_AVID1 = 0x003A0000,
|
||||||
WNNC_NET_DRIVEONWEB = 0x003E0000,
|
WNNC_NET_DFS = 0x003B0000,
|
||||||
WNNC_NET_VMWARE = 0x003F0000,
|
WNNC_NET_KWNP = 0x003C0000,
|
||||||
WNNC_NET_RSFX = 0x00400000,
|
WNNC_NET_ZENWORKS = 0x003D0000,
|
||||||
WNNC_NET_MFILES = 0x00410000,
|
WNNC_NET_DRIVEONWEB = 0x003E0000,
|
||||||
WNNC_NET_MS_NFS = 0x00420000,
|
WNNC_NET_VMWARE = 0x003F0000,
|
||||||
WNNC_NET_GOOGLE = 0x00430000
|
WNNC_NET_RSFX = 0x00400000,
|
||||||
};
|
WNNC_NET_MFILES = 0x00410000,
|
||||||
|
WNNC_NET_MS_NFS = 0x00420000,
|
||||||
struct CommonNetworkRelativeLink {
|
WNNC_NET_GOOGLE = 0x00430000
|
||||||
type::Size32 CommonNetworkRelativeLinkSize;
|
};
|
||||||
CommonNetworkRelativeLinkFlags CommonNetworkRelativeLinkFlags;
|
|
||||||
u32 NetNameOffset;
|
struct CommonNetworkRelativeLink {
|
||||||
u32 DeviceNameOffset;
|
type::Size32 CommonNetworkRelativeLinkSize;
|
||||||
NetworkProviderType NetworkProviderType;
|
CommonNetworkRelativeLinkFlags CommonNetworkRelativeLinkFlags;
|
||||||
|
u32 NetNameOffset;
|
||||||
if (NetNameOffset > 0x14) {
|
u32 DeviceNameOffset;
|
||||||
u32 NetNameOffsetUnicode;
|
NetworkProviderType NetworkProviderType;
|
||||||
u32 DeviceNameOffsetUnicode;
|
|
||||||
}
|
if (NetNameOffset > 0x14) {
|
||||||
|
u32 NetNameOffsetUnicode;
|
||||||
char NetName[];
|
u32 DeviceNameOffsetUnicode;
|
||||||
char DeviceName[];
|
}
|
||||||
|
|
||||||
if (NetNameOffset > 0x14) {
|
char NetName[];
|
||||||
char16 NetNameUnicode[];
|
char DeviceName[];
|
||||||
char16 DeviceNameUnicode[];
|
|
||||||
}
|
if (NetNameOffset > 0x14) {
|
||||||
};
|
char16 NetNameUnicode[];
|
||||||
|
char16 DeviceNameUnicode[];
|
||||||
struct LinkInfo {
|
}
|
||||||
type::Size32 LinkInfoSize;
|
};
|
||||||
type::Size32 LinkInfoHeaderSize;
|
|
||||||
LinkInfoFlags LinkInfoFlags;
|
struct LinkInfo {
|
||||||
u32 VolumeIDOffset;
|
type::Size32 LinkInfoSize;
|
||||||
u32 LocalBasePathOffset;
|
type::Size32 LinkInfoHeaderSize;
|
||||||
u32 CommonNetworkRelativeLinkOffset;
|
LinkInfoFlags LinkInfoFlags;
|
||||||
u32 CommonPathSuffixOffset;
|
u32 VolumeIDOffset;
|
||||||
|
u32 LocalBasePathOffset;
|
||||||
if (LinkInfoHeaderSize >= 0x24) {
|
u32 CommonNetworkRelativeLinkOffset;
|
||||||
u32 LocalBasePathOffsetUnicode;
|
u32 CommonPathSuffixOffset;
|
||||||
u32 CommonPathSuffixOffsetUnicode;
|
|
||||||
}
|
if (LinkInfoHeaderSize >= 0x24) {
|
||||||
|
u32 LocalBasePathOffsetUnicode;
|
||||||
if (LinkInfoFlags.VolumeIDAndLocalBasePath) {
|
u32 CommonPathSuffixOffsetUnicode;
|
||||||
VolumeID VolumeID;
|
}
|
||||||
char LocalBasePath[];
|
|
||||||
}
|
if (LinkInfoFlags.VolumeIDAndLocalBasePath) {
|
||||||
|
VolumeID VolumeID;
|
||||||
if (LinkInfoFlags.CommonNetworkRelativeLinkAndPathSuffix)
|
char LocalBasePath[];
|
||||||
CommonNetworkRelativeLink CommonNetworkRelativeLink;
|
}
|
||||||
|
|
||||||
char CommonPathSuffix[];
|
if (LinkInfoFlags.CommonNetworkRelativeLinkAndPathSuffix)
|
||||||
|
CommonNetworkRelativeLink CommonNetworkRelativeLink;
|
||||||
if (LinkInfoHeaderSize >= 0x24) {
|
|
||||||
if (LinkInfoFlags.VolumeIDAndLocalBasePath)
|
char CommonPathSuffix[];
|
||||||
char16 LocalBasePathUnicode[];
|
|
||||||
char16 CommonPathSuffixUnicode[];
|
if (LinkInfoHeaderSize >= 0x24) {
|
||||||
}
|
if (LinkInfoFlags.VolumeIDAndLocalBasePath)
|
||||||
};
|
char16 LocalBasePathUnicode[];
|
||||||
|
char16 CommonPathSuffixUnicode[];
|
||||||
struct String {
|
}
|
||||||
u16 CountCharacters;
|
};
|
||||||
char16 String[CountCharacters];
|
|
||||||
};
|
struct String {
|
||||||
|
u16 CountCharacters;
|
||||||
struct StringData {
|
char16 String[CountCharacters];
|
||||||
if (parent.ShellLinkHeader.LinkFlags.HasName)
|
};
|
||||||
String NAME_STRING;
|
|
||||||
if (parent.ShellLinkHeader.LinkFlags.HasRelativePath)
|
struct StringData {
|
||||||
String RELATIVE_PATH;
|
if (parent.ShellLinkHeader.LinkFlags.HasName)
|
||||||
if (parent.ShellLinkHeader.LinkFlags.HasWorkingDir)
|
String NAME_STRING;
|
||||||
String WORKING_DIR;
|
if (parent.ShellLinkHeader.LinkFlags.HasRelativePath)
|
||||||
if (parent.ShellLinkHeader.LinkFlags.HasArguments)
|
String RELATIVE_PATH;
|
||||||
String COMMAND_LINE_ARGUMENTS;
|
if (parent.ShellLinkHeader.LinkFlags.HasWorkingDir)
|
||||||
if (parent.ShellLinkHeader.LinkFlags.HasIconLocation)
|
String WORKING_DIR;
|
||||||
String ICON_LOCATION;
|
if (parent.ShellLinkHeader.LinkFlags.HasArguments)
|
||||||
};
|
String COMMAND_LINE_ARGUMENTS;
|
||||||
|
if (parent.ShellLinkHeader.LinkFlags.HasIconLocation)
|
||||||
bitfield FillAttributes {
|
String ICON_LOCATION;
|
||||||
FOREGROUND_BLUE : 1;
|
};
|
||||||
FOREGROUND_GREEN : 1;
|
|
||||||
FOREGROUND_RED : 1;
|
bitfield FillAttributes {
|
||||||
FOREGROUND_INTENSITY : 1;
|
FOREGROUND_BLUE : 1;
|
||||||
|
FOREGROUND_GREEN : 1;
|
||||||
BACKGROUND_BLUE : 1;
|
FOREGROUND_RED : 1;
|
||||||
BACKGROUND_GREEN : 1;
|
FOREGROUND_INTENSITY : 1;
|
||||||
BACKGROUND_RED : 1;
|
|
||||||
BACKGROUND_INTENSITY : 1;
|
BACKGROUND_BLUE : 1;
|
||||||
|
BACKGROUND_GREEN : 1;
|
||||||
padding : 8;
|
BACKGROUND_RED : 1;
|
||||||
} [[right_to_left]];
|
BACKGROUND_INTENSITY : 1;
|
||||||
|
|
||||||
struct ConsoleDataBlock {
|
padding : 8;
|
||||||
FillAttributes FillAttributes;
|
};
|
||||||
FillAttributes PopupFillAttributes;
|
|
||||||
u16 ScreenBufferSizeX, ScreenBufferSizeY;
|
struct ConsoleDataBlock {
|
||||||
u16 WindowSizeX, WindowSizeY;
|
FillAttributes FillAttributes;
|
||||||
u16 WindowOriginX, WindowOriginY;
|
FillAttributes PopupFillAttributes;
|
||||||
padding[4];
|
u16 ScreenBufferSizeX, ScreenBufferSizeY;
|
||||||
padding[4];
|
u16 WindowSizeX, WindowSizeY;
|
||||||
u32 FontSize;
|
u16 WindowOriginX, WindowOriginY;
|
||||||
u32 FontFamily;
|
padding[4];
|
||||||
u32 FontWeight;
|
padding[4];
|
||||||
char16 FaceName[32];
|
u32 FontSize;
|
||||||
u32 CursorSize;
|
u32 FontFamily;
|
||||||
u32 FullScreen;
|
u32 FontWeight;
|
||||||
u32 QuickEdit;
|
char16 FaceName[32];
|
||||||
u32 InsertMode;
|
u32 CursorSize;
|
||||||
u32 AutoPosition;
|
u32 FullScreen;
|
||||||
u32 HistoryBufferSize;
|
u32 QuickEdit;
|
||||||
u32 NumberOfHistoryBuffers;
|
u32 InsertMode;
|
||||||
u32 HistoryNoDup;
|
u32 AutoPosition;
|
||||||
u32 ColorTable[16];
|
u32 HistoryBufferSize;
|
||||||
};
|
u32 NumberOfHistoryBuffers;
|
||||||
|
u32 HistoryNoDup;
|
||||||
struct ConsoleFEDataBlock {
|
u32 ColorTable[16];
|
||||||
u32 CodePage;
|
};
|
||||||
};
|
|
||||||
|
struct ConsoleFEDataBlock {
|
||||||
struct DarwinDataBlock {
|
u32 CodePage;
|
||||||
char DarwinDataAnsi[260];
|
};
|
||||||
char16 DarwinDataUnicode[260];
|
|
||||||
};
|
struct DarwinDataBlock {
|
||||||
|
char DarwinDataAnsi[260];
|
||||||
struct EnvironmentVariableDataBlock {
|
char16 DarwinDataUnicode[260];
|
||||||
char TargetAnsi[260];
|
};
|
||||||
char16 TargetUnicode[260];
|
|
||||||
};
|
struct EnvironmentVariableDataBlock {
|
||||||
|
char TargetAnsi[260];
|
||||||
struct IconEnvironmentDataBlock {
|
char16 TargetUnicode[260];
|
||||||
char TargetAnsi[260];
|
};
|
||||||
char16 TargetUnicode[260];
|
|
||||||
};
|
struct IconEnvironmentDataBlock {
|
||||||
|
char TargetAnsi[260];
|
||||||
struct KnownFolderDataBlock {
|
char16 TargetUnicode[260];
|
||||||
type::GUID KnownFolderID;
|
};
|
||||||
u32 Offset;
|
|
||||||
};
|
struct KnownFolderDataBlock {
|
||||||
|
type::GUID KnownFolderID;
|
||||||
struct PropertyStoreDataBlock {
|
u32 Offset;
|
||||||
u8 Bytes[parent.BlockSize - sizeof(parent.BlockSize) - sizeof(parent.BlockSignature)];
|
};
|
||||||
std::warning("PropertyStoreDataBlock is not yet implemented!");
|
|
||||||
};
|
struct PropertyStoreDataBlock {
|
||||||
|
u8 Bytes[parent.BlockSize - sizeof(parent.BlockSize) - sizeof(parent.BlockSignature)];
|
||||||
struct ShimDataBlock {
|
std::warning("PropertyStoreDataBlock is not yet implemented!");
|
||||||
char16 LayerName[(parent.BlockSize - sizeof(parent.BlockSize) - sizeof(parent.BlockSignature)) / sizeof(char16)];
|
};
|
||||||
};
|
|
||||||
|
struct ShimDataBlock {
|
||||||
struct SpecialFolderDataBlock {
|
char16 LayerName[(parent.BlockSize - sizeof(parent.BlockSize) - sizeof(parent.BlockSignature)) / sizeof(char16)];
|
||||||
u32 SpecialFolderID;
|
};
|
||||||
u32 Offset;
|
|
||||||
};
|
struct SpecialFolderDataBlock {
|
||||||
|
u32 SpecialFolderID;
|
||||||
struct TrackerDataBlock {
|
u32 Offset;
|
||||||
type::Size32 Length;
|
};
|
||||||
u32 Version;
|
|
||||||
char MachineID[16];
|
struct TrackerDataBlock {
|
||||||
type::GUID Droid[2];
|
type::Size32 Length;
|
||||||
type::GUID DroidBirth[2];
|
u32 Version;
|
||||||
};
|
char MachineID[16];
|
||||||
|
type::GUID Droid[2];
|
||||||
struct VistaAndAboveIDListDataBlock {
|
type::GUID DroidBirth[2];
|
||||||
IDList IDList;
|
};
|
||||||
};
|
|
||||||
|
struct VistaAndAboveIDListDataBlock {
|
||||||
struct ExtraDataBlock {
|
IDList IDList;
|
||||||
type::Size32 BlockSize;
|
};
|
||||||
|
|
||||||
if (BlockSize < 0x04)
|
struct ExtraDataBlock {
|
||||||
break;
|
type::Size32 BlockSize;
|
||||||
else {
|
|
||||||
u32 BlockSignature;
|
if (BlockSize < 0x04)
|
||||||
|
break;
|
||||||
if (BlockSignature == 0xA000'0002)
|
else {
|
||||||
ConsoleDataBlock CONSOLE_PROPS;
|
u32 BlockSignature;
|
||||||
else if (BlockSignature == 0xA000'0004)
|
|
||||||
ConsoleFEDataBlock CONSOLE_FE_PROPS;
|
if (BlockSignature == 0xA000'0002)
|
||||||
else if (BlockSignature == 0xA000'0006)
|
ConsoleDataBlock CONSOLE_PROPS;
|
||||||
DarwinDataBlock DARWIN_PROPS;
|
else if (BlockSignature == 0xA000'0004)
|
||||||
else if (BlockSignature == 0xA000'0001)
|
ConsoleFEDataBlock CONSOLE_FE_PROPS;
|
||||||
EnvironmentVariableDataBlock ENVIRONMENT_PROPS;
|
else if (BlockSignature == 0xA000'0006)
|
||||||
else if (BlockSignature == 0xA000'0007)
|
DarwinDataBlock DARWIN_PROPS;
|
||||||
IconEnvironmentDataBlock ICON_ENVIRONMENT_PROPS;
|
else if (BlockSignature == 0xA000'0001)
|
||||||
else if (BlockSignature == 0xA000'000B)
|
EnvironmentVariableDataBlock ENVIRONMENT_PROPS;
|
||||||
KnownFolderDataBlock KNOWN_FOLDER_PROPS;
|
else if (BlockSignature == 0xA000'0007)
|
||||||
else if (BlockSignature == 0xA000'0009)
|
IconEnvironmentDataBlock ICON_ENVIRONMENT_PROPS;
|
||||||
PropertyStoreDataBlock PROPERTY_STORE_PROPS;
|
else if (BlockSignature == 0xA000'000B)
|
||||||
else if (BlockSignature == 0xA000'0008)
|
KnownFolderDataBlock KNOWN_FOLDER_PROPS;
|
||||||
ShimDataBlock SHIM_PROPS;
|
else if (BlockSignature == 0xA000'0009)
|
||||||
else if (BlockSignature == 0xA000'0005)
|
PropertyStoreDataBlock PROPERTY_STORE_PROPS;
|
||||||
SpecialFolderDataBlock SPECIAL_FOLDER_PROPS;
|
else if (BlockSignature == 0xA000'0008)
|
||||||
else if (BlockSignature == 0xA000'0003)
|
ShimDataBlock SHIM_PROPS;
|
||||||
TrackerDataBlock TRACKER_PROPS;
|
else if (BlockSignature == 0xA000'0005)
|
||||||
else if (BlockSignature == 0xA000'000C)
|
SpecialFolderDataBlock SPECIAL_FOLDER_PROPS;
|
||||||
VistaAndAboveIDListDataBlock VISTA_AND_ABOVE_IDLIST_PROPS;
|
else if (BlockSignature == 0xA000'0003)
|
||||||
}
|
TrackerDataBlock TRACKER_PROPS;
|
||||||
};
|
else if (BlockSignature == 0xA000'000C)
|
||||||
|
VistaAndAboveIDListDataBlock VISTA_AND_ABOVE_IDLIST_PROPS;
|
||||||
struct ExtraData {
|
}
|
||||||
ExtraDataBlock ExtraDataBlock[while(true)];
|
};
|
||||||
};
|
|
||||||
|
struct ExtraData {
|
||||||
struct LNK {
|
ExtraDataBlock ExtraDataBlock[while(true)];
|
||||||
ShellLinkHeader ShellLinkHeader;
|
};
|
||||||
if (ShellLinkHeader.LinkFlags.HasLinkTargetIDList)
|
|
||||||
LinkTargetIDList LinkTargetIDList;
|
struct LNK {
|
||||||
if (ShellLinkHeader.LinkFlags.HasLinkInfo)
|
ShellLinkHeader ShellLinkHeader;
|
||||||
LinkInfo LinkInfo;
|
if (ShellLinkHeader.LinkFlags.HasLinkTargetIDList)
|
||||||
StringData StringData;
|
LinkTargetIDList LinkTargetIDList;
|
||||||
ExtraData ExtraData;
|
if (ShellLinkHeader.LinkFlags.HasLinkInfo)
|
||||||
};
|
LinkInfo LinkInfo;
|
||||||
|
StringData StringData;
|
||||||
LNK lnk @ 0x00;
|
ExtraData ExtraData;
|
||||||
|
};
|
||||||
|
|
||||||
|
LNK lnk @ 0x00;
|
||||||
|
|||||||
@@ -1,383 +1,383 @@
|
|||||||
#pragma MIME application/x-mach-binary
|
#pragma MIME application/x-mach-binary
|
||||||
|
|
||||||
#include <type/size.pat>
|
#include <type/size.pat>
|
||||||
|
|
||||||
enum Magic : u32 {
|
enum Magic : u32 {
|
||||||
_32BitMagic = 0xFEEDFACE,
|
_32BitMagic = 0xFEEDFACE,
|
||||||
_64BitMagic = 0xFEEDFACF
|
_64BitMagic = 0xFEEDFACF
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CpuType : u32 {
|
enum CpuType : u32 {
|
||||||
VAX = 1,
|
VAX = 1,
|
||||||
ROMP = 2,
|
ROMP = 2,
|
||||||
BS32032 = 4,
|
BS32032 = 4,
|
||||||
BS32332 = 5,
|
BS32332 = 5,
|
||||||
MC680x0 = 6,
|
MC680x0 = 6,
|
||||||
I386 = 7,
|
I386 = 7,
|
||||||
X86_64 = CpuType::I386 | 0x100'0000,
|
X86_64 = CpuType::I386 | 0x100'0000,
|
||||||
MIPS = 8,
|
MIPS = 8,
|
||||||
NS32532 = 9,
|
NS32532 = 9,
|
||||||
HPPA = 11,
|
HPPA = 11,
|
||||||
ARM = 12,
|
ARM = 12,
|
||||||
MC88000 = 13,
|
MC88000 = 13,
|
||||||
SPARC = 14,
|
SPARC = 14,
|
||||||
I860 = be u32(15),
|
I860 = be u32(15),
|
||||||
I860_LITTLE = 16,
|
I860_LITTLE = 16,
|
||||||
RS6000 = 17,
|
RS6000 = 17,
|
||||||
MC980000 = 18,
|
MC980000 = 18,
|
||||||
POWERPC = 18,
|
POWERPC = 18,
|
||||||
POWERPC64 = CpuType::POWERPC | 0x100'0000,
|
POWERPC64 = CpuType::POWERPC | 0x100'0000,
|
||||||
VEO = 255
|
VEO = 255
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuTypeVAX : u24 {
|
enum SubCpuTypeVAX : u24 {
|
||||||
ALL = 0,
|
ALL = 0,
|
||||||
VAX780 = 1,
|
VAX780 = 1,
|
||||||
VAX785 = 2,
|
VAX785 = 2,
|
||||||
VAX750 = 3,
|
VAX750 = 3,
|
||||||
VAX730 = 4,
|
VAX730 = 4,
|
||||||
UVAXI = 5,
|
UVAXI = 5,
|
||||||
UVAXII = 6,
|
UVAXII = 6,
|
||||||
VAX8200 = 7,
|
VAX8200 = 7,
|
||||||
VAX8500 = 8,
|
VAX8500 = 8,
|
||||||
VAX8600 = 9,
|
VAX8600 = 9,
|
||||||
VAX8650 = 10,
|
VAX8650 = 10,
|
||||||
VAX8800 = 11,
|
VAX8800 = 11,
|
||||||
UVAXIII = 12
|
UVAXIII = 12
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuTypeROMP : u24 {
|
enum SubCpuTypeROMP : u24 {
|
||||||
ALL = 0,
|
ALL = 0,
|
||||||
PC = 1,
|
PC = 1,
|
||||||
APC = 2,
|
APC = 2,
|
||||||
_135 = 3
|
_135 = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuType32XXX : u24 {
|
enum SubCpuType32XXX : u24 {
|
||||||
ALL = 0,
|
ALL = 0,
|
||||||
MMAX_DPC = 1,
|
MMAX_DPC = 1,
|
||||||
SQT = 2,
|
SQT = 2,
|
||||||
MMAX_APC_FPU = 3,
|
MMAX_APC_FPU = 3,
|
||||||
MMAX_APC_FPA = 4,
|
MMAX_APC_FPA = 4,
|
||||||
MMAX_XPC = 5
|
MMAX_XPC = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuTypeI386 : u24 {
|
enum SubCpuTypeI386 : u24 {
|
||||||
_386 = 3,
|
_386 = 3,
|
||||||
_486 = 4,
|
_486 = 4,
|
||||||
_486SX = SubCpuTypeI386::_486 + 128,
|
_486SX = SubCpuTypeI386::_486 + 128,
|
||||||
_586 = 5,
|
_586 = 5,
|
||||||
IntelPentium = 5 + (0 << 4),
|
IntelPentium = 5 + (0 << 4),
|
||||||
IntelPentiumPro = 6 + (1 << 4),
|
IntelPentiumPro = 6 + (1 << 4),
|
||||||
IntelPentiumIIM3 = 6 + (3 << 4),
|
IntelPentiumIIM3 = 6 + (3 << 4),
|
||||||
IntelPentiumIIM5 = 6 + (5 << 4),
|
IntelPentiumIIM5 = 6 + (5 << 4),
|
||||||
IntelPentium4 = 10 + (0 << 4),
|
IntelPentium4 = 10 + (0 << 4),
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuTypeMips : u24 {
|
enum SubCpuTypeMips : u24 {
|
||||||
ALL = 0,
|
ALL = 0,
|
||||||
R2300 = 1,
|
R2300 = 1,
|
||||||
R2600 = 2,
|
R2600 = 2,
|
||||||
R2800 = 3,
|
R2800 = 3,
|
||||||
R2000a = 4
|
R2000a = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuType680x0 : u24 {
|
enum SubCpuType680x0 : u24 {
|
||||||
ALL = 1,
|
ALL = 1,
|
||||||
MC68030 = 1,
|
MC68030 = 1,
|
||||||
MC68040 = 2,
|
MC68040 = 2,
|
||||||
MC68030_Only = 3
|
MC68030_Only = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuTypeHPPA : u24 {
|
enum SubCpuTypeHPPA : u24 {
|
||||||
ALL = 0,
|
ALL = 0,
|
||||||
_7100 = 0,
|
_7100 = 0,
|
||||||
_7100LC = 1
|
_7100LC = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuTypeARM : u24 {
|
enum SubCpuTypeARM : u24 {
|
||||||
ALL = 0,
|
ALL = 0,
|
||||||
A500_ARCH = 1,
|
A500_ARCH = 1,
|
||||||
A500 = 2,
|
A500 = 2,
|
||||||
A440 = 3,
|
A440 = 3,
|
||||||
M4 = 4,
|
M4 = 4,
|
||||||
V4T = 5,
|
V4T = 5,
|
||||||
V6 = 6,
|
V6 = 6,
|
||||||
V5TEJ = 7,
|
V5TEJ = 7,
|
||||||
XSCALE = 8,
|
XSCALE = 8,
|
||||||
V7 = 9,
|
V7 = 9,
|
||||||
V7F = 10, /* Cortex A9 */
|
V7F = 10, /* Cortex A9 */
|
||||||
V7S = 11, /* Swift */
|
V7S = 11, /* Swift */
|
||||||
V7K = 12 /* Kirkwood40 */
|
V7K = 12 /* Kirkwood40 */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuTypeMC88000 : u24 {
|
enum SubCpuTypeMC88000 : u24 {
|
||||||
ALL = 0,
|
ALL = 0,
|
||||||
MMAX_JPC = 1,
|
MMAX_JPC = 1,
|
||||||
MC88100 = 1,
|
MC88100 = 1,
|
||||||
MC88110 = 2
|
MC88110 = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuTypeMC98000 : u24 {
|
enum SubCpuTypeMC98000 : u24 {
|
||||||
ALL = 0,
|
ALL = 0,
|
||||||
MC98601 = 1
|
MC98601 = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuTypeI860 : u24 {
|
enum SubCpuTypeI860 : u24 {
|
||||||
ALL = 0,
|
ALL = 0,
|
||||||
_860 = 1
|
_860 = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuTypeI860Little : u24 {
|
enum SubCpuTypeI860Little : u24 {
|
||||||
ALL = 0 ... 1
|
ALL = 0 ... 1
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuTypeRS6000 : u24 {
|
enum SubCpuTypeRS6000 : u24 {
|
||||||
ALL = 0 ... 1
|
ALL = 0 ... 1
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuTypeSparc : u24 {
|
enum SubCpuTypeSparc : u24 {
|
||||||
ALL = 0,
|
ALL = 0,
|
||||||
_260 = 1,
|
_260 = 1,
|
||||||
_110 = 2
|
_110 = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuTypePowerPC : u24 {
|
enum SubCpuTypePowerPC : u24 {
|
||||||
ALL = 0,
|
ALL = 0,
|
||||||
_601 = 1,
|
_601 = 1,
|
||||||
_602 = 2,
|
_602 = 2,
|
||||||
_603 = 3,
|
_603 = 3,
|
||||||
_603e = 4,
|
_603e = 4,
|
||||||
_603ev = 5,
|
_603ev = 5,
|
||||||
_604 = 6,
|
_604 = 6,
|
||||||
_604e = 7,
|
_604e = 7,
|
||||||
_620 = 8,
|
_620 = 8,
|
||||||
_750 = 9,
|
_750 = 9,
|
||||||
_7400 = 10,
|
_7400 = 10,
|
||||||
_7450 = 11,
|
_7450 = 11,
|
||||||
_970 = 100
|
_970 = 100
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SubCpuTypeVEO : u24 {
|
enum SubCpuTypeVEO : u24 {
|
||||||
_1 = 1,
|
_1 = 1,
|
||||||
_2 = 2,
|
_2 = 2,
|
||||||
_3 = 3,
|
_3 = 3,
|
||||||
_4 = 4,
|
_4 = 4,
|
||||||
ALL = SubCpuTypeVEO::_2
|
ALL = SubCpuTypeVEO::_2
|
||||||
};
|
};
|
||||||
|
|
||||||
bitfield Capabilities {
|
bitfield Capabilities {
|
||||||
padding : 7;
|
padding : 7;
|
||||||
lib64 : 1;
|
lib64 : 1;
|
||||||
} [[right_to_left]];
|
};
|
||||||
|
|
||||||
enum FileType : u32 {
|
enum FileType : u32 {
|
||||||
Object = 1,
|
Object = 1,
|
||||||
Execute = 2,
|
Execute = 2,
|
||||||
FVMLib = 3,
|
FVMLib = 3,
|
||||||
Core = 4,
|
Core = 4,
|
||||||
Preload = 5,
|
Preload = 5,
|
||||||
DyLib = 6,
|
DyLib = 6,
|
||||||
DyLinker = 7,
|
DyLinker = 7,
|
||||||
Bundle = 8,
|
Bundle = 8,
|
||||||
DyLibStub = 9,
|
DyLibStub = 9,
|
||||||
DSym = 10,
|
DSym = 10,
|
||||||
KExtBundle = 11,
|
KExtBundle = 11,
|
||||||
};
|
};
|
||||||
|
|
||||||
bitfield Flags {
|
bitfield Flags {
|
||||||
noUndefs : 1;
|
noUndefs : 1;
|
||||||
incrLink : 1;
|
incrLink : 1;
|
||||||
dyldLink : 1;
|
dyldLink : 1;
|
||||||
binDatLoad : 1;
|
binDatLoad : 1;
|
||||||
prebound : 1;
|
prebound : 1;
|
||||||
splitSegs : 1;
|
splitSegs : 1;
|
||||||
lazyInit : 1;
|
lazyInit : 1;
|
||||||
twoLevel : 1;
|
twoLevel : 1;
|
||||||
forceFlat : 1;
|
forceFlat : 1;
|
||||||
noMultiDefs : 1;
|
noMultiDefs : 1;
|
||||||
noFixPrebinding : 1;
|
noFixPrebinding : 1;
|
||||||
prebindable : 1;
|
prebindable : 1;
|
||||||
allModsBound : 1;
|
allModsBound : 1;
|
||||||
subSectionsViaSymbols : 1;
|
subSectionsViaSymbols : 1;
|
||||||
canonical : 1;
|
canonical : 1;
|
||||||
weakDefines : 1;
|
weakDefines : 1;
|
||||||
bindsToWeak : 1;
|
bindsToWeak : 1;
|
||||||
allowStackExecution : 1;
|
allowStackExecution : 1;
|
||||||
rootSafe : 1;
|
rootSafe : 1;
|
||||||
setuidSafe : 1;
|
setuidSafe : 1;
|
||||||
noReexportedDylibs : 1;
|
noReexportedDylibs : 1;
|
||||||
pie : 1;
|
pie : 1;
|
||||||
deadStrippableDylib : 1;
|
deadStrippableDylib : 1;
|
||||||
hasTlvDescriptors : 1;
|
hasTlvDescriptors : 1;
|
||||||
noHeapExecution : 1;
|
noHeapExecution : 1;
|
||||||
appExtensionSafe : 1;
|
appExtensionSafe : 1;
|
||||||
nlistOutOfSyncWithDyldinof : 1;
|
nlistOutOfSyncWithDyldinof : 1;
|
||||||
simSupport : 1;
|
simSupport : 1;
|
||||||
} [[right_to_left]];
|
};
|
||||||
|
|
||||||
struct Header {
|
struct Header {
|
||||||
Magic magic;
|
Magic magic;
|
||||||
CpuType cpuType;
|
CpuType cpuType;
|
||||||
if (cpuType == CpuType::VAX) SubCpuTypeVAX subCpuType;
|
if (cpuType == CpuType::VAX) SubCpuTypeVAX subCpuType;
|
||||||
else if (cpuType == CpuType::ROMP) SubCpuTypeROMP subCpuType;
|
else if (cpuType == CpuType::ROMP) SubCpuTypeROMP subCpuType;
|
||||||
else if (cpuType == CpuType::BS32032 || cpuType == CpuType::BS32332 || cpuType == CpuType::NS32532) SubCpuType32XXX subCpuType;
|
else if (cpuType == CpuType::BS32032 || cpuType == CpuType::BS32332 || cpuType == CpuType::NS32532) SubCpuType32XXX subCpuType;
|
||||||
else if (cpuType == CpuType::I386 || cpuType == CpuType::X86_64) SubCpuTypeI386 subCpuType;
|
else if (cpuType == CpuType::I386 || cpuType == CpuType::X86_64) SubCpuTypeI386 subCpuType;
|
||||||
else if (cpuType == CpuType::MIPS) SubCpuTypeMips subCpuType;
|
else if (cpuType == CpuType::MIPS) SubCpuTypeMips subCpuType;
|
||||||
else if (cpuType == CpuType::HPPA) SubCpuTypeHPPA subCpuType;
|
else if (cpuType == CpuType::HPPA) SubCpuTypeHPPA subCpuType;
|
||||||
else if (cpuType == CpuType::ARM) SubCpuTypeARM subCpuType;
|
else if (cpuType == CpuType::ARM) SubCpuTypeARM subCpuType;
|
||||||
else if (cpuType == CpuType::MC88000) SubCpuTypeMC88000 subCpuType;
|
else if (cpuType == CpuType::MC88000) SubCpuTypeMC88000 subCpuType;
|
||||||
else if (cpuType == CpuType::MC98000) SubCpuTypeMC98000 subCpuType;
|
else if (cpuType == CpuType::MC98000) SubCpuTypeMC98000 subCpuType;
|
||||||
else if (cpuType == CpuType::I860 || cpuType == CpuType::I860_LITTLE) SubCpuTypeI860 subCpuType;
|
else if (cpuType == CpuType::I860 || cpuType == CpuType::I860_LITTLE) SubCpuTypeI860 subCpuType;
|
||||||
else if (cpuType == CpuType::SPARC) SubCpuTypeSparc subCpuType;
|
else if (cpuType == CpuType::SPARC) SubCpuTypeSparc subCpuType;
|
||||||
else if (cpuType == CpuType::POWERPC || cpuType == CpuType::POWERPC64) SubCpuTypePowerPC subCpuType;
|
else if (cpuType == CpuType::POWERPC || cpuType == CpuType::POWERPC64) SubCpuTypePowerPC subCpuType;
|
||||||
else if (cpuType == CpuType::VEO) SubCpuTypeVEO subCpuType;
|
else if (cpuType == CpuType::VEO) SubCpuTypeVEO subCpuType;
|
||||||
else u24 subCpuType;
|
else u24 subCpuType;
|
||||||
Capabilities capabilities;
|
Capabilities capabilities;
|
||||||
FileType fileType;
|
FileType fileType;
|
||||||
u32 numCommands;
|
u32 numCommands;
|
||||||
type::Size<u32> sizeOfCommands;
|
type::Size<u32> sizeOfCommands;
|
||||||
Flags flags;
|
Flags flags;
|
||||||
|
|
||||||
if (magic == Magic::_64BitMagic) padding[sizeof(u32)];
|
if (magic == Magic::_64BitMagic) padding[sizeof(u32)];
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Command : u32 {
|
enum Command : u32 {
|
||||||
ReqDyLd = 0x8000'0000,
|
ReqDyLd = 0x8000'0000,
|
||||||
|
|
||||||
Segment = 0x01,
|
Segment = 0x01,
|
||||||
SymTab = 0x02,
|
SymTab = 0x02,
|
||||||
SymSeg = 0x03,
|
SymSeg = 0x03,
|
||||||
Thread = 0x04,
|
Thread = 0x04,
|
||||||
UnixThread = 0x05,
|
UnixThread = 0x05,
|
||||||
LoadFVMLib = 0x06,
|
LoadFVMLib = 0x06,
|
||||||
IdFVMLib = 0x07,
|
IdFVMLib = 0x07,
|
||||||
Ident = 0x08,
|
Ident = 0x08,
|
||||||
FVMFile = 0x09,
|
FVMFile = 0x09,
|
||||||
PrePage = 0x0A,
|
PrePage = 0x0A,
|
||||||
DySymTab = 0x0B,
|
DySymTab = 0x0B,
|
||||||
LoadDyLib = 0x0C,
|
LoadDyLib = 0x0C,
|
||||||
IdDyLib = 0x0D,
|
IdDyLib = 0x0D,
|
||||||
LoadDyLinker = 0x0E,
|
LoadDyLinker = 0x0E,
|
||||||
IdDyLinker = 0x0F,
|
IdDyLinker = 0x0F,
|
||||||
PreboundDyLib = 0x10,
|
PreboundDyLib = 0x10,
|
||||||
Routines = 0x11,
|
Routines = 0x11,
|
||||||
SubFramework = 0x12,
|
SubFramework = 0x12,
|
||||||
SubUmbrella = 0x13,
|
SubUmbrella = 0x13,
|
||||||
SubClient = 0x14,
|
SubClient = 0x14,
|
||||||
SubLibrary = 0x15,
|
SubLibrary = 0x15,
|
||||||
TwoLevelHints = 0x16,
|
TwoLevelHints = 0x16,
|
||||||
PrebindCksum = 0x17,
|
PrebindCksum = 0x17,
|
||||||
LoadWeakDyLib = 0x18 | Command::ReqDyLd,
|
LoadWeakDyLib = 0x18 | Command::ReqDyLd,
|
||||||
Segment64 = 0x19,
|
Segment64 = 0x19,
|
||||||
Routines64 = 0x1A,
|
Routines64 = 0x1A,
|
||||||
UUID = 0x1B,
|
UUID = 0x1B,
|
||||||
RPath = 0x1C | 0x8000'0000,
|
RPath = 0x1C | 0x8000'0000,
|
||||||
CodeSignature = 0x1D,
|
CodeSignature = 0x1D,
|
||||||
SegmentSplitInfo = 0x1E,
|
SegmentSplitInfo = 0x1E,
|
||||||
ReExportDyLib = 0x1F | Command::ReqDyLd,
|
ReExportDyLib = 0x1F | Command::ReqDyLd,
|
||||||
LazyLoadDyLib = 0x20,
|
LazyLoadDyLib = 0x20,
|
||||||
EncryptionInfo = 0x21,
|
EncryptionInfo = 0x21,
|
||||||
DyLdInfo = 0x22,
|
DyLdInfo = 0x22,
|
||||||
DyLdInfoOnly = 0x22 | Command::ReqDyLd,
|
DyLdInfoOnly = 0x22 | Command::ReqDyLd,
|
||||||
LoadUpwardDyLib = 0x23 | Command::ReqDyLd,
|
LoadUpwardDyLib = 0x23 | Command::ReqDyLd,
|
||||||
VersionMinMacOSX = 0x24,
|
VersionMinMacOSX = 0x24,
|
||||||
VersionMinIPhoneOS = 0x25,
|
VersionMinIPhoneOS = 0x25,
|
||||||
FunctionStarts = 0x26,
|
FunctionStarts = 0x26,
|
||||||
DyLdEnvironment = 0x27,
|
DyLdEnvironment = 0x27,
|
||||||
Main = 0x28 | Command::ReqDyLd,
|
Main = 0x28 | Command::ReqDyLd,
|
||||||
DataInCode = 0x29,
|
DataInCode = 0x29,
|
||||||
SourceVersion = 0x2A,
|
SourceVersion = 0x2A,
|
||||||
DyLibCodeSignDRS = 0x2B
|
DyLibCodeSignDRS = 0x2B
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CommandUUID {
|
struct CommandUUID {
|
||||||
u128 uuid;
|
u128 uuid;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Section {
|
struct Section {
|
||||||
char sectionName[16];
|
char sectionName[16];
|
||||||
char segmentName[16];
|
char segmentName[16];
|
||||||
u32 address;
|
u32 address;
|
||||||
type::Size<u32> size;
|
type::Size<u32> size;
|
||||||
u32 offset;
|
u32 offset;
|
||||||
u32 align;
|
u32 align;
|
||||||
u32 reloff;
|
u32 reloff;
|
||||||
u32 numRelocs;
|
u32 numRelocs;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
padding[8];
|
padding[8];
|
||||||
|
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
u8 data[size] @ offset [[sealed]];
|
u8 data[size] @ offset [[sealed]];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CommandSegment {
|
struct CommandSegment {
|
||||||
char segmentName[16];
|
char segmentName[16];
|
||||||
u32 vmAddress;
|
u32 vmAddress;
|
||||||
type::Size<u32> vmSize;
|
type::Size<u32> vmSize;
|
||||||
u32 fileOffset;
|
u32 fileOffset;
|
||||||
type::Size<u32> fileSize;
|
type::Size<u32> fileSize;
|
||||||
u32 maxProtection;
|
u32 maxProtection;
|
||||||
u32 initProtection;
|
u32 initProtection;
|
||||||
u32 numSections;
|
u32 numSections;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
|
|
||||||
Section sections[numSections];
|
Section sections[numSections];
|
||||||
|
|
||||||
if (fileOffset > 0)
|
if (fileOffset > 0)
|
||||||
u8 data[fileSize] @ fileOffset [[sealed]];
|
u8 data[fileSize] @ fileOffset [[sealed]];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Section64 {
|
struct Section64 {
|
||||||
char sectionName[16];
|
char sectionName[16];
|
||||||
char segmentName[16];
|
char segmentName[16];
|
||||||
u64 address;
|
u64 address;
|
||||||
type::Size<u64> size;
|
type::Size<u64> size;
|
||||||
u32 offset;
|
u32 offset;
|
||||||
u32 align;
|
u32 align;
|
||||||
u32 reloff;
|
u32 reloff;
|
||||||
u32 numRelocs;
|
u32 numRelocs;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
padding[12];
|
padding[12];
|
||||||
|
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
u8 data[size] @ offset [[sealed]];
|
u8 data[size] @ offset [[sealed]];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CommandSegment64 {
|
struct CommandSegment64 {
|
||||||
char segmentName[16];
|
char segmentName[16];
|
||||||
u64 vmAddress;
|
u64 vmAddress;
|
||||||
type::Size<u64> vmSize;
|
type::Size<u64> vmSize;
|
||||||
u64 fileOffset;
|
u64 fileOffset;
|
||||||
type::Size<u64> fileSize;
|
type::Size<u64> fileSize;
|
||||||
u32 maxProtection;
|
u32 maxProtection;
|
||||||
u32 initProtection;
|
u32 initProtection;
|
||||||
u32 numSections;
|
u32 numSections;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
|
|
||||||
Section64 sections[numSections];
|
Section64 sections[numSections];
|
||||||
|
|
||||||
if (fileOffset > 0)
|
if (fileOffset > 0)
|
||||||
u8 data[fileSize] @ fileOffset [[sealed]];
|
u8 data[fileSize] @ fileOffset [[sealed]];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LoadCommand {
|
struct LoadCommand {
|
||||||
Command command;
|
Command command;
|
||||||
type::Size<u32> commandSize;
|
type::Size<u32> commandSize;
|
||||||
|
|
||||||
if (command == Command::UUID)
|
if (command == Command::UUID)
|
||||||
CommandUUID data;
|
CommandUUID data;
|
||||||
else if (command == Command::Segment)
|
else if (command == Command::Segment)
|
||||||
CommandSegment data;
|
CommandSegment data;
|
||||||
else if (command == Command::Segment64)
|
else if (command == Command::Segment64)
|
||||||
CommandSegment64 data;
|
CommandSegment64 data;
|
||||||
else
|
else
|
||||||
u8 data[commandSize - 8] [[sealed]];
|
u8 data[commandSize - 8] [[sealed]];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MachO {
|
struct MachO {
|
||||||
Header header;
|
Header header;
|
||||||
LoadCommand loadCommands[header.numCommands];
|
LoadCommand loadCommands[header.numCommands];
|
||||||
};
|
};
|
||||||
|
|
||||||
MachO macho @ 0x00;
|
MachO macho @ 0x00;
|
||||||
@@ -1,423 +1,423 @@
|
|||||||
#pragma MIME application/x-dmp
|
#pragma MIME application/x-dmp
|
||||||
|
|
||||||
#include <type/time.pat>
|
#include <type/time.pat>
|
||||||
#include <type/types/win32.pat>
|
#include <type/types/win32.pat>
|
||||||
#include <type/size.pat>
|
#include <type/size.pat>
|
||||||
|
|
||||||
using RVA = ULONG32;
|
using RVA = ULONG32;
|
||||||
using RVA64 = ULONG64;
|
using RVA64 = ULONG64;
|
||||||
|
|
||||||
enum MINIDUMP_STREAM_TYPE : ULONG32 {
|
enum MINIDUMP_STREAM_TYPE : ULONG32 {
|
||||||
UnusedStream = 0,
|
UnusedStream = 0,
|
||||||
ReservedStream0 = 1,
|
ReservedStream0 = 1,
|
||||||
ReservedStream1 = 2,
|
ReservedStream1 = 2,
|
||||||
ThreadListStream = 3,
|
ThreadListStream = 3,
|
||||||
ModuleListStream = 4,
|
ModuleListStream = 4,
|
||||||
MemoryListStream = 5,
|
MemoryListStream = 5,
|
||||||
ExceptionStream = 6,
|
ExceptionStream = 6,
|
||||||
SystemInfoStream = 7,
|
SystemInfoStream = 7,
|
||||||
ThreadExListStream = 8,
|
ThreadExListStream = 8,
|
||||||
Memory64ListStream = 9,
|
Memory64ListStream = 9,
|
||||||
CommentStreamA = 10,
|
CommentStreamA = 10,
|
||||||
CommentStreamW = 11,
|
CommentStreamW = 11,
|
||||||
HandleDataStream = 12,
|
HandleDataStream = 12,
|
||||||
FunctionTableStream = 13,
|
FunctionTableStream = 13,
|
||||||
UnloadedModuleListStream = 14,
|
UnloadedModuleListStream = 14,
|
||||||
MiscInfoStream = 15,
|
MiscInfoStream = 15,
|
||||||
MemoryInfoListStream = 16,
|
MemoryInfoListStream = 16,
|
||||||
ThreadInfoListStream = 17,
|
ThreadInfoListStream = 17,
|
||||||
HandleOperationListStream = 18,
|
HandleOperationListStream = 18,
|
||||||
TokenStream = 19,
|
TokenStream = 19,
|
||||||
JavaScriptDataStream = 20,
|
JavaScriptDataStream = 20,
|
||||||
SystemMemoryInfoStream = 21,
|
SystemMemoryInfoStream = 21,
|
||||||
ProcessVmCountersStream = 22,
|
ProcessVmCountersStream = 22,
|
||||||
IptTraceStream = 23,
|
IptTraceStream = 23,
|
||||||
ThreadNamesStream = 24,
|
ThreadNamesStream = 24,
|
||||||
ceStreamNull = 0x8000,
|
ceStreamNull = 0x8000,
|
||||||
ceStreamSystemInfo = 0x8001,
|
ceStreamSystemInfo = 0x8001,
|
||||||
ceStreamException = 0x8002,
|
ceStreamException = 0x8002,
|
||||||
ceStreamModuleList = 0x8003,
|
ceStreamModuleList = 0x8003,
|
||||||
ceStreamProcessList = 0x8004,
|
ceStreamProcessList = 0x8004,
|
||||||
ceStreamThreadList = 0x8005,
|
ceStreamThreadList = 0x8005,
|
||||||
ceStreamThreadContextList = 0x8006,
|
ceStreamThreadContextList = 0x8006,
|
||||||
ceStreamThreadCallStackList = 0x8007,
|
ceStreamThreadCallStackList = 0x8007,
|
||||||
ceStreamMemoryVirtualList = 0x8008,
|
ceStreamMemoryVirtualList = 0x8008,
|
||||||
ceStreamMemoryPhysicalList = 0x8009,
|
ceStreamMemoryPhysicalList = 0x8009,
|
||||||
ceStreamBucketParameters = 0x800A,
|
ceStreamBucketParameters = 0x800A,
|
||||||
ceStreamProcessModuleMap = 0x800B,
|
ceStreamProcessModuleMap = 0x800B,
|
||||||
ceStreamDiagnosisList = 0x800C,
|
ceStreamDiagnosisList = 0x800C,
|
||||||
LastReservedStream = 0xFFFF
|
LastReservedStream = 0xFFFF
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_LOCATION_DESCRIPTOR {
|
struct MINIDUMP_LOCATION_DESCRIPTOR {
|
||||||
type::Size32 DataSize;
|
type::Size32 DataSize;
|
||||||
RVA Rva;
|
RVA Rva;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_MEMORY_DESCRIPTOR {
|
struct MINIDUMP_MEMORY_DESCRIPTOR {
|
||||||
ULONG64 StartOfMemoryRange;
|
ULONG64 StartOfMemoryRange;
|
||||||
MINIDUMP_LOCATION_DESCRIPTOR Memory;
|
MINIDUMP_LOCATION_DESCRIPTOR Memory;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_THREAD {
|
struct MINIDUMP_THREAD {
|
||||||
ULONG32 ThreadId;
|
ULONG32 ThreadId;
|
||||||
ULONG32 SuspendCount;
|
ULONG32 SuspendCount;
|
||||||
ULONG32 PriorityClass;
|
ULONG32 PriorityClass;
|
||||||
ULONG32 Priority;
|
ULONG32 Priority;
|
||||||
ULONG64 Teb;
|
ULONG64 Teb;
|
||||||
MINIDUMP_MEMORY_DESCRIPTOR Stack;
|
MINIDUMP_MEMORY_DESCRIPTOR Stack;
|
||||||
MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
|
MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_THREAD_LIST {
|
struct MINIDUMP_THREAD_LIST {
|
||||||
ULONG32 NumberOfThreads;
|
ULONG32 NumberOfThreads;
|
||||||
MINIDUMP_THREAD Threads[NumberOfThreads];
|
MINIDUMP_THREAD Threads[NumberOfThreads];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VS_FIXEDFILEINFO {
|
struct VS_FIXEDFILEINFO {
|
||||||
DWORD dwSignature;
|
DWORD dwSignature;
|
||||||
DWORD dwStrucVersion;
|
DWORD dwStrucVersion;
|
||||||
DWORD dwFileVersionMS;
|
DWORD dwFileVersionMS;
|
||||||
DWORD dwFileVersionLS;
|
DWORD dwFileVersionLS;
|
||||||
DWORD dwProductVersionMS;
|
DWORD dwProductVersionMS;
|
||||||
DWORD dwProductVersionLS;
|
DWORD dwProductVersionLS;
|
||||||
DWORD dwFileFlagsMask;
|
DWORD dwFileFlagsMask;
|
||||||
DWORD dwFileFlags;
|
DWORD dwFileFlags;
|
||||||
DWORD dwFileOS;
|
DWORD dwFileOS;
|
||||||
DWORD dwFileType;
|
DWORD dwFileType;
|
||||||
DWORD dwFileSubtype;
|
DWORD dwFileSubtype;
|
||||||
DWORD dwFileDateMS;
|
DWORD dwFileDateMS;
|
||||||
DWORD dwFileDateLS;
|
DWORD dwFileDateLS;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_MODULE {
|
struct MINIDUMP_MODULE {
|
||||||
ULONG64 BaseOfImage;
|
ULONG64 BaseOfImage;
|
||||||
type::Size32 SizeOfImage;
|
type::Size32 SizeOfImage;
|
||||||
ULONG32 CheckSum;
|
ULONG32 CheckSum;
|
||||||
type::time32_t TimeDateStamp;
|
type::time32_t TimeDateStamp;
|
||||||
RVA ModuleNameRva;
|
RVA ModuleNameRva;
|
||||||
VS_FIXEDFILEINFO VersionInfo;
|
VS_FIXEDFILEINFO VersionInfo;
|
||||||
MINIDUMP_LOCATION_DESCRIPTOR CvRecord;
|
MINIDUMP_LOCATION_DESCRIPTOR CvRecord;
|
||||||
MINIDUMP_LOCATION_DESCRIPTOR MiscRecord;
|
MINIDUMP_LOCATION_DESCRIPTOR MiscRecord;
|
||||||
ULONG64 Reserved0;
|
ULONG64 Reserved0;
|
||||||
ULONG64 Reserved1;
|
ULONG64 Reserved1;
|
||||||
|
|
||||||
char16 ModuleName[] @ ModuleNameRva + 4 [[hidden]];
|
char16 ModuleName[] @ ModuleNameRva + 4 [[hidden]];
|
||||||
} [[format("format_module")]];
|
} [[format("format_module")]];
|
||||||
|
|
||||||
fn format_module(ref MINIDUMP_MODULE module) {
|
fn format_module(ref MINIDUMP_MODULE module) {
|
||||||
return module.ModuleName;
|
return module.ModuleName;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_MODULE_LIST {
|
struct MINIDUMP_MODULE_LIST {
|
||||||
ULONG32 NumberOfModules;
|
ULONG32 NumberOfModules;
|
||||||
MINIDUMP_MODULE Modules[NumberOfModules];
|
MINIDUMP_MODULE Modules[NumberOfModules];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_MEMORY_LIST {
|
struct MINIDUMP_MEMORY_LIST {
|
||||||
ULONG32 NumberOfMemoryRanges;
|
ULONG32 NumberOfMemoryRanges;
|
||||||
MINIDUMP_MEMORY_DESCRIPTOR MemoryRanges[NumberOfMemoryRanges];
|
MINIDUMP_MEMORY_DESCRIPTOR MemoryRanges[NumberOfMemoryRanges];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_EXCEPTION {
|
struct MINIDUMP_EXCEPTION {
|
||||||
ULONG32 ExceptionCode;
|
ULONG32 ExceptionCode;
|
||||||
ULONG32 ExceptionFlags;
|
ULONG32 ExceptionFlags;
|
||||||
ULONG64 ExceptionRecord;
|
ULONG64 ExceptionRecord;
|
||||||
ULONG64 ExceptionAddress;
|
ULONG64 ExceptionAddress;
|
||||||
ULONG32 NumberParameters;
|
ULONG32 NumberParameters;
|
||||||
padding[4];
|
padding[4];
|
||||||
ULONG64 ExceptionInformation[15];
|
ULONG64 ExceptionInformation[15];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_EXCEPTION_STREAM {
|
struct MINIDUMP_EXCEPTION_STREAM {
|
||||||
ULONG32 ThreadId;
|
ULONG32 ThreadId;
|
||||||
padding[4];
|
padding[4];
|
||||||
MINIDUMP_EXCEPTION ExceptionRecord;
|
MINIDUMP_EXCEPTION ExceptionRecord;
|
||||||
MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
|
MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CPU_INFORMATION {
|
struct CPU_INFORMATION {
|
||||||
ULONG32 VendorId[3];
|
ULONG32 VendorId[3];
|
||||||
ULONG32 VersionInformation;
|
ULONG32 VersionInformation;
|
||||||
ULONG32 FeatureInformation;
|
ULONG32 FeatureInformation;
|
||||||
ULONG32 AMDExtendedCpuFeatures;
|
ULONG32 AMDExtendedCpuFeatures;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_SYSTEM_INFO {
|
struct MINIDUMP_SYSTEM_INFO {
|
||||||
USHORT ProcessorArchitecture;
|
USHORT ProcessorArchitecture;
|
||||||
USHORT ProcessorLevel;
|
USHORT ProcessorLevel;
|
||||||
USHORT ProcessorRevision;
|
USHORT ProcessorRevision;
|
||||||
UCHAR NumberOfProcessors;
|
UCHAR NumberOfProcessors;
|
||||||
UCHAR ProductType;
|
UCHAR ProductType;
|
||||||
ULONG32 MajorVersion;
|
ULONG32 MajorVersion;
|
||||||
ULONG32 MinorVersion;
|
ULONG32 MinorVersion;
|
||||||
ULONG32 BuildNumber;
|
ULONG32 BuildNumber;
|
||||||
ULONG32 PlatformId;
|
ULONG32 PlatformId;
|
||||||
RVA CSDVersionRva;
|
RVA CSDVersionRva;
|
||||||
USHORT SuiteMask;
|
USHORT SuiteMask;
|
||||||
USHORT Reserved;
|
USHORT Reserved;
|
||||||
CPU_INFORMATION Cpu;
|
CPU_INFORMATION Cpu;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_THREAD_EX {
|
struct MINIDUMP_THREAD_EX {
|
||||||
ULONG32 ThreadId;
|
ULONG32 ThreadId;
|
||||||
ULONG32 SuspendCount;
|
ULONG32 SuspendCount;
|
||||||
ULONG32 PriorityClass;
|
ULONG32 PriorityClass;
|
||||||
ULONG32 Priority;
|
ULONG32 Priority;
|
||||||
ULONG64 Teb;
|
ULONG64 Teb;
|
||||||
MINIDUMP_MEMORY_DESCRIPTOR Stack;
|
MINIDUMP_MEMORY_DESCRIPTOR Stack;
|
||||||
MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
|
MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
|
||||||
MINIDUMP_MEMORY_DESCRIPTOR BackingStore;
|
MINIDUMP_MEMORY_DESCRIPTOR BackingStore;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_THREAD_EX_LIST {
|
struct MINIDUMP_THREAD_EX_LIST {
|
||||||
ULONG32 NumberOfThreads;
|
ULONG32 NumberOfThreads;
|
||||||
MINIDUMP_THREAD_EX Threads[NumberOfThreads];
|
MINIDUMP_THREAD_EX Threads[NumberOfThreads];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_MEMORY_DESCRIPTOR64 {
|
struct MINIDUMP_MEMORY_DESCRIPTOR64 {
|
||||||
ULONG64 StartOfMemoryRange;
|
ULONG64 StartOfMemoryRange;
|
||||||
type::Size64 DataSize;
|
type::Size64 DataSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_MEMORY64_LIST {
|
struct MINIDUMP_MEMORY64_LIST {
|
||||||
ULONG64 NumberOfMemoryRanges;
|
ULONG64 NumberOfMemoryRanges;
|
||||||
RVA64 BaseRva;
|
RVA64 BaseRva;
|
||||||
MINIDUMP_MEMORY_DESCRIPTOR64 MemoryRanges[NumberOfMemoryRanges];
|
MINIDUMP_MEMORY_DESCRIPTOR64 MemoryRanges[NumberOfMemoryRanges];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_HANDLE_DESCRIPTOR {
|
struct MINIDUMP_HANDLE_DESCRIPTOR {
|
||||||
ULONG64 Handle;
|
ULONG64 Handle;
|
||||||
RVA TypeNameRva;
|
RVA TypeNameRva;
|
||||||
RVA ObjectNameRva;
|
RVA ObjectNameRva;
|
||||||
ULONG32 Attributes;
|
ULONG32 Attributes;
|
||||||
ULONG32 GrantedAccess;
|
ULONG32 GrantedAccess;
|
||||||
ULONG32 HandleCount;
|
ULONG32 HandleCount;
|
||||||
ULONG32 PointerCount;
|
ULONG32 PointerCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_HANDLE_DESCRIPTOR_2 {
|
struct MINIDUMP_HANDLE_DESCRIPTOR_2 {
|
||||||
ULONG64 Handle;
|
ULONG64 Handle;
|
||||||
RVA TypeNameRva;
|
RVA TypeNameRva;
|
||||||
RVA ObjectNameRva;
|
RVA ObjectNameRva;
|
||||||
ULONG32 Attributes;
|
ULONG32 Attributes;
|
||||||
ULONG32 GrantedAccess;
|
ULONG32 GrantedAccess;
|
||||||
ULONG32 HandleCount;
|
ULONG32 HandleCount;
|
||||||
ULONG32 PointerCount;
|
ULONG32 PointerCount;
|
||||||
RVA ObjectInfoRva;
|
RVA ObjectInfoRva;
|
||||||
ULONG32 Reserved0;
|
ULONG32 Reserved0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_HANDLE_DATA_STREAM {
|
struct MINIDUMP_HANDLE_DATA_STREAM {
|
||||||
ULONG32 SizeOfHeader;
|
ULONG32 SizeOfHeader;
|
||||||
ULONG32 SizeOfDescriptor;
|
ULONG32 SizeOfDescriptor;
|
||||||
ULONG32 NumberOfDescriptors;
|
ULONG32 NumberOfDescriptors;
|
||||||
ULONG32 Reserved;
|
ULONG32 Reserved;
|
||||||
|
|
||||||
if (SizeOfDescriptor == 32)
|
if (SizeOfDescriptor == 32)
|
||||||
MINIDUMP_HANDLE_DESCRIPTOR HandleDescriptors[NumberOfDescriptors];
|
MINIDUMP_HANDLE_DESCRIPTOR HandleDescriptors[NumberOfDescriptors];
|
||||||
else if (SizeOfDescriptor == 40)
|
else if (SizeOfDescriptor == 40)
|
||||||
MINIDUMP_HANDLE_DESCRIPTOR_2 HandleDescriptors[NumberOfDescriptors];
|
MINIDUMP_HANDLE_DESCRIPTOR_2 HandleDescriptors[NumberOfDescriptors];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_FUNCTION_TABLE_DESCRIPTOR {
|
struct MINIDUMP_FUNCTION_TABLE_DESCRIPTOR {
|
||||||
ULONG64 MinimumAddress;
|
ULONG64 MinimumAddress;
|
||||||
ULONG64 MaximumAddress;
|
ULONG64 MaximumAddress;
|
||||||
ULONG64 BaseAddress;
|
ULONG64 BaseAddress;
|
||||||
ULONG32 EntryCount;
|
ULONG32 EntryCount;
|
||||||
type::Size32 SizeOfAlignPad;
|
type::Size32 SizeOfAlignPad;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_FUNCTION_TABLE_STREAM {
|
struct MINIDUMP_FUNCTION_TABLE_STREAM {
|
||||||
type::Size32 SizeOfHeader;
|
type::Size32 SizeOfHeader;
|
||||||
type::Size32 SizeOfDescriptor;
|
type::Size32 SizeOfDescriptor;
|
||||||
type::Size32 SizeOfNativeDescriptor;
|
type::Size32 SizeOfNativeDescriptor;
|
||||||
type::Size32 SizeOfFunctionEntry;
|
type::Size32 SizeOfFunctionEntry;
|
||||||
ULONG32 NumberOfDescriptors;
|
ULONG32 NumberOfDescriptors;
|
||||||
ULONG32 SizeOfAlignPad;
|
ULONG32 SizeOfAlignPad;
|
||||||
|
|
||||||
MINIDUMP_FUNCTION_TABLE_DESCRIPTOR FunctionDescriptors[NumberOfDescriptors];
|
MINIDUMP_FUNCTION_TABLE_DESCRIPTOR FunctionDescriptors[NumberOfDescriptors];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_UNLOADED_MODULE {
|
struct MINIDUMP_UNLOADED_MODULE {
|
||||||
ULONG64 BaseOfImage;
|
ULONG64 BaseOfImage;
|
||||||
type::Size32 SizeOfImage;
|
type::Size32 SizeOfImage;
|
||||||
ULONG32 CheckSum;
|
ULONG32 CheckSum;
|
||||||
ULONG32 TimeDateStamp;
|
ULONG32 TimeDateStamp;
|
||||||
RVA ModuleNameRva;
|
RVA ModuleNameRva;
|
||||||
|
|
||||||
char16 ModuleName[] @ ModuleNameRva + 4 [[hidden]];
|
char16 ModuleName[] @ ModuleNameRva + 4 [[hidden]];
|
||||||
} [[format("format_unloaded_module")]];
|
} [[format("format_unloaded_module")]];
|
||||||
|
|
||||||
fn format_unloaded_module(ref MINIDUMP_UNLOADED_MODULE module) {
|
fn format_unloaded_module(ref MINIDUMP_UNLOADED_MODULE module) {
|
||||||
return module.ModuleName;
|
return module.ModuleName;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_UNLOADED_MODULE_LIST {
|
struct MINIDUMP_UNLOADED_MODULE_LIST {
|
||||||
ULONG32 SizeOfHeader;
|
ULONG32 SizeOfHeader;
|
||||||
ULONG32 SizeOfEntry;
|
ULONG32 SizeOfEntry;
|
||||||
ULONG32 NumberOfEntries;
|
ULONG32 NumberOfEntries;
|
||||||
|
|
||||||
if (SizeOfHeader > 12)
|
if (SizeOfHeader > 12)
|
||||||
padding[header.SizeOfHeader - 12];
|
padding[header.SizeOfHeader - 12];
|
||||||
|
|
||||||
MINIDUMP_UNLOADED_MODULE Modules[NumberOfEntries];
|
MINIDUMP_UNLOADED_MODULE Modules[NumberOfEntries];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_MISC_INFO {
|
struct MINIDUMP_MISC_INFO {
|
||||||
ULONG32 SizeOfInfo;
|
ULONG32 SizeOfInfo;
|
||||||
ULONG32 Flags1;
|
ULONG32 Flags1;
|
||||||
ULONG32 ProcessId;
|
ULONG32 ProcessId;
|
||||||
ULONG32 ProcessCreateTime;
|
ULONG32 ProcessCreateTime;
|
||||||
ULONG32 ProcessUserTime;
|
ULONG32 ProcessUserTime;
|
||||||
ULONG32 ProcessKernelTime;
|
ULONG32 ProcessKernelTime;
|
||||||
|
|
||||||
if (SizeOfInfo > 24) {
|
if (SizeOfInfo > 24) {
|
||||||
ULONG32 ProcessorMaxMhz;
|
ULONG32 ProcessorMaxMhz;
|
||||||
ULONG32 ProcessorCurrentMhz;
|
ULONG32 ProcessorCurrentMhz;
|
||||||
ULONG32 ProcessorMhzLimit;
|
ULONG32 ProcessorMhzLimit;
|
||||||
ULONG32 ProcessorMaxIdleState;
|
ULONG32 ProcessorMaxIdleState;
|
||||||
ULONG32 ProcessorCurrentIdleState;
|
ULONG32 ProcessorCurrentIdleState;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_MEMORY_INFO {
|
struct MINIDUMP_MEMORY_INFO {
|
||||||
ULONG64 BaseAddress;
|
ULONG64 BaseAddress;
|
||||||
ULONG64 AllocationBase;
|
ULONG64 AllocationBase;
|
||||||
ULONG32 AllocationProtect;
|
ULONG32 AllocationProtect;
|
||||||
padding[4];
|
padding[4];
|
||||||
type::Size64 RegionSize;
|
type::Size64 RegionSize;
|
||||||
ULONG32 State;
|
ULONG32 State;
|
||||||
ULONG32 Protect;
|
ULONG32 Protect;
|
||||||
ULONG32 Type;
|
ULONG32 Type;
|
||||||
padding[4];
|
padding[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_MEMORY_INFO_LIST {
|
struct MINIDUMP_MEMORY_INFO_LIST {
|
||||||
ULONG SizeOfHeader;
|
ULONG SizeOfHeader;
|
||||||
ULONG SizeOfEntry;
|
ULONG SizeOfEntry;
|
||||||
ULONG64 NumberOfEntries;
|
ULONG64 NumberOfEntries;
|
||||||
|
|
||||||
if (SizeOfHeader > 16)
|
if (SizeOfHeader > 16)
|
||||||
padding[SizeOfHeader - 16];
|
padding[SizeOfHeader - 16];
|
||||||
|
|
||||||
MINIDUMP_MEMORY_INFO Info[NumberOfEntries];
|
MINIDUMP_MEMORY_INFO Info[NumberOfEntries];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_THREAD_INFO {
|
struct MINIDUMP_THREAD_INFO {
|
||||||
ULONG32 ThreadId;
|
ULONG32 ThreadId;
|
||||||
ULONG32 DumpFlags;
|
ULONG32 DumpFlags;
|
||||||
ULONG32 DumpError;
|
ULONG32 DumpError;
|
||||||
ULONG32 ExitStatus;
|
ULONG32 ExitStatus;
|
||||||
ULONG64 CreateTime;
|
ULONG64 CreateTime;
|
||||||
ULONG64 ExitTime;
|
ULONG64 ExitTime;
|
||||||
ULONG64 KernelTime;
|
ULONG64 KernelTime;
|
||||||
ULONG64 UserTime;
|
ULONG64 UserTime;
|
||||||
ULONG64 StartAddress;
|
ULONG64 StartAddress;
|
||||||
ULONG64 Affinity;
|
ULONG64 Affinity;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_THREAD_INFO_LIST {
|
struct MINIDUMP_THREAD_INFO_LIST {
|
||||||
ULONG SizeOfHeader;
|
ULONG SizeOfHeader;
|
||||||
ULONG SizeOfEntry;
|
ULONG SizeOfEntry;
|
||||||
ULONG NumberOfEntries;
|
ULONG NumberOfEntries;
|
||||||
|
|
||||||
if (SizeOfHeader > 12)
|
if (SizeOfHeader > 12)
|
||||||
padding[SizeOfHeader - 12];
|
padding[SizeOfHeader - 12];
|
||||||
|
|
||||||
MINIDUMP_THREAD_INFO Info[NumberOfEntries];
|
MINIDUMP_THREAD_INFO Info[NumberOfEntries];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_HANDLE_OPERATION_LIST {
|
struct MINIDUMP_HANDLE_OPERATION_LIST {
|
||||||
ULONG32 SizeOfHeader;
|
ULONG32 SizeOfHeader;
|
||||||
ULONG32 SizeOfEntry;
|
ULONG32 SizeOfEntry;
|
||||||
ULONG32 NumberOfEntries;
|
ULONG32 NumberOfEntries;
|
||||||
ULONG32 Reserved;
|
ULONG32 Reserved;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP_DIRECTORY {
|
struct MINIDUMP_DIRECTORY {
|
||||||
MINIDUMP_STREAM_TYPE StreamType;
|
MINIDUMP_STREAM_TYPE StreamType;
|
||||||
MINIDUMP_LOCATION_DESCRIPTOR Location;
|
MINIDUMP_LOCATION_DESCRIPTOR Location;
|
||||||
|
|
||||||
if (StreamType == MINIDUMP_STREAM_TYPE::ThreadListStream)
|
if (StreamType == MINIDUMP_STREAM_TYPE::ThreadListStream)
|
||||||
MINIDUMP_THREAD_LIST ThreadList @ Location.Rva;
|
MINIDUMP_THREAD_LIST ThreadList @ Location.Rva;
|
||||||
else if (StreamType == MINIDUMP_STREAM_TYPE::ModuleListStream)
|
else if (StreamType == MINIDUMP_STREAM_TYPE::ModuleListStream)
|
||||||
MINIDUMP_MODULE_LIST ModuleList @ Location.Rva;
|
MINIDUMP_MODULE_LIST ModuleList @ Location.Rva;
|
||||||
else if (StreamType == MINIDUMP_STREAM_TYPE::MemoryListStream)
|
else if (StreamType == MINIDUMP_STREAM_TYPE::MemoryListStream)
|
||||||
MINIDUMP_MEMORY_LIST MemoryList @ Location.Rva;
|
MINIDUMP_MEMORY_LIST MemoryList @ Location.Rva;
|
||||||
else if (StreamType == MINIDUMP_STREAM_TYPE::ExceptionStream)
|
else if (StreamType == MINIDUMP_STREAM_TYPE::ExceptionStream)
|
||||||
MINIDUMP_EXCEPTION_STREAM ExceptionInfo @ Location.Rva;
|
MINIDUMP_EXCEPTION_STREAM ExceptionInfo @ Location.Rva;
|
||||||
else if (StreamType == MINIDUMP_STREAM_TYPE::SystemInfoStream)
|
else if (StreamType == MINIDUMP_STREAM_TYPE::SystemInfoStream)
|
||||||
MINIDUMP_SYSTEM_INFO SystemInfo @ Location.Rva;
|
MINIDUMP_SYSTEM_INFO SystemInfo @ Location.Rva;
|
||||||
else if (StreamType == MINIDUMP_STREAM_TYPE::ThreadExListStream)
|
else if (StreamType == MINIDUMP_STREAM_TYPE::ThreadExListStream)
|
||||||
MINIDUMP_THREAD_EX_LIST ThreadExList @ Location.Rva;
|
MINIDUMP_THREAD_EX_LIST ThreadExList @ Location.Rva;
|
||||||
else if (StreamType == MINIDUMP_STREAM_TYPE::Memory64ListStream)
|
else if (StreamType == MINIDUMP_STREAM_TYPE::Memory64ListStream)
|
||||||
MINIDUMP_MEMORY64_LIST Mem64List @ Location.Rva;
|
MINIDUMP_MEMORY64_LIST Mem64List @ Location.Rva;
|
||||||
else if (StreamType == MINIDUMP_STREAM_TYPE::CommentStreamA)
|
else if (StreamType == MINIDUMP_STREAM_TYPE::CommentStreamA)
|
||||||
char Comment[] @ Location.Rva;
|
char Comment[] @ Location.Rva;
|
||||||
else if (StreamType == MINIDUMP_STREAM_TYPE::CommentStreamW)
|
else if (StreamType == MINIDUMP_STREAM_TYPE::CommentStreamW)
|
||||||
char16 Comment[] @ Location.Rva;
|
char16 Comment[] @ Location.Rva;
|
||||||
else if (StreamType == MINIDUMP_STREAM_TYPE::HandleDataStream)
|
else if (StreamType == MINIDUMP_STREAM_TYPE::HandleDataStream)
|
||||||
MINIDUMP_HANDLE_DATA_STREAM HandleData @ Location.Rva;
|
MINIDUMP_HANDLE_DATA_STREAM HandleData @ Location.Rva;
|
||||||
else if (StreamType == MINIDUMP_STREAM_TYPE::FunctionTableStream)
|
else if (StreamType == MINIDUMP_STREAM_TYPE::FunctionTableStream)
|
||||||
MINIDUMP_FUNCTION_TABLE_STREAM FunctionTable @ Location.Rva;
|
MINIDUMP_FUNCTION_TABLE_STREAM FunctionTable @ Location.Rva;
|
||||||
else if (StreamType == MINIDUMP_STREAM_TYPE::UnloadedModuleListStream)
|
else if (StreamType == MINIDUMP_STREAM_TYPE::UnloadedModuleListStream)
|
||||||
MINIDUMP_UNLOADED_MODULE_LIST UnloadModuleList @ Location.Rva;
|
MINIDUMP_UNLOADED_MODULE_LIST UnloadModuleList @ Location.Rva;
|
||||||
else if (StreamType == MINIDUMP_STREAM_TYPE::MiscInfoStream)
|
else if (StreamType == MINIDUMP_STREAM_TYPE::MiscInfoStream)
|
||||||
MINIDUMP_MISC_INFO MiscInfo @ Location.Rva;
|
MINIDUMP_MISC_INFO MiscInfo @ Location.Rva;
|
||||||
else if (StreamType == MINIDUMP_STREAM_TYPE::MemoryInfoListStream)
|
else if (StreamType == MINIDUMP_STREAM_TYPE::MemoryInfoListStream)
|
||||||
MINIDUMP_MEMORY_INFO_LIST MemInfoList @ Location.Rva;
|
MINIDUMP_MEMORY_INFO_LIST MemInfoList @ Location.Rva;
|
||||||
else if (StreamType == MINIDUMP_STREAM_TYPE::ThreadInfoListStream)
|
else if (StreamType == MINIDUMP_STREAM_TYPE::ThreadInfoListStream)
|
||||||
MINIDUMP_THREAD_INFO_LIST ThreadInfoList @ Location.Rva;
|
MINIDUMP_THREAD_INFO_LIST ThreadInfoList @ Location.Rva;
|
||||||
else if (StreamType == MINIDUMP_STREAM_TYPE::HandleOperationListStream)
|
else if (StreamType == MINIDUMP_STREAM_TYPE::HandleOperationListStream)
|
||||||
MINIDUMP_HANDLE_OPERATION_LIST HandleOperList @ Location.Rva;
|
MINIDUMP_HANDLE_OPERATION_LIST HandleOperList @ Location.Rva;
|
||||||
};
|
};
|
||||||
|
|
||||||
bitfield MINIDUMP_TYPE {
|
bitfield MINIDUMP_TYPE {
|
||||||
MiniDumpWithDataSegs : 1;
|
MiniDumpWithDataSegs : 1;
|
||||||
MiniDumpWithFullMemory : 1;
|
MiniDumpWithFullMemory : 1;
|
||||||
MiniDumpWithHandleData : 1;
|
MiniDumpWithHandleData : 1;
|
||||||
MiniDumpFilterMemory : 1;
|
MiniDumpFilterMemory : 1;
|
||||||
MiniDumpScanMemory : 1;
|
MiniDumpScanMemory : 1;
|
||||||
MiniDumpWithUnloadedModules : 1;
|
MiniDumpWithUnloadedModules : 1;
|
||||||
MiniDumpWithIndirectlyReferencedMemory : 1;
|
MiniDumpWithIndirectlyReferencedMemory : 1;
|
||||||
MiniDumpFilterModulePaths : 1;
|
MiniDumpFilterModulePaths : 1;
|
||||||
MiniDumpWithProcessThreadData : 1;
|
MiniDumpWithProcessThreadData : 1;
|
||||||
MiniDumpWithPrivateReadWriteMemory : 1;
|
MiniDumpWithPrivateReadWriteMemory : 1;
|
||||||
MiniDumpWithoutOptionalData : 1;
|
MiniDumpWithoutOptionalData : 1;
|
||||||
MiniDumpWithFullMemoryInfo : 1;
|
MiniDumpWithFullMemoryInfo : 1;
|
||||||
MiniDumpWithThreadInfo : 1;
|
MiniDumpWithThreadInfo : 1;
|
||||||
MiniDumpWithCodeSegs : 1;
|
MiniDumpWithCodeSegs : 1;
|
||||||
MiniDumpWithoutAuxiliaryState : 1;
|
MiniDumpWithoutAuxiliaryState : 1;
|
||||||
MiniDumpWithFullAuxiliaryState : 1;
|
MiniDumpWithFullAuxiliaryState : 1;
|
||||||
MiniDumpWithPrivateWriteCopyMemory : 1;
|
MiniDumpWithPrivateWriteCopyMemory : 1;
|
||||||
MiniDumpIgnoreInaccessibleMemory : 1;
|
MiniDumpIgnoreInaccessibleMemory : 1;
|
||||||
MiniDumpWithTokenInformation : 1;
|
MiniDumpWithTokenInformation : 1;
|
||||||
MiniDumpWithModuleHeaders : 1;
|
MiniDumpWithModuleHeaders : 1;
|
||||||
MiniDumpFilterTriage : 1;
|
MiniDumpFilterTriage : 1;
|
||||||
MiniDumpWithAvxXStateContext : 1;
|
MiniDumpWithAvxXStateContext : 1;
|
||||||
MiniDumpWithIptTrace : 1;
|
MiniDumpWithIptTrace : 1;
|
||||||
MiniDumpScanInaccessiblePartialPages : 1;
|
MiniDumpScanInaccessiblePartialPages : 1;
|
||||||
padding : 40;
|
padding : 40;
|
||||||
} [[right_to_left]];
|
};
|
||||||
|
|
||||||
struct MINIDUMP_HEADER {
|
struct MINIDUMP_HEADER {
|
||||||
char Signature[4];
|
char Signature[4];
|
||||||
ULONG32 Version;
|
ULONG32 Version;
|
||||||
ULONG32 NumberOfStreams;
|
ULONG32 NumberOfStreams;
|
||||||
RVA StreamDirectoryRva;
|
RVA StreamDirectoryRva;
|
||||||
ULONG32 Checksum;
|
ULONG32 Checksum;
|
||||||
type::time32_t TimeDateStamp;
|
type::time32_t TimeDateStamp;
|
||||||
MINIDUMP_TYPE Flags;
|
MINIDUMP_TYPE Flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MINIDUMP {
|
struct MINIDUMP {
|
||||||
MINIDUMP_HEADER Header;
|
MINIDUMP_HEADER Header;
|
||||||
MINIDUMP_DIRECTORY Streams[Header.NumberOfStreams] [[format_entries("format_stream")]];
|
MINIDUMP_DIRECTORY Streams[Header.NumberOfStreams] [[format_entries("format_stream")]];
|
||||||
};
|
};
|
||||||
|
|
||||||
fn format_stream(ref MINIDUMP_DIRECTORY stream) {
|
fn format_stream(ref MINIDUMP_DIRECTORY stream) {
|
||||||
return stream.StreamType;
|
return stream.StreamType;
|
||||||
};
|
};
|
||||||
|
|
||||||
MINIDUMP MiniDump @ 0x00;
|
MINIDUMP MiniDump @ 0x00;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#include <std/mem.pat>
|
#include <std/mem.pat>
|
||||||
|
|
||||||
#pragma bitfield_order right_to_left
|
|
||||||
|
|
||||||
struct DOSHeader {
|
struct DOSHeader {
|
||||||
char signature[2];
|
char signature[2];
|
||||||
u16 lastPageSize;
|
u16 lastPageSize;
|
||||||
@@ -186,7 +184,7 @@ bitfield SegmentTableFlags {
|
|||||||
containsRelocationInfo : 1;
|
containsRelocationInfo : 1;
|
||||||
padding : 1;
|
padding : 1;
|
||||||
discardPriority : 4;
|
discardPriority : 4;
|
||||||
} [[right_to_left]];
|
};
|
||||||
|
|
||||||
struct SegmentTable {
|
struct SegmentTable {
|
||||||
u16 segmentDataPointer;
|
u16 segmentDataPointer;
|
||||||
|
|||||||
@@ -1,161 +1,165 @@
|
|||||||
bitfield AccessCapability {
|
#include <std/core.pat>
|
||||||
Read : 4;
|
|
||||||
Write : 4;
|
using BitfieldOrder = std::core::BitfieldOrder;
|
||||||
} [[left_to_right]];
|
|
||||||
|
bitfield AccessCapability {
|
||||||
struct CapabilityContainer {
|
Read : 4;
|
||||||
u8 magic;
|
Write : 4;
|
||||||
u8 version;
|
} [[bitfield_order(BitfieldOrder::MostToLeastSignificant, 8)]];
|
||||||
u8 memorySize;
|
|
||||||
AccessCapability accessCapability;
|
struct CapabilityContainer {
|
||||||
};
|
u8 magic;
|
||||||
|
u8 version;
|
||||||
bitfield NDEFFlags {
|
u8 memorySize;
|
||||||
MB : 1;
|
be AccessCapability accessCapability;
|
||||||
ME : 1;
|
};
|
||||||
CF : 1;
|
|
||||||
SR : 1;
|
bitfield NDEFFlags {
|
||||||
IL : 1;
|
MB : 1;
|
||||||
TNF : 3;
|
ME : 1;
|
||||||
} [[left_to_right]];
|
CF : 1;
|
||||||
|
SR : 1;
|
||||||
enum TNFType : u8 {
|
IL : 1;
|
||||||
Empty = 0x00,
|
TNF : 3;
|
||||||
NFCForumWellKnownType = 0x01,
|
} [[bitfield_order(BitfieldOrder::MostToLeastSignificant, 8)]];
|
||||||
MediaType = 0x02,
|
|
||||||
AbsoluteURI = 0x03,
|
enum TNFType : u8 {
|
||||||
NFCForumExternalType = 0x04,
|
Empty = 0x00,
|
||||||
Unknown = 0x05,
|
NFCForumWellKnownType = 0x01,
|
||||||
Unchanged = 0x06,
|
MediaType = 0x02,
|
||||||
Reserved = 0x07
|
AbsoluteURI = 0x03,
|
||||||
};
|
NFCForumExternalType = 0x04,
|
||||||
|
Unknown = 0x05,
|
||||||
struct NDEF {
|
Unchanged = 0x06,
|
||||||
NDEFFlags flags;
|
Reserved = 0x07
|
||||||
u8 typeLength;
|
};
|
||||||
|
|
||||||
if (flags.SR)
|
struct NDEF {
|
||||||
u8 payloadLength;
|
NDEFFlags flags;
|
||||||
else
|
u8 typeLength;
|
||||||
u32 payloadLength;
|
|
||||||
|
if (flags.SR)
|
||||||
if (flags.IL)
|
u8 payloadLength;
|
||||||
u8 idLength;
|
else
|
||||||
|
u32 payloadLength;
|
||||||
char type[typeLength];
|
|
||||||
|
if (flags.IL)
|
||||||
if (flags.IL)
|
u8 idLength;
|
||||||
u8 id[idLength];
|
|
||||||
|
char type[typeLength];
|
||||||
u8 payload[payloadLength];
|
|
||||||
|
if (flags.IL)
|
||||||
if (flags.ME)
|
u8 id[idLength];
|
||||||
break;
|
|
||||||
};
|
u8 payload[payloadLength];
|
||||||
|
|
||||||
struct LockControl {
|
if (flags.ME)
|
||||||
u8 dynamicLockByteOffset;
|
break;
|
||||||
u8 numBits;
|
};
|
||||||
u8 pageControlInfo;
|
|
||||||
};
|
struct LockControl {
|
||||||
|
u8 dynamicLockByteOffset;
|
||||||
struct MemoryControl {
|
u8 numBits;
|
||||||
u8 reservedBytesOffset;
|
u8 pageControlInfo;
|
||||||
u8 numBytes;
|
};
|
||||||
u8 pageSize;
|
|
||||||
};
|
struct MemoryControl {
|
||||||
|
u8 reservedBytesOffset;
|
||||||
struct Length {
|
u8 numBytes;
|
||||||
u8 byte [[hidden, no_unique_address]];
|
u8 pageSize;
|
||||||
if (byte == 0xFF)
|
};
|
||||||
u24 length;
|
|
||||||
else
|
struct Length {
|
||||||
u8 length;
|
u8 byte [[hidden, no_unique_address]];
|
||||||
} [[sealed, transform("transform_length"), format("transform_length")]];
|
if (byte == 0xFF)
|
||||||
|
u24 length;
|
||||||
fn transform_length(Length length) {
|
else
|
||||||
return length.length;
|
u8 length;
|
||||||
};
|
} [[sealed, transform("transform_length"), format("transform_length")]];
|
||||||
|
|
||||||
enum Tag : u8 {
|
fn transform_length(Length length) {
|
||||||
NULL = 0x00,
|
return length.length;
|
||||||
LockControl = 0x01,
|
};
|
||||||
MemoryControl = 0x02,
|
|
||||||
NDEFMessage = 0x03,
|
enum Tag : u8 {
|
||||||
Proprietary = 0xFD,
|
NULL = 0x00,
|
||||||
TerminatorTLV = 0xFE
|
LockControl = 0x01,
|
||||||
};
|
MemoryControl = 0x02,
|
||||||
|
NDEFMessage = 0x03,
|
||||||
struct TLV {
|
Proprietary = 0xFD,
|
||||||
Tag tag;
|
TerminatorTLV = 0xFE
|
||||||
if (tag == Tag::TerminatorTLV) {
|
};
|
||||||
break;
|
|
||||||
} else if (tag == Tag::NULL) {
|
struct TLV {
|
||||||
// Empty
|
Tag tag;
|
||||||
} else {
|
if (tag == Tag::TerminatorTLV) {
|
||||||
Length length;
|
break;
|
||||||
|
} else if (tag == Tag::NULL) {
|
||||||
if (length > 0) {
|
// Empty
|
||||||
if (tag == Tag::LockControl) {
|
} else {
|
||||||
LockControl lockControl;
|
Length length;
|
||||||
} else if (tag == Tag::MemoryControl) {
|
|
||||||
LockControl lockControl;
|
if (length > 0) {
|
||||||
} else if (tag == Tag::NDEFMessage) {
|
if (tag == Tag::LockControl) {
|
||||||
NDEF ndef[while(true)];
|
LockControl lockControl;
|
||||||
} else {
|
} else if (tag == Tag::MemoryControl) {
|
||||||
u8 value[length];
|
LockControl lockControl;
|
||||||
}
|
} else if (tag == Tag::NDEFMessage) {
|
||||||
}
|
NDEF ndef[while(true)];
|
||||||
}
|
} else {
|
||||||
};
|
u8 value[length];
|
||||||
|
}
|
||||||
struct ManufacturerData {
|
}
|
||||||
u8 serial1[3];
|
}
|
||||||
u8 checkByte0;
|
};
|
||||||
u8 serial2[4];
|
|
||||||
u8 checkByte1;
|
struct ManufacturerData {
|
||||||
u8 internal;
|
u8 serial1[3];
|
||||||
u16 lockBytes;
|
u8 checkByte0;
|
||||||
};
|
u8 serial2[4];
|
||||||
|
u8 checkByte1;
|
||||||
struct DynamicLockBytes {
|
u8 internal;
|
||||||
u8 bytes[3];
|
u16 lockBytes;
|
||||||
padding[1];
|
};
|
||||||
};
|
|
||||||
|
struct DynamicLockBytes {
|
||||||
bitfield MIRROR {
|
u8 bytes[3];
|
||||||
MIRROR_CONF : 2;
|
padding[1];
|
||||||
MIRROR_BYTE : 2;
|
};
|
||||||
padding : 1;
|
|
||||||
STRG_MOD_EN : 1;
|
bitfield MIRROR {
|
||||||
padding : 2;
|
MIRROR_CONF : 2;
|
||||||
} [[left_to_right]];
|
MIRROR_BYTE : 2;
|
||||||
|
padding : 1;
|
||||||
bitfield ACCESS {
|
STRG_MOD_EN : 1;
|
||||||
PROT : 1;
|
padding : 2;
|
||||||
CFGLCK : 1;
|
} [[bitfield_order(BitfieldOrder::MostToLeastSignificant, 8)]];
|
||||||
padding : 1;
|
|
||||||
NFC_CNT_EN : 1;
|
bitfield ACCESS {
|
||||||
NFC_CNT_PWD_PROT : 1;
|
PROT : 1;
|
||||||
AUTHLIM : 3;
|
CFGLCK : 1;
|
||||||
};
|
padding : 1;
|
||||||
|
NFC_CNT_EN : 1;
|
||||||
struct Config {
|
NFC_CNT_PWD_PROT : 1;
|
||||||
MIRROR MIRROR;
|
AUTHLIM : 3;
|
||||||
u8 MIRROR_PAGE;
|
};
|
||||||
u8 AUTH0;
|
|
||||||
ACCESS ACCESS;
|
struct Config {
|
||||||
u32 PWD;
|
MIRROR MIRROR;
|
||||||
u16 PACK;
|
u8 MIRROR_PAGE;
|
||||||
};
|
u8 AUTH0;
|
||||||
|
ACCESS ACCESS;
|
||||||
struct NTAG {
|
u32 PWD;
|
||||||
ManufacturerData manufacturerData;
|
u16 PACK;
|
||||||
CapabilityContainer cc;
|
};
|
||||||
TLV tlv[while(true)];
|
|
||||||
padding[addressof(tlv) + cc.memorySize * 8 - sizeof(tlv)];
|
struct NTAG {
|
||||||
DynamicLockBytes dynamicLockBytes;
|
ManufacturerData manufacturerData;
|
||||||
Config config;
|
CapabilityContainer cc;
|
||||||
};
|
TLV tlv[while(true)];
|
||||||
|
padding[addressof(tlv) + cc.memorySize * 8 - sizeof(tlv)];
|
||||||
NTAG ntag @ 0x00;
|
DynamicLockBytes dynamicLockBytes;
|
||||||
|
Config config;
|
||||||
|
};
|
||||||
|
|
||||||
|
NTAG ntag @ 0x00;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#pragma MIME application/x-dosexec
|
#pragma MIME application/x-dosexec
|
||||||
#pragma MIME application/x-msdownload
|
#pragma MIME application/x-msdownload
|
||||||
#pragma bitfield_order right_to_left
|
|
||||||
#pragma pattern_limit 0x400000
|
#pragma pattern_limit 0x400000
|
||||||
|
|
||||||
#include <std/string.pat>
|
#include <std/string.pat>
|
||||||
@@ -378,7 +377,7 @@ fn architecture() {
|
|||||||
bitfield OrdinalFlagByte {
|
bitfield OrdinalFlagByte {
|
||||||
flag : 1;
|
flag : 1;
|
||||||
padding : 7;
|
padding : 7;
|
||||||
} [[left_to_right]];
|
};
|
||||||
|
|
||||||
struct NameTableEntry {
|
struct NameTableEntry {
|
||||||
u16 hint;
|
u16 hint;
|
||||||
@@ -1278,4 +1277,4 @@ struct StringTable {
|
|||||||
StringTableString strings[while($ < addressof(this) + size)];
|
StringTableString strings[while($ < addressof(this) + size)];
|
||||||
} [[inline]];
|
} [[inline]];
|
||||||
|
|
||||||
StringTable stringTable[checkForDebugInformation] @ addressof(symbolTable) + sizeof(symbolTable);
|
StringTable stringTable[checkForDebugInformation] @ addressof(symbolTable) + sizeof(symbolTable);
|
||||||
@@ -1,66 +1,67 @@
|
|||||||
#include <std/mem.pat>
|
#include <std/core.pat>
|
||||||
|
#include <std/mem.pat>
|
||||||
#include <type/leb128.pat>
|
|
||||||
|
#include <type/leb128.pat>
|
||||||
struct ZigZag32 {
|
|
||||||
u32 value;
|
struct ZigZag32 {
|
||||||
} [[sealed, format("format_zigzag32")]];
|
u32 value;
|
||||||
|
} [[sealed, format("format_zigzag32")]];
|
||||||
fn format_zigzag32(ZigZag32 zigzag) {
|
|
||||||
return s32((s32(zigzag.value) << 1) ^ (s32(zigzag.value) >> 31));
|
fn format_zigzag32(ZigZag32 zigzag) {
|
||||||
};
|
return s32((s32(zigzag.value) << 1) ^ (s32(zigzag.value) >> 31));
|
||||||
|
};
|
||||||
struct ZigZag64 {
|
|
||||||
u64 value;
|
struct ZigZag64 {
|
||||||
} [[sealed, format("format_zigzag64")]];
|
u64 value;
|
||||||
|
} [[sealed, format("format_zigzag64")]];
|
||||||
fn format_zigzag64(ZigZag64 zigzag) {
|
|
||||||
return s64((s64(zigzag.value) << 1) ^ (s64(zigzag.value) >> 63));
|
fn format_zigzag64(ZigZag64 zigzag) {
|
||||||
};
|
return s64((s64(zigzag.value) << 1) ^ (s64(zigzag.value) >> 63));
|
||||||
|
};
|
||||||
enum WireType : u8 {
|
|
||||||
Varint = 0,
|
enum WireType : u8 {
|
||||||
_64Bit = 1,
|
Varint = 0,
|
||||||
LengthDelimited = 2,
|
_64Bit = 1,
|
||||||
StartGroup = 3,
|
LengthDelimited = 2,
|
||||||
EndGroup = 4,
|
StartGroup = 3,
|
||||||
_32Bit = 5
|
EndGroup = 4,
|
||||||
};
|
_32Bit = 5
|
||||||
|
};
|
||||||
bitfield Key {
|
|
||||||
field_number : 5;
|
bitfield Key {
|
||||||
wire_type : 3;
|
field_number : 5;
|
||||||
} [[left_to_right]];
|
wire_type : 3;
|
||||||
|
} [[bitfield_order(std::core::BitfieldOrder::MostToLeastSignificant, 8)]];
|
||||||
union _64Bit {
|
|
||||||
u64 fixed64;
|
union _64Bit {
|
||||||
ZigZag64 sfixed64;
|
u64 fixed64;
|
||||||
double dbl;
|
ZigZag64 sfixed64;
|
||||||
};
|
double dbl;
|
||||||
|
};
|
||||||
union _32Bit {
|
|
||||||
u32 fixed32;
|
union _32Bit {
|
||||||
ZigZag32 sfixed32;
|
u32 fixed32;
|
||||||
float flt;
|
ZigZag32 sfixed32;
|
||||||
};
|
float flt;
|
||||||
|
};
|
||||||
struct LengthDelimited {
|
|
||||||
type::LEB128 length;
|
struct LengthDelimited {
|
||||||
char data[length];
|
type::LEB128 length;
|
||||||
};
|
char data[length];
|
||||||
|
};
|
||||||
|
|
||||||
struct Entry {
|
|
||||||
Key key;
|
struct Entry {
|
||||||
|
Key key;
|
||||||
if (key.wire_type == WireType::Varint)
|
|
||||||
type::LEB128 value;
|
if (key.wire_type == WireType::Varint)
|
||||||
else if (key.wire_type == WireType::_64Bit)
|
type::LEB128 value;
|
||||||
_64Bit value;
|
else if (key.wire_type == WireType::_64Bit)
|
||||||
else if (key.wire_type == WireType::LengthDelimited)
|
_64Bit value;
|
||||||
LengthDelimited value;
|
else if (key.wire_type == WireType::LengthDelimited)
|
||||||
else if (key.wire_type == WireType::_32Bit)
|
LengthDelimited value;
|
||||||
_32Bit value;
|
else if (key.wire_type == WireType::_32Bit)
|
||||||
};
|
_32Bit value;
|
||||||
|
};
|
||||||
Entry entries[while(!std::mem::eof())] @ 0x00;
|
|
||||||
|
Entry entries[while(!std::mem::eof())] @ 0x00;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#pragma MIME image/qoi
|
#pragma MIME image/qoi
|
||||||
#pragma endian big
|
#pragma endian big
|
||||||
#pragma bitfield_order left_to_right
|
|
||||||
|
|
||||||
#include <std/mem.pat>
|
#include <std/mem.pat>
|
||||||
|
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ namespace v5 {
|
|||||||
folder : 1;
|
folder : 1;
|
||||||
encrypted : 1;
|
encrypted : 1;
|
||||||
padding : 5;
|
padding : 5;
|
||||||
} [[left_to_right]];
|
};
|
||||||
|
|
||||||
bitfield Flags2 {
|
bitfield Flags2 {
|
||||||
padding : 7;
|
padding : 7;
|
||||||
resource_fork : 1;
|
resource_fork : 1;
|
||||||
padding : 8;
|
padding : 8;
|
||||||
} [[left_to_right]];
|
};
|
||||||
|
|
||||||
using MacOSHFSPlusDate = u32 [[format("v5::format_macos_date")]];
|
using MacOSHFSPlusDate = u32 [[format("v5::format_macos_date")]];
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#include <std/mem.pat>
|
||||||
|
|
||||||
enum GeneratorID : u16 {
|
enum GeneratorID : u16 {
|
||||||
Khronos = 0,
|
Khronos = 0,
|
||||||
LunarG = 1,
|
LunarG = 1,
|
||||||
@@ -642,4 +644,4 @@ struct Instruction {
|
|||||||
Header header @ 0x00;
|
Header header @ 0x00;
|
||||||
|
|
||||||
// SPIR-V does not have any footer, increase number of instructions manually if you encounter a bigger shader
|
// SPIR-V does not have any footer, increase number of instructions manually if you encounter a bigger shader
|
||||||
Instruction instructions[1024] @ 0x14;
|
Instruction instructions[while (!std::mem::eof())] @ 0x14;
|
||||||
@@ -1,269 +1,272 @@
|
|||||||
#include <std/io.pat>
|
#include <std/core.pat>
|
||||||
#include <std/mem.pat>
|
#include <std/io.pat>
|
||||||
#include <std/string.pat>
|
#include <std/mem.pat>
|
||||||
|
#include <std/string.pat>
|
||||||
enum DescriptorType : u8 {
|
|
||||||
DeviceDescriptor = 0x01,
|
using BitfieldOrder = std::core::BitfieldOrder;
|
||||||
ConfigDescriptor = 0x02,
|
|
||||||
StringDescriptor = 0x03,
|
enum DescriptorType : u8 {
|
||||||
InterfaceDescriptor = 0x04,
|
DeviceDescriptor = 0x01,
|
||||||
EndpointDescriptor = 0x05,
|
ConfigDescriptor = 0x02,
|
||||||
DeviceQualifierDescriptor = 0x06,
|
StringDescriptor = 0x03,
|
||||||
OtherSpeedConfigurationDescriptor = 0x07,
|
InterfaceDescriptor = 0x04,
|
||||||
InterfacePowerDescriptor = 0x08,
|
EndpointDescriptor = 0x05,
|
||||||
OTGDescriptor = 0x09,
|
DeviceQualifierDescriptor = 0x06,
|
||||||
DebugDescriptor = 0x0A,
|
OtherSpeedConfigurationDescriptor = 0x07,
|
||||||
InterfaceAssociationDescriptor = 0x0B,
|
InterfacePowerDescriptor = 0x08,
|
||||||
|
OTGDescriptor = 0x09,
|
||||||
HIDDescriptor = 0x21,
|
DebugDescriptor = 0x0A,
|
||||||
ReportDescriptor = 0x22,
|
InterfaceAssociationDescriptor = 0x0B,
|
||||||
PhysicalDescriptor = 0x23
|
|
||||||
};
|
HIDDescriptor = 0x21,
|
||||||
|
ReportDescriptor = 0x22,
|
||||||
enum InterfaceClass : u8 {
|
PhysicalDescriptor = 0x23
|
||||||
UseClassInformationInInterfaceDescriptors = 0x00,
|
};
|
||||||
Audio = 0x01,
|
|
||||||
CommunicationAndCDCControl = 0x02,
|
enum InterfaceClass : u8 {
|
||||||
HID = 0x03,
|
UseClassInformationInInterfaceDescriptors = 0x00,
|
||||||
Physical = 0x05,
|
Audio = 0x01,
|
||||||
Image = 0x06,
|
CommunicationAndCDCControl = 0x02,
|
||||||
Printer = 0x07,
|
HID = 0x03,
|
||||||
MassStorage = 0x08,
|
Physical = 0x05,
|
||||||
Hub = 0x09,
|
Image = 0x06,
|
||||||
CDCData = 0x0A,
|
Printer = 0x07,
|
||||||
SmartCard = 0x0B,
|
MassStorage = 0x08,
|
||||||
ContentSecurity = 0x0C,
|
Hub = 0x09,
|
||||||
Video = 0x0E,
|
CDCData = 0x0A,
|
||||||
PersonalHealthcare = 0x0F,
|
SmartCard = 0x0B,
|
||||||
AudioVideoDevice = 0x10,
|
ContentSecurity = 0x0C,
|
||||||
BillboardDevice = 0x11,
|
Video = 0x0E,
|
||||||
USBTypeCBridge = 0x12,
|
PersonalHealthcare = 0x0F,
|
||||||
I3CDevice = 0x3C,
|
AudioVideoDevice = 0x10,
|
||||||
DiagnosticDevice = 0xDC,
|
BillboardDevice = 0x11,
|
||||||
WirelessController = 0xE0,
|
USBTypeCBridge = 0x12,
|
||||||
Miscellaneous = 0xEF,
|
I3CDevice = 0x3C,
|
||||||
ApplicationSpecific = 0xFE,
|
DiagnosticDevice = 0xDC,
|
||||||
VendorSpecific = 0xFF
|
WirelessController = 0xE0,
|
||||||
};
|
Miscellaneous = 0xEF,
|
||||||
|
ApplicationSpecific = 0xFE,
|
||||||
enum CountryCode : u8 {
|
VendorSpecific = 0xFF
|
||||||
NotSupported = 0,
|
};
|
||||||
Arabic = 1,
|
|
||||||
Belgian = 2,
|
enum CountryCode : u8 {
|
||||||
CanadianBilingual = 3,
|
NotSupported = 0,
|
||||||
CanadianFrench = 4,
|
Arabic = 1,
|
||||||
CzechRepublic = 5,
|
Belgian = 2,
|
||||||
Danish = 6,
|
CanadianBilingual = 3,
|
||||||
Finnish = 7,
|
CanadianFrench = 4,
|
||||||
French = 8,
|
CzechRepublic = 5,
|
||||||
German = 9,
|
Danish = 6,
|
||||||
Greek = 10,
|
Finnish = 7,
|
||||||
Hebrew = 11,
|
French = 8,
|
||||||
Hungary = 12,
|
German = 9,
|
||||||
International = 13,
|
Greek = 10,
|
||||||
Italian = 14,
|
Hebrew = 11,
|
||||||
JapanKatakana = 15,
|
Hungary = 12,
|
||||||
Korean = 16,
|
International = 13,
|
||||||
LatinAmerican = 17,
|
Italian = 14,
|
||||||
Dutch = 18,
|
JapanKatakana = 15,
|
||||||
Norwegian = 19,
|
Korean = 16,
|
||||||
PersianFarsi = 20,
|
LatinAmerican = 17,
|
||||||
Polish = 21,
|
Dutch = 18,
|
||||||
Portuguese = 22,
|
Norwegian = 19,
|
||||||
Russian = 23,
|
PersianFarsi = 20,
|
||||||
Slovakian = 24,
|
Polish = 21,
|
||||||
Spanish = 25,
|
Portuguese = 22,
|
||||||
Swedish = 26,
|
Russian = 23,
|
||||||
SwissFrench = 27,
|
Slovakian = 24,
|
||||||
SwissGerman = 28,
|
Spanish = 25,
|
||||||
Switzerland = 29,
|
Swedish = 26,
|
||||||
Taiwan = 30,
|
SwissFrench = 27,
|
||||||
TurkishQ = 31,
|
SwissGerman = 28,
|
||||||
EnglishUK = 32,
|
Switzerland = 29,
|
||||||
EnglishUS = 33,
|
Taiwan = 30,
|
||||||
Yugoslavian = 34,
|
TurkishQ = 31,
|
||||||
TurkishF = 35,
|
EnglishUK = 32,
|
||||||
Reserved = 36 ... 255
|
EnglishUS = 33,
|
||||||
};
|
Yugoslavian = 34,
|
||||||
|
TurkishF = 35,
|
||||||
enum HubInterfaceSubClass : u8 {
|
Reserved = 36 ... 255
|
||||||
Hub = 0x00
|
};
|
||||||
};
|
|
||||||
|
enum HubInterfaceSubClass : u8 {
|
||||||
enum AudioVideoDeviceSubClass : u8 {
|
Hub = 0x00
|
||||||
AVControlInterface = 0x01,
|
};
|
||||||
AVDataVideoStreamingInterface = 0x02,
|
|
||||||
AVDataAudioStreamingInterface = 0x03
|
enum AudioVideoDeviceSubClass : u8 {
|
||||||
};
|
AVControlInterface = 0x01,
|
||||||
|
AVDataVideoStreamingInterface = 0x02,
|
||||||
enum HubInterfaceProtocol : u8 {
|
AVDataAudioStreamingInterface = 0x03
|
||||||
FullSpeedHub = 0x00,
|
};
|
||||||
HiSpeedHubWithSingleTT = 0x01,
|
|
||||||
HiSpeedHubWithMultipleTTs = 0x02
|
enum HubInterfaceProtocol : u8 {
|
||||||
};
|
FullSpeedHub = 0x00,
|
||||||
|
HiSpeedHubWithSingleTT = 0x01,
|
||||||
struct Ampere {
|
HiSpeedHubWithMultipleTTs = 0x02
|
||||||
u8 amps;
|
};
|
||||||
} [[sealed, format("format_ampere")]];
|
|
||||||
|
struct Ampere {
|
||||||
fn format_ampere(Ampere ampere) {
|
u8 amps;
|
||||||
return std::format("{} mA", ampere.amps * 2);
|
} [[sealed, format("format_ampere")]];
|
||||||
};
|
|
||||||
|
fn format_ampere(Ampere ampere) {
|
||||||
bitfield ConfigAttributes {
|
return std::format("{} mA", ampere.amps * 2);
|
||||||
padding : 1;
|
};
|
||||||
SelfPowered : 1;
|
|
||||||
RemoteWakeup : 1;
|
bitfield ConfigAttributes {
|
||||||
padding : 5;
|
padding : 1;
|
||||||
} [[left_to_right]];
|
SelfPowered : 1;
|
||||||
|
RemoteWakeup : 1;
|
||||||
struct BCD<auto Size> {
|
padding : 5;
|
||||||
u8 bytes[Size];
|
} [[bitfield_order(BitfieldOrder::MostToLeastSignificant, 8)]];
|
||||||
} [[sealed, format("format_bcd")]];
|
|
||||||
|
struct BCD<auto Size> {
|
||||||
fn format_bcd(ref auto bcd) {
|
u8 bytes[Size];
|
||||||
str result;
|
} [[sealed, format("format_bcd")]];
|
||||||
for (s8 i = sizeof(bcd.bytes) - 1, i >= 0, i -= 1)
|
|
||||||
result += std::format("{:X}.", bcd.bytes[i]);
|
fn format_bcd(ref auto bcd) {
|
||||||
|
str result;
|
||||||
return std::string::substr(result, 0, std::string::length(result) - 1);
|
for (s8 i = sizeof(bcd.bytes) - 1, i >= 0, i -= 1)
|
||||||
};
|
result += std::format("{:X}.", bcd.bytes[i]);
|
||||||
|
|
||||||
struct DeviceDescriptor {
|
return std::string::substr(result, 0, std::string::length(result) - 1);
|
||||||
BCD<2> bcdUSB;
|
};
|
||||||
InterfaceClass bDeviceClass;
|
|
||||||
if (bDeviceClass == InterfaceClass::Hub) {
|
struct DeviceDescriptor {
|
||||||
HubInterfaceSubClass bDeviceSubClass;
|
BCD<2> bcdUSB;
|
||||||
if (bDeviceSubClass == HubInterfaceSubClass::Hub)
|
InterfaceClass bDeviceClass;
|
||||||
HubInterfaceProtocol bDeviceSubClass;
|
if (bDeviceClass == InterfaceClass::Hub) {
|
||||||
else
|
HubInterfaceSubClass bDeviceSubClass;
|
||||||
u8 bDeviceSubClass;
|
if (bDeviceSubClass == HubInterfaceSubClass::Hub)
|
||||||
} else if (bDeviceClass == InterfaceClass::AudioVideoDevice) {
|
HubInterfaceProtocol bDeviceSubClass;
|
||||||
AudioVideoDeviceSubClass bDeviceSubClass;
|
else
|
||||||
u8 bDeviceSubClass;
|
u8 bDeviceSubClass;
|
||||||
} else {
|
} else if (bDeviceClass == InterfaceClass::AudioVideoDevice) {
|
||||||
u8 bDeviceSubClass;
|
AudioVideoDeviceSubClass bDeviceSubClass;
|
||||||
}
|
u8 bDeviceSubClass;
|
||||||
};
|
} else {
|
||||||
|
u8 bDeviceSubClass;
|
||||||
struct ConfigDescriptor {
|
}
|
||||||
u16 wTotalLength;
|
};
|
||||||
u8 bNumInterfaces;
|
|
||||||
u8 bConfigurationValue;
|
struct ConfigDescriptor {
|
||||||
u8 iConfiguration;
|
u16 wTotalLength;
|
||||||
ConfigAttributes bmAttributes;
|
u8 bNumInterfaces;
|
||||||
Ampere bMaxPower;
|
u8 bConfigurationValue;
|
||||||
};
|
u8 iConfiguration;
|
||||||
|
ConfigAttributes bmAttributes;
|
||||||
struct StringDescriptor {
|
Ampere bMaxPower;
|
||||||
char bString[parent.bLength - 2];
|
};
|
||||||
};
|
|
||||||
|
struct StringDescriptor {
|
||||||
struct InterfaceDescriptor {
|
char bString[parent.bLength - 2];
|
||||||
u8 bInterfaceNumber;
|
};
|
||||||
u8 bAlternateSetting;
|
|
||||||
u8 bNumEndpoints;
|
struct InterfaceDescriptor {
|
||||||
|
u8 bInterfaceNumber;
|
||||||
InterfaceClass bInterfaceClass;
|
u8 bAlternateSetting;
|
||||||
if (bInterfaceClass == InterfaceClass::Hub) {
|
u8 bNumEndpoints;
|
||||||
HubInterfaceSubClass bInterfaceSubClass;
|
|
||||||
if (bInterfaceSubClass == HubInterfaceSubClass::Hub)
|
InterfaceClass bInterfaceClass;
|
||||||
HubInterfaceProtocol bInterfaceProtocol;
|
if (bInterfaceClass == InterfaceClass::Hub) {
|
||||||
else
|
HubInterfaceSubClass bInterfaceSubClass;
|
||||||
u8 bInterfaceProtocol;
|
if (bInterfaceSubClass == HubInterfaceSubClass::Hub)
|
||||||
} else if (bInterfaceClass == InterfaceClass::AudioVideoDevice) {
|
HubInterfaceProtocol bInterfaceProtocol;
|
||||||
AudioVideoDeviceSubClass bInterfaceSubClass;
|
else
|
||||||
u8 bInterfaceProtocol;
|
u8 bInterfaceProtocol;
|
||||||
} else {
|
} else if (bInterfaceClass == InterfaceClass::AudioVideoDevice) {
|
||||||
u8 bInterfaceSubClass;
|
AudioVideoDeviceSubClass bInterfaceSubClass;
|
||||||
u8 bInterfaceProtocol;
|
u8 bInterfaceProtocol;
|
||||||
}
|
} else {
|
||||||
|
u8 bInterfaceSubClass;
|
||||||
u8 iInterface;
|
u8 bInterfaceProtocol;
|
||||||
};
|
}
|
||||||
|
|
||||||
enum EndpointDirection : u8 {
|
u8 iInterface;
|
||||||
OUT = 0,
|
};
|
||||||
IN = 1
|
|
||||||
};
|
enum EndpointDirection : u8 {
|
||||||
|
OUT = 0,
|
||||||
fn format_direction(u8 value) {
|
IN = 1
|
||||||
EndpointDirection direction;
|
};
|
||||||
direction = value;
|
|
||||||
return direction;
|
fn format_direction(u8 value) {
|
||||||
};
|
EndpointDirection direction;
|
||||||
|
direction = value;
|
||||||
bitfield EndpointAddress {
|
return direction;
|
||||||
Direction : 1 [[format("format_direction")]];
|
};
|
||||||
padding : 3;
|
|
||||||
EndpointNumber : 4;
|
bitfield EndpointAddress {
|
||||||
} [[left_to_right]];
|
EndpointNumber : 4;
|
||||||
|
padding : 3;
|
||||||
bitfield EndpointAttributes {
|
Direction : 1 [[format("format_direction")]];
|
||||||
TransferType : 2;
|
};
|
||||||
SynchronizationType : 2;
|
|
||||||
UsageType : 2;
|
bitfield EndpointAttributes {
|
||||||
} [[right_to_left]];
|
TransferType : 2;
|
||||||
|
SynchronizationType : 2;
|
||||||
struct EndpointDescriptor {
|
UsageType : 2;
|
||||||
EndpointAddress bEndPointAddress;
|
};
|
||||||
EndpointAttributes bmAttributes;
|
|
||||||
u16 wMaxPacketSize;
|
struct EndpointDescriptor {
|
||||||
u8 bInterval;
|
EndpointAddress bEndPointAddress;
|
||||||
};
|
EndpointAttributes bmAttributes;
|
||||||
|
u16 wMaxPacketSize;
|
||||||
struct OtherSpeedConfigurationDescriptor {
|
u8 bInterval;
|
||||||
ConfigDescriptor content [[inline]];
|
};
|
||||||
};
|
|
||||||
|
struct OtherSpeedConfigurationDescriptor {
|
||||||
struct DeviceQualifierDescriptor {
|
ConfigDescriptor content [[inline]];
|
||||||
DeviceDescriptor deviceDescriptor [[inline]];
|
};
|
||||||
u8 bMaxPacketSize0;
|
|
||||||
u8 bNumConfigurations;
|
struct DeviceQualifierDescriptor {
|
||||||
padding[1];
|
DeviceDescriptor deviceDescriptor [[inline]];
|
||||||
};
|
u8 bMaxPacketSize0;
|
||||||
|
u8 bNumConfigurations;
|
||||||
bitfield OTGAttributes {
|
padding[1];
|
||||||
SRPSupport : 1;
|
};
|
||||||
HNPSupport : 1;
|
|
||||||
} [[right_to_left]];
|
bitfield OTGAttributes {
|
||||||
|
SRPSupport : 1;
|
||||||
struct OTGDescriptor {
|
HNPSupport : 1;
|
||||||
OTGAttributes bmAttributes;
|
} [[right_to_left]];
|
||||||
};
|
|
||||||
|
struct OTGDescriptor {
|
||||||
struct HIDDescriptor {
|
OTGAttributes bmAttributes;
|
||||||
BCD<2> bcdVersion;
|
};
|
||||||
CountryCode bCountryCode;
|
|
||||||
u8 bNumDescriptors;
|
struct HIDDescriptor {
|
||||||
DescriptorType bDescriptorType;
|
BCD<2> bcdVersion;
|
||||||
u16 wDescriptorLength;
|
CountryCode bCountryCode;
|
||||||
};
|
u8 bNumDescriptors;
|
||||||
|
DescriptorType bDescriptorType;
|
||||||
struct USBDescriptor {
|
u16 wDescriptorLength;
|
||||||
u8 bLength;
|
};
|
||||||
DescriptorType bDescriptorType;
|
|
||||||
|
struct USBDescriptor {
|
||||||
if (bDescriptorType == DescriptorType::DeviceDescriptor)
|
u8 bLength;
|
||||||
DeviceDescriptor deviceDescriptor [[inline]];
|
DescriptorType bDescriptorType;
|
||||||
else if (bDescriptorType == DescriptorType::ConfigDescriptor)
|
|
||||||
ConfigDescriptor configDescriptor [[inline]];
|
if (bDescriptorType == DescriptorType::DeviceDescriptor)
|
||||||
else if (bDescriptorType == DescriptorType::StringDescriptor)
|
DeviceDescriptor deviceDescriptor [[inline]];
|
||||||
StringDescriptor stringDescriptor [[inline]];
|
else if (bDescriptorType == DescriptorType::ConfigDescriptor)
|
||||||
else if (bDescriptorType == DescriptorType::InterfaceDescriptor)
|
ConfigDescriptor configDescriptor [[inline]];
|
||||||
InterfaceDescriptor interfaceDescriptor [[inline]];
|
else if (bDescriptorType == DescriptorType::StringDescriptor)
|
||||||
else if (bDescriptorType == DescriptorType::EndpointDescriptor)
|
StringDescriptor stringDescriptor [[inline]];
|
||||||
EndpointDescriptor endpointDescriptor [[inline]];
|
else if (bDescriptorType == DescriptorType::InterfaceDescriptor)
|
||||||
else if (bDescriptorType == DescriptorType::OtherSpeedConfigurationDescriptor)
|
InterfaceDescriptor interfaceDescriptor [[inline]];
|
||||||
OtherSpeedConfigurationDescriptor otherSpeedConfigurationDescriptor [[inline]];
|
else if (bDescriptorType == DescriptorType::EndpointDescriptor)
|
||||||
else if (bDescriptorType == DescriptorType::DeviceQualifierDescriptor)
|
EndpointDescriptor endpointDescriptor [[inline]];
|
||||||
DeviceQualifierDescriptor deviceQualifierDescriptor [[inline]];
|
else if (bDescriptorType == DescriptorType::OtherSpeedConfigurationDescriptor)
|
||||||
else if (bDescriptorType == DescriptorType::OTGDescriptor)
|
OtherSpeedConfigurationDescriptor otherSpeedConfigurationDescriptor [[inline]];
|
||||||
OTGDescriptor otgDescriptor [[inline]];
|
else if (bDescriptorType == DescriptorType::DeviceQualifierDescriptor)
|
||||||
else if (bDescriptorType == DescriptorType::HIDDescriptor)
|
DeviceQualifierDescriptor deviceQualifierDescriptor [[inline]];
|
||||||
HIDDescriptor hidDescriptor [[inline]];
|
else if (bDescriptorType == DescriptorType::OTGDescriptor)
|
||||||
|
OTGDescriptor otgDescriptor [[inline]];
|
||||||
padding[bLength - ($ - addressof(this))];
|
else if (bDescriptorType == DescriptorType::HIDDescriptor)
|
||||||
};
|
HIDDescriptor hidDescriptor [[inline]];
|
||||||
|
|
||||||
|
padding[bLength - ($ - addressof(this))];
|
||||||
|
};
|
||||||
|
|
||||||
USBDescriptor descriptors[while(!std::mem::eof())] @ 0x00;
|
USBDescriptor descriptors[while(!std::mem::eof())] @ 0x00;
|
||||||
@@ -22,7 +22,7 @@ bitfield AllowedMedia {
|
|||||||
padding : 20;
|
padding : 20;
|
||||||
NonSecureHardDisk : 1;
|
NonSecureHardDisk : 1;
|
||||||
NonSecureMode : 1;
|
NonSecureMode : 1;
|
||||||
} [[right_to_left]];
|
};
|
||||||
|
|
||||||
bitfield GameRegion {
|
bitfield GameRegion {
|
||||||
NorthAmerica : 1;
|
NorthAmerica : 1;
|
||||||
@@ -30,7 +30,7 @@ bitfield GameRegion {
|
|||||||
RestOfTheWorld : 1;
|
RestOfTheWorld : 1;
|
||||||
padding : 28;
|
padding : 28;
|
||||||
Manufacturing : 1;
|
Manufacturing : 1;
|
||||||
} [[right_to_left]];
|
};
|
||||||
|
|
||||||
struct Certificate {
|
struct Certificate {
|
||||||
type::Size<u32> certificateSize;
|
type::Size<u32> certificateSize;
|
||||||
@@ -52,7 +52,7 @@ bitfield InitializationFlags {
|
|||||||
Limit64Megabytes : 1;
|
Limit64Megabytes : 1;
|
||||||
DontSetuptHarddisk : 1;
|
DontSetuptHarddisk : 1;
|
||||||
padding : 28;
|
padding : 28;
|
||||||
} [[right_to_left]];
|
};
|
||||||
|
|
||||||
union EntryPoint {
|
union EntryPoint {
|
||||||
u32 betaAddress [[format("format_beta_entrypoint")]];
|
u32 betaAddress [[format("format_beta_entrypoint")]];
|
||||||
@@ -333,7 +333,7 @@ bitfield LibraryFlags {
|
|||||||
QFEVersion : 13;
|
QFEVersion : 13;
|
||||||
Approved : 2;
|
Approved : 2;
|
||||||
DebugBuild : 1;
|
DebugBuild : 1;
|
||||||
} [[right_to_left]];
|
};
|
||||||
|
|
||||||
struct LibraryVersion {
|
struct LibraryVersion {
|
||||||
char libraryName[8];
|
char libraryName[8];
|
||||||
@@ -349,7 +349,7 @@ bitfield SectionFlags {
|
|||||||
HeadPageReadOnly : 1;
|
HeadPageReadOnly : 1;
|
||||||
TailPageReadOnly : 1;
|
TailPageReadOnly : 1;
|
||||||
padding : 26;
|
padding : 26;
|
||||||
} [[right_to_left]];
|
};
|
||||||
|
|
||||||
struct SectionHeader {
|
struct SectionHeader {
|
||||||
SectionFlags sectionFlags;
|
SectionFlags sectionFlags;
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
// https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md
|
// https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md
|
||||||
|
|
||||||
#pragma MIME application/zstd
|
#pragma MIME application/zstd
|
||||||
|
|
||||||
|
#include <std/core.pat>
|
||||||
#include <std/io.pat>
|
#include <std/io.pat>
|
||||||
#include <std/mem.pat>
|
#include <std/mem.pat>
|
||||||
#include <std/sys.pat>
|
#include <std/sys.pat>
|
||||||
|
|
||||||
|
using BitfieldOrder = std::core::BitfieldOrder;
|
||||||
|
|
||||||
#define ZSTD_MAGIC_NUMBER 0xFD2FB528
|
#define ZSTD_MAGIC_NUMBER 0xFD2FB528
|
||||||
|
|
||||||
bitfield frame_header_descriptor_t {
|
bitfield frame_header_descriptor_t {
|
||||||
@@ -15,12 +18,12 @@ bitfield frame_header_descriptor_t {
|
|||||||
reserved_bit : 1;
|
reserved_bit : 1;
|
||||||
content_checksum_flag : 1;
|
content_checksum_flag : 1;
|
||||||
dictionary_id_flag : 2;
|
dictionary_id_flag : 2;
|
||||||
} [[left_to_right]];
|
} [[bitfield_order(BitfieldOrder::MostToLeastSignificant, 8)]];
|
||||||
|
|
||||||
bitfield window_descriptor_t {
|
bitfield window_descriptor_t {
|
||||||
exponent : 5;
|
exponent : 5;
|
||||||
mantissa : 3;
|
mantissa : 3;
|
||||||
} [[left_to_right]];
|
} [[bitfield_order(BitfieldOrder::MostToLeastSignificant, 8)]];
|
||||||
|
|
||||||
fn window_size(window_descriptor_t window_descriptor) {
|
fn window_size(window_descriptor_t window_descriptor) {
|
||||||
u64 window_log = 10 + window_descriptor.exponent;
|
u64 window_log = 10 + window_descriptor.exponent;
|
||||||
@@ -67,7 +70,7 @@ bitfield block_header_t {
|
|||||||
last_block : 1;
|
last_block : 1;
|
||||||
block_type : 2;
|
block_type : 2;
|
||||||
block_size : 21;
|
block_size : 21;
|
||||||
} [[right_to_left]];
|
};
|
||||||
|
|
||||||
enum block_type : u8 {
|
enum block_type : u8 {
|
||||||
raw_block = 0,
|
raw_block = 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user