@@ -237,15 +237,8 @@ inline auto ParsePattern(const std::string_view svInput)
237237 return result;
238238}
239239
240- class CModule
240+ class CModule : public CMemory
241241{
242- private:
243- std::string m_sPath;
244- std::string m_sLastError;
245- std::vector<Section_t> m_vecSections;
246- const Section_t *m_pExecutableSection;
247- void * m_pHandle;
248-
249242public:
250243 template <std::size_t SIZE>
251244 class CSignatureView : public Pattern_t <SIZE>
@@ -261,6 +254,8 @@ class CModule
261254 constexpr CSignatureView (const Base_t& pattern, CModule* module ) : Base_t(pattern), m_pModule(module ) {}
262255 constexpr CSignatureView (Base_t&& pattern, CModule* module ) : Base_t(std::move(pattern)), m_pModule(module ) {}
263256
257+ bool IsValid () const { return m_pModule && m_pModule->IsValid (); }
258+
264259 [[nodiscard]]
265260 CMemory operator ()(const CMemory pStart = nullptr , const Section_t* pSection = nullptr ) const
266261 {
@@ -274,14 +269,22 @@ class CModule
274269 [[nodiscard]] CMemory OffsetAndFind (const std::ptrdiff_t offset, CMemory pStart, const Section_t* pSection = nullptr ) const { return Find (pStart + offset, pSection); }
275270 [[nodiscard]] CMemory OffsetFromSelfAndFind (const CMemory pStart, const Section_t* pSection = nullptr ) const { return OffsetAndFind (Base_t::m_nSize, pStart, pSection); }
276271 [[nodiscard]] CMemory DerefAndFind (const std::uintptr_t deref, CMemory pStart, const Section_t* pSection = nullptr ) const { return Find (pStart.Deref (deref), pSection); }
277- }; // struct CSignatureView
272+ }; // class CSignatureView<SIZE>
278273
279- CModule () : m_pExecutableSection(nullptr ), m_pHandle(nullptr ) {}
274+ private:
275+ std::string m_sPath;
276+ std::string m_sLastError;
277+ std::vector<Section_t> m_vecSections;
278+
279+ const Section_t *m_pExecutableSection;
280+
281+ public:
282+ CModule () : m_pExecutableSection(nullptr ) {}
280283 ~CModule ();
281284
282285 CModule (const CModule&) = delete ;
283286 CModule& operator =(const CModule&) = delete ;
284- CModule (CModule&& other) noexcept : m_sPath(std::move(other.m_sPath)), m_vecSections(std::move(other.m_vecSections)), m_pExecutableSection(std::move(other.m_pExecutableSection)), m_pHandle(std::move(other.m_pHandle)) {}
287+ CModule (CModule&& other) noexcept = default ;
285288 CModule (const CMemory pModuleMemory);
286289 explicit CModule (const std::string_view svModuleName);
287290 explicit CModule (const char * pszModuleName) : CModule(std::string_view(pszModuleName)) {}
@@ -466,7 +469,7 @@ class CModule
466469 [[nodiscard]] CMemory GetVirtualTableByName (const std::string_view svTableName, bool bDecorated = false ) const ;
467470 [[nodiscard]] CMemory GetFunctionByName (const std::string_view svFunctionName) const noexcept ;
468471
469- [[nodiscard]] void * GetHandle () const noexcept { return m_pHandle ; }
472+ [[nodiscard]] void * GetHandle () const noexcept { return GetPtr () ; }
470473 [[nodiscard]] CMemory GetBase () const noexcept ;
471474 [[nodiscard]] std::string_view GetPath () const { return m_sPath; }
472475 [[nodiscard]] std::string_view GetLastError () const { return m_sLastError; }
@@ -484,6 +487,13 @@ class CModule
484487 void SaveLastError ();
485488}; // class CModule
486489
490+ class Module final : CModule
491+ {
492+ public:
493+ using CBase = CModule;
494+ using CBase::CBase;
495+ };
496+
487497} // namespace DynLibUtils
488498
489499#endif // DYNLIBUTILS_MODULE_HPP
0 commit comments