diff --git a/src/hack.cpp b/src/hack.cpp index bd87f163..cd0cfd00 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -259,6 +259,24 @@ void hack::Initialize() { hooks::client.Set(g_IBaseClient); hooks::client.HookMethod((void*)FrameStageNotify_hook, offsets::FrameStageNotify()); hooks::client.HookMethod((void*)DispatchUserMessage_hook, offsets::DispatchUserMessage()); + +#if TEXTMODE + //g_IMaterialSystem->SetInStubMode(true); + /*IF_GAME(IsTF2()) { + logging::Info("Graphics Nullified"); + // TODO offsets::()? + hooks::materialsystem.Set((void*)g_IMaterialSystem); + uintptr_t base = *(uintptr_t*)(g_IMaterialSystem); + hooks::materialsystem.HookMethod((void*)ReloadTextures_null_hook, 70); + hooks::materialsystem.HookMethod((void*)ReloadMaterials_null_hook, 71); + hooks::materialsystem.HookMethod((void*)FindMaterial_null_hook, 73); + hooks::materialsystem.HookMethod((void*)FindTexture_null_hook, 81); + hooks::materialsystem.HookMethod((void*)ReloadFilesInList_null_hook, 121); + hooks::materialsystem.HookMethod((void*)FindMaterialEx_null_hook, 123); + hooks::materialsystem.Apply(); + //hooks::materialsystem.HookMethod(); + }*/ +#endif #ifndef TEXTMODE hooks::client.HookMethod((void*)IN_KeyEvent_hook, offsets::IN_KeyEvent()); #endif /* TEXTMODE */ @@ -288,12 +306,6 @@ void hack::Initialize() { // FIXME [MP] hacks::shared::killsay::Init(); - hack::command_stack().push("exec cat_autoexec"); -#ifdef TEXTMODE - hack::command_stack().push("exec cat_autoexec_textmode"); -#endif - hack::command_stack().push("cat_killsay_reload"); - hack::command_stack().push("cat_spam_reload"); logging::Info("Hooked!"); velocity::Init(); playerlist::Load(); @@ -338,6 +350,13 @@ void hack::Initialize() { init_stack().pop(); } logging::Info("Initializer stack done"); + +#ifdef TEXTMODE + hack::command_stack().push("exec cat_autoexec_textmode"); +#endif + hack::command_stack().push("exec cat_autoexec"); + hack::command_stack().push("cat_killsay_reload"); + hack::command_stack().push("cat_spam_reload"); } void hack::Think() { diff --git a/src/helpers.cpp b/src/helpers.cpp index 18525921..d614daf8 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -771,6 +771,9 @@ CatCommand print_classnames("debug_print_classnames", "Lists classnames currentl }); void PrintChat(const char* fmt, ...) { +#if TEXTMODE + return; +#endif CHudBaseChat* chat = (CHudBaseChat*)g_CHUD->FindElement("CHudChat"); if (chat) { char* buf = new char[1024]; diff --git a/src/hooks.cpp b/src/hooks.cpp index 1401cb4d..3e86ca27 100644 --- a/src/hooks.cpp +++ b/src/hooks.cpp @@ -87,5 +87,6 @@ VMTHook matsurface {}; VMTHook studiorender {}; VMTHook modelrender {}; VMTHook clientmode4 {}; +VMTHook materialsystem {}; } diff --git a/src/hooks.h b/src/hooks.h index 7b37ce9c..a2f47388 100644 --- a/src/hooks.h +++ b/src/hooks.h @@ -59,6 +59,7 @@ extern VMTHook modelrender; extern VMTHook baseclientstate; extern VMTHook baseclientstate8; extern VMTHook steamfriends; +extern VMTHook materialsystem; } diff --git a/src/hooks/nographics.cpp b/src/hooks/nographics.cpp new file mode 100644 index 00000000..8f047361 --- /dev/null +++ b/src/hooks/nographics.cpp @@ -0,0 +1,31 @@ +/* + * nographics.cpp + * + * Created on: Aug 1, 2017 + * Author: nullifiedcat + */ + +#include "../common.h" + +/*// 81 +ITexture *FindTexture_null_hook(void* this_, char const* pTextureName, const char *pTextureGroupName, bool complain, int nAdditionalCreationFlags) { + static ITexture *st = ((FindTexture_t)hooks::materialsystem.GetMethod(81))(this_, pTextureName, pTextureGroupName, complain, nAdditionalCreationFlags); + return st; +} + +// 123 +IMaterial *FindMaterialEx_null_hook(void* this_, char const* pMaterialName, const char *pTextureGroupName, int nContext, bool complain, const char *pComplainPrefix) { + static IMaterial *st = ((FindMaterialEx_t)hooks::materialsystem.GetMethod(123))(this_, pMaterialName, pTextureGroupName, nContext, complain, pComplainPrefix); + return st; +} + +// 73 +IMaterial *FindMaterial_null_hook(void* this_, char const* pMaterialName, const char *pTextureGroupName, bool complain, const char *pComplainPrefix) { + static IMaterial *st = ((FindMaterial_t)hooks::materialsystem.GetMethod(73))(this_, pMaterialName, pTextureGroupName, complain, pComplainPrefix); + return st; +} + +void ReloadTextures_null_hook(void* this_) {} +void ReloadMaterials_null_hook(void* this_, const char *pSubString) {} +void ReloadFilesInList_null_hook(void* this_, IFileList *pFilesToReload) {} +*/ diff --git a/src/hooks/others.h b/src/hooks/others.h index 48173386..dfbfe301 100644 --- a/src/hooks/others.h +++ b/src/hooks/others.h @@ -26,6 +26,20 @@ void FrameStageNotify_hook(void*, int); void LevelInit_hook(void*, const char*); void LevelShutdown_hook(void*); + +#ifdef TEXTMODE +typedef ITexture*(*FindTexture_t)(void*, const char*, const char*, bool, int); +typedef IMaterial*(*FindMaterialEx_t)(void*, const char*, const char*, int, bool, const char*); +typedef IMaterial*(*FindMaterial_t)(void*, const char*, const char*, bool, const char*); + +/* 70 */ void ReloadTextures_null_hook(void* this_); +/* 71 */ void ReloadMaterials_null_hook(void* this_, const char *pSubString); +/* 73 */ IMaterial *FindMaterial_null_hook(void* this_, char const* pMaterialName, const char *pTextureGroupName, bool complain, const char *pComplainPrefix); +/* 81 */ ITexture *FindTexture_null_hook(void* this_, char const* pTextureName, const char *pTextureGroupName, bool complain, int nAdditionalCreationFlags); +/* 121 */ void ReloadFilesInList_null_hook(void* this_, IFileList *pFilesToReload); +/* 123 */ IMaterial *FindMaterialEx_null_hook(void* this_, char const* pMaterialName, const char *pTextureGroupName, int nContext, bool complain, const char *pComplainPrefix); +#endif + //extern unsigned int* swapwindow_ptr; //extern unsigned int swapwindow_orig; diff --git a/src/interfaces.cpp b/src/interfaces.cpp index 84da2249..3b7061d9 100644 --- a/src/interfaces.cpp +++ b/src/interfaces.cpp @@ -127,13 +127,13 @@ void CreateInterfaces() { logging::Info("GTFGCClientSystem() = 0x%08x", get_gc); g_TFGCClientSystem = get_gc(); } + g_IMaterialSystem = BruteforceInterface("VMaterialSystem", sharedobj::materialsystem()); #ifndef TEXTMODE g_IVDebugOverlay = BruteforceInterface("VDebugOverlay", sharedobj::engine()); g_IPanel = BruteforceInterface("VGUI_Panel", sharedobj::vgui2()); g_ISurface = BruteforceInterface("VGUI_Surface", sharedobj::vguimatsurface()); g_IStudioRender = BruteforceInterface("VStudioRender", sharedobj::studiorender()); - g_IMaterialSystem = BruteforceInterface("VMaterialSystem", sharedobj::materialsystem()); g_IVRenderView = BruteforceInterface("VEngineRenderView", sharedobj::engine()); g_IMaterialSystemHL = (IMaterialSystem*)g_IMaterialSystem; IF_GAME (IsTF2()) { diff --git a/src/ipc.cpp b/src/ipc.cpp index 1edefb60..ec49303b 100644 --- a/src/ipc.cpp +++ b/src/ipc.cpp @@ -193,7 +193,7 @@ void StoreClientData() { UpdateServerAddress(); user_data_s& data = peer->memory->peer_user_data[peer->client_id]; data.friendid = g_ISteamUser->GetSteamID().GetAccountID(); - strncpy(data.name, g_ISteamFriends->GetPersonaName(), sizeof(data.name)); + strncpy(data.name, GetFriendPersonaName_hook(g_ISteamFriends, g_ISteamUser->GetSteamID()), sizeof(data.name)); } diff --git a/src/sharedobj.cpp b/src/sharedobj.cpp index ef45f5d0..3f12bb14 100644 --- a/src/sharedobj.cpp +++ b/src/sharedobj.cpp @@ -79,11 +79,11 @@ void LoadAllSharedObjects() { vstdlib().Load(); tier0().Load(); inputsystem().Load(); + materialsystem().Load(); #ifndef TEXTMODE vguimatsurface().Load(); vgui2().Load(); studiorender().Load(); - materialsystem().Load(); libsdl().Load(); #endif } catch (std::exception& ex) { @@ -115,6 +115,10 @@ SharedObject& inputsystem() { static SharedObject obj("inputsystem.so", true); return obj; } +SharedObject& materialsystem() { + static SharedObject obj("materialsystem.so", true); + return obj; +} #ifndef TEXTMODE SharedObject& vguimatsurface() { static SharedObject obj("vguimatsurface.so", true); @@ -128,10 +132,6 @@ SharedObject& studiorender() { static SharedObject obj("studiorender.so", true); return obj; } -SharedObject& materialsystem() { - static SharedObject obj("materialsystem.so", true); - return obj; -} SharedObject& libsdl() { static SharedObject obj("libSDL2-2.0.so.0", false); return obj; diff --git a/src/sharedobj.h b/src/sharedobj.h index ef3e4ebd..57356101 100644 --- a/src/sharedobj.h +++ b/src/sharedobj.h @@ -42,11 +42,11 @@ SharedObject& engine(); SharedObject& vstdlib(); SharedObject& tier0(); SharedObject& inputsystem(); +SharedObject& materialsystem(); #ifndef TEXTMODE SharedObject& vguimatsurface(); SharedObject& vgui2(); SharedObject& studiorender(); -SharedObject& materialsystem(); SharedObject& libsdl(); #endif