From 17a8cef5c5fbb25c5275f01d62e3096301a62184 Mon Sep 17 00:00:00 2001 From: KouKouChan <1010433454@qq.com> Date: Fri, 19 Nov 2021 22:58:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=87=AA=E5=8A=A8=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=BD=95=E5=83=8F?= 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/autorep.cpp | 54 +++++++++++++++++++ WarcraftHelper/autorep.h | 10 ++++ WarcraftHelper/helper.cpp | 3 ++ WarcraftHelper/helper.h | 2 + readme.md | 6 ++- 7 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 WarcraftHelper/autorep.cpp create mode 100644 WarcraftHelper/autorep.h diff --git a/WarcraftHelper/WarcraftHelper.vcxproj b/WarcraftHelper/WarcraftHelper.vcxproj index 9294211..1b2c26e 100644 --- a/WarcraftHelper/WarcraftHelper.vcxproj +++ b/WarcraftHelper/WarcraftHelper.vcxproj @@ -163,6 +163,7 @@ + @@ -172,6 +173,7 @@ + diff --git a/WarcraftHelper/WarcraftHelper.vcxproj.filters b/WarcraftHelper/WarcraftHelper.vcxproj.filters index 84a0c09..093c0a3 100644 --- a/WarcraftHelper/WarcraftHelper.vcxproj.filters +++ b/WarcraftHelper/WarcraftHelper.vcxproj.filters @@ -51,6 +51,9 @@ 源文件 + + 源文件 + @@ -77,5 +80,8 @@ 头文件 + + 头文件 + \ No newline at end of file diff --git a/WarcraftHelper/autorep.cpp b/WarcraftHelper/autorep.cpp new file mode 100644 index 0000000..49d5db4 --- /dev/null +++ b/WarcraftHelper/autorep.cpp @@ -0,0 +1,54 @@ +#include "autorep.h" +#include +#include + +bool AutoRep_Hooked = false; + +int(__fastcall *orgSaveRep)(DWORD pthis, DWORD unused, const char* path); + +int __fastcall SaveRep(DWORD pthis, DWORD unused, const char* path) { + DWORD len = strlen(path); + if (len > 14 && !strncmp(path + len - 14, "LastReplay.w3g", 14)) { + char whpath[MAX_PATH]; + memset(whpath, 0, MAX_PATH * sizeof(char)); + GetModuleFileName(NULL, whpath, MAX_PATH); + whpath[strrchr(whpath, '\\') - whpath + 1] = 0; + char name[MAX_PATH]; + time_t timep; + time(&timep); + strftime(name, MAX_PATH, "\\Replay\\WHReplay\\%Y_%m_%d_%H_%M_%S.w3g", localtime(&timep)); + strcat(whpath, name); + return orgSaveRep(pthis, unused, whpath); + } + return orgSaveRep(pthis, unused, path); +} + +void AutoRep::Start(DWORD m_GamedllBase, Version m_War3Version) { + if (AutoRep_Hooked) { + return; + } + if (!m_GamedllBase) { + MessageBox(0, "GameDllʼʧ", "CrashFixer", 0); + return; + } + DWORD SaveRep_addr = m_GamedllBase; + switch (m_War3Version) { + case Version::v120e: + SaveRep_addr += 0x28D320; + break; + case Version::v124e: + SaveRep_addr += 0x53EE60; + break; + case Version::v127a: + SaveRep_addr += 0x3122C0; + break; + default: + return; + } + InlineHook((void*)SaveRep_addr, SaveRep, (void*&)orgSaveRep); + AutoRep_Hooked = true; +} + +void AutoRep::Stop() { + +} diff --git a/WarcraftHelper/autorep.h b/WarcraftHelper/autorep.h new file mode 100644 index 0000000..aa71197 --- /dev/null +++ b/WarcraftHelper/autorep.h @@ -0,0 +1,10 @@ +#pragma once + +#include "hook.h" + +class AutoRep { +public: + void Start(DWORD m_GamedllBase, Version m_War3Version); + void Stop(); +}; + diff --git a/WarcraftHelper/helper.cpp b/WarcraftHelper/helper.cpp index c0fde11..7398ae7 100644 --- a/WarcraftHelper/helper.cpp +++ b/WarcraftHelper/helper.cpp @@ -31,6 +31,7 @@ Helper::Helper() { this->m_UnlockFPS = &UnlockFPS(); this->m_CrashFixer = &CrashFixer(); this->m_WindowFixer = &WindowFixer(); + this->m_AutoRep = &AutoRep(); } void Helper::Start() { @@ -43,6 +44,7 @@ void Helper::Start() { this->m_UnlockFPS->Start(this->m_GamedllBase, this->m_War3Version); this->m_CrashFixer->Start(this->m_GamedllBase, this->m_War3Version); this->m_WindowFixer->Start(); + this->m_AutoRep->Start(this->m_GamedllBase, this->m_War3Version); } void Helper::Stop() { @@ -54,6 +56,7 @@ void Helper::Stop() { this->m_UnlockFPS->Stop(); this->m_CrashFixer->Stop(); this->m_WindowFixer->Stop(); + this->m_AutoRep->Stop(); } bool Helper::IsWar3() { diff --git a/WarcraftHelper/helper.h b/WarcraftHelper/helper.h index 54c9c92..aa775c0 100644 --- a/WarcraftHelper/helper.h +++ b/WarcraftHelper/helper.h @@ -5,6 +5,7 @@ #include "widescreen.h" #include "CrashFixer.h" #include "windowfixer.h" +#include "autorep.h" class Helper { public: @@ -21,6 +22,7 @@ class Helper { UnlockFPS *m_UnlockFPS; CrashFixer *m_CrashFixer; WindowFixer *m_WindowFixer; + AutoRep *m_AutoRep; bool IsWar3(); }; diff --git a/readme.md b/readme.md index 6ab1551..47e3a17 100644 --- a/readme.md +++ b/readme.md @@ -2,10 +2,14 @@ #### 介绍 -魔兽辅助插件,解除地图大小限制,宽屏支持,解锁FPS +魔兽辅助插件,解除地图大小限制,宽屏支持,解锁FPS,自动保存录像 如果你的显示器大于1080p,产生了字体重叠问题,游戏内使用F7键可以刷新窗口,需要窗口化模式。 +1.20e和1.24e魔兽建议打上d3d8to9补丁。 + +录像会自动保存在魔兽replay目录的WHReplay子目录下。 + 支持版本:1.20e、1.24e和1.27a 使用方法:直接放到魔兽目录下。