void CKeyValues3::LoadFromBuffer(const char* szString)
{
CUtlBuffer buffer(0, (memory::StringLength(szString) + 10), 1);
buffer.PutString(szString);
LoadKV3(&buffer);
}
bool CKeyValues3::LoadKV3(CUtlBuffer* buffer)
{
bool(__fastcall * FnLoadKeyValues)(CKeyValues3*, void*, CUtlBuffer*, KV3ID_t*, void*);
using fnLoadKeyValues = bool(__fastcall*)(CKeyValues3*, void*, CUtlBuffer*, KV3ID_t*, void*);
static const fnLoadKeyValues oLoadKeyValues = reinterpret_cast<fnLoadKeyValues>(memory::GetAbsoluteAddress(memory::PatternScan("tier0.dll", "E8 ? ? ? ? EB ? F7 43"), 0x1, 0x0)); // E8 ? ? ? ? EB 36 8B 43 10
const char* szName = "";
KV3ID_t kv3ID = KV3ID_t("generic", 0x41B818518343427E, 0xB5F447C23C0CDF8C);
return oLoadKeyValues(this, nullptr, buffer, &kv3ID, nullptr);
}
CKeyValues3* CKeyValues3::CreateMaterialResource()
{
static void* pSetTypeKV3 = nullptr;
if (!pSetTypeKV3) {
void* pPattern = memory::PatternScan("client.dll", "40 53 48 83 EC ? 4C 8B 11 41 B9");
if (pPattern) {
pSetTypeKV3 = pPattern;
printf("[DEBUG] SetTypeKV3 found at: %p\n", pSetTypeKV3);
} else {
printf("[ERROR] SetTypeKV3 function not found!\n");
return nullptr;
}
}
using fnSetTypeKV3 = CKeyValues3*(__fastcall*)(CKeyValues3*, unsigned int, unsigned int);
auto oSetTypeKV3 = reinterpret_cast<fnSetTypeKV3>(pSetTypeKV3);
CKeyValues3* pKeyValue = new CKeyValues3[0x10];
return oSetTypeKV3(pKeyValue, 1U, 6U);
}