diff options
Diffstat (limited to 'include/winapi')
-rw-r--r-- | include/winapi/buffer.hpp | 5 | ||||
-rw-r--r-- | include/winapi/process.hpp | 9 | ||||
-rw-r--r-- | include/winapi/resource.hpp | 27 |
3 files changed, 40 insertions, 1 deletions
diff --git a/include/winapi/buffer.hpp b/include/winapi/buffer.hpp index 246822e..7c8f928 100644 --- a/include/winapi/buffer.hpp +++ b/include/winapi/buffer.hpp @@ -7,6 +7,7 @@ #include <cstddef> #include <cstring> +#include <initializer_list> #include <sstream> #include <stdexcept> #include <string> @@ -21,6 +22,8 @@ public: Buffer() = default; + Buffer(std::initializer_list<unsigned char> lst) : Parent(lst) {} + explicit Buffer(Parent&& src) : Parent(std::move(src)) {} template <typename CharT> @@ -28,7 +31,7 @@ public: set(src); } - explicit Buffer(const void* src, std::size_t nb) { set(src, nb); } + Buffer(const void* src, std::size_t nb) { set(src, nb); } template <typename CharT> void set(const std::basic_string<CharT>& src) { diff --git a/include/winapi/process.hpp b/include/winapi/process.hpp index f404b33..469653c 100644 --- a/include/winapi/process.hpp +++ b/include/winapi/process.hpp @@ -7,10 +7,14 @@ #include "cmd_line.hpp" #include "handle.hpp" +#include "resource.hpp" #include "stream.hpp" #include <boost/config.hpp> +#include <windows.h> + +#include <string> #include <utility> namespace winapi { @@ -52,9 +56,14 @@ public: int get_exit_code() const; + static Resource get_resource(unsigned int id); + static std::string get_resource_string(unsigned int id); + private: explicit Process(Handle&& handle) : m_handle{std::move(handle)} {} + static HMODULE get_exe_module(); + Handle m_handle; }; diff --git a/include/winapi/resource.hpp b/include/winapi/resource.hpp new file mode 100644 index 0000000..2f77d3e --- /dev/null +++ b/include/winapi/resource.hpp @@ -0,0 +1,27 @@ +// Copyright (c) 2020 Egor Tensin <Egor.Tensin@gmail.com> +// This file is part of the "winapi-common" project. +// For details, see https://github.com/egor-tensin/winapi-common. +// Distributed under the MIT License. + +#pragma once + +#include "buffer.hpp" + +#include <cstddef> + +namespace winapi { + +struct Resource { + // This is just a pointer to static data. + + Resource() = default; + + Resource(const void* data, std::size_t nb) : data{data}, nb{nb} {} + + Buffer copy() const { return {data, nb}; } + + const void* data = nullptr; + std::size_t nb = 0; +}; + +} // namespace winapi |