3 Star 3 Fork 0

Akatsuki/VGUI2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
GameUI.cpp 7.67 KB
一键复制 编辑 原始数据 按行查看 历史
Akatsuki 提交于 2015-10-21 01:25 . add some sample code
#include <metahook.h>
#include <IGameUI.h>
namespace vgui
{
bool VGui_InitInterfacesList(const char *moduleName, CreateInterfaceFn *factoryList, int numFactories);
}
void DEM_CreateFrame(void);
IGameUI *g_pGameUI = 0;
void (__fastcall *g_pfnCGameUI_Initialize)(void *pthis, int edx, CreateInterfaceFn *factories, int count) = 0;
void (__fastcall *g_pfnCGameUI_Start)(void *pthis, int edx, struct cl_enginefuncs_s *engineFuncs, int interfaceVersion, void *system) = 0;
void (__fastcall *g_pfnCGameUI_Shutdown)(void *pthis, int edx) = 0;
int (__fastcall *g_pfnCGameUI_ActivateGameUI)(void *pthis, int edx) = 0;
int (__fastcall *g_pfnCGameUI_ActivateDemoUI)(void *pthis, int edx) = 0;
int (__fastcall *g_pfnCGameUI_HasExclusiveInput)(void *pthis, int edx) = 0;
void (__fastcall *g_pfnCGameUI_RunFrame)(void *pthis, int edx) = 0;
void (__fastcall *g_pfnCGameUI_ConnectToServer)(void *pthis, int edx, const char *game, int IP, int port) = 0;
void (__fastcall *g_pfnCGameUI_DisconnectFromServer)(void *pthis, int edx) = 0;
void (__fastcall *g_pfnCGameUI_HideGameUI)(void *pthis, int edx) = 0;
bool (__fastcall *g_pfnCGameUI_IsGameUIActive)(void *pthis, int edx) = 0;
void (__fastcall *g_pfnCGameUI_LoadingStarted)(void *pthis, int edx, const char *resourceType, const char *resourceName) = 0;
void (__fastcall *g_pfnCGameUI_LoadingFinished)(void *pthis, int edx, const char *resourceType, const char *resourceName) = 0;
void (__fastcall *g_pfnCGameUI_StartProgressBar)(void *pthis, int edx, const char *progressType, int progressSteps) = 0;
int (__fastcall *g_pfnCGameUI_ContinueProgressBar)(void *pthis, int edx, int progressPoint, float progressFraction) = 0;
void (__fastcall *g_pfnCGameUI_StopProgressBar)(void *pthis, int edx, bool bError, const char *failureReason, const char *extendedReason) = 0;
int (__fastcall *g_pfnCGameUI_SetProgressBarStatusText)(void *pthis, int edx, const char *statusText) = 0;
void (__fastcall *g_pfnCGameUI_SetSecondaryProgressBar)(void *pthis, int edx, float progress) = 0;
void (__fastcall *g_pfnCGameUI_SetSecondaryProgressBarText)(void *pthis, int edx, const char *statusText) = 0;
class CGameUI : public IGameUI
{
public:
void Initialize(CreateInterfaceFn *factories, int count);
void Start(struct cl_enginefuncs_s *engineFuncs, int interfaceVersion, void *system);
void Shutdown(void);
int ActivateGameUI(void);
int ActivateDemoUI(void);
int HasExclusiveInput(void);
void RunFrame(void);
void ConnectToServer(const char *game, int IP, int port);
void DisconnectFromServer(void);
void HideGameUI(void);
bool IsGameUIActive(void);
void LoadingStarted(const char *resourceType, const char *resourceName);
void LoadingFinished(const char *resourceType, const char *resourceName);
void StartProgressBar(const char *progressType, int progressSteps);
int ContinueProgressBar(int progressPoint, float progressFraction);
void StopProgressBar(bool bError, const char *failureReason, const char *extendedReason = NULL);
int SetProgressBarStatusText(const char *statusText);
void SetSecondaryProgressBar(float progress);
void SetSecondaryProgressBarText(const char *statusText);
};
void CGameUI::Initialize(CreateInterfaceFn *factories, int count)
{
g_pfnCGameUI_Initialize(this, 0, factories, count);
// !!! Init all interface
vgui::VGui_InitInterfacesList("GameUI", factories, count);
DEM_CreateFrame();
}
void CGameUI::Start(struct cl_enginefuncs_s *engineFuncs, int interfaceVersion, void *system)
{
return g_pfnCGameUI_Start(this, 0, engineFuncs, interfaceVersion, system);
}
void CGameUI::Shutdown(void)
{
return g_pfnCGameUI_Shutdown(this, 0);
}
int CGameUI::ActivateGameUI(void)
{
return g_pfnCGameUI_ActivateGameUI(this, 0);
}
int CGameUI::ActivateDemoUI(void)
{
return g_pfnCGameUI_ActivateDemoUI(this, 0);
}
int CGameUI::HasExclusiveInput(void)
{
return g_pfnCGameUI_HasExclusiveInput(this, 0);
}
void CGameUI::RunFrame(void)
{
return g_pfnCGameUI_RunFrame(this, 0);
}
void CGameUI::ConnectToServer(const char *game, int IP, int port)
{
return g_pfnCGameUI_ConnectToServer(this, 0, game, IP, port);
}
void CGameUI::DisconnectFromServer(void)
{
return g_pfnCGameUI_DisconnectFromServer(this, 0);
}
void CGameUI::HideGameUI(void)
{
return g_pfnCGameUI_HideGameUI(this, 0);
}
bool CGameUI::IsGameUIActive(void)
{
return g_pfnCGameUI_IsGameUIActive(this, 0);
}
void CGameUI::LoadingStarted(const char *resourceType, const char *resourceName)
{
return g_pfnCGameUI_LoadingStarted(this, 0, resourceType, resourceName);
}
void CGameUI::LoadingFinished(const char *resourceType, const char *resourceName)
{
return g_pfnCGameUI_LoadingFinished(this, 0, resourceType, resourceName);
}
void CGameUI::StartProgressBar(const char *progressType, int progressSteps)
{
return g_pfnCGameUI_StartProgressBar(this, 0, progressType, progressSteps);
}
int CGameUI::ContinueProgressBar(int progressPoint, float progressFraction)
{
return g_pfnCGameUI_ContinueProgressBar(this, 0, progressPoint, progressFraction);
}
void CGameUI::StopProgressBar(bool bError, const char *failureReason, const char *extendedReason)
{
return g_pfnCGameUI_StopProgressBar(this, 0, bError, failureReason, extendedReason);
}
int CGameUI::SetProgressBarStatusText(const char *statusText)
{
return g_pfnCGameUI_SetProgressBarStatusText(this, 0, statusText);
}
void CGameUI::SetSecondaryProgressBar(float progress)
{
return g_pfnCGameUI_SetSecondaryProgressBar(this, 0, progress);
}
void CGameUI::SetSecondaryProgressBarText(const char *statusText)
{
return g_pfnCGameUI_SetSecondaryProgressBarText(this, 0, statusText);
}
void GameUI_InstallHook(void)
{
CreateInterfaceFn GameUICreateInterface = Sys_GetFactory((HINTERFACEMODULE)GetModuleHandleA("GameUI.dll"));
g_pGameUI = (IGameUI *)GameUICreateInterface(GAMEUI_INTERFACE_VERSION, 0);
CGameUI GameUI;
DWORD *pVFTable = *(DWORD **)&GameUI;
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 1, (void *)pVFTable[ 1], (void *&)g_pfnCGameUI_Initialize);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 2, (void *)pVFTable[ 2], (void *&)g_pfnCGameUI_Start);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 3, (void *)pVFTable[ 3], (void *&)g_pfnCGameUI_Shutdown);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 4, (void *)pVFTable[ 4], (void *&)g_pfnCGameUI_ActivateGameUI);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 5, (void *)pVFTable[ 5], (void *&)g_pfnCGameUI_ActivateDemoUI);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 6, (void *)pVFTable[ 6], (void *&)g_pfnCGameUI_HasExclusiveInput);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 7, (void *)pVFTable[ 7], (void *&)g_pfnCGameUI_RunFrame);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 8, (void *)pVFTable[ 8], (void *&)g_pfnCGameUI_ConnectToServer);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 9, (void *)pVFTable[ 9], (void *&)g_pfnCGameUI_DisconnectFromServer);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 10, (void *)pVFTable[10], (void *&)g_pfnCGameUI_HideGameUI);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 11, (void *)pVFTable[11], (void *&)g_pfnCGameUI_IsGameUIActive);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 12, (void *)pVFTable[12], (void *&)g_pfnCGameUI_LoadingStarted);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 13, (void *)pVFTable[13], (void *&)g_pfnCGameUI_LoadingFinished);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 14, (void *)pVFTable[14], (void *&)g_pfnCGameUI_StartProgressBar);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 15, (void *)pVFTable[15], (void *&)g_pfnCGameUI_ContinueProgressBar);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 16, (void *)pVFTable[16], (void *&)g_pfnCGameUI_StopProgressBar);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 17, (void *)pVFTable[17], (void *&)g_pfnCGameUI_SetProgressBarStatusText);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 18, (void *)pVFTable[18], (void *&)g_pfnCGameUI_SetSecondaryProgressBar);
g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 19, (void *)pVFTable[19], (void *&)g_pfnCGameUI_SetSecondaryProgressBarText);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/akcode/VGUI2.git
git@gitee.com:akcode/VGUI2.git
akcode
VGUI2
VGUI2
master

搜索帮助