Kawe Mazidjatari 8c1dfb50f4 Address class cleanup/improvements
* Move most definitions to implementation file to avoid recompiling whole program for small changes
* Pass strings by reference for where possible.
* Split Module class to dedicated file.
* Add const qualifiers to all eligible methods for address/module class
* Some renaming
2022-04-10 19:59:34 +02:00

43 lines
1.4 KiB
C++

#ifndef MODULE_H
#define MODULE_H
class CModule
{
public:
struct ModuleSections_t
{
ModuleSections_t(void) = default;
ModuleSections_t(const 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;
}
string m_svSectionName; // Name of section.
uintptr_t m_pSectionBase{}; // Start address of section.
size_t m_nSectionSize{}; // Size of section.
};
CModule(void) = default;
CModule(const string& moduleName);
CMemory FindPatternSIMD(const uint8_t* szPattern, const char* szMask) const;
CMemory FindString(const string& string, const ptrdiff_t occurence = 1, bool nullTerminator = false) const;
CMemory FindStringReadOnly(const string& svString, bool nullTerminator) const;
CMemory GetExportedFunction(const string& svFunctionName) const;
ModuleSections_t GetSectionByName(const string& svSectionName) const;
uintptr_t GetModuleBase(void) const;
string GetModuleName(void) const;
private:
string m_svModuleName;
uintptr_t m_pModuleBase{};
DWORD m_nModuleSize{};
IMAGE_NT_HEADERS64* m_pNTHeaders = nullptr;
IMAGE_DOS_HEADER* m_pDOSHeader = nullptr;
vector<ModuleSections_t> m_vModuleSections{};
};
#endif // MODULE_H