[MetaHook] BaseUI hook

Hook IBaseUI function.

 #include <metahook.h>

 #include <IBaseUI.h>

 IBaseUI *g_pBaseUI = ;

 void (__fastcall *g_pfnCBaseUI_Initialize)(void *pthis, int edx, CreateInterfaceFn *factories, int count) = ;
void (__fastcall *g_pfnCBaseUI_Start)(void *pthis, int edx, struct cl_enginefuncs_s *engineFuncs, int interfaceVersion) = ;
void (__fastcall *g_pfnCBaseUI_Shutdown)(void *pthis, int edx) = ;
int (__fastcall *g_pfnCBaseUI_Key_Event)(void *pthis, int edx, int down, int keynum, const char *pszCurrentBinding) = ;
void (__fastcall *g_pfnCBaseUI_CallEngineSurfaceProc)(void *pthis, int edx, void *hwnd, unsigned int msg, unsigned int wparam, long lparam) = ;
void (__fastcall *g_pfnCBaseUI_Paint)(void *pthis, int edx, int x, int y, int right, int bottom) = ;
void (__fastcall *g_pfnCBaseUI_HideGameUI)(void *pthis, int edx) = ;
void (__fastcall *g_pfnCBaseUI_ActivateGameUI)(void *pthis, int edx) = ;
bool (__fastcall *g_pfnCBaseUI_IsGameUIVisible)(void *pthis, int edx) = ;
void (__fastcall *g_pfnCBaseUI_HideConsole)(void *pthis, int edx) = ;
void (__fastcall *g_pfnCBaseUI_ShowConsole)(void *pthis, int edx) = ; 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, , factories, count);
} void CBaseUI::Start(struct cl_enginefuncs_s *engineFuncs, int interfaceVersion)
{
return g_pfnCBaseUI_Start(this, , engineFuncs, interfaceVersion);
} void CBaseUI::Shutdown(void)
{
return g_pfnCBaseUI_Shutdown(this, );
} int CBaseUI::Key_Event(int down, int keynum, const char *pszCurrentBinding)
{
return g_pfnCBaseUI_Key_Event(this, , down, keynum, pszCurrentBinding);
} void CBaseUI::CallEngineSurfaceProc(void *hwnd, unsigned int msg, unsigned int wparam, long lparam)
{
return g_pfnCBaseUI_CallEngineSurfaceProc(this, , hwnd, msg, wparam, lparam);
} void CBaseUI::Paint(int x, int y, int right, int bottom)
{
return g_pfnCBaseUI_Paint(this, , x, y, right, bottom);
} void CBaseUI::HideGameUI(void)
{
return g_pfnCBaseUI_HideGameUI(this, );
} void CBaseUI::ActivateGameUI(void)
{
return g_pfnCBaseUI_ActivateGameUI(this, );
} bool CBaseUI::IsGameUIVisible(void)
{
return g_pfnCBaseUI_IsGameUIVisible(this, );
} void CBaseUI::HideConsole(void)
{
return g_pfnCBaseUI_HideConsole(this, );
} void CBaseUI::ShowConsole(void)
{
return g_pfnCBaseUI_ShowConsole(this, );
} void BaseUI_InstallHook(void)
{
CreateInterfaceFn EngineCreateInterface = g_pMetaHookAPI->GetEngineFactory();
g_pBaseUI = (IBaseUI *)EngineCreateInterface(BASEUI_INTERFACE_VERSION, ); CBaseUI BaseUI;
DWORD *pVFTable = *(DWORD **)&BaseUI; g_pMetaHookAPI->VFTHook(g_pBaseUI, , , (void *)pVFTable[ ], (void *&)g_pfnCBaseUI_Initialize);
g_pMetaHookAPI->VFTHook(g_pBaseUI, , , (void *)pVFTable[ ], (void *&)g_pfnCBaseUI_Start);
g_pMetaHookAPI->VFTHook(g_pBaseUI, , , (void *)pVFTable[ ], (void *&)g_pfnCBaseUI_Shutdown);
g_pMetaHookAPI->VFTHook(g_pBaseUI, , , (void *)pVFTable[ ], (void *&)g_pfnCBaseUI_Key_Event);
g_pMetaHookAPI->VFTHook(g_pBaseUI, , , (void *)pVFTable[ ], (void *&)g_pfnCBaseUI_CallEngineSurfaceProc);
g_pMetaHookAPI->VFTHook(g_pBaseUI, , , (void *)pVFTable[ ], (void *&)g_pfnCBaseUI_Paint);
g_pMetaHookAPI->VFTHook(g_pBaseUI, , , (void *)pVFTable[ ], (void *&)g_pfnCBaseUI_HideGameUI);
g_pMetaHookAPI->VFTHook(g_pBaseUI, , , (void *)pVFTable[ ], (void *&)g_pfnCBaseUI_ActivateGameUI);
g_pMetaHookAPI->VFTHook(g_pBaseUI, , , (void *)pVFTable[ ], (void *&)g_pfnCBaseUI_IsGameUIVisible);
g_pMetaHookAPI->VFTHook(g_pBaseUI, , , (void *)pVFTable[], (void *&)g_pfnCBaseUI_HideConsole);
g_pMetaHookAPI->VFTHook(g_pBaseUI, , , (void *)pVFTable[], (void *&)g_pfnCBaseUI_ShowConsole);
}
上一篇:(Skill)238. Product of Array Except Self


下一篇:UVa LA 3266 - Tian Ji -- The Horse Racing 贪心,不只处理一端,也处理另一端以理清局面 难度: 2