From c66d1f5c0af70161f4ad4c4175f4280e95b55dfd Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Sun, 19 Jun 2016 11:58:16 +0200 Subject: Initial commit of a mz-header parser. --- mz/mz_header.hpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 mz/mz_header.hpp (limited to 'mz/mz_header.hpp') diff --git a/mz/mz_header.hpp b/mz/mz_header.hpp new file mode 100644 index 0000000..ad5f419 --- /dev/null +++ b/mz/mz_header.hpp @@ -0,0 +1,47 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include + +BOOST_STRONG_TYPEDEF(uint16_t, Magic); + +struct NotAMZFileException : public std::runtime_error { + NotAMZFileException(); +}; + +struct UnexpectedEOS : public std::runtime_error { + UnexpectedEOS(); + + UnexpectedEOS(std::string location); +}; + +struct MZHeader { + Magic magic; + uint16_t bytes_in_last_block; + uint16_t blocks_in_file; + uint16_t num_relocs; + uint16_t header_paragraphs; + uint16_t min_extra_paragraphs; + uint16_t max_extra_paragraphs; + uint16_t ss; + uint16_t sp; + uint16_t checksum; + uint16_t ip; + uint16_t cs; + uint16_t reloc_table_offset; + uint16_t overlay_number; +}; + +uint16_t parse_uint16_t(std::istream& is, std::string name = ""); + +MZHeader parse_mz_file(std::istream& is); + +void print_mz_header(MZHeader const& header); + +std::ostream& operator<<(std::ostream& os, MZHeader const& header); + -- cgit v1.2.3-70-g09d2