Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class cKeyValues
- {
- char __pad[6000];
- };
- bool bDataCompare(const BYTE *pData, const BYTE *bMask, const char *szMask)
- {
- for (; *szMask; ++szMask, ++pData, ++bMask)
- if (*szMask == 'x' && *pData != *bMask)
- return false;
- return (*szMask) == NULL;
- }
- DWORD dwFindPattern(DWORD dwAddress, DWORD dwLen, BYTE *bMask, char *szMask)
- {
- for (DWORD i = 0; i < dwLen; i++)
- if (bDataCompare((BYTE*)(dwAddress + i), bMask, szMask))
- return (DWORD)(dwAddress + i);
- return 0;
- }
- void GameFunc_InitKeyValues(cKeyValues* pKeyValues, const char* name)
- {
- /*Mid function Pattern -> sub 0x45*/
- /*8B 0E 33 4D FC 81 E1 ? ? ? ? 31 0E 88 46 03 C1 F8 08 66 89 46 12 8B C6*/
- static uint32_t funcAddr = dwFindPattern((DWORD)GetModuleHandleA(XOR("client.dll")), MAXDWORD, (PBYTE)"\x8B\x0E\x33\x4D\xFC\x81\xE1\x00\x00\x00\x00\x31\x0E\x88\x46\x03\xC1\xF8\x08\x66\x89\x46\x12\x8B\xC6", "xxxxxxx????xxxxxxxxxxxxxx") - 0x45;
- typedef void(__thiscall* orgGameFunc_InitKeyValues)(void* thisptr, const char* name);
- static orgGameFunc_InitKeyValues pInitKeyValues = reinterpret_cast<orgGameFunc_InitKeyValues>(funcAddr);
- pInitKeyValues(pKeyValues, name);
- }
- void GameFunc_LoadFromBuffer(cKeyValues* pKeyValues, const char* resourceName, const char* pBuffer, IBaseFileSystem* pFileSystem = nullptr, const char* pPathID = NULL, void* pfnEvaluateSymbolProc = nullptr)
- {
- /*55 8B EC 83 E4 F8 83 EC 34 53 8B 5D 0C 89 4C 24 04*/
- static uint32_t funcAddr = dwFindPattern((DWORD)GetModuleHandleA(XOR("client.dll")), MAXDWORD, (PBYTE)"\x55\x8B\xEC\x83\xE4\xF8\x83\xEC\x34\x53\x8B\x5D\x0C\x89\x4C\x24\x04", "xxxxxxxxxxxxxxxxx");
- typedef void(__thiscall* orgGameFunc_LoadFromBuffer)(void* thisptr, const char* resourceName, const char* pBuffer, IBaseFileSystem* pFileSystem, const char* pPathID, void* pfnEvaluateSymbolProc);
- static orgGameFunc_LoadFromBuffer pLoadFromBuffer = reinterpret_cast<orgGameFunc_LoadFromBuffer>(funcAddr);
- pLoadFromBuffer(pKeyValues, resourceName, pBuffer, pFileSystem, pPathID, pfnEvaluateSymbolProc);
- }
- IMaterial* CreateMaterial()
- {
- /*Assemble the material*/
- //std::string std_StrMaterialData1 = "\"VertexLitGeneric\"\n{\n\t\"$basetexture\" \"vgui/white_additive\"\n\t\"$envmap\" \"\"\n\t\"$model\" \"1\"\n\t\"$flat\" \"1\"\n\t\"$nocull\" \"0\"\n\t\"$selfillum\" \"1\"\n\t\"$halflambert\" \"1\"\n\t\"$nofog\" \"0\"\n\t\"$znearer\" \"0\"\n\t\"$wireframe\" \"0\"\n}\n";
- std::string std_StrMaterialData2 = XOR("\"VertexLitGeneric\"\n{\n\t\"$basetexture\" \"vgui/white_additive\"\n\t\"$envmap\" \"\"\n\t\"$model\" \"1\"\n\t\"$flat\" \"1\"\n\t\"$nocull\" \"0\"\n\t\"$selfillum\" \"1\"\n\t\"$halflambert\" \"1\"\n\t\"$nofog\" \"1\"\n\t\"$znearer\" \"1\"\n\t\"$wireframe\" \"0\"\n}\n");
- std::string std_StrMaterialName = XOR("mmat.vtf");
- /*Register the material*/
- cKeyValues* pKeyValues = new cKeyValues();
- GameFunc_InitKeyValues(pKeyValues, XOR("VertexLitGeneric"));
- GameFunc_LoadFromBuffer(pKeyValues, std_StrMaterialName.c_str(), std_StrMaterialData2.c_str(), nullptr, NULL, nullptr);
- /*Create the new material (Increasing refCount by 1 to keep engine from freeing it)*/
- IMaterial* pMaterial = materials->CreateMaterial(std_StrMaterialName.c_str(), pKeyValues);
- pMaterial->IncrementReferenceCount();
- return pMaterial;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement