From b3e6da21dccc47ba685c79a38cd558614d453870 Mon Sep 17 00:00:00 2001 From: TheApadayo Date: Tue, 27 Dec 2016 10:42:13 -0500 Subject: [PATCH] [Materials] Add material compare hook. - It takes forever to run with it on because there are so many comparisons and logging it takes a while --- src/Components/Modules/Materials.cpp | 27 ++++++++++++++++++++++++--- src/Components/Modules/Materials.hpp | 1 + 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/Components/Modules/Materials.cpp b/src/Components/Modules/Materials.cpp index 1b60ca5c..2c1a812e 100644 --- a/src/Components/Modules/Materials.cpp +++ b/src/Components/Modules/Materials.cpp @@ -30,7 +30,7 @@ namespace Components { Materials::ImageNameLength = 4 + length; std::string image(imagePtr, length); - + return Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, image.data()).material; } @@ -65,7 +65,7 @@ namespace Components int Materials::WriteDeathMessageIcon(char* string, int offset, Game::Material* material) { - if (!material) + if (!material) { material = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, "default").material; } @@ -126,6 +126,24 @@ namespace Components fclose(fp); } } + + int Materials::MaterialComparePrint(Game::Material* m1, Game::Material* m2) + { + static Game::Material* a = m1; + static Game::Material* b = m2; + int result = 0; + __asm + { + push m1 + push m2 + mov eax, 0x5235B0 + call eax + add esp, 8 + mov result, eax + } + return result; + } + #endif Materials::Materials() @@ -160,13 +178,16 @@ namespace Components Utils::Hook::Nop(0x51F5AC, 5); Utils::Hook::Nop(0x51F4C4, 5); } + + Logger::Print("%d\n", sizeof(int (*)(Game::Material*, Game::Material*))); + Utils::Hook::Set(0x523894, static_cast(Materials::MaterialComparePrint)); #endif // Renderer::OnFrame([] () // { // Game::Font* font = Game::R_RegisterFont("fonts/normalFont"); // float color[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; -// +// // Game::R_AddCmdDrawText("test^==preview_mp_rustzob", 0x7FFFFFFF, font, 500.0f, 150.0f, 1.0f, 1.0f, 0.0f, color, Game::ITEM_TEXTSTYLE_SHADOWED); // }); } diff --git a/src/Components/Modules/Materials.hpp b/src/Components/Modules/Materials.hpp index bc95d454..47ca95d7 100644 --- a/src/Components/Modules/Materials.hpp +++ b/src/Components/Modules/Materials.hpp @@ -28,6 +28,7 @@ namespace Components #ifdef DEBUG static void DumpImageCfg(int, const char*, const char* material); static void DumpImageCfgPath(int, const char*, const char* material); + static int MaterialComparePrint(Game::Material* m1, Game::Material* m2); #endif }; }