aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/pdb/symbol.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/symbol.hpp
downloadwinapi-debug-c67055bad3cdfc93e2ac57d87f36c6e0993af690.tar.gz
winapi-debug-c67055bad3cdfc93e2ac57d87f36c6e0993af690.zip
initial commit
Diffstat (limited to 'include/pdb/symbol.hpp')
-rw-r--r--include/pdb/symbol.hpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/include/pdb/symbol.hpp b/include/pdb/symbol.hpp
new file mode 100644
index 0000000..9e11d04
--- /dev/null
+++ b/include/pdb/symbol.hpp
@@ -0,0 +1,81 @@
+// 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 "module.hpp"
+
+#include <Windows.h>
+#include <DbgHelp.h>
+
+#include <cstring>
+
+#include <string>
+
+namespace pdb
+{
+ class SymbolInfo
+ {
+ public:
+ typedef SYMBOL_INFO Raw;
+
+ SymbolInfo()
+ : raw{*reinterpret_cast<Raw*>(buffer)}
+ {
+ raw.SizeOfStruct = sizeof(Raw);
+ raw.MaxNameLen = MAX_SYM_NAME;
+ }
+
+ SymbolInfo(const Raw& raw)
+ : SymbolInfo{}
+ {
+ std::memcpy(buffer, &raw, raw.SizeOfStruct + raw.NameLen - 1);
+ }
+
+ explicit operator Raw&() { return raw; }
+
+ explicit operator const Raw&() const { return raw; }
+
+ std::string get_name() const { return {raw.Name, raw.NameLen}; }
+
+ Address get_offline_base() const { return raw.ModBase; }
+
+ Address get_offline_address() const { return raw.Address; }
+
+ typedef ULONG Tag;
+
+ Tag get_tag() const { return raw.Tag; }
+
+ enum class Type : Tag
+ {
+ Function = SymTagFunction,
+ RESERVED = SymTagMax,
+ };
+
+ Type get_type() const { return static_cast<Type>(get_tag()); }
+
+ bool is_function() const { return get_type() == Type::Function; }
+
+ private:
+ unsigned char buffer[sizeof(Raw) + MAX_SYM_NAME - 1];
+
+ protected:
+ Raw& raw;
+ };
+
+ class Symbol : public SymbolInfo
+ {
+ public:
+ Symbol(Address online_address, const SymbolInfo& info)
+ : SymbolInfo{info}
+ , online_address{online_address}
+ { }
+
+ Address get_online_address() const { return online_address; }
+
+ private:
+ const Address online_address;
+ };
+}