summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-07-05 17:51:21 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2016-07-05 17:51:21 +0200
commit06336eaddcc6a8f9cc578d8f059117c3aa535c9f (patch)
tree4884cc68161df06112a49a04007fa6d03775d507
parentb80a82fcc9edc73057796005cede4eea8380e193 (diff)
downloadopenwar-06336eaddcc6a8f9cc578d8f059117c3aa535c9f.tar.gz
openwar-06336eaddcc6a8f9cc578d8f059117c3aa535c9f.tar.bz2
openwar-06336eaddcc6a8f9cc578d8f059117c3aa535c9f.zip
Made the interface somewhat more consistant.
-rw-r--r--binparse/output.cpp8
-rw-r--r--binparse/output.hpp2
-rw-r--r--binparse/parse.cpp35
-rw-r--r--binparse/parse.hpp6
-rw-r--r--binparse/types.hpp4
-rw-r--r--disasm/disasm.cpp26
-rw-r--r--le/CMakeLists.txt4
-rw-r--r--le/le_entry_table.cpp49
-rw-r--r--le/le_entry_table.hpp21
-rw-r--r--le/le_entry_table_entry.cpp55
-rw-r--r--le/le_entry_table_entry.hpp33
-rw-r--r--le/le_fixup_record_table.cpp2
-rw-r--r--le/le_object_page_table.cpp19
-rw-r--r--le/le_object_page_table.hpp21
-rw-r--r--le/le_object_page_table_entry.cpp27
-rw-r--r--le/le_object_page_table_entry.hpp28
-rw-r--r--le/le_object_table.cpp22
-rw-r--r--le/le_object_table.hpp36
-rw-r--r--le/le_object_table_entry.cpp31
-rw-r--r--le/le_object_table_entry.hpp42
-rw-r--r--le/le_resident_name_table.cpp19
-rw-r--r--le/le_resident_name_table.hpp12
-rw-r--r--le/le_resident_name_table_entry.cpp26
-rw-r--r--le/le_resident_name_table_entry.hpp21
24 files changed, 249 insertions, 300 deletions
diff --git a/binparse/output.cpp b/binparse/output.cpp
index 16447a7..de9db29 100644
--- a/binparse/output.cpp
+++ b/binparse/output.cpp
@@ -35,6 +35,13 @@ std::ostream& operator<<(std::ostream& os, Offset16 o) {
return os << std::hex << std::setw(sizeof(o) * 2) << std::setfill('0') << static_cast<uint16_t>(o);
}
+std::ostream&operator<<(std::ostream& os, Value24 v)
+{
+ std::array<uint8_t, 3> va = v;
+ uint32_t tv = (va[2] << 16 | va[1] << 8 | va[0] << 0);
+ return os << std::dec << tv;
+}
+
std::ostream& operator<<(std::ostream& os, Value32 v) {
return os << std::dec << static_cast<uint32_t>(v);
}
@@ -63,4 +70,5 @@ std::ostream&operator<<(std::ostream& os, std::vector<uint8_t> vec)
return os;
}
+
}
diff --git a/binparse/output.hpp b/binparse/output.hpp
index 3919bef..d942fca 100644
--- a/binparse/output.hpp
+++ b/binparse/output.hpp
@@ -29,6 +29,8 @@ std::ostream& operator<<(std::ostream& os, Magic16 m);
std::ostream& operator<<(std::ostream& os, Value16 v);
std::ostream& operator<<(std::ostream& os, Offset16 o);
+std::ostream& operator<<(std::ostream& os, Value24 v);
+
std::ostream& operator<<(std::ostream& os, Value32 v);
std::ostream& operator<<(std::ostream& os, Offset32 o);
diff --git a/binparse/parse.cpp b/binparse/parse.cpp
index a26e72e..de0f04d 100644
--- a/binparse/parse.cpp
+++ b/binparse/parse.cpp
@@ -80,6 +80,12 @@ Offset16 parse<Offset16>(std::istream& is, std::string name) {
}
template<>
+Value24 parse<Value24>(std::istream& is, std::__cxx11::string name)
+{
+ return Value24(parse<std::array<uint8_t, 3>>(is, name));
+}
+
+template<>
Value32 parse<Value32>(std::istream& is, std::string name) {
return Value32(parse<uint32_t>(is, name));
}
@@ -97,13 +103,13 @@ PString8 parse<PString8>(std::istream& is, std::string name) {
return PString8(std::string(data.begin(), data.end()));
}
-template<>
-std::array<uint8_t, 8> parse<std::array<uint8_t, 8>>(std::istream& is, std::string name) {
+template<typename T, unsigned int N>
+std::array<T, N> parse(std::istream& is, std::string name) {
if(!is) {
throw UnexpectedEOS();
}
- std::array<uint8_t, 8> buffer;
+ std::array<T, N> buffer;
is.read(reinterpret_cast<char*>(buffer.data()), buffer.size());
if(!is) {
@@ -114,19 +120,18 @@ std::array<uint8_t, 8> parse<std::array<uint8_t, 8>>(std::istream& is, std::stri
}
template<>
+std::array<uint8_t, 3> parse<std::array<uint8_t, 3>>(std::istream& is, std::string name) {
+ return parse<uint8_t, 3>(is, name);
+}
+
+template<>
+std::array<uint8_t, 8> parse<std::array<uint8_t, 8>>(std::istream& is, std::string name) {
+ return parse<uint8_t, 8>(is, name);
+}
+
+template<>
std::array<uint8_t, 22> parse<std::array<uint8_t, 22>>(std::istream& is, std::string name) {
- if(!is) {
- throw UnexpectedEOS();
- }
-
- std::array<uint8_t, 22> buffer;
- is.read(reinterpret_cast<char*>(buffer.data()), buffer.size());
-
- if(!is) {
- throw UnexpectedEOS(name);
- }
-
- return buffer;
+ return parse<uint8_t, 22>(is, name);
}
void dump_bytes(std::istream& is, std::vector<uint8_t>& buffer, std::string name)
diff --git a/binparse/parse.hpp b/binparse/parse.hpp
index e02b230..5c641d8 100644
--- a/binparse/parse.hpp
+++ b/binparse/parse.hpp
@@ -49,6 +49,9 @@ template<>
Offset16 parse<Offset16>(std::istream& is, std::string name);
template<>
+Value24 parse<Value24>(std::istream& is, std::string name);
+
+template<>
Value32 parse<Value32>(std::istream& is, std::string name);
template<>
@@ -58,6 +61,9 @@ template<>
PString8 parse<PString8>(std::istream& is, std::string name);
template<>
+std::array<uint8_t, 3> parse<std::array<uint8_t, 3>>(std::istream& is, std::string name);
+
+template<>
std::array<uint8_t, 8> parse<std::array<uint8_t, 8>>(std::istream& is, std::string name);
template<>
diff --git a/binparse/types.hpp b/binparse/types.hpp
index d1b1910..5d7f7d7 100644
--- a/binparse/types.hpp
+++ b/binparse/types.hpp
@@ -3,6 +3,7 @@
#include <boost/serialization/strong_typedef.hpp>
#include <cstdint>
+#include <array>
namespace binparse {
@@ -19,6 +20,9 @@ BOOST_STRONG_TYPEDEF(uint32_t, Value32)
BOOST_STRONG_TYPEDEF(std::string, PString8);
+typedef std::array<uint8_t, 3> uint24_t;
+BOOST_STRONG_TYPEDEF(uint24_t, Value24);
+
template <typename T>
T operator+(T const lh, T const rh) {
return T(0 + lh + rh);
diff --git a/disasm/disasm.cpp b/disasm/disasm.cpp
index 609794e..862813c 100644
--- a/disasm/disasm.cpp
+++ b/disasm/disasm.cpp
@@ -8,6 +8,7 @@
#include <iostream>
#include <istream>
+#include <iomanip>
int main(int argc, char* argv[]) {
boost::program_options::options_description description;
@@ -58,11 +59,28 @@ int main(int argc, char* argv[]) {
std::basic_ifstream<char> code_file(file_path.string());
std::vector<uint8_t> code(std::istreambuf_iterator<char>(code_file), {});
- _DecodedInst inst;
+ std::vector<_DecodedInst> instructions;
+ instructions.resize(100000);
unsigned int read_inst;
+
+ auto eip_object = x.object_table.entries[x.le_header.EIP_object];
+ auto index = eip_object.page_table_index;
+ auto page = x.object_page_table.entries[index];
- auto result = distorm_decode64(x.mz_header.ip, code.data(), 1, Decode16Bits, &inst, 1, &read_inst);
+ binparse::Offset32 offset = x.le_offset + x.le_header.data_page_offset;
- std::cout << inst.mnemonic.p << " " << inst.operands.p << std::endl;
-
+ auto result = distorm_decode64(0x00010000, code.data() + offset, x.object_table.entries[1].nr_page_table_entries * x.le_header.page_size, Decode32Bits, instructions.data(), instructions.size(), &read_inst);
+
+ instructions.resize(read_inst);
+ instructions.shrink_to_fit();
+
+ if(result) {
+
+ }
+
+ for(auto&& inst : instructions) {
+ std::cout << std::hex << std::setw(8) << std::setfill('0') << inst.offset << ":\t" << inst.mnemonic.p << " " << inst.operands.p << std::endl;
+ }
+
+ return 0;
}
diff --git a/le/CMakeLists.txt b/le/CMakeLists.txt
index a453669..6bea735 100644
--- a/le/CMakeLists.txt
+++ b/le/CMakeLists.txt
@@ -3,15 +3,11 @@ add_library(le STATIC
le_header.hpp le_header.cpp
le_file.hpp le_file.cpp
le_object_table.hpp le_object_table.cpp
- le_object_table_entry.hpp le_object_table_entry.cpp
le_object_page_table.hpp le_object_page_table.cpp
- le_object_page_table_entry.hpp le_object_page_table_entry.cpp
le_object_iterate_data_map_table.hpp le_object_iterate_data_map_table.cpp
le_resource_table.hpp le_resource_table.cpp
le_resident_name_table.hpp le_resident_name_table.cpp
- le_resident_name_table_entry.hpp le_resident_name_table_entry.cpp
le_entry_table.hpp le_entry_table.cpp
- le_entry_table_entry.hpp le_entry_table_entry.cpp
le_fixup_page_table.hpp le_fixup_page_table.cpp
le_fixup_record_table.hpp le_fixup_record_table.cpp
)
diff --git a/le/le_entry_table.cpp b/le/le_entry_table.cpp
index 28f901d..6e8b0c7 100644
--- a/le/le_entry_table.cpp
+++ b/le/le_entry_table.cpp
@@ -1,9 +1,58 @@
#include "le_entry_table.hpp"
+#include "parse.hpp"
#include "output.hpp"
+#include "boost/fusion/adapted/struct.hpp"
+
+typedef boost::variant<binparse::Offset16, binparse::Offset32> EntryT;
+
+BOOST_FUSION_ADAPT_STRUCT(
+ le::EntryTable::Entry::EntryPoint,
+ (binparse::Value8, flags)
+ (EntryT, entry)
+)
+
+BOOST_FUSION_ADAPT_STRUCT(
+ le::EntryTable::Entry,
+ (binparse::Value8, nr_entries)
+ (binparse::Value8, flags)
+ (binparse::Value16, object_index)
+ (std::vector<le::EntryTable::Entry::EntryPoint>, entries)
+)
+
namespace le {
+EntryTable::Entry parse_entry_table_entry(std::istream& is) {
+ EntryTable::Entry entry;
+
+ entry.nr_entries = binparse::parse<binparse::Value8>(is, "nr_entries");
+ entry.flags = binparse::parse<binparse::Value8>(is, "flags");
+ entry.object_index = binparse::parse<binparse::Value16>(is, "object_index");
+
+ for(Value8 i = Value8(0); i < entry.nr_entries; i++) {
+ if(entry.flags & 2) {
+ entry.entries.push_back({
+ binparse::parse<Value8>(is, "flags"),
+ binparse::parse<Offset32>(is, "entry")
+ });
+ } else {
+ entry.entries.push_back({
+ binparse::parse<Value8>(is, "flags"),
+ binparse::parse<Offset16>(is, "entry")
+ });
+ }
+ }
+
+ return entry;
+}
+
+std::ostream& operator<<(std::ostream& os, EntryTable::Entry const& entry)
+{
+ return binparse::operator<<(os, entry);
+}
+
+
EntryTable parse_entry_table(std::istream& is, binparse::Offset32 offset)
{
is.seekg(0, std::ios::beg);
diff --git a/le/le_entry_table.hpp b/le/le_entry_table.hpp
index f31f542..ad2bbe5 100644
--- a/le/le_entry_table.hpp
+++ b/le/le_entry_table.hpp
@@ -1,15 +1,32 @@
#pragma once
-#include "le_entry_table_entry.hpp"
+#include "types.hpp"
+
+#include <boost/variant.hpp>
#include <map>
#include <iostream>
+#include <vector>
namespace le {
+using namespace binparse;
+
struct EntryTable
{
- std::map<uint32_t, EntryTableEntry> entries;
+ struct Entry {
+ struct EntryPoint {
+ Value8 flags;
+ boost::variant<Offset16, Offset32> entry;
+ };
+
+ Value8 nr_entries;
+ Value8 flags;
+ Value16 object_index;
+ std::vector<EntryPoint> entries;
+ };
+
+ std::map<uint32_t, EntryTable::Entry> entries;
};
EntryTable parse_entry_table(std::istream& is, binparse::Offset32 offset);
diff --git a/le/le_entry_table_entry.cpp b/le/le_entry_table_entry.cpp
deleted file mode 100644
index 4894ec0..0000000
--- a/le/le_entry_table_entry.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-#include "le_entry_table_entry.hpp"
-
-#include "parse.hpp"
-#include "output.hpp"
-
-#include <boost/fusion/adapted/struct.hpp>
-
-typedef boost::variant<binparse::Offset16, binparse::Offset32> EntryT;
-
-BOOST_FUSION_ADAPT_STRUCT(
- le::EntryPoint,
- (binparse::Value8, flags)
- (EntryT, entry)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- le::EntryTableEntry,
- (binparse::Value8, nr_entries)
- (binparse::Value8, flags)
- (binparse::Value16, object_index)
- (std::vector<le::EntryPoint>, entries)
-)
-
-namespace le {
-
-EntryTableEntry parse_entry_table_entry(std::istream& is) {
- EntryTableEntry entry;
-
- entry.nr_entries = binparse::parse<binparse::Value8>(is, "nr_entries");
- entry.flags = binparse::parse<binparse::Value8>(is, "flags");
- entry.object_index = binparse::parse<binparse::Value16>(is, "object_index");
-
- for(Value8 i = Value8(0); i < entry.nr_entries; i++) {
- if(entry.flags & 2) {
- entry.entries.push_back({
- binparse::parse<Value8>(is, "flags"),
- binparse::parse<Offset32>(is, "entry")
- });
- } else {
- entry.entries.push_back({
- binparse::parse<Value8>(is, "flags"),
- binparse::parse<Offset16>(is, "entry")
- });
- }
- }
-
- return entry;
-}
-
-std::ostream&operator<<(std::ostream& os, const EntryTableEntry& entry)
-{
- return binparse::operator<<(os, entry);
-}
-
-} \ No newline at end of file
diff --git a/le/le_entry_table_entry.hpp b/le/le_entry_table_entry.hpp
deleted file mode 100644
index 209c1bb..0000000
--- a/le/le_entry_table_entry.hpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#pragma once
-
-#include "types.hpp"
-
-#include <boost/variant.hpp>
-
-#include <vector>
-
-namespace le {
-
-using binparse::Value8;
-using binparse::Value16;
-using binparse::Offset16;
-using binparse::Offset32;
-
-struct EntryPoint {
- binparse::Value8 flags;
- boost::variant<Offset16, Offset32> entry;
-};
-
-struct EntryTableEntry {
-
- Value8 nr_entries;
- Value8 flags;
- Value16 object_index;
- std::vector<EntryPoint> entries;
-};
-
-EntryTableEntry parse_entry_table_entry(std::istream& is);
-
-std::ostream& operator<<(std::ostream& os, EntryTableEntry const& entry);
-
-}
diff --git a/le/le_fixup_record_table.cpp b/le/le_fixup_record_table.cpp
index 9331626..51dee60 100644
--- a/le/le_fixup_record_table.cpp
+++ b/le/le_fixup_record_table.cpp
@@ -222,8 +222,6 @@ FixupRecordTable parse_fixup_record_table(std::istream& is, Offset32 offset, Fix
auto x = parse(is);
table.entries[Value32(i)].push_back(x);
}
-
-
}
return table;
diff --git a/le/le_object_page_table.cpp b/le/le_object_page_table.cpp
index d8fd290..9843689 100644
--- a/le/le_object_page_table.cpp
+++ b/le/le_object_page_table.cpp
@@ -3,8 +3,27 @@
#include "parse.hpp"
#include "output.hpp"
+#include <boost/fusion/adapted/struct.hpp>
+
+BOOST_FUSION_ADAPT_STRUCT(
+ le::ObjectPageTable::Entry,
+ (binparse::Value16, high)
+ (binparse::Value8, low)
+ (binparse::Value8, flags)
+)
+
namespace le {
+ObjectPageTable::Entry parse_object_page_table_entry(std::istream& is)
+{
+ return binparse::parse<ObjectPageTable::Entry>(is);
+}
+
+std::ostream& operator<<(std::ostream& os, ObjectPageTable::Entry const& entry)
+{
+ return binparse::operator<<(os, entry);
+}
+
ObjectPageTable parse_object_page_table(std::istream& is, binparse::Offset32 offset, binparse::Value32 nr_pages)
{
is.seekg(0, std::ios::beg);
diff --git a/le/le_object_page_table.hpp b/le/le_object_page_table.hpp
index 08a67e6..da464b5 100644
--- a/le/le_object_page_table.hpp
+++ b/le/le_object_page_table.hpp
@@ -2,18 +2,29 @@
#include "types.hpp"
-#include "le_object_page_table_entry.hpp"
-
#include <map>
namespace le {
-using binparse::Value32;
-using binparse::Offset32;
+using namespace binparse;
struct ObjectPageTable
{
- std::map<Value32, ObjectPageTableEntry> entries;
+ struct Entry {
+ enum class object_page_flags {
+ legal_physical = 0,
+ iteration_data = 1,
+ invalid = 2,
+ zero_filled = 3,
+ range_of = 4
+ };
+
+ Value16 high;
+ Value8 low;
+ Value8 flags;
+ };
+
+ std::map<Value32, ObjectPageTable::Entry> entries;
};
ObjectPageTable parse_object_page_table(std::istream& is, Offset32 offset, Value32 nr_pages);
diff --git a/le/le_object_page_table_entry.cpp b/le/le_object_page_table_entry.cpp
deleted file mode 100644
index 73bdb61..0000000
--- a/le/le_object_page_table_entry.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "le_object_page_table_entry.hpp"
-
-#include "parse.hpp"
-#include "output.hpp"
-
-#include <boost/fusion/adapted/struct.hpp>
-
-BOOST_FUSION_ADAPT_STRUCT(
- le::ObjectPageTableEntry,
- (binparse::Offset16, high_page_number)
- (binparse::Value8, low_page_number)
- (binparse::Value8, flags)
-)
-
-namespace le {
-
-ObjectPageTableEntry parse_object_page_table_entry(std::istream& is)
-{
- return binparse::parse<ObjectPageTableEntry>(is);
-}
-
-std::ostream& operator<<(std::ostream& os, const ObjectPageTableEntry& entry)
-{
- return binparse::operator<<(os, entry);
-}
-
-} \ No newline at end of file
diff --git a/le/le_object_page_table_entry.hpp b/le/le_object_page_table_entry.hpp
deleted file mode 100644
index 3254365..0000000
--- a/le/le_object_page_table_entry.hpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#pragma once
-
-#include "types.hpp"
-
-namespace le {
-
-using binparse::Offset16;
-using binparse::Value8;
-
-enum class object_page_flags {
- legal_physical = 0,
- iteration_data = 1,
- invalid = 2,
- zero_filled = 3,
- range_of = 4
-};
-
-struct ObjectPageTableEntry {
- Offset16 high_page_number;
- Value8 low_page_number;
- Value8 flags;
-};
-
-ObjectPageTableEntry parse_object_page_table_entry(std::istream& is);
-
-std::ostream& operator<<(std::ostream& os, ObjectPageTableEntry const& entry);
-
-}
diff --git a/le/le_object_table.cpp b/le/le_object_table.cpp
index 3e87fb0..7523257 100644
--- a/le/le_object_table.cpp
+++ b/le/le_object_table.cpp
@@ -1,11 +1,33 @@
#include "le_object_table.hpp"
#include "output.hpp"
+#include "parse.hpp"
+
+#include <boost/fusion/adapted/struct.hpp>
#include <iostream>
+BOOST_FUSION_ADAPT_STRUCT(
+ le::ObjectTable::Entry,
+ (binparse::Value32, virtual_size)
+ (binparse::Offset32, reloc_base_address)
+ (binparse::Value32, object_flags)
+ (binparse::Value32, page_table_index)
+ (binparse::Value32, nr_page_table_entries)
+ (binparse::Value32, reserved)
+)
+
namespace le {
+ObjectTable::Entry parse_object_table_entry(std::istream& is) {
+ return parse<ObjectTable::Entry>(is);
+}
+
+std::ostream& operator<<(std::ostream& os, ObjectTable::Entry const& entry)
+{
+ return binparse::operator<<(os, entry);
+}
+
ObjectTable parse_object_table(std::istream& is, Offset32 offset, Value32 nr_objects)
{
is.seekg(0, std::ios::beg);
diff --git a/le/le_object_table.hpp b/le/le_object_table.hpp
index c840734..c3f584d 100644
--- a/le/le_object_table.hpp
+++ b/le/le_object_table.hpp
@@ -1,13 +1,43 @@
#pragma once
-#include "le_object_table_entry.hpp"
+#include "types.hpp"
#include <map>
namespace le {
-struct ObjectTable {
- std::map<uint32_t, ObjectTableEntry> entries;
+using namespace binparse;
+
+struct ObjectTable {
+ struct Entry {
+ enum class ObjectFlags {
+ readable = 0x1,
+ writable = 0x2,
+ executable = 0x4,
+ resource = 0x8,
+ discardable = 0x10,
+ shared = 0x20,
+ has_preload_pages = 0x40,
+ has_invalid_pages = 0x80,
+ has_zero_filled_pages = 0x100,
+ is_resident = 0x200,
+ is_resident_and_contiguous = 0x300,
+ is_resident_and_long_lockable = 0x400,
+ alias_16_16_required = 0x1000,
+ big_bit_setting = 0x2000,
+ is_conforming_for_code = 0x4000,
+ IO_privilege_level = 0x8000,
+ };
+
+ Value32 virtual_size;
+ Offset32 reloc_base_address;
+ Value32 object_flags;
+ Value32 page_table_index;
+ Value32 nr_page_table_entries;
+ Value32 reserved;
+ };
+
+ std::map<uint32_t, Entry> entries;
};
ObjectTable parse_object_table(std::istream& is, Offset32 offset, Value32 nr_objects);
diff --git a/le/le_object_table_entry.cpp b/le/le_object_table_entry.cpp
deleted file mode 100644
index 68e77ba..0000000
--- a/le/le_object_table_entry.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "le_object_table_entry.hpp"
-
-#include "parse.hpp"
-#include "output.hpp"
-
-#include <boost/fusion/adapted/struct.hpp>
-
-BOOST_FUSION_ADAPT_STRUCT(
- le::ObjectTableEntry,
- (binparse::Value32, virtual_size)
- (binparse::Offset32, reloc_base_address)
- (binparse::Value32, object_flags)
- (binparse::Value32, page_table_index)
- (binparse::Value32, nr_page_table_entries)
- (binparse::Value32, reserved)
-)
-
-namespace le {
-
-ObjectTableEntry parse_object_table_entry(std::istream& is) {
- using binparse::parse;
-
- return parse<ObjectTableEntry>(is);
-}
-
-std::ostream& operator<<(std::ostream& os, const ObjectTableEntry& entry)
-{
- return binparse::operator<<(os, entry);
-}
-
-}
diff --git a/le/le_object_table_entry.hpp b/le/le_object_table_entry.hpp
deleted file mode 100644
index c456a15..0000000
--- a/le/le_object_table_entry.hpp
+++ /dev/null
@@ -1,42 +0,0 @@
-#pragma once
-
-#include "types.hpp"
-
-namespace le {
-
-using binparse::Value32;
-using binparse::Offset32;
-
-enum class ObjectFlags {
- readable = 0x1,
- writable = 0x2,
- executable = 0x4,
- resource = 0x8,
- discardable = 0x10,
- shared = 0x20,
- has_preload_pages = 0x40,
- has_invalid_pages = 0x80,
- has_zero_filled_pages = 0x100,
- is_resident = 0x200,
- is_resident_and_contiguous = 0x300,
- is_resident_and_long_lockable = 0x400,
- alias_16_16_required = 0x1000,
- big_bit_setting = 0x2000,
- is_conforming_for_code = 0x4000,
- IO_privilege_level = 0x8000,
-};
-
-struct ObjectTableEntry {
- Value32 virtual_size;
- Offset32 reloc_base_address;
- Value32 object_flags;
- Value32 page_table_index;
- Value32 nr_page_table_entries;
- Value32 reserved;
-};
-
-ObjectTableEntry parse_object_table_entry(std::istream& is);
-
-std::ostream& operator<<(std::ostream& os, ObjectTableEntry const& entry);
-
-}
diff --git a/le/le_resident_name_table.cpp b/le/le_resident_name_table.cpp
index bc34999..4633431 100644
--- a/le/le_resident_name_table.cpp
+++ b/le/le_resident_name_table.cpp
@@ -1,9 +1,28 @@
#include "le_resident_name_table.hpp"
+#include "parse.hpp"
#include "output.hpp"
+#include <boost/fusion/adapted/struct.hpp>
+
+BOOST_FUSION_ADAPT_STRUCT(
+ le::ResidentNameTable::Entry,
+ (binparse::PString8, string)
+ (binparse::Value16, index)
+)
+
namespace le {
+ResidentNameTable::Entry parse_resident_name_table_entry(std::istream& is)
+{
+ return binparse::parse<ResidentNameTable::Entry>(is);
+}
+
+std::ostream&operator<<(std::ostream& os, ResidentNameTable::Entry const& entry)
+{
+ return binparse::operator<<(os, entry);
+}
+
ResidentNameTable parse_resident_name_table(std::istream& is, binparse::Offset32 offset)
{
is.seekg(0, std::ios::beg);
diff --git a/le/le_resident_name_table.hpp b/le/le_resident_name_table.hpp
index aa81577..1369383 100644
--- a/le/le_resident_name_table.hpp
+++ b/le/le_resident_name_table.hpp
@@ -1,14 +1,22 @@
#pragma once
-#include "le_resident_name_table_entry.hpp"
+#include "types.hpp"
#include <vector>
#include <iostream>
namespace le {
+using namespace binparse;
+
struct ResidentNameTable {
- std::vector<ResidentNameTableEntry> entries;
+
+ struct Entry {
+ PString8 string;
+ Value16 index;
+ };
+
+ std::vector<ResidentNameTable::Entry> entries;
};
ResidentNameTable parse_resident_name_table(std::istream& is, binparse::Offset32 offset);
diff --git a/le/le_resident_name_table_entry.cpp b/le/le_resident_name_table_entry.cpp
deleted file mode 100644
index a82cbeb..0000000
--- a/le/le_resident_name_table_entry.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "le_resident_name_table_entry.hpp"
-
-#include "parse.hpp"
-#include "output.hpp"
-
-#include <boost/fusion/adapted/struct.hpp>
-
-BOOST_FUSION_ADAPT_STRUCT(
- le::ResidentNameTableEntry,
- (binparse::PString8, string)
- (binparse::Value16, index)
-)
-
-namespace le {
-
-ResidentNameTableEntry parse_resident_name_table_entry(std::istream& is)
-{
- return binparse::parse<ResidentNameTableEntry>(is);
-}
-
-std::ostream&operator<<(std::ostream& os, ResidentNameTableEntry const& entry)
-{
- return binparse::operator<<(os, entry);
-}
-
-} \ No newline at end of file
diff --git a/le/le_resident_name_table_entry.hpp b/le/le_resident_name_table_entry.hpp
deleted file mode 100644
index 95c83bc..0000000
--- a/le/le_resident_name_table_entry.hpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#pragma once
-
-#include "types.hpp"
-
-#include <string>
-
-namespace le {
-
-using binparse::PString8;
-using binparse::Value16;
-
-struct ResidentNameTableEntry {
- PString8 string;
- Value16 index;
-};
-
-ResidentNameTableEntry parse_resident_name_table_entry(std::istream& is);
-
-std::ostream& operator<<(std::ostream& os, ResidentNameTableEntry const& entry);
-
-} \ No newline at end of file