diff options
Diffstat (limited to 'include/winapi/debug/address.hpp')
-rw-r--r-- | include/winapi/debug/address.hpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/include/winapi/debug/address.hpp b/include/winapi/debug/address.hpp new file mode 100644 index 0000000..3d7acd6 --- /dev/null +++ b/include/winapi/debug/address.hpp @@ -0,0 +1,34 @@ +// Copyright (c) 2017 Egor Tensin <Egor.Tensin@gmail.com> +// This file is part of the "winapi-debug" project. +// For details, see https://github.com/egor-tensin/winapi-debug. +// Distributed under the MIT License. + +#pragma once + +#include <windows.h> + +#include <sstream> +#include <string> + +namespace pdb { + +typedef DWORD64 Address; + +inline std::string format_address(Address address) { + std::ostringstream oss; + oss << std::hex << std::showbase << address; + return oss.str(); +} + +inline std::string format_address(void* address) { + return format_address(reinterpret_cast<Address>(address)); +} + +inline bool parse_address(Address& dest, const std::string& src) { + std::istringstream iss{src}; + iss >> std::hex; + char c; + return iss >> dest && !iss.get(c); +} + +} // namespace pdb |