diff options
author | Davide Beatrici <git@davidebeatrici.dev> | 2020-11-02 11:09:40 +0300 |
---|---|---|
committer | Davide Beatrici <git@davidebeatrici.dev> | 2020-11-02 11:15:54 +0300 |
commit | c96153e2c6d80239404fd58f7e06aefd55bdc7bd (patch) | |
tree | 5c9691532ff9cc9132a0091773c9f7156bfecdbc /plugins | |
parent | d7f0302ce721c28ab9b4928ac5e65c0670f9d266 (diff) |
REFAC(plugins): Move "m_ok" variable from HostLinux and HostWindows to Process
HostWindows' constructor only initializes its variables now, like HostLinux'.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/HostLinux.cpp | 2 | ||||
-rw-r--r-- | plugins/HostLinux.h | 3 | ||||
-rw-r--r-- | plugins/HostWindows.cpp | 2 | ||||
-rw-r--r-- | plugins/HostWindows.h | 3 | ||||
-rw-r--r-- | plugins/Process.cpp | 2 | ||||
-rw-r--r-- | plugins/Process.h | 3 | ||||
-rw-r--r-- | plugins/ProcessLinux.cpp | 6 | ||||
-rw-r--r-- | plugins/ProcessWindows.cpp | 6 |
8 files changed, 6 insertions, 21 deletions
diff --git a/plugins/HostLinux.cpp b/plugins/HostLinux.cpp index 146e4f086..cf8fcb4c4 100644 --- a/plugins/HostLinux.cpp +++ b/plugins/HostLinux.cpp @@ -12,7 +12,7 @@ #include <sys/uio.h> -HostLinux::HostLinux(const procid_t pid) : m_ok(true), m_pid(pid) { +HostLinux::HostLinux(const procid_t pid) : m_pid(pid) { } HostLinux::~HostLinux() { diff --git a/plugins/HostLinux.h b/plugins/HostLinux.h index ec24b61f9..6cf56fcf3 100644 --- a/plugins/HostLinux.h +++ b/plugins/HostLinux.h @@ -15,12 +15,9 @@ typedef uint64_t procptr_t; class HostLinux { protected: - bool m_ok; procid_t m_pid; public: - inline bool isOk() const { return m_ok; } - bool peek(const procptr_t address, void *dst, const size_t size) const; procptr_t module(const std::string &module) const; diff --git a/plugins/HostWindows.cpp b/plugins/HostWindows.cpp index 6d3ea43ad..66e6c6d43 100644 --- a/plugins/HostWindows.cpp +++ b/plugins/HostWindows.cpp @@ -10,7 +10,7 @@ #include <windows.h> #include <tlhelp32.h> -HostWindows::HostWindows(const procid_t pid) : m_ok(true), m_pid(pid) { +HostWindows::HostWindows(const procid_t pid) : m_pid(pid) { } HostWindows::~HostWindows() { diff --git a/plugins/HostWindows.h b/plugins/HostWindows.h index 5c8b88852..b42c1dbc1 100644 --- a/plugins/HostWindows.h +++ b/plugins/HostWindows.h @@ -15,12 +15,9 @@ typedef uint64_t procptr_t; class HostWindows { protected: - bool m_ok; procid_t m_pid; public: - inline bool isOk() const { return m_ok; } - bool peek(const procptr_t address, void *dst, const size_t size) const; procptr_t module(const std::string &module) const; diff --git a/plugins/Process.cpp b/plugins/Process.cpp index 46c0c40dc..ad5a6b7c7 100644 --- a/plugins/Process.cpp +++ b/plugins/Process.cpp @@ -9,7 +9,7 @@ #include <chrono> -Process::Process(const procid_t id, const std::string &name) : Host(id), m_name(name), m_pointerSize(0) { +Process::Process(const procid_t id, const std::string &name) : Host(id), m_ok(false), m_name(name), m_pointerSize(0) { } Process::~Process() { diff --git a/plugins/Process.h b/plugins/Process.h index 5ca184bd7..8e1db93ab 100644 --- a/plugins/Process.h +++ b/plugins/Process.h @@ -21,6 +21,7 @@ using Host = HostLinux; /// Only defines stuff that can be used with both Linux and Windows processes. class Process : public Host { protected: + bool m_ok; std::string m_name; uint8_t m_pointerSize; @@ -28,6 +29,8 @@ public: using Host::module; using Host::peek; + inline bool isOk() const { return m_ok; } + template< typename T > inline bool peek(const procptr_t address, T &dst) const { return peek(address, &dst, sizeof(T)); } diff --git a/plugins/ProcessLinux.cpp b/plugins/ProcessLinux.cpp index d42c0b57e..a263d4c55 100644 --- a/plugins/ProcessLinux.cpp +++ b/plugins/ProcessLinux.cpp @@ -8,12 +8,6 @@ #include <elf.h> ProcessLinux::ProcessLinux(const procid_t id, const std::string &name) : Process(id, name) { - if (!m_ok) { - return; - } - - m_ok = false; - const auto address = module(name); if (!address) { return; diff --git a/plugins/ProcessWindows.cpp b/plugins/ProcessWindows.cpp index d94a9157a..b872cf64d 100644 --- a/plugins/ProcessWindows.cpp +++ b/plugins/ProcessWindows.cpp @@ -8,12 +8,6 @@ #include "mumble_plugin_win32_internals.h" ProcessWindows::ProcessWindows(const procid_t id, const std::string &name) : Process(id, name) { - if (!m_ok) { - return; - } - - m_ok = false; - const auto address = module(name); if (!address) { return; |