#include "types.hpp" #include namespace le { struct NotALEFileException : public std::runtime_error { NotALEFileException(); }; enum class Bord : uint8_t { little_endian = 0, big_endian = 1, }; enum class Word : uint8_t { little_endian = 0, big_endian = 0, }; enum class CpuType : uint16_t { _80286 = 1, _80386 = 2, _80486 = 3, }; enum class OsType : uint16_t { Unknown = 0, OS_2 = 1, Windows = 2, Dos_4x = 3, Windows_386 = 4, }; enum class module_flags { per_process_library_initialization = 0x4, internal_fixups = 0x10, incompat_pm_windowing = 0x100, compat_pm_windowing = 0x200, uses_pm_windowing = 0x300, module_not_loadable = 0x2000, module_type_mask = 0x38000, program_module = 0x0, library_module = 0x8000, protected_memory_library_module = 0x18000, physical_device_driver_module = 0x20000, virtual_device_driver_module = 0x28000, per_process_library_temrination = 0x40000000, }; using binparse::Magic16; using binparse::Value8; using binparse::Value16; using binparse::Value32; using binparse::Offset32; struct Header { Magic16 magic; Value8 B_ord; Value8 W_ord; Value32 format_level; Value16 cpu_type; Value16 os_type; Value32 module_version; Value32 module_flags; Value32 module_nr_of_pages; Offset32 EIP_object; Offset32 EIP; Offset32 ESP_object; Offset32 ESP; Value32 page_size; Offset32 page_offset_shift; Value32 fixup_section_size; Value32 fixup_section_checksum; Value32 loader_section_size; Value32 loader_section_checksum; Offset32 object_table_offset; Value32 nr_objects_in_module; Offset32 object_page_table_offset; Offset32 objct_iter_pages_offset; Offset32 resource_table_offset; Value32 nr_resource_table_entries; Offset32 resident_name_table_offset; Offset32 entry_table_offset; Offset32 module_directives_offset; Value32 nr_module_directives; Offset32 fixup_page_table_offset; Offset32 fixup_record_table_offset; Offset32 import_module_table_offset; Value32 import_mod_entries; Offset32 import_proc_table_offset; Offset32 per_page_checksum_offset; Offset32 data_page_offset; Value32 nr_preload_pages; Offset32 non_res_name_table_offset; Value32 non_res_name_table_length; Value32 non_res_name_table_checksum; Value32 auto_ds_object_nr; Offset32 debug_info_offset; Value32 debug_info_length; Value32 nr_instance_preload; Value32 nr_instance_demand; Value32 heapsize; }; Header parse_header(std::istream& is); std::ostream& operator<<(std::ostream& os, Header const& header); }