diff --git a/WarcraftHelper/helper.cpp b/WarcraftHelper/helper.cpp index 7287db2..3601979 100644 --- a/WarcraftHelper/helper.cpp +++ b/WarcraftHelper/helper.cpp @@ -68,6 +68,7 @@ void Helper::Stop() { this->m_ShowFPS->Stop(); this->m_PathFix->Stop(); this->m_ShowHPBar->Stop(); + Sleep(60); } bool Helper::IsWar3() { diff --git a/WarcraftHelper/showhpbar.cpp b/WarcraftHelper/showhpbar.cpp index 734eb61..8feea3f 100644 --- a/WarcraftHelper/showhpbar.cpp +++ b/WarcraftHelper/showhpbar.cpp @@ -1,28 +1,36 @@ #include "showhpbar.h" +#include bool ShowHPBar_Patched = false; bool ShowHPBar_Closed = false; -DWORD is_chat_addr = 0x45CB8C; +DWORD *is_chat_addr = (DWORD*)0x45CB8C; +DWORD game_status = 0; + +int(__fastcall* orgSetGameStatus)(DWORD *ecx, DWORD edx, DWORD status) = 0; +int __fastcall SetGameStatus(DWORD *ecx, DWORD edx, DWORD status) { + DWORD ret = orgSetGameStatus(ecx, edx, status); + game_status = ecx[156]; + return ret; +} DWORD __stdcall ShowBar(LPVOID lpThreadParameter) { - HWND h_war3 = FindWindow(0, "Warcraft III"); while (1) { if (ShowHPBar_Closed) { ExitThread(0); } - if (*(DWORD*)is_chat_addr) { + if (IsBadReadPtr(is_chat_addr, 4)) { + break; + } + if (*is_chat_addr) { + continue; + } + if (game_status != 4) { continue; } keybd_event(219, 0, 0, 0); keybd_event(221, 0, 0, 0); - Sleep(500); - - /* PostMessage(h_war3, WM_KEYDOWN, 219, 0); - PostMessage(h_war3, WM_KEYDOWN, 221, 0); - - PostMessage(h_war3, WM_KEYUP, 219, 0); - PostMessage(h_war3, WM_KEYUP, 221, 0);*/ + Sleep(50); } return 0; } @@ -39,8 +47,10 @@ void ShowHPBar::Start(DWORD m_GamedllBase, Version m_War3Version) { MessageBoxA(0, "GameDllʼʧ", "ShowHPBar", 0); return; } + DWORD SetGameStatus_addr = 0; switch (m_War3Version) { case Version::v120e: + SetGameStatus_addr = 0x6F283B60; break; default: return; @@ -53,11 +63,10 @@ void ShowHPBar::Start(DWORD m_GamedllBase, Version m_War3Version) { return; } this->thread = CreateThread(NULL, NULL, ShowBar, NULL, NULL, NULL); + InlineHook((void*)SetGameStatus_addr, SetGameStatus, (void*&)orgSetGameStatus); } void ShowHPBar::Stop() { ShowHPBar_Closed = true; - Sleep(51); - keybd_event(219, 0, 2, 0); - keybd_event(221, 0, 2, 0); + DetachHook((void*)orgSetGameStatus, SetGameStatus); } diff --git a/WarcraftHelper/windowfixer.cpp b/WarcraftHelper/windowfixer.cpp index a2a8d36..1a375cd 100644 --- a/WarcraftHelper/windowfixer.cpp +++ b/WarcraftHelper/windowfixer.cpp @@ -40,5 +40,4 @@ void WindowFixer::Start() { void WindowFixer::Stop() { t_closed = true; - Sleep(51); } diff --git a/readme.md b/readme.md index 45c6de6..e8b0e8d 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ #### 介绍 -魔兽辅助插件,解除地图大小限制,宽屏支持,解锁FPS,自动保存录像,自动显示fps,最大刷新率修复,目录中文名修复 +魔兽辅助插件,解除地图大小限制,宽屏支持,解锁FPS,自动保存录像,自动显示fps,最大刷新率修复,目录中文名修复,自动显血 支持版本:1.20e、1.24e和1.27a @@ -15,6 +15,7 @@ | 自动显示fps | × | √ | √ | | 最大刷新率修复 | √ | √ | √ | | 地图目录中文名修复 | √ | √ | √ | +| 自动显血 | √ | 游戏自带 | 游戏自带 | 使用方法:把WarcraftHelper.mix文件直接放到魔兽目录下,第一次运行使用窗口化模式启动魔兽争霸3,以便插件覆盖注册表中魔兽fps最大值数据。 @@ -36,6 +37,13 @@ HKEY_CURRENT_USER\\SOFTWARE\\Blizzard Entertainment\\Warcraft III\\Video 将表项`showfps`设置为1即可,**不支持**1.20e版本魔兽,你仍然可以在游戏内使用`/fps`来关闭fps显示。 - 对于高刷新率屏幕,魔兽全屏模式下鼠标会有延迟感,第一次打开游戏时会刷新注册表,第二次进入游戏后就正常不会有延迟感了。 +- 对于1.20e的版本,如果要开启自动显血,需要**进入注册表**: + +``` +HKEY_CURRENT_USER\\SOFTWARE\\Blizzard Entertainment\\Warcraft III\\Gameplay +``` + +将表项`healthbars`设置为1即可,**支持**1.20e版本魔兽。