|
|
Thanks to Akatsuki
Remember to call "BaseUI_InstallHook" while loading client
IBaseUI.h
- #ifndef IBASEUI_H
- #define IBASEUI_H
- #ifdef _WIN32
- #pragma once
- #endif
- #include "interface.h"
- struct cl_enginefuncs_s;
- class IBaseSystem;
- namespace vgui2
- {
- class Panel;
- }
- class IBaseUI : public IBaseInterface
- {
- public:
- virtual void Initialize(CreateInterfaceFn *factories, int count) = 0;
- virtual void Start(struct cl_enginefuncs_s *engineFuncs, int interfaceVersion) = 0;
- virtual void Shutdown(void) = 0;
- virtual int Key_Event(int down, int keynum, const char *pszCurrentBinding) = 0;
- virtual void CallEngineSurfaceProc(void *hwnd, unsigned int msg, unsigned int wparam, long lparam) = 0;
- virtual void Paint(int x, int y, int right, int bottom) = 0;
- virtual void HideGameUI(void) = 0;
- virtual void ActivateGameUI(void) = 0;
- virtual bool IsGameUIVisible(void) = 0;
- virtual void HideConsole(void) = 0;
- virtual void ShowConsole(void) = 0;
- };
- #define BASEUI_INTERFACE_VERSION "BaseUI001"
- #endif
- void BaseUI_InstallHook(void);
复制代码 BaseUI.cpp
- #include <metahook.h>
- #include <IBaseUI.h>
- IBaseUI *g_pBaseUI = 0;
- void (__fastcall *g_pfnCBaseUI_Initialize)(void *pthis, int edx, CreateInterfaceFn *factories, int count) = 0;
- void (__fastcall *g_pfnCBaseUI_Start)(void *pthis, int edx, struct cl_enginefuncs_s *engineFuncs, int interfaceVersion) = 0;
- void (__fastcall *g_pfnCBaseUI_Shutdown)(void *pthis, int edx) = 0;
- int (__fastcall *g_pfnCBaseUI_Key_Event)(void *pthis, int edx, int down, int keynum, const char *pszCurrentBinding) = 0;
- void (__fastcall *g_pfnCBaseUI_CallEngineSurfaceProc)(void *pthis, int edx, void *hwnd, unsigned int msg, unsigned int wparam, long lparam) = 0;
- void (__fastcall *g_pfnCBaseUI_Paint)(void *pthis, int edx, int x, int y, int right, int bottom) = 0;
- void (__fastcall *g_pfnCBaseUI_HideGameUI)(void *pthis, int edx) = 0;
- void (__fastcall *g_pfnCBaseUI_ActivateGameUI)(void *pthis, int edx) = 0;
- bool (__fastcall *g_pfnCBaseUI_IsGameUIVisible)(void *pthis, int edx) = 0;
- void (__fastcall *g_pfnCBaseUI_HideConsole)(void *pthis, int edx) = 0;
- void (__fastcall *g_pfnCBaseUI_ShowConsole)(void *pthis, int edx) = 0;
- class CBaseUI : public IBaseUI
- {
- public:
- void Initialize(CreateInterfaceFn *factories, int count);
- void Start(struct cl_enginefuncs_s *engineFuncs, int interfaceVersion);
- void Shutdown(void);
- int Key_Event(int down, int keynum, const char *pszCurrentBinding);
- void CallEngineSurfaceProc(void *hwnd, unsigned int msg, unsigned int wparam, long lparam);
- void Paint(int x, int y, int right, int bottom);
- void HideGameUI(void);
- void ActivateGameUI(void);
- bool IsGameUIVisible(void);
- void HideConsole(void);
- void ShowConsole(void);
- };
- void CBaseUI::Initialize(CreateInterfaceFn *factories, int count)
- {
- return g_pfnCBaseUI_Initialize(this, 0, factories, count);
- }
- void CBaseUI::Start(struct cl_enginefuncs_s *engineFuncs, int interfaceVersion)
- {
- return g_pfnCBaseUI_Start(this, 0, engineFuncs, interfaceVersion);
- }
- void CBaseUI::Shutdown(void)
- {
- return g_pfnCBaseUI_Shutdown(this, 0);
- }
- int CBaseUI::Key_Event(int down, int keynum, const char *pszCurrentBinding)
- {
- return g_pfnCBaseUI_Key_Event(this, 0, down, keynum, pszCurrentBinding);
- }
- void CBaseUI::CallEngineSurfaceProc(void *hwnd, unsigned int msg, unsigned int wparam, long lparam)
- {
- return g_pfnCBaseUI_CallEngineSurfaceProc(this, 0, hwnd, msg, wparam, lparam);
- }
- void CBaseUI::Paint(int x, int y, int right, int bottom)
- {
- return g_pfnCBaseUI_Paint(this, 0, x, y, right, bottom);
- }
- void CBaseUI::HideGameUI(void)
- {
- return g_pfnCBaseUI_HideGameUI(this, 0);
- }
- void CBaseUI::ActivateGameUI(void)
- {
- return g_pfnCBaseUI_ActivateGameUI(this, 0);
- }
- bool CBaseUI::IsGameUIVisible(void)
- {
- return g_pfnCBaseUI_IsGameUIVisible(this, 0);
- }
- void CBaseUI::HideConsole(void)
- {
- return g_pfnCBaseUI_HideConsole(this, 0);
- }
- void CBaseUI::ShowConsole(void)
- {
- return g_pfnCBaseUI_ShowConsole(this, 0);
- }
- void BaseUI_InstallHook(void)
- {
- CreateInterfaceFn EngineCreateInterface = g_pMetaHookAPI->GetEngineFactory();
- g_pBaseUI = (IBaseUI *)EngineCreateInterface(BASEUI_INTERFACE_VERSION, 0);
- CBaseUI BaseUI;
- DWORD *pVFTable = *(DWORD **)&BaseUI;
- g_pMetaHookAPI->VFTHook(g_pBaseUI, 0, 1, (void *)pVFTable[ 1], (void *&)g_pfnCBaseUI_Initialize);
- g_pMetaHookAPI->VFTHook(g_pBaseUI, 0, 2, (void *)pVFTable[ 2], (void *&)g_pfnCBaseUI_Start);
- g_pMetaHookAPI->VFTHook(g_pBaseUI, 0, 3, (void *)pVFTable[ 3], (void *&)g_pfnCBaseUI_Shutdown);
- g_pMetaHookAPI->VFTHook(g_pBaseUI, 0, 4, (void *)pVFTable[ 4], (void *&)g_pfnCBaseUI_Key_Event);
- g_pMetaHookAPI->VFTHook(g_pBaseUI, 0, 5, (void *)pVFTable[ 5], (void *&)g_pfnCBaseUI_CallEngineSurfaceProc);
- g_pMetaHookAPI->VFTHook(g_pBaseUI, 0, 6, (void *)pVFTable[ 6], (void *&)g_pfnCBaseUI_Paint);
- g_pMetaHookAPI->VFTHook(g_pBaseUI, 0, 7, (void *)pVFTable[ 7], (void *&)g_pfnCBaseUI_HideGameUI);
- g_pMetaHookAPI->VFTHook(g_pBaseUI, 0, 8, (void *)pVFTable[ 8], (void *&)g_pfnCBaseUI_ActivateGameUI);
- g_pMetaHookAPI->VFTHook(g_pBaseUI, 0, 9, (void *)pVFTable[ 9], (void *&)g_pfnCBaseUI_IsGameUIVisible);
- g_pMetaHookAPI->VFTHook(g_pBaseUI, 0, 10, (void *)pVFTable[10], (void *&)g_pfnCBaseUI_HideConsole);
- g_pMetaHookAPI->VFTHook(g_pBaseUI, 0, 11, (void *)pVFTable[11], (void *&)g_pfnCBaseUI_ShowConsole);
- }
复制代码 |
|