Safe PE/COFF inspection, import/export extraction, and security metadata auditing for MoonBit.
moon add 404-32/moon-pe-inspect@0.2.0git clone https://github.com/404-32/byc001.git
cd byc001
moon test --target wasmmoon run cmd/main -- inspect examples/minimal-pe32.exemoon run cmd/main -- imports examples/minimal-pe32.exe
moon run cmd/main -- exports examples/minimal-pe32.exemoon run cmd/main -- inspect examples/minimal-pe32plus.exe --json
moon run cmd/main -- security examples/minimal-pe32plus.exe --jsonmoon run cmd/main -- directories examples/minimal-pe32.exe
moon run cmd/main -- resources examples/minimal-pe32.exe
moon run cmd/main -- delay-imports examples/minimal-pe32.exe
moon run cmd/main -- load-config examples/minimal-pe32.exe
moon run cmd/main -- diff examples/minimal-pe32.exe examples/minimal-pe32plus.exemoon run cmd/main -- sections C:\Windows\System32\notepad.exe///|
let image = @pe.PEImage::parse(file_bytes)
///|
let sections = image.sections
///|
let imports = image.imports()
///|
let exports = image.exports()
///|
let resources = image.resources()
///|
let relocations = image.base_relocations()
///|
let delay_imports = image.delay_imports()
///|
let tls = image.tls()
///|
let debug_entries = image.debug_entries()
///|
let load_config = image.load_config()
///|
let exceptions = image.exception_entries()
///|
let diagnostics = image.security_diagnostics()
///|
let offset = image.rva_to_offset(0x1000UL)python scripts/generate_fixtures.py
moon check --target wasm --deny-warn
moon test --target wasm --deny-warn
moon fmt --check
moon run cmd/main -- inspect examples/minimal-pe32.exepub(all) struct DataDirectory {
index : Int
name : String
virtual_address : UInt64
size : Int
}pub(all) struct DebugEntry {
debug_type : Int
type_name : String
timestamp : Int
size_of_data : Int
address_of_raw_data : UInt64
pointer_to_raw_data : Int
pdb_path : String?
pdb_age : Int?
pdb_guid : String?
}pub(all) struct DelayImportLibrary {
name : String
attributes : Int
timestamp : Int
symbols : Array[ImportSymbol]
}pub(all) struct ExceptionEntry {
begin_rva : UInt64
end_rva : UInt64
unwind_info_rva : UInt64
}pub(all) struct ExportSymbol {
name : String
ordinal : Int
rva : UInt64
forwarder : String?
}pub(all) struct LoadConfigInfo {
structure_size : Int
timestamp : Int
global_flags_clear : Int?
global_flags_set : Int?
security_cookie : UInt64?
se_handler_table : UInt64?
se_handler_count : Int?
guard_cf_check_pointer : UInt64?
guard_cf_dispatch_pointer : UInt64?
guard_cf_function_table : UInt64?
guard_cf_function_count : Int?
guard_flags : Int?
}pub(all) struct PEImage {
data : Bytes
pe_offset : Int
format : PEFormat
machine : Int
number_of_sections : Int
timestamp : UInt64
symbol_table_pointer : UInt64
number_of_symbols : UInt64
size_of_optional_header : Int
characteristics : Int
entry_point : UInt64
image_base : UInt64
section_alignment : Int
file_alignment : Int
size_of_image : Int
size_of_headers : Int
checksum : UInt64
subsystem : Int
dll_characteristics : Int
sections : Array[Section]
directories : Array[DataDirectory]
}pub(all) struct RelocationEntry {
relocation_type : Int
offset : Int
target_rva : UInt64
}pub(all) struct ResourceEntry {
path : String
type_id : Int?
name_id : Int?
language_id : Int?
data_rva : UInt64
file_offset : Int?
size : Int
code_page : Int
}pub(all) struct Section {
name : String
virtual_size : Int
virtual_address : UInt64
raw_size : Int
raw_offset : Int
characteristics : UInt64
}pub(all) struct TlsInfo {
raw_data_start : UInt64
raw_data_end : UInt64
index_address : UInt64
callbacks_address : UInt64
size_of_zero_fill : Int
characteristics : Int
callbacks : Array[UInt64]
}Install
Download zipSafe PE/COFF inspection, import/export extraction, and security metadata auditing for MoonBit.