2022-04-10 19:59:34 +02:00
|
|
|
#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);
|
2022-09-09 19:47:31 +02:00
|
|
|
CMemory FindPatternSIMD(const uint8_t* szPattern, const char* szMask, const ModuleSections_t& moduleSection = {}, const uint32_t nOccurrence = 0) const;
|
2022-08-15 21:05:42 +02:00
|
|
|
CMemory FindPatternSIMD(const string& svPattern, const ModuleSections_t& moduleSection = {}) const;
|
2022-09-09 19:47:31 +02:00
|
|
|
CMemory FindString(const string& string, const ptrdiff_t occurrence = 1, bool nullTerminator = false) const;
|
2022-04-10 19:59:34 +02:00
|
|
|
CMemory FindStringReadOnly(const string& svString, bool nullTerminator) const;
|
|
|
|
|
2022-08-15 21:05:42 +02:00
|
|
|
CMemory GetVirtualMethodTable(const string& svTableName, const uint32_t nRefIndex = 0);
|
2022-04-10 19:59:34 +02:00
|
|
|
CMemory GetExportedFunction(const string& svFunctionName) const;
|
|
|
|
ModuleSections_t GetSectionByName(const string& svSectionName) const;
|
|
|
|
uintptr_t GetModuleBase(void) const;
|
2022-05-03 02:37:37 +02:00
|
|
|
DWORD GetModuleSize(void) const;
|
2022-04-10 19:59:34 +02:00
|
|
|
string GetModuleName(void) const;
|
|
|
|
|
2022-06-13 23:34:06 +02:00
|
|
|
ModuleSections_t m_ExecutableCode;
|
|
|
|
ModuleSections_t m_ExceptionTable;
|
|
|
|
ModuleSections_t m_RunTimeData;
|
|
|
|
ModuleSections_t m_ReadOnlyData;
|
|
|
|
|
2022-04-10 19:59:34 +02:00
|
|
|
private:
|
|
|
|
string m_svModuleName;
|
|
|
|
uintptr_t m_pModuleBase{};
|
|
|
|
DWORD m_nModuleSize{};
|
|
|
|
IMAGE_NT_HEADERS64* m_pNTHeaders = nullptr;
|
|
|
|
IMAGE_DOS_HEADER* m_pDOSHeader = nullptr;
|
2022-06-13 23:34:06 +02:00
|
|
|
vector<ModuleSections_t> m_vModuleSections;
|
2022-04-10 19:59:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MODULE_H
|