请选择 进入手机版 | 继续访问电脑版
设为首页收藏本站

ESFKAMI

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz

ESFX

ESF: Xenoverse

ESF123

ESF1.2.3

EVM2.1

EVM2.1

ECXSSJ

ECX: TeamSSJ

ECX2.2

ECX RC2

ECX2.3

ECX RC3

查看: 1155|回复: 0

[MetaHook]GameUI Hook

[复制链接]

212

主题

217

帖子

1195

积分

ESFKAMI

Rank: 8Rank: 8

积分
1195
发表于 2017-7-14 16:46:10 | 显示全部楼层 |阅读模式

by Akatsuki

IGameUI.h

  1. #ifndef IGAMEUI_H
  2. #define IGAMEUI_H

  3. #ifdef _WIN32
  4. #pragma once
  5. #endif

  6. #include <vgui/VGUI.h>
  7. #include "interface.h"

  8. class IGameUI : public IBaseInterface
  9. {
  10. public:
  11.         virtual void Initialize(CreateInterfaceFn *factories, int count) = 0;
  12.         virtual void Start(struct cl_enginefuncs_s *engineFuncs, int interfaceVersion, void *system) = 0;
  13.         virtual void Shutdown(void) = 0;
  14.         virtual int ActivateGameUI(void) = 0;
  15.         virtual int ActivateDemoUI(void) = 0;
  16.         virtual int HasExclusiveInput(void) = 0;
  17.         virtual void RunFrame(void) = 0;
  18.         virtual void ConnectToServer(const char *game, int IP, int port) = 0;
  19.         virtual void DisconnectFromServer(void) = 0;
  20.         virtual void HideGameUI(void) = 0;
  21.         virtual bool IsGameUIActive(void) = 0;
  22.         virtual void LoadingStarted(const char *resourceType, const char *resourceName) = 0;
  23.         virtual void LoadingFinished(const char *resourceType, const char *resourceName) = 0;
  24.         virtual void StartProgressBar(const char *progressType, int progressSteps) = 0;
  25.         virtual int ContinueProgressBar(int progressPoint, float progressFraction) = 0;
  26.         virtual void StopProgressBar(bool bError, const char *failureReason, const char *extendedReason = NULL) = 0;
  27.         virtual int SetProgressBarStatusText(const char *statusText) = 0;
  28.         virtual void SetSecondaryProgressBar(float progress) = 0;
  29.         virtual void SetSecondaryProgressBarText(const char *statusText) = 0;
  30. };

  31. #define GAMEUI_INTERFACE_VERSION "GameUI007"
  32. #endif

  33. void GameUI_InstallHook(void);
复制代码
GameUI.cpp

  1. #include <metahook.h>

  2. #include <IGameUI.h>

  3. IGameUI *g_pGameUI = 0;

  4. void (__fastcall *g_pfnCGameUI_Initialize)(void *pthis, int edx, CreateInterfaceFn *factories, int count) = 0;
  5. void (__fastcall *g_pfnCGameUI_Start)(void *pthis, int edx, struct cl_enginefuncs_s *engineFuncs, int interfaceVersion, void *system) = 0;
  6. void (__fastcall *g_pfnCGameUI_Shutdown)(void *pthis, int edx) = 0;
  7. int (__fastcall *g_pfnCGameUI_ActivateGameUI)(void *pthis, int edx) = 0;
  8. int (__fastcall *g_pfnCGameUI_ActivateDemoUI)(void *pthis, int edx) = 0;
  9. int (__fastcall *g_pfnCGameUI_HasExclusiveInput)(void *pthis, int edx) = 0;
  10. void (__fastcall *g_pfnCGameUI_RunFrame)(void *pthis, int edx) = 0;
  11. void (__fastcall *g_pfnCGameUI_ConnectToServer)(void *pthis, int edx, const char *game, int IP, int port) = 0;
  12. void (__fastcall *g_pfnCGameUI_DisconnectFromServer)(void *pthis, int edx) = 0;
  13. void (__fastcall *g_pfnCGameUI_HideGameUI)(void *pthis, int edx) = 0;
  14. bool (__fastcall *g_pfnCGameUI_IsGameUIActive)(void *pthis, int edx) = 0;
  15. void (__fastcall *g_pfnCGameUI_LoadingStarted)(void *pthis, int edx, const char *resourceType, const char *resourceName) = 0;
  16. void (__fastcall *g_pfnCGameUI_LoadingFinished)(void *pthis, int edx, const char *resourceType, const char *resourceName) = 0;
  17. void (__fastcall *g_pfnCGameUI_StartProgressBar)(void *pthis, int edx, const char *progressType, int progressSteps) = 0;
  18. int (__fastcall *g_pfnCGameUI_ContinueProgressBar)(void *pthis, int edx, int progressPoint, float progressFraction) = 0;
  19. void (__fastcall *g_pfnCGameUI_StopProgressBar)(void *pthis, int edx, bool bError, const char *failureReason, const char *extendedReason) = 0;
  20. int (__fastcall *g_pfnCGameUI_SetProgressBarStatusText)(void *pthis, int edx, const char *statusText) = 0;
  21. void (__fastcall *g_pfnCGameUI_SetSecondaryProgressBar)(void *pthis, int edx, float progress) = 0;
  22. void (__fastcall *g_pfnCGameUI_SetSecondaryProgressBarText)(void *pthis, int edx, const char *statusText) = 0;

  23. class CGameUI : public IGameUI
  24. {
  25. public:
  26.     void Initialize(CreateInterfaceFn *factories, int count);
  27.     void Start(struct cl_enginefuncs_s *engineFuncs, int interfaceVersion, void *system);
  28.     void Shutdown(void);
  29.     int ActivateGameUI(void);
  30.     int ActivateDemoUI(void);
  31.     int HasExclusiveInput(void);
  32.     void RunFrame(void);
  33.     void ConnectToServer(const char *game, int IP, int port);
  34.     void DisconnectFromServer(void);
  35.     void HideGameUI(void);
  36.     bool IsGameUIActive(void);
  37.     void LoadingStarted(const char *resourceType, const char *resourceName);
  38.     void LoadingFinished(const char *resourceType, const char *resourceName);
  39.     void StartProgressBar(const char *progressType, int progressSteps);
  40.     int ContinueProgressBar(int progressPoint, float progressFraction);
  41.     void StopProgressBar(bool bError, const char *failureReason, const char *extendedReason = NULL);
  42.     int SetProgressBarStatusText(const char *statusText);
  43.     void SetSecondaryProgressBar(float progress);
  44.     void SetSecondaryProgressBarText(const char *statusText);
  45. };

  46. void CGameUI::Initialize(CreateInterfaceFn *factories, int count)
  47. {
  48.     return g_pfnCGameUI_Initialize(this, 0, factories, count);
  49. }

  50. void CGameUI::Start(struct cl_enginefuncs_s *engineFuncs, int interfaceVersion, void *system)
  51. {
  52.     return g_pfnCGameUI_Start(this, 0, engineFuncs, interfaceVersion, system);
  53. }

  54. void CGameUI::Shutdown(void)
  55. {
  56.     return g_pfnCGameUI_Shutdown(this, 0);
  57. }

  58. int CGameUI::ActivateGameUI(void)
  59. {
  60.     return g_pfnCGameUI_ActivateGameUI(this, 0);
  61. }

  62. int CGameUI::ActivateDemoUI(void)
  63. {
  64.     return g_pfnCGameUI_ActivateDemoUI(this, 0);
  65. }

  66. int CGameUI::HasExclusiveInput(void)
  67. {
  68.     return g_pfnCGameUI_HasExclusiveInput(this, 0);
  69. }

  70. void CGameUI::RunFrame(void)
  71. {
  72.     return g_pfnCGameUI_RunFrame(this, 0);
  73. }

  74. void CGameUI::ConnectToServer(const char *game, int IP, int port)
  75. {
  76.     return g_pfnCGameUI_ConnectToServer(this, 0, game, IP, port);
  77. }

  78. void CGameUI::DisconnectFromServer(void)
  79. {
  80.     return g_pfnCGameUI_DisconnectFromServer(this, 0);
  81. }

  82. void CGameUI::HideGameUI(void)
  83. {
  84.     return g_pfnCGameUI_HideGameUI(this, 0);
  85. }

  86. bool CGameUI::IsGameUIActive(void)
  87. {
  88.     return g_pfnCGameUI_IsGameUIActive(this, 0);
  89. }

  90. void CGameUI::LoadingStarted(const char *resourceType, const char *resourceName)
  91. {
  92.     return g_pfnCGameUI_LoadingStarted(this, 0, resourceType, resourceName);
  93. }

  94. void CGameUI::LoadingFinished(const char *resourceType, const char *resourceName)
  95. {
  96.     return g_pfnCGameUI_LoadingFinished(this, 0, resourceType, resourceName);
  97. }

  98. void CGameUI::StartProgressBar(const char *progressType, int progressSteps)
  99. {
  100.     return g_pfnCGameUI_StartProgressBar(this, 0, progressType, progressSteps);
  101. }

  102. int CGameUI::ContinueProgressBar(int progressPoint, float progressFraction)
  103. {
  104.     return g_pfnCGameUI_ContinueProgressBar(this, 0, progressPoint, progressFraction);
  105. }

  106. void CGameUI::StopProgressBar(bool bError, const char *failureReason, const char *extendedReason)
  107. {
  108.     return g_pfnCGameUI_StopProgressBar(this, 0, bError, failureReason, extendedReason);
  109. }

  110. int CGameUI::SetProgressBarStatusText(const char *statusText)
  111. {
  112.     return g_pfnCGameUI_SetProgressBarStatusText(this, 0, statusText);
  113. }

  114. void CGameUI::SetSecondaryProgressBar(float progress)
  115. {
  116.     return g_pfnCGameUI_SetSecondaryProgressBar(this, 0, progress);
  117. }

  118. void CGameUI::SetSecondaryProgressBarText(const char *statusText)
  119. {
  120.     return g_pfnCGameUI_SetSecondaryProgressBarText(this, 0, statusText);
  121. }

  122. void GameUI_InstallHook(void)
  123. {
  124.     CreateInterfaceFn GameUICreateInterface = Sys_GetFactory((HINTERFACEMODULE)GetModuleHandleA("GameUI.dll"));
  125.     g_pGameUI = (IGameUI *)GameUICreateInterface(GAMEUI_INTERFACE_VERSION, 0);

  126.     CGameUI GameUI;
  127.     DWORD *pVFTable = *(DWORD **)&GameUI;

  128.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0,  1, (void *)pVFTable[ 1], (void *&)g_pfnCGameUI_Initialize);
  129.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0,  2, (void *)pVFTable[ 2], (void *&)g_pfnCGameUI_Start);
  130.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0,  3, (void *)pVFTable[ 3], (void *&)g_pfnCGameUI_Shutdown);
  131.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0,  4, (void *)pVFTable[ 4], (void *&)g_pfnCGameUI_ActivateGameUI);
  132.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0,  5, (void *)pVFTable[ 5], (void *&)g_pfnCGameUI_ActivateDemoUI);
  133.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0,  6, (void *)pVFTable[ 6], (void *&)g_pfnCGameUI_HasExclusiveInput);
  134.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0,  7, (void *)pVFTable[ 7], (void *&)g_pfnCGameUI_RunFrame);
  135.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0,  8, (void *)pVFTable[ 8], (void *&)g_pfnCGameUI_ConnectToServer);
  136.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0,  9, (void *)pVFTable[ 9], (void *&)g_pfnCGameUI_DisconnectFromServer);
  137.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 10, (void *)pVFTable[10], (void *&)g_pfnCGameUI_HideGameUI);
  138.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 11, (void *)pVFTable[11], (void *&)g_pfnCGameUI_IsGameUIActive);
  139.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 12, (void *)pVFTable[12], (void *&)g_pfnCGameUI_LoadingStarted);
  140.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 13, (void *)pVFTable[13], (void *&)g_pfnCGameUI_LoadingFinished);
  141.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 14, (void *)pVFTable[14], (void *&)g_pfnCGameUI_StartProgressBar);
  142.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 15, (void *)pVFTable[15], (void *&)g_pfnCGameUI_ContinueProgressBar);
  143.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 16, (void *)pVFTable[16], (void *&)g_pfnCGameUI_StopProgressBar);
  144.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 17, (void *)pVFTable[17], (void *&)g_pfnCGameUI_SetProgressBarStatusText);
  145.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 18, (void *)pVFTable[18], (void *&)g_pfnCGameUI_SetSecondaryProgressBar);
  146.     g_pMetaHookAPI->VFTHook(g_pGameUI, 0, 19, (void *)pVFTable[19], (void *&)g_pfnCGameUI_SetSecondaryProgressBarText);
  147. }
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|ESFKAMI    

GMT+8, 2018-7-20 18:36 , Processed in 0.296054 second(s), 21 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表