#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
use std::fmt;
use bitflags::bitflags;
use num_derive::FromPrimitive;
use scroll::{Endian, Pread, Pwrite, SizeWith};
use smart_default::SmartDefault;
pub type RVA = u32;
pub type RVA64 = u64;
pub const MINIDUMP_SIGNATURE: u32 = 0x504d444d;
pub const MINIDUMP_VERSION: u32 = 42899;
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_HEADER {
pub signature: u32,
pub version: u32,
pub stream_count: u32,
pub stream_directory_rva: RVA,
pub checksum: u32,
pub time_date_stamp: u32,
pub flags: u64,
}
#[derive(Debug, Copy, Default, Clone, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_LOCATION_DESCRIPTOR {
pub data_size: u32,
pub rva: RVA,
}
impl From<u8> for MINIDUMP_LOCATION_DESCRIPTOR {
fn from(_val: u8) -> Self {
Self::default()
}
}
#[derive(Debug, Copy, Clone, Default, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_MEMORY_DESCRIPTOR {
pub start_of_memory_range: u64,
pub memory: MINIDUMP_LOCATION_DESCRIPTOR,
}
#[derive(Debug, Copy, Clone, Default, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_MEMORY_DESCRIPTOR64 {
pub start_of_memory_range: u64,
pub data_size: u64,
}
#[derive(Debug, Clone, Default, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_DIRECTORY {
pub stream_type: u32,
pub location: MINIDUMP_LOCATION_DESCRIPTOR,
}
#[repr(u32)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, FromPrimitive)]
pub enum MINIDUMP_STREAM_TYPE {
UnusedStream = 0,
ReservedStream0 = 1,
ReservedStream1 = 2,
ThreadListStream = 3,
ModuleListStream = 4,
MemoryListStream = 5,
ExceptionStream = 6,
SystemInfoStream = 7,
ThreadExListStream = 8,
Memory64ListStream = 9,
CommentStreamA = 10,
CommentStreamW = 11,
HandleDataStream = 12,
FunctionTable = 13,
UnloadedModuleListStream = 14,
MiscInfoStream = 15,
MemoryInfoListStream = 16,
ThreadInfoListStream = 17,
HandleOperationListStream = 18,
TokenStream = 19,
JavaScriptDataStream = 20,
SystemMemoryInfoStream = 21,
ProcessVmCountersStream = 22,
IptTraceStream = 23,
ThreadNamesStream = 24,
ceStreamNull = 0x00008000,
ceStreamSystemInfo = 0x00008001,
ceStreamException = 0x00008002,
ceStreamModuleList = 0x00008003,
ceStreamProcessList = 0x00008004,
ceStreamThreadList = 0x00008005,
ceStreamThreadContextList = 0x00008006,
ceStreamThreadCallStackList = 0x00008007,
ceStreamMemoryVirtualList = 0x00008008,
ceStreamMemoryPhysicalList = 0x00008009,
ceStreamBucketParameters = 0x0000800a,
ceStreamProcessModuleMap = 0x0000800b,
ceStreamDiagnosisList = 0x0000800c,
LastReservedStream = 0x0000ffff,
BreakpadInfoStream = 0x47670001,
AssertionInfoStream = 0x47670002,
LinuxCpuInfo = 0x47670003,
LinuxProcStatus = 0x47670004,
LinuxLsbRelease = 0x47670005,
LinuxCmdLine = 0x47670006,
LinuxEnviron = 0x47670007,
LinuxAuxv = 0x47670008,
LinuxMaps = 0x47670009,
LinuxDsoDebug = 0x4767000A,
CrashpadInfoStream = 0x43500001,
StabilityReportStream = 0x4b6b0002,
MozMacosCrashInfoStream = 0x4d7a0001,
MozMacosBootargsStream = 0x4d7a0002,
MozLinuxLimits = 0x4d7a0003,
MozSoftErrors = 0x4d7a0004,
}
impl From<MINIDUMP_STREAM_TYPE> for u32 {
fn from(ty: MINIDUMP_STREAM_TYPE) -> Self {
ty as u32
}
}
#[derive(Debug, Clone, Default, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_THREAD_NAME {
pub thread_id: u32,
pub thread_name_rva: RVA64,
}
#[derive(Debug, Clone, Default, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_MODULE {
pub base_of_image: u64,
pub size_of_image: u32,
pub checksum: u32,
pub time_date_stamp: u32,
pub module_name_rva: RVA,
pub version_info: VS_FIXEDFILEINFO,
pub cv_record: MINIDUMP_LOCATION_DESCRIPTOR,
pub misc_record: MINIDUMP_LOCATION_DESCRIPTOR,
pub reserved0: [u32; 2],
pub reserved1: [u32; 2],
}
#[derive(Debug, Clone, Default, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_UNLOADED_MODULE {
pub base_of_image: u64,
pub size_of_image: u32,
pub checksum: u32,
pub time_date_stamp: u32,
pub module_name_rva: RVA,
}
#[derive(Debug, Clone, Default, Pread, Pwrite, SizeWith)]
pub struct VS_FIXEDFILEINFO {
pub signature: u32,
pub struct_version: u32,
pub file_version_hi: u32,
pub file_version_lo: u32,
pub product_version_hi: u32,
pub product_version_lo: u32,
pub file_flags_mask: u32,
pub file_flags: u32,
pub file_os: u32,
pub file_type: u32,
pub file_subtype: u32,
pub file_date_hi: u32,
pub file_date_lo: u32,
}
pub const VS_FFI_SIGNATURE: u32 = 0xfeef04bd;
pub const VS_FFI_STRUCVERSION: u32 = 0x00010000;
#[repr(u32)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, FromPrimitive)]
pub enum CvSignature {
Pdb20 = 0x3031424e,
Pdb70 = 0x53445352,
Elf = 0x4270454c,
Cv41 = 0x3930424e,
Cv50 = 0x3131424e,
}
#[derive(Debug, Clone)]
pub struct CV_INFO_PDB20 {
pub cv_signature: u32,
pub cv_offset: u32,
pub signature: u32,
pub age: u32,
pub pdb_file_name: Vec<u8>,
}
impl scroll::ctx::TryFromCtx<'_, Endian> for CV_INFO_PDB20 {
type Error = scroll::Error;
fn try_from_ctx(src: &[u8], endian: Endian) -> Result<(Self, usize), Self::Error> {
let offset = &mut 0;
Ok((
CV_INFO_PDB20 {
cv_signature: src.gread_with(offset, endian)?,
cv_offset: src.gread_with(offset, endian)?,
signature: src.gread_with(offset, endian)?,
age: src.gread_with(offset, endian)?,
pdb_file_name: {
let size = src.len() - *offset;
src.gread_with::<&[u8]>(offset, size)?.to_owned()
},
},
*offset,
))
}
}
#[derive(Debug, Clone)]
pub struct CV_INFO_PDB70 {
pub cv_signature: u32,
pub signature: GUID,
pub age: u32,
pub pdb_file_name: Vec<u8>,
}
impl scroll::ctx::TryFromCtx<'_, Endian> for CV_INFO_PDB70 {
type Error = scroll::Error;
fn try_from_ctx(src: &[u8], endian: Endian) -> Result<(Self, usize), Self::Error> {
let offset = &mut 0;
Ok((
CV_INFO_PDB70 {
cv_signature: src.gread_with(offset, endian)?,
signature: src.gread_with(offset, endian)?,
age: src.gread_with(offset, endian)?,
pdb_file_name: {
let size = src.len() - *offset;
src.gread_with::<&[u8]>(offset, size)?.to_owned()
},
},
*offset,
))
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Pread, Pwrite, SizeWith)]
pub struct GUID {
pub data1: u32,
pub data2: u16,
pub data3: u16,
pub data4: [u8; 8],
}
impl From<[u8; 16]> for GUID {
fn from(uuid: [u8; 16]) -> Self {
let data1 = ((uuid[0] as u32) << 24)
| ((uuid[1] as u32) << 16)
| ((uuid[2] as u32) << 8)
| uuid[3] as u32;
let data2 = ((uuid[4] as u16) << 8) | uuid[5] as u16;
let data3 = ((uuid[6] as u16) << 8) | uuid[7] as u16;
let mut data4 = [0u8; 8];
data4.copy_from_slice(&uuid[8..]);
Self {
data1,
data2,
data3,
data4,
}
}
}
impl fmt::Display for GUID {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if f.alternate() {
write!(
f,
"{:08X}{:04X}{:04X}{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}",
self.data1,
self.data2,
self.data3,
self.data4[0],
self.data4[1],
self.data4[2],
self.data4[3],
self.data4[4],
self.data4[5],
self.data4[6],
self.data4[7],
)
} else {
write!(
f,
"{:08x}-{:04x}-{:04x}-{:02x}{:02x}-{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
self.data1,
self.data2,
self.data3,
self.data4[0],
self.data4[1],
self.data4[2],
self.data4[3],
self.data4[4],
self.data4[5],
self.data4[6],
self.data4[7],
)
}
}
}
#[derive(Debug, Clone)]
pub struct CV_INFO_ELF {
pub cv_signature: u32,
pub build_id: Vec<u8>,
}
impl<'a> scroll::ctx::TryFromCtx<'a, Endian> for CV_INFO_ELF {
type Error = scroll::Error;
fn try_from_ctx(src: &'a [u8], endian: Endian) -> Result<(Self, usize), Self::Error> {
let offset = &mut 0;
Ok((
CV_INFO_ELF {
cv_signature: src.gread_with(offset, endian)?,
build_id: {
let size = src.len() - *offset;
src.gread_with::<&[u8]>(offset, size)?.to_owned()
},
},
*offset,
))
}
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct IMAGE_DEBUG_MISC {
pub data_type: u32,
pub length: u32,
pub unicode: u8,
pub reserved: [u8; 3],
pub data: [u8; 1],
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_THREAD {
pub thread_id: u32,
pub suspend_count: u32,
pub priority_class: u32,
pub priority: u32,
pub teb: u64,
pub stack: MINIDUMP_MEMORY_DESCRIPTOR,
pub thread_context: MINIDUMP_LOCATION_DESCRIPTOR,
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_EXCEPTION_STREAM {
pub thread_id: u32,
pub __align: u32,
pub exception_record: MINIDUMP_EXCEPTION,
pub thread_context: MINIDUMP_LOCATION_DESCRIPTOR,
}
#[derive(Debug, Clone, Default, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_EXCEPTION {
pub exception_code: u32,
pub exception_flags: u32,
pub exception_record: u64,
pub exception_address: u64,
pub number_parameters: u32,
pub __align: u32,
pub exception_information: [u64; 15], }
pub const CONTEXT_CPU_MASK: u32 = 0xffffff00;
pub const CONTEXT_HAS_XSTATE: u32 = 0x00000040;
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ContextFlagsCpu: u32 {
const CONTEXT_IA64 = 0x80000;
const CONTEXT_SHX = 0xc0;
const CONTEXT_ARM_OLD = 0x40;
const CONTEXT_ALPHA = 0x20000;
const CONTEXT_AMD64 = 0x100000;
const CONTEXT_ARM = 0x40000000;
const CONTEXT_ARM64 = 0x400000;
const CONTEXT_ARM64_OLD = 0x80000000;
const CONTEXT_MIPS = 0x40000;
const CONTEXT_MIPS64 = 0x80000;
const CONTEXT_PPC = 0x20000000;
const CONTEXT_PPC64 = 0x1000000;
const CONTEXT_SPARC = 0x10000000;
const CONTEXT_X86 = 0x10000;
}
}
impl ContextFlagsCpu {
pub fn from_flags(flags: u32) -> ContextFlagsCpu {
ContextFlagsCpu::from_bits_truncate(flags & CONTEXT_CPU_MASK)
}
}
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ContextFlagsAmd64: u32 {
const CONTEXT_AMD64_CONTROL = 0x00000001 | ContextFlagsCpu::CONTEXT_AMD64.bits();
const CONTEXT_AMD64_INTEGER = 0x00000002 | ContextFlagsCpu::CONTEXT_AMD64.bits();
const CONTEXT_AMD64_SEGMENTS = 0x00000004 | ContextFlagsCpu::CONTEXT_AMD64.bits();
const CONTEXT_AMD64_FLOATING_POINT = 0x00000008 | ContextFlagsCpu::CONTEXT_AMD64.bits();
const CONTEXT_AMD64_DEBUG_REGISTERS = 0x00000010 | ContextFlagsCpu::CONTEXT_AMD64.bits();
const CONTEXT_AMD64_XSTATE = 0x00000020 | ContextFlagsCpu::CONTEXT_AMD64.bits();
const CONTEXT_AMD64_FULL = Self::CONTEXT_AMD64_CONTROL.bits() | Self::CONTEXT_AMD64_INTEGER.bits() | Self::CONTEXT_AMD64_FLOATING_POINT.bits();
const CONTEXT_AMD64_ALL = Self::CONTEXT_AMD64_FULL.bits() | Self::CONTEXT_AMD64_SEGMENTS.bits() | Self::CONTEXT_AMD64_DEBUG_REGISTERS.bits();
}
}
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ContextFlagsX86: u32 {
const CONTEXT_X86_CONTROL = 0x00000001 | ContextFlagsCpu::CONTEXT_X86.bits();
const CONTEXT_X86_INTEGER = 0x00000002 | ContextFlagsCpu::CONTEXT_X86.bits();
const CONTEXT_X86_SEGMENTS = 0x00000004 | ContextFlagsCpu::CONTEXT_X86.bits();
const CONTEXT_X86_FLOATING_POINT = 0x00000008 | ContextFlagsCpu::CONTEXT_X86.bits();
const CONTEXT_X86_DEBUG_REGISTERS = 0x00000010 | ContextFlagsCpu::CONTEXT_X86.bits();
const CONTEXT_X86_EXTENDED_REGISTERS = 0x00000020 | ContextFlagsCpu::CONTEXT_X86.bits();
const CONTEXT_X86_XSTATE = 0x00000040 | ContextFlagsCpu::CONTEXT_X86.bits();
const CONTEXT_X86_FULL = Self::CONTEXT_X86_CONTROL.bits() | Self::CONTEXT_X86_INTEGER.bits() | Self::CONTEXT_X86_SEGMENTS.bits();
const CONTEXT_X86_ALL = Self::CONTEXT_X86_FULL.bits() | Self::CONTEXT_X86_FLOATING_POINT.bits() | Self::CONTEXT_X86_DEBUG_REGISTERS.bits() | Self::CONTEXT_X86_EXTENDED_REGISTERS.bits();
}
}
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ContextFlagsArm64: u32 {
const CONTEXT_ARM64_CONTROL = 0x00000001 | ContextFlagsCpu::CONTEXT_ARM64.bits();
const CONTEXT_ARM64_INTEGER = 0x00000002 | ContextFlagsCpu::CONTEXT_ARM64.bits();
const CONTEXT_ARM64_FLOATING_POINT = 0x00000004 | ContextFlagsCpu::CONTEXT_ARM64.bits();
const CONTEXT_ARM64_DEBUG_REGISTERS = 0x0000008 | ContextFlagsCpu::CONTEXT_ARM64.bits();
const CONTEXT_ARM64_X18 = 0x0000010 | ContextFlagsCpu::CONTEXT_ARM64.bits();
const CONTEXT_ARM64_FULL = Self::CONTEXT_ARM64_CONTROL.bits() | Self::CONTEXT_ARM64_INTEGER.bits() | Self::CONTEXT_ARM64_FLOATING_POINT.bits();
const CONTEXT_ARM64_ALL = Self::CONTEXT_ARM64_FULL.bits() | Self::CONTEXT_ARM64_DEBUG_REGISTERS.bits() | Self::CONTEXT_ARM64_X18.bits();
}
}
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ContextFlagsArm64Old: u32 {
const CONTEXT_ARM64_OLD_INTEGER = 0x00000002 | ContextFlagsCpu::CONTEXT_ARM64_OLD.bits();
const CONTEXT_ARM64_OLD_FLOATING_POINT = 0x00000004 | ContextFlagsCpu::CONTEXT_ARM64_OLD.bits();
const CONTEXT_ARM64_OLD_FULL = Self::CONTEXT_ARM64_OLD_INTEGER.bits() | Self::CONTEXT_ARM64_OLD_FLOATING_POINT.bits();
const CONTEXT_ARM64_OLD_ALL = Self::CONTEXT_ARM64_OLD_FULL.bits();
}
}
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ContextFlagsArm: u32 {
const CONTEXT_ARM_CONTROL = 0x00000001 | ContextFlagsCpu::CONTEXT_ARM.bits();
const CONTEXT_ARM_INTEGER = 0x00000002 | ContextFlagsCpu::CONTEXT_ARM.bits();
const CONTEXT_ARM_FLOATING_POINT = 0x00000004 | ContextFlagsCpu::CONTEXT_ARM.bits();
const CONTEXT_ARM_DEBUG_REGISTERS = 0x00000008 | ContextFlagsCpu::CONTEXT_ARM.bits();
const CONTEXT_ARM_FULL = Self::CONTEXT_ARM_CONTROL.bits() | Self::CONTEXT_ARM_INTEGER.bits() | Self::CONTEXT_ARM_FLOATING_POINT.bits();
const CONTEXT_ARM_ALL = Self::CONTEXT_ARM_FULL.bits() | Self::CONTEXT_ARM_DEBUG_REGISTERS.bits();
}
}
#[derive(Debug, SmartDefault, Clone, Pread, Pwrite, SizeWith)]
pub struct XMM_SAVE_AREA32 {
pub control_word: u16,
pub status_word: u16,
pub tag_word: u8,
pub reserved1: u8,
pub error_opcode: u16,
pub error_offset: u32,
pub error_selector: u16,
pub reserved2: u16,
pub data_offset: u32,
pub data_selector: u16,
pub reserved3: u16,
pub mx_csr: u32,
pub mx_csr_mask: u32,
#[default([0; 8])]
pub float_registers: [u128; 8],
#[default([0; 16])]
pub xmm_registers: [u128; 16],
#[default([0; 96])]
pub reserved4: [u8; 96],
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct SSE_REGISTERS {
pub header: [u128; 2],
pub legacy: [u128; 8],
pub xmm0: u128,
pub xmm1: u128,
pub xmm2: u128,
pub xmm3: u128,
pub xmm4: u128,
pub xmm5: u128,
pub xmm6: u128,
pub xmm7: u128,
pub xmm8: u128,
pub xmm9: u128,
pub xmm10: u128,
pub xmm11: u128,
pub xmm12: u128,
pub xmm13: u128,
pub xmm14: u128,
pub xmm15: u128,
}
#[derive(Debug, SmartDefault, Clone, Pread, Pwrite, SizeWith)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct CONTEXT_AMD64 {
pub p1_home: u64,
pub p2_home: u64,
pub p3_home: u64,
pub p4_home: u64,
pub p5_home: u64,
pub p6_home: u64,
pub context_flags: u32,
pub mx_csr: u32,
pub cs: u16,
pub ds: u16,
pub es: u16,
pub fs: u16,
pub gs: u16,
pub ss: u16,
pub eflags: u32,
pub dr0: u64,
pub dr1: u64,
pub dr2: u64,
pub dr3: u64,
pub dr6: u64,
pub dr7: u64,
pub rax: u64,
pub rcx: u64,
pub rdx: u64,
pub rbx: u64,
pub rsp: u64,
pub rbp: u64,
pub rsi: u64,
pub rdi: u64,
pub r8: u64,
pub r9: u64,
pub r10: u64,
pub r11: u64,
pub r12: u64,
pub r13: u64,
pub r14: u64,
pub r15: u64,
pub rip: u64,
#[default([0; 512])]
pub float_save: [u8; 512],
#[default([0; 26])]
pub vector_register: [u128; 26],
pub vector_control: u64,
pub debug_control: u64,
pub last_branch_to_rip: u64,
pub last_branch_from_rip: u64,
pub last_exception_to_rip: u64,
pub last_exception_from_rip: u64,
}
#[derive(Debug, Clone, Default, Pread, Pwrite, SizeWith)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct FLOATING_SAVE_AREA_ARM {
pub fpscr: u64,
pub regs: [u64; 32],
pub extra: [u32; 8],
}
#[derive(Debug, Clone, Default, Pread, Pwrite, SizeWith)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct CONTEXT_ARM {
pub context_flags: u32,
pub iregs: [u32; 16],
pub cpsr: u32,
pub float_save: FLOATING_SAVE_AREA_ARM,
}
#[repr(usize)]
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum ArmRegisterNumbers {
IosFramePointer = 7,
FramePointer = 11,
StackPointer = 13,
LinkRegister = 14,
ProgramCounter = 15,
}
impl ArmRegisterNumbers {
pub const fn name(self) -> &'static str {
match self {
Self::IosFramePointer => "r7",
Self::FramePointer => "r11",
Self::StackPointer => "r13",
Self::LinkRegister => "r14",
Self::ProgramCounter => "r15",
}
}
}
#[derive(Debug, Clone, Copy, Default, Pread, Pwrite, SizeWith)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct CONTEXT_ARM64_OLD {
pub context_flags: u64,
pub iregs: [u64; 31],
pub sp: u64,
pub pc: u64,
pub cpsr: u32,
pub fpsr: u32,
pub fpcr: u32,
pub float_regs: [u128; 32usize],
}
#[derive(Debug, Default, Clone, Pread, Pwrite, SizeWith)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct CONTEXT_ARM64 {
pub context_flags: u32,
pub cpsr: u32,
pub iregs: [u64; 31],
pub sp: u64,
pub pc: u64,
pub float_regs: [u128; 32usize],
pub fpcr: u32,
pub fpsr: u32,
pub bcr: [u32; 8],
pub bvr: [u64; 8],
pub wcr: [u32; 2],
pub wvr: [u64; 2],
}
#[repr(usize)]
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum Arm64RegisterNumbers {
FramePointer = 29,
LinkRegister = 30,
}
impl Arm64RegisterNumbers {
pub const fn name(self) -> &'static str {
match self {
Self::FramePointer => "x29",
Self::LinkRegister => "x30",
}
}
}
#[derive(Debug, Default, Clone, Pread, Pwrite, SizeWith)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct FLOATING_SAVE_AREA_MIPS {
pub regs: [u64; 32],
pub fpcsr: u32,
pub fir: u32,
}
#[derive(Debug, Default, Clone, Pread, Pwrite, SizeWith)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct CONTEXT_MIPS {
pub context_flags: u32,
pub _pad0: u32,
pub iregs: [u64; 32],
pub mdhi: u64,
pub mdlo: u64,
pub hi: [u32; 3],
pub lo: [u32; 3],
pub dsp_control: u32,
pub _pad1: u32,
pub epc: u64,
pub badvaddr: u64,
pub status: u32,
pub cause: u32,
pub float_save: FLOATING_SAVE_AREA_MIPS,
}
#[repr(usize)]
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum MipsRegisterNumbers {
S0 = 16,
S1 = 17,
S2 = 18,
S3 = 19,
S4 = 20,
S5 = 21,
S6 = 22,
S7 = 23,
GlobalPointer = 28,
StackPointer = 29,
FramePointer = 30,
ReturnAddress = 31,
}
impl MipsRegisterNumbers {
pub const fn name(self) -> &'static str {
match self {
MipsRegisterNumbers::S0 => "s0",
MipsRegisterNumbers::S1 => "s1",
MipsRegisterNumbers::S2 => "s2",
MipsRegisterNumbers::S3 => "s3",
MipsRegisterNumbers::S4 => "s4",
MipsRegisterNumbers::S5 => "s5",
MipsRegisterNumbers::S6 => "s6",
MipsRegisterNumbers::S7 => "s7",
MipsRegisterNumbers::GlobalPointer => "gp",
MipsRegisterNumbers::StackPointer => "sp",
MipsRegisterNumbers::FramePointer => "fp",
MipsRegisterNumbers::ReturnAddress => "ra",
}
}
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct FLOATING_SAVE_AREA_PPC {
pub fpregs: [u64; 32],
pub fpscr_pad: u32,
pub fpscr: u32,
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct VECTOR_SAVE_AREA_PPC {
pub save_vr: [u128; 32],
pub save_vscr: u128,
pub save_pad5: [u32; 4],
pub save_vrvalid: u32,
pub save_pad6: [u32; 7],
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct CONTEXT_PPC {
pub context_flags: u32,
pub srr0: u32,
pub srr1: u32,
pub gpr: [u32; 32],
pub cr: u32,
pub xer: u32,
pub lr: u32,
pub ctr: u32,
pub mq: u32,
pub vrsave: u32,
pub float_save: FLOATING_SAVE_AREA_PPC,
pub vector_save: VECTOR_SAVE_AREA_PPC,
}
#[repr(usize)]
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum PpcRegisterNumbers {
StackPointer = 1,
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct CONTEXT_PPC64 {
pub context_flags: u64,
pub srr0: u64,
pub srr1: u64,
pub gpr: [u64; 32],
pub cr: u64,
pub xer: u64,
pub lr: u64,
pub ctr: u64,
pub vrsave: u64,
pub float_save: FLOATING_SAVE_AREA_PPC,
pub vector_save: VECTOR_SAVE_AREA_PPC,
}
#[repr(usize)]
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum Ppc64RegisterNumbers {
StackPointer = 1,
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct FLOATING_SAVE_AREA_SPARC {
pub regs: [u64; 32],
pub filler: u64,
pub fsr: u64,
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct CONTEXT_SPARC {
pub context_flags: u32,
pub flag_pad: u32,
pub g_r: [u64; 32],
pub ccr: u64,
pub pc: u64,
pub npc: u64,
pub y: u64,
pub asi: u64,
pub fprs: u64,
pub float_save: FLOATING_SAVE_AREA_SPARC,
}
#[repr(usize)]
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum SparcRegisterNumbers {
StackPointer = 14,
}
#[derive(Debug, Clone, SmartDefault, Pread, Pwrite, SizeWith)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct FLOATING_SAVE_AREA_X86 {
pub control_word: u32,
pub status_word: u32,
pub tag_word: u32,
pub error_offset: u32,
pub error_selector: u32,
pub data_offset: u32,
pub data_selector: u32,
#[default([0; 80])]
pub register_area: [u8; 80], pub cr0_npx_state: u32,
}
#[derive(Debug, Clone, SmartDefault, Pread, Pwrite, SizeWith)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct CONTEXT_X86 {
pub context_flags: u32,
pub dr0: u32,
pub dr1: u32,
pub dr2: u32,
pub dr3: u32,
pub dr6: u32,
pub dr7: u32,
pub float_save: FLOATING_SAVE_AREA_X86,
pub gs: u32,
pub fs: u32,
pub es: u32,
pub ds: u32,
pub edi: u32,
pub esi: u32,
pub ebx: u32,
pub edx: u32,
pub ecx: u32,
pub eax: u32,
pub ebp: u32,
pub eip: u32,
pub cs: u32,
pub eflags: u32,
pub esp: u32,
pub ss: u32,
#[default([0; 512])]
pub extended_registers: [u8; 512], }
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct CPU_INFORMATION {
pub data: [u8; 24],
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct X86CpuInfo {
pub vendor_id: [u32; 3],
pub version_information: u32,
pub feature_information: u32,
pub amd_extended_cpu_features: u32,
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct ARMCpuInfo {
pub cpuid: u32,
pub elf_hwcaps: u32,
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct OtherCpuInfo {
pub processor_features: [u64; 2],
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_SYSTEM_INFO {
pub processor_architecture: u16,
pub processor_level: u16,
pub processor_revision: u16,
pub number_of_processors: u8,
pub product_type: u8,
pub major_version: u32,
pub minor_version: u32,
pub build_number: u32,
pub platform_id: u32,
pub csd_version_rva: RVA,
pub suite_mask: u16,
pub reserved2: u16,
pub cpu: CPU_INFORMATION,
}
#[repr(u16)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, FromPrimitive)]
pub enum ProcessorArchitecture {
PROCESSOR_ARCHITECTURE_INTEL = 0,
PROCESSOR_ARCHITECTURE_MIPS = 1,
PROCESSOR_ARCHITECTURE_ALPHA = 2,
PROCESSOR_ARCHITECTURE_PPC = 3,
PROCESSOR_ARCHITECTURE_SHX = 4,
PROCESSOR_ARCHITECTURE_ARM = 5,
PROCESSOR_ARCHITECTURE_IA64 = 6,
PROCESSOR_ARCHITECTURE_ALPHA64 = 7,
PROCESSOR_ARCHITECTURE_MSIL = 8,
PROCESSOR_ARCHITECTURE_AMD64 = 9,
PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 = 10,
PROCESSOR_ARCHITECTURE_ARM64 = 12,
PROCESSOR_ARCHITECTURE_SPARC = 0x8001,
PROCESSOR_ARCHITECTURE_PPC64 = 0x8002,
PROCESSOR_ARCHITECTURE_ARM64_OLD = 0x8003,
PROCESSOR_ARCHITECTURE_MIPS64 = 0x8004,
PROCESSOR_ARCHITECTURE_UNKNOWN = 0xffff,
}
#[repr(u32)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, FromPrimitive)]
pub enum PlatformId {
VER_PLATFORM_WIN32s = 1,
VER_PLATFORM_WIN32_WINDOWS = 2,
VER_PLATFORM_WIN32_NT = 3,
VER_PLATFORM_WIN32_CE = 4,
Unix = 0x8000,
MacOs = 0x8101,
Ios = 0x8102,
Linux = 0x8201,
Solaris = 0x8202,
Android = 0x8203,
Ps3 = 0x8204,
NaCl = 0x8205,
}
#[derive(Debug, Clone, Default, Pread, Pwrite, SizeWith, PartialEq, Eq)]
pub struct SYSTEMTIME {
pub year: u16,
pub month: u16,
pub day_of_week: u16,
pub day: u16,
pub hour: u16,
pub minute: u16,
pub second: u16,
pub milliseconds: u16,
}
#[derive(Debug, Clone, Default, Pread, Pwrite, SizeWith)]
pub struct TIME_ZONE_INFORMATION {
pub bias: i32,
pub standard_name: [u16; 32],
pub standard_date: SYSTEMTIME,
pub standard_bias: i32,
pub daylight_name: [u16; 32],
pub daylight_date: SYSTEMTIME,
pub daylight_bias: i32,
}
macro_rules! multi_structs {
(@next { $($prev:tt)* }) => {};
(@next { $($prev:tt)* } $(#[$attr:meta])* pub struct $name:ident { $($cur:tt)* } $($tail:tt)* ) => {
multi_structs!($(#[$attr])* pub struct $name { $($prev)* $($cur)* } $($tail)*);
};
// Declare a single struct.
($(#[$attr:meta])* pub struct $name:ident { $( pub $field:ident: $t:tt, )* } $($tail:tt)* ) => {
$(#[$attr])*
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct $name {
$( pub $field: $t, )*
}
multi_structs!(@next { $( pub $field: $t, )* } $($tail)*);
};
}
multi_structs! {
pub struct MINIDUMP_MISC_INFO {
pub size_of_info: u32,
pub flags1: u32,
pub process_id: u32,
pub process_create_time: u32,
pub process_user_time: u32,
pub process_kernel_time: u32,
}
pub struct MINIDUMP_MISC_INFO_2 {
pub processor_max_mhz: u32,
pub processor_current_mhz: u32,
pub processor_mhz_limit: u32,
pub processor_max_idle_state: u32,
pub processor_current_idle_state: u32,
}
pub struct MINIDUMP_MISC_INFO_3 {
pub process_integrity_level: u32,
pub process_execute_flags: u32,
pub protected_process: u32,
pub time_zone_id: u32,
pub time_zone: TIME_ZONE_INFORMATION,
}
pub struct MINIDUMP_MISC_INFO_4 {
pub build_string: [u16; 260], pub dbg_bld_str: [u16; 40],
}
pub struct MINIDUMP_MISC_INFO_5 {
pub xstate_data: XSTATE_CONFIG_FEATURE_MSC_INFO,
pub process_cookie: u32,
}
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct XSTATE_CONFIG_FEATURE_MSC_INFO {
pub size_of_info: u32,
pub context_size: u32,
pub enabled_features: u64,
pub features: [XSTATE_FEATURE; 64],
}
impl Default for XSTATE_CONFIG_FEATURE_MSC_INFO {
fn default() -> Self {
Self {
size_of_info: std::mem::size_of::<XSTATE_CONFIG_FEATURE_MSC_INFO>() as u32,
context_size: 0,
enabled_features: 0,
features: [XSTATE_FEATURE::default(); 64],
}
}
}
impl XSTATE_CONFIG_FEATURE_MSC_INFO {
pub fn iter(&self) -> XstateFeatureIter<'_> {
XstateFeatureIter { info: self, idx: 0 }
}
}
#[derive(Debug)]
pub struct XstateFeatureIter<'a> {
info: &'a XSTATE_CONFIG_FEATURE_MSC_INFO,
idx: usize,
}
impl Iterator for XstateFeatureIter<'_> {
type Item = (usize, XSTATE_FEATURE);
fn next(&mut self) -> Option<Self::Item> {
while self.idx < self.info.features.len() {
let cur_idx = self.idx;
self.idx += 1;
if (self.info.enabled_features & (1 << cur_idx)) != 0 {
return Some((cur_idx, self.info.features[cur_idx]));
}
}
None
}
}
#[repr(usize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum XstateFeatureIndex {
LEGACY_FLOATING_POINT = 0,
LEGACY_SSE = 1,
GSSE_AND_AVX = 2,
MPX_BNDREGS = 3,
MPX_BNDCSR = 4,
AVX512_KMASK = 5,
AVX512_ZMM_H = 6,
ACK512_ZMM = 7,
XSTATE_IPT = 8,
XSTATE_LWP = 62,
}
impl XstateFeatureIndex {
pub fn from_index(idx: usize) -> Option<Self> {
use XstateFeatureIndex::*;
match idx {
0 => Some(LEGACY_FLOATING_POINT),
1 => Some(LEGACY_SSE),
2 => Some(GSSE_AND_AVX),
3 => Some(MPX_BNDREGS),
4 => Some(MPX_BNDCSR),
5 => Some(AVX512_KMASK),
6 => Some(AVX512_ZMM_H),
7 => Some(ACK512_ZMM),
8 => Some(XSTATE_IPT),
62 => Some(XSTATE_LWP),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, Default, Pread, Pwrite, SizeWith, PartialEq, Eq)]
pub struct XSTATE_FEATURE {
pub offset: u32,
pub size: u32,
}
impl From<u8> for XSTATE_FEATURE {
fn from(_input: u8) -> Self {
XSTATE_FEATURE { offset: 0, size: 0 }
}
}
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct MiscInfoFlags: u32 {
const MINIDUMP_MISC1_PROCESS_ID = 0x00000001;
const MINIDUMP_MISC1_PROCESS_TIMES = 0x00000002;
const MINIDUMP_MISC1_PROCESSOR_POWER_INFO = 0x00000004;
const MINIDUMP_MISC3_PROCESS_INTEGRITY = 0x00000010;
const MINIDUMP_MISC3_PROCESS_EXECUTE_FLAGS = 0x00000020;
const MINIDUMP_MISC3_TIMEZONE = 0x00000040;
const MINIDUMP_MISC3_PROTECTED_PROCESS = 0x00000080;
const MINIDUMP_MISC4_BUILDSTRING = 0x00000100;
const MINIDUMP_MISC5_PROCESS_COOKIE = 0x00000200;
}
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_MEMORY_INFO_LIST {
pub size_of_header: u32,
pub size_of_entry: u32,
pub number_of_entries: u64,
}
#[derive(Debug, Clone, PartialEq, Eq, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_MEMORY_INFO {
pub base_address: u64,
pub allocation_base: u64,
pub allocation_protection: u32,
pub __alignment1: u32,
pub region_size: u64,
pub state: u32,
pub protection: u32,
pub _type: u32,
pub __alignment2: u32,
}
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct MemoryState: u32 {
const MEM_COMMIT = 0x01000;
const MEM_FREE = 0x10000;
const MEM_RESERVE = 0x02000;
}
}
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct MemoryProtection: u32 {
const PAGE_NOACCESS = 0x01;
const PAGE_READONLY = 0x02;
const PAGE_READWRITE = 0x04;
const PAGE_WRITECOPY = 0x08;
const PAGE_EXECUTE = 0x10;
const PAGE_EXECUTE_READ = 0x20;
const PAGE_EXECUTE_READWRITE = 0x40;
const PAGE_EXECUTE_WRITECOPY = 0x80;
const ACCESS_MASK = 0xff;
const PAGE_GUARD = 0x100;
const PAGE_NOCACHE = 0x200;
const PAGE_WRITECOMBINE = 0x400;
}
}
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct MemoryType: u32 {
const MEM_PRIVATE = 0x00020000;
const MEM_MAPPED = 0x00040000;
const MEM_IMAGE = 0x01000000;
}
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_BREAKPAD_INFO {
pub validity: u32,
pub dump_thread_id: u32,
pub requesting_thread_id: u32,
}
bitflags! {
pub struct BreakpadInfoValid: u32 {
const DumpThreadId = 1 << 0;
const RequestingThreadId = 1 << 1;
}
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_ASSERTION_INFO {
pub expression: [u16; 128],
pub function: [u16; 128],
pub file: [u16; 128],
pub line: u32,
pub _type: u32,
}
#[repr(u32)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, FromPrimitive)]
pub enum AssertionType {
Unknown = 0,
InvalidParameter = 1,
PureVirtualCall = 2,
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct LINK_MAP_32 {
pub addr: u32,
pub name: RVA,
pub ld: u32,
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct DSO_DEBUG_32 {
pub version: u32,
pub map: RVA,
pub dso_count: u32,
pub brk: u32,
pub ldbase: u32,
pub dynamic: u32,
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct LINK_MAP_64 {
pub addr: u64,
pub name: RVA,
pub ld: u64,
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct DSO_DEBUG_64 {
pub version: u32,
pub map: RVA,
pub dso_count: u32,
pub brk: u64,
pub ldbase: u64,
pub dynamic: u64,
}
#[derive(Debug, Clone)]
pub struct MINIDUMP_UTF8_STRING {
pub length: u32,
pub buffer: Vec<u8>,
}
impl scroll::ctx::TryFromCtx<'_, Endian> for MINIDUMP_UTF8_STRING {
type Error = scroll::Error;
fn try_from_ctx(src: &[u8], endian: Endian) -> Result<(Self, usize), Self::Error> {
let offset = &mut 0;
let length: u32 = src.gread_with(offset, endian)?;
let data: &[u8] = src.gread_with(offset, length as usize + 1)?;
if !data.ends_with(&[0]) {
return Err(scroll::Error::Custom(
"Minidump String does not end with NUL byte".to_owned(),
));
}
let buffer = data.to_vec();
Ok((Self { length, buffer }, *offset))
}
}
#[derive(Clone, Debug, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_SIMPLE_STRING_DICTIONARY_ENTRY {
pub key: RVA,
pub value: RVA,
}
#[derive(Clone, Debug, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_SIMPLE_STRING_DICTIONARY {
pub count: u32,
}
#[derive(Clone, Debug, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_RVA_LIST {
pub count: u32,
}
#[derive(Clone, Debug, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_ANNOTATION {
pub name: RVA,
pub ty: u16,
pub _reserved: u16,
pub value: RVA,
}
impl MINIDUMP_ANNOTATION {
pub const TYPE_INVALID: u16 = 0;
pub const TYPE_STRING: u16 = 1;
pub const TYPE_USER_DEFINED: u16 = 0x8000;
}
#[derive(Clone, Debug, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_MODULE_CRASHPAD_INFO {
pub version: u32,
pub list_annotations: MINIDUMP_LOCATION_DESCRIPTOR,
pub simple_annotations: MINIDUMP_LOCATION_DESCRIPTOR,
pub annotation_objects: MINIDUMP_LOCATION_DESCRIPTOR,
}
impl MINIDUMP_MODULE_CRASHPAD_INFO {
pub const VERSION: u32 = 1;
}
#[derive(Clone, Debug, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_MODULE_CRASHPAD_INFO_LINK {
pub minidump_module_list_index: u32,
pub location: MINIDUMP_LOCATION_DESCRIPTOR,
}
#[derive(Clone, Debug, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_MODULE_CRASHPAD_INFO_LIST {
pub count: u32,
}
#[derive(Clone, Debug, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_CRASHPAD_INFO {
pub version: u32,
pub report_id: GUID,
pub client_id: GUID,
pub simple_annotations: MINIDUMP_LOCATION_DESCRIPTOR,
pub module_list: MINIDUMP_LOCATION_DESCRIPTOR,
}
impl MINIDUMP_CRASHPAD_INFO {
pub const VERSION: u32 = 1;
}
#[derive(Debug, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_MAC_CRASH_INFO {
pub stream_type: u32,
pub record_count: u32,
pub record_start_size: u32,
pub records: [MINIDUMP_LOCATION_DESCRIPTOR; 20],
}
multi_structs! {
pub struct MINIDUMP_MAC_CRASH_INFO_RECORD {
pub stream_type: u64,
pub version: u64,
}
pub struct MINIDUMP_MAC_CRASH_INFO_RECORD_4 {
pub thread: u64,
pub dialog_mode: u64,
}
pub struct MINIDUMP_MAC_CRASH_INFO_RECORD_5 {
pub abort_cause: u64,
}
}
macro_rules! replace_expr {
($_t:tt $sub:expr) => {
$sub
};
}
macro_rules! count_tts {
($($tts:tt)*) => {0usize $(+ replace_expr!($tts 1usize))*};
}
macro_rules! multi_strings {
(@next { $($prev:tt)* }) => {};
(@next { $($prev:tt)* } $(#[$attr:meta])* pub struct $name:ident { $($cur:tt)* } $($tail:tt)* ) => {
multi_strings!($(#[$attr])* pub struct $name { $($prev)* $($cur)* } $($tail)*);
};
// Declare a single struct.
($(#[$attr:meta])* pub struct $name:ident { $( pub $field:ident: $t:tt, )* } $($tail:tt)* ) => {
$(#[$attr])*
#[derive(Default, Debug, Clone)]
pub struct $name {
$( pub $field: $t, )*
}
impl $name {
pub fn num_strings() -> usize {
count_tts!($($t)*)
}
#[allow(unused_variables, unused_mut)]
pub fn set_string(&mut self, idx: usize, string: String) {
let mut cur_idx = 0;
$(if cur_idx == idx {
self.$field = string;
return;
}
cur_idx += 1;
)*
panic!("string index out of bounds {} >= {}", idx, cur_idx);
}
}
multi_strings!(@next { $( pub $field: $t, )* } $($tail)*);
};
}
multi_strings! {
pub struct MINIDUMP_MAC_CRASH_INFO_RECORD_STRINGS {
}
pub struct MINIDUMP_MAC_CRASH_INFO_RECORD_STRINGS_4 {
pub module_path: String,
pub message: String,
pub signature_string: String,
pub backtrace: String,
pub message2: String,
}
pub struct MINIDUMP_MAC_CRASH_INFO_RECORD_STRINGS_5 {
}
}
pub const MAC_CRASH_INFO_STRING_MAX_SIZE: usize = 8192;
pub const MAC_CRASH_INFOS_MAX: usize = 20;
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_MAC_BOOTARGS {
pub stream_type: u32,
pub bootargs: RVA64,
}
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ArmElfHwCaps: u32 {
const HWCAP_SWP = (1 << 0);
const HWCAP_HALF = (1 << 1);
const HWCAP_THUMB = (1 << 2);
const HWCAP_26BIT = (1 << 3);
const HWCAP_FAST_MULT = (1 << 4);
const HWCAP_FPA = (1 << 5);
const HWCAP_VFP = (1 << 6);
const HWCAP_EDSP = (1 << 7);
const HWCAP_JAVA = (1 << 8);
const HWCAP_IWMMXT = (1 << 9);
const HWCAP_CRUNCH = (1 << 10);
const HWCAP_THUMBEE = (1 << 11);
const HWCAP_NEON = (1 << 12);
const HWCAP_VFPv3 = (1 << 13);
const HWCAP_VFPv3D16 = (1 << 14);
const HWCAP_TLS = (1 << 15);
const HWCAP_VFPv4 = (1 << 16);
const HWCAP_IDIVA = (1 << 17);
const HWCAP_IDIVT = (1 << 18);
const HWCAP_VFPD32 = (1 << 19);
const HWCAP_IDIV = ArmElfHwCaps::HWCAP_IDIVA.bits() | Self::HWCAP_IDIVT.bits();
const HWCAP_LPAE = (1 << 20);
const HWCAP_EVTSTRM = (1 << 21);
}
}
#[repr(u32)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, FromPrimitive)]
pub enum MINIDUMP_HANDLE_OBJECT_INFORMATION_TYPE {
MiniHandleObjectInformationNone,
MiniThreadInformation1,
MiniMutantInformation1,
MiniMutantInformation2,
MiniProcessInformation1,
MiniProcessInformation2,
MiniEventInformation1,
MiniSectionInformation1,
MiniSemaphoreInformation1,
MiniHandleObjectInformationTypeMax,
}
/// OS-specific handle object information. Microsoft headers state that it can
/// change based on the target platform. The object is larger than this structure
/// (as specified by `size_of_info`) and the remaining data is stored after the
/// `size_of_info` field. The format of this information is not specified.
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_HANDLE_OBJECT_INFORMATION {
/// RVA pointing to the next handle object information. Elements of this type
/// are chained and the last one has this field set to 0.
pub next_info_rva: RVA,
/// Type of this handle object information element, see [`MINIDUMP_HANDLE_OBJECT_INFORMATION_TYPE`]
pub info_type: u32,
/// Size of this element, this must be larger than `size_of::<MINIDUMP_HANDLE_OBJECT_INFORMATION>()`
pub size_of_info: u32,
}
#[derive(Debug, Default, Clone, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_HANDLE_DESCRIPTOR {
/// The operating system handle value. A HANDLE on Windows and file descriptor number on Linux.
pub handle: u64,
/// An RVA to a `MINIDUMP_STRING` structure that specifies the object type of the handle.
/// This member can be zero.
pub type_name_rva: RVA,
/// An RVA to a `MINIDUMP_STRING` structure that specifies the object name of the handle.
/// This member can be zero.
pub object_name_rva: RVA,
/// The meaning of this member depends on the handle type and the operating system.
pub attributes: u32,
/// The meaning of this member depends on the handle type and the operating system.
pub granted_access: u32,
/// The meaning of this member depends on the handle type and the operating system.
pub handle_count: u32,
/// The meaning of this member depends on the handle type and the operating system.
pub pointer_count: u32,
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_HANDLE_DESCRIPTOR_2 {
/// The operating system handle value. A HANDLE on Windows and file descriptor number on Linux.
pub handle: u64,
/// An RVA to a `MINIDUMP_STRING` structure that specifies the object type of the handle.
/// This member can be zero.
pub type_name_rva: RVA,
/// An RVA to a `MINIDUMP_STRING` structure that specifies the object name of the handle.
/// This member can be zero.
pub object_name_rva: RVA,
/// The meaning of this member depends on the handle type and the operating system.
pub attributes: u32,
/// The meaning of this member depends on the handle type and the operating system.
pub granted_access: u32,
/// The meaning of this member depends on the handle type and the operating system.
pub handle_count: u32,
/// The meaning of this member depends on the handle type and the operating system.
pub pointer_count: u32,
/// An RVA to a [`MINIDUMP_HANDLE_OBJECT_INFORMATION`] structure that specifies object-specific information.
/// This member can be 0 if there is no extra information.
pub object_info_rva: RVA,
/// Reserved for future use; must be zero.
reserved0: u32,
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_HANDLE_DATA_STREAM {
/// The size of this header, in bytes.
pub size_of_header: u32,
/// The size of each descriptor in the stream, in bytes.
pub size_of_descriptor: u32,
/// The number of descriptors in the stream.
pub number_of_descriptors: u32,
/// Reserved for future use; must be zero.
pub reserved: u32,
}
#[derive(Debug, Clone, Pread, Pwrite, SizeWith)]
pub struct MINIDUMP_THREAD_INFO {
/// Thread identifier
pub thread_id: u32,
/// Thread state flags
pub dump_flags: u32,
/// HRESULT value of dump status
pub dump_error: u32,
/// The thread's exit code
pub exit_status: u32,
/// UTC time the thread was created
pub create_time: u64,
/// UTC time the thread exited
pub exit_time: u64,
/// Time executed in kernel mode
pub kernel_time: u64,
/// Time executed in user mode
pub user_time: u64,
/// Start address of the thread
pub start_address: u64,
/// Processor affinity mask
pub affinity: u64,
}