Added str_holder to support <16 length strings.

This commit is contained in:
yuv420p10le 2024-08-26 21:58:44 +03:00
parent d4f1d18bac
commit 7d5a79c019
2 changed files with 22 additions and 6 deletions

View File

@ -376,9 +376,11 @@ bool process_feature(const char* guid, [[maybe_unused]] uintptr_t caller)
return false;
}
uint64_t hook_is_feature_available(uintptr_t user, const char** feature)
uint64_t hook_is_feature_available(uintptr_t user, str_holder* feature)
{
if(process_feature(*feature, reinterpret_cast<uintptr_t>(_ReturnAddress()) - get_current_process_handle()))
std::string_view str(feature->obj.length >= 16 ? feature->obj.str : feature->str);
if(process_feature(str.data(), reinterpret_cast<uintptr_t>(_ReturnAddress()) - get_current_process_handle()))
{
return true;
}
@ -386,10 +388,12 @@ uint64_t hook_is_feature_available(uintptr_t user, const char** feature)
return _is_feature_available.call<uint64_t>(user, feature);
}
uint64_t* hook_map_find(uintptr_t* rcx, uintptr_t rdx, const char** str)
uint64_t* hook_map_find(uintptr_t* rcx, uintptr_t rdx, str_holder* str)
{
std::string_view feature(str->obj.length >= 16 ? str->obj.str : str->str);
if(_feature_manager != nullptr && rcx == &_feature_manager->m_feature_map() &&
process_feature(*str, reinterpret_cast<uintptr_t>(_ReturnAddress()) - get_current_process_handle()))
process_feature(feature.data(), reinterpret_cast<uintptr_t>(_ReturnAddress()) - get_current_process_handle()))
{
static uint64_t FAKE_PTR = 0;

View File

@ -24,11 +24,23 @@ public:
member_at(uintptr_t, m_map_offset, m_feature_map);
};
union str_holder
{
struct
{
const char* str;
uintptr_t pad[2];
size_t length;
} obj;
const char str[16];
};
uintptr_t get_current_process_handle();
std::optional<std::tuple<uintptr_t, uintptr_t>> get_section_info(std::string_view name);
std::optional<uintptr_t> sig_scan(const uintptr_t start, const uintptr_t end, std::string_view pattern);
uint64_t hook_is_feature_available(uintptr_t rcx, const char** guid);
uint64_t* hook_map_find(uintptr_t* rcx, uintptr_t rdx, const char** str);
uint64_t hook_is_feature_available(uintptr_t rcx, str_holder* guid);
uint64_t* hook_map_find(uintptr_t* rcx, uintptr_t rdx, str_holder* str);
void hook_bitset_init(uintptr_t rcx, uintptr_t rdx);
FeatureManager* hook_feature_manager_init(FeatureManager* rcx);
void hook();