summaryrefslogtreecommitdiff
path: root/mz/mz_header.hpp
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-06-19 20:23:07 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2016-06-19 20:23:07 +0200
commitcea325b7451c1fb8dd22462ec2e7b5b88ea9b547 (patch)
treeffa2811b2ca24b3aa7e08bb28b45e7e9adbd154c /mz/mz_header.hpp
parentc66d1f5c0af70161f4ad4c4175f4280e95b55dfd (diff)
downloadopenwar-cea325b7451c1fb8dd22462ec2e7b5b88ea9b547.tar.gz
openwar-cea325b7451c1fb8dd22462ec2e7b5b88ea9b547.tar.bz2
openwar-cea325b7451c1fb8dd22462ec2e7b5b88ea9b547.zip
Adds an LE executable parser.
Adds the binparse library that holds common components for the MZ and LE parsers.
Diffstat (limited to 'mz/mz_header.hpp')
-rw-r--r--mz/mz_header.hpp41
1 files changed, 20 insertions, 21 deletions
diff --git a/mz/mz_header.hpp b/mz/mz_header.hpp
index ad5f419..fd42b43 100644
--- a/mz/mz_header.hpp
+++ b/mz/mz_header.hpp
@@ -1,14 +1,16 @@
#pragma once
+#include "types.hpp"
+
#include <cstdint>
#include <cstddef>
#include <stdexcept>
#include <istream>
#include <ostream>
-#include <boost/serialization/strong_typedef.hpp>
+namespace mz {
-BOOST_STRONG_TYPEDEF(uint16_t, Magic);
+using namespace binparse;
struct NotAMZFileException : public std::runtime_error {
NotAMZFileException();
@@ -21,27 +23,24 @@ struct UnexpectedEOS : public std::runtime_error {
};
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;
+ Magic16 magic;
+ Value16 bytes_in_last_block;
+ Value16 blocks_in_file;
+ Value16 num_relocs;
+ Value16 header_paragraphs;
+ Value16 min_extra_paragraphs;
+ Value16 max_extra_paragraphs;
+ Offset16 ss;
+ Offset16 sp;
+ Value16 checksum;
+ Offset16 ip;
+ Offset16 cs;
+ Offset16 reloc_table_offset;
+ Value16 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);
+MZHeader parse_file(std::istream& is);
std::ostream& operator<<(std::ostream& os, MZHeader const& header);
+}