From ddb25597326e97a6c2ddbfeeaad5700b60c11a2b Mon Sep 17 00:00:00 2001 From: KouKouChan <1010433454@qq.com> Date: Mon, 5 Sep 2022 21:20:38 +0800 Subject: [PATCH] =?UTF-8?q?add:=201.20e=E6=98=BE=E8=A1=80=EF=BC=8C?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D=E8=BE=93=E5=85=A5=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=BE=85=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarcraftHelper/WarcraftHelper.vcxproj | 2 + WarcraftHelper/WarcraftHelper.vcxproj.filters | 6 ++ WarcraftHelper/helper.cpp | 3 + WarcraftHelper/helper.h | 3 + WarcraftHelper/showhpbar.cpp | 63 +++++++++++++++++++ WarcraftHelper/showhpbar.h | 15 +++++ 6 files changed, 92 insertions(+) create mode 100644 WarcraftHelper/showhpbar.cpp create mode 100644 WarcraftHelper/showhpbar.h diff --git a/WarcraftHelper/WarcraftHelper.vcxproj b/WarcraftHelper/WarcraftHelper.vcxproj index 275d6ab..3ad9290 100644 --- a/WarcraftHelper/WarcraftHelper.vcxproj +++ b/WarcraftHelper/WarcraftHelper.vcxproj @@ -170,6 +170,7 @@ + @@ -180,6 +181,7 @@ + diff --git a/WarcraftHelper/WarcraftHelper.vcxproj.filters b/WarcraftHelper/WarcraftHelper.vcxproj.filters index 4b6e22d..542fc23 100644 --- a/WarcraftHelper/WarcraftHelper.vcxproj.filters +++ b/WarcraftHelper/WarcraftHelper.vcxproj.filters @@ -45,6 +45,9 @@ 源文件 + + 源文件 + @@ -77,5 +80,8 @@ 头文件 + + 头文件 + \ No newline at end of file diff --git a/WarcraftHelper/helper.cpp b/WarcraftHelper/helper.cpp index dffc604..7287db2 100644 --- a/WarcraftHelper/helper.cpp +++ b/WarcraftHelper/helper.cpp @@ -34,6 +34,7 @@ Helper::Helper() { this->m_AutoRep = &AutoRep(); this->m_ShowFPS = &ShowFPS(); this->m_PathFix = &PathFix(); + this->m_ShowHPBar = &ShowHPBar(); } Helper::~Helper() { @@ -51,6 +52,7 @@ void Helper::Start() { this->m_AutoRep->Start(this->m_GamedllBase, this->m_War3Version); this->m_ShowFPS->Start(this->m_GamedllBase, this->m_War3Version); this->m_PathFix->Start(this->m_GamedllBase, this->m_War3Version); + this->m_ShowHPBar->Start(this->m_GamedllBase, this->m_War3Version); } void Helper::Stop() { @@ -65,6 +67,7 @@ void Helper::Stop() { this->m_AutoRep->Stop(); this->m_ShowFPS->Stop(); this->m_PathFix->Stop(); + this->m_ShowHPBar->Stop(); } bool Helper::IsWar3() { diff --git a/WarcraftHelper/helper.h b/WarcraftHelper/helper.h index 1f2af10..cef658b 100644 --- a/WarcraftHelper/helper.h +++ b/WarcraftHelper/helper.h @@ -7,6 +7,8 @@ #include "autorep.h" #include "showfps.h" #include "pathfix.h" +#include "showhpbar.h" + class Helper { public: @@ -27,6 +29,7 @@ class Helper { AutoRep *m_AutoRep; ShowFPS* m_ShowFPS; PathFix* m_PathFix; + ShowHPBar* m_ShowHPBar; bool IsWar3(); }; diff --git a/WarcraftHelper/showhpbar.cpp b/WarcraftHelper/showhpbar.cpp new file mode 100644 index 0000000..734eb61 --- /dev/null +++ b/WarcraftHelper/showhpbar.cpp @@ -0,0 +1,63 @@ +#include "showhpbar.h" + +bool ShowHPBar_Patched = false; +bool ShowHPBar_Closed = false; +DWORD is_chat_addr = 0x45CB8C; + +DWORD __stdcall ShowBar(LPVOID lpThreadParameter) { + HWND h_war3 = FindWindow(0, "Warcraft III"); + while (1) + { + if (ShowHPBar_Closed) { + ExitThread(0); + } + if (*(DWORD*)is_chat_addr) { + 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);*/ + } + return 0; +} + +ShowHPBar::ShowHPBar() {} +ShowHPBar::~ShowHPBar() {} + +void ShowHPBar::Start(DWORD m_GamedllBase, Version m_War3Version) { + if (ShowHPBar_Patched) { + return; + } + ShowHPBar_Patched = true; + if (!m_GamedllBase) { + MessageBoxA(0, "GameDllʼʧ", "ShowHPBar", 0); + return; + } + switch (m_War3Version) { + case Version::v120e: + break; + default: + return; + } + + + DWORD is_showfps = ReadDwordFromReg("SOFTWARE\\Blizzard Entertainment\\Warcraft III\\Gameplay", "healthbars"); + WriteDwordToReg("SOFTWARE\\Blizzard Entertainment\\Warcraft III\\Gameplay", "healthbars", is_showfps); + if (!is_showfps) { + return; + } + this->thread = CreateThread(NULL, NULL, ShowBar, NULL, NULL, NULL); +} + +void ShowHPBar::Stop() { + ShowHPBar_Closed = true; + Sleep(51); + keybd_event(219, 0, 2, 0); + keybd_event(221, 0, 2, 0); +} diff --git a/WarcraftHelper/showhpbar.h b/WarcraftHelper/showhpbar.h new file mode 100644 index 0000000..21a7b38 --- /dev/null +++ b/WarcraftHelper/showhpbar.h @@ -0,0 +1,15 @@ +#pragma once +#pragma once + +#include "hook.h" + +class ShowHPBar { +public: + ShowHPBar(); + ~ShowHPBar(); + void Start(DWORD m_GamedllBase, Version m_War3Version); + void Stop(); +private: + HANDLE thread; +}; +