43 std::memcpy(&
word,
reinterpret_cast<const void*
>(
address),
sizeof(
word));
50 std::memcpy(&value,
reinterpret_cast<const void*
>(
address),
sizeof(value));
56 std::vector<uintptr_t>
found;
84 const std::string_view
memory(
reinterpret_cast<const char*
>(
range.Base),
range.Size);
88 if (
at > 0 && (std::isalnum(
static_cast<unsigned char>(
memory[
at - 1])) ||
memory[
at - 1] ==
'_'))
101 return reinterpret_cast<void*
>(
typeInfo +
sizeof(
void*));
135 const auto* name =
reinterpret_cast<const char*
>(
ReadWord(
address +
sizeof(
void*)));
140 return std::isdigit(
static_cast<unsigned char>(*name)) || *name ==
'N' || *name ==
'*';
145 const auto* name =
reinterpret_cast<const char*
>(
ReadWord(
address +
sizeof(
void*)));
147 name[
wanted.size()] ==
'\0';
152 if (
kinds.SingleBase)
179 if (!
kinds.MultipleBases &&
238 return std::unexpected(
Error::Invalid(
"the class has no readable typeinfo"));
242 std::vector<FoundBase>
found;
249 if (
found.size() > 1)
253 if (
found.front().Virtual)
257 return static_cast<int>(
found.front().Offset);
262 void*
found =
nullptr;
void Warn(std::format_string< Args... > fmt, Args &&... args)
void * FindVirtualTableByTypeInfo(std::span< const ScanRange > ranges, const void *typeInfo, intptr_t offsetToTop)
bool FindImage(std::string_view moduleName, Image &module)
static constexpr int MaxDepth
static std::vector< uintptr_t > FindWords(std::span< const ScanRange > ranges, uintptr_t value)
static uint32_t ReadU32(uintptr_t address)
static std::string ReadFile(const std::filesystem::path &path)
bool IsExecutableAddress(const void *address)
bool IsReadableAddress(const void *address, size_t bytes)
static uintptr_t ReadWord(uintptr_t address)
static void CollectBases(uintptr_t typeInfo, std::string_view wanted, FoundBase at, const TypeInfoKinds &kinds, int depth, std::vector< FoundBase > &found)
static bool HasSingleBase(uintptr_t typeInfo, const TypeInfoKinds &kinds)
static bool NameIs(uintptr_t address, std::string_view wanted)
static bool LooksLikeTypeInfo(uintptr_t address)
Result< int > FindBaseOffsetByTypeInfo(const void *typeInfo, std::string_view baseName, const TypeInfoKinds &kinds)
static uint32_t BaseCount(uintptr_t typeInfo, const TypeInfoKinds &kinds)
static constexpr size_t TypeInfoFlags
static constexpr uintptr_t VirtualBaseFlag
void * FindVirtualTableByTypeName(std::span< const ScanRange > ranges, std::string_view className)
static constexpr size_t TypeInfoCount
std::string LengthPrefixedName(std::string_view className)
static constexpr size_t BaseEntrySize
static constexpr uint32_t MaxBases
static constexpr size_t TypeInfoBaseList
void * FindVirtualTable(std::string_view moduleName, std::string_view className)
static constexpr size_t TypeInfoBase
std::expected< T, Error > Result
std::string PlatformModuleName(std::string_view moduleName)
bool IsInstanceOf(const void *object, const void *table)
void * FindVirtualTableIn(const Image &module, std::string_view className)
static Error Invalid(std::string detail)
static Error Unsupported(std::string detail)
static Error NotFound(std::string detail)