aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/pdb/module.hpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2017-05-17 06:00:20 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2017-05-17 06:00:20 +0300
commitc67055bad3cdfc93e2ac57d87f36c6e0993af690 (patch)
treeda8759c66f1af00415784e5824e6bfc2195aee92 /include/pdb/module.hpp
downloadwinapi-debug-c67055bad3cdfc93e2ac57d87f36c6e0993af690.tar.gz
winapi-debug-c67055bad3cdfc93e2ac57d87f36c6e0993af690.zip
initial commit
Diffstat (limited to '')
-rw-r--r--include/pdb/module.hpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/include/pdb/module.hpp b/include/pdb/module.hpp
new file mode 100644
index 0000000..118a53b
--- /dev/null
+++ b/include/pdb/module.hpp
@@ -0,0 +1,65 @@
+// Copyright (c) 2017 Egor Tensin <Egor.Tensin@gmail.com>
+// This file is part of the "PDB repository" project.
+// For details, see https://github.com/egor-tensin/pdb-repo.
+// Distributed under the MIT License.
+
+#pragma once
+
+#include "address.hpp"
+
+#include <Windows.h>
+#include <DbgHelp.h>
+
+#include <cstring>
+
+#include <string>
+
+namespace pdb
+{
+ class ModuleInfo
+ {
+ public:
+ typedef IMAGEHLP_MODULE64 Raw;
+
+ ModuleInfo()
+ : raw{prepare_buffer()}
+ { }
+
+ explicit ModuleInfo(const Raw& raw)
+ : raw{raw}
+ { }
+
+ explicit operator Raw&() { return raw; }
+
+ explicit operator const Raw&() const { return raw; }
+
+ Address get_offline_base() const { return raw.BaseOfImage; }
+
+ std::string get_name() const { return raw.ModuleName; }
+
+ private:
+ static Raw prepare_buffer()
+ {
+ Raw raw;
+ std::memset(&raw, 0, sizeof(raw));
+ raw.SizeOfStruct = sizeof(raw);
+ return raw;
+ }
+
+ Raw raw;
+ };
+
+ class Module : public ModuleInfo
+ {
+ public:
+ Module(Address online_base, const ModuleInfo& info)
+ : ModuleInfo{info}
+ , online_base{online_base}
+ { }
+
+ Address get_online_base() const { return online_base; }
+
+ private:
+ const Address online_base;
+ };
+}