diff options
author | Emma Miler <emma.pi@protonmail.com> | 2022-12-19 19:32:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-19 19:32:16 +0100 |
commit | e04f3b36accccb590a2d51b4829256b9964ac3fd (patch) | |
tree | 20ee30c82e6f53e6e772be2e1b9613eebca12bf3 /NorthstarDLL/memory.h | |
parent | 33f18a735986dcd136bf8ba70ad8331306c28227 (diff) | |
download | NorthstarLauncher-e04f3b36accccb590a2d51b4829256b9964ac3fd.tar.gz NorthstarLauncher-e04f3b36accccb590a2d51b4829256b9964ac3fd.zip |
Restructuring (#365)
* Remove launcher proxy
* Restructuring
* More restructuring
* Fix include dirs
* Fix merge
* Remove clang thing
* Filters
* Oops
Diffstat (limited to 'NorthstarDLL/memory.h')
-rw-r--r-- | NorthstarDLL/memory.h | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/NorthstarDLL/memory.h b/NorthstarDLL/memory.h deleted file mode 100644 index 38c76cb3..00000000 --- a/NorthstarDLL/memory.h +++ /dev/null @@ -1,90 +0,0 @@ -#pragma once - -class MemoryAddress -{ - public: - uintptr_t m_nAddress; - - public: - MemoryAddress(); - MemoryAddress(const uintptr_t nAddress); - MemoryAddress(const void* pAddress); - - // operators - operator uintptr_t() const; - operator void*() const; - operator bool() const; - - bool operator==(const MemoryAddress& other) const; - bool operator!=(const MemoryAddress& other) const; - bool operator==(const uintptr_t& addr) const; - bool operator!=(const uintptr_t& addr) const; - - MemoryAddress operator+(const MemoryAddress& other) const; - MemoryAddress operator-(const MemoryAddress& other) const; - MemoryAddress operator+(const uintptr_t& other) const; - MemoryAddress operator-(const uintptr_t& other) const; - MemoryAddress operator*() const; - - template <typename T> T As() - { - return reinterpret_cast<T>(m_nAddress); - } - - // traversal - MemoryAddress Offset(const uintptr_t nOffset) const; - MemoryAddress Deref(const int nNumDerefs = 1) const; - - // patching - void Patch(const uint8_t* pBytes, const size_t nSize); - void Patch(const std::initializer_list<uint8_t> bytes); - void Patch(const char* pBytes); - void NOP(const size_t nSize); - - bool IsMemoryReadable(const size_t nSize); -}; - -// based on https://github.com/Mauler125/r5sdk/blob/master/r5dev/public/include/module.h -class CModule : public MemoryAddress -{ - public: - struct ModuleSections_t - { - ModuleSections_t(void) = default; - ModuleSections_t(const std::string& svSectionName, uintptr_t pSectionBase, size_t nSectionSize) - : m_svSectionName(svSectionName), m_pSectionBase(pSectionBase), m_nSectionSize(nSectionSize) - { - } - - bool IsSectionValid(void) const - { - return m_nSectionSize != 0; - } - - std::string m_svSectionName; // Name of section. - uintptr_t m_pSectionBase {}; // Start address of section. - size_t m_nSectionSize {}; // Size of section. - }; - - ModuleSections_t m_ExecutableCode; - ModuleSections_t m_ExceptionTable; - ModuleSections_t m_RunTimeData; - ModuleSections_t m_ReadOnlyData; - - private: - std::string m_svModuleName; - uintptr_t m_pModuleBase {}; - DWORD m_nModuleSize {}; - IMAGE_NT_HEADERS64* m_pNTHeaders = nullptr; - IMAGE_DOS_HEADER* m_pDOSHeader = nullptr; - std::vector<ModuleSections_t> m_vModuleSections; - - public: - CModule() = delete; // no default, we need a module name - CModule(const HMODULE pModule); - CModule(const char* pModuleName); - - MemoryAddress GetExport(const char* pExportName); - MemoryAddress FindPattern(const uint8_t* pPattern, const char* pMask); - MemoryAddress FindPattern(const char* pPattern); -}; |