Skip to content

Commit

Permalink
支持自动保存录像
Browse files Browse the repository at this point in the history
  • Loading branch information
LoveBeforT committed Nov 19, 2021
1 parent 62471ff commit 17a8cef
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 1 deletion.
2 changes: 2 additions & 0 deletions WarcraftHelper/WarcraftHelper.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
<ClCompile Include="..\ThirdParty\Detours\detours.cpp" />
<ClCompile Include="..\ThirdParty\Detours\disasm.cpp" />
<ClCompile Include="..\ThirdParty\Detours\modules.cpp" />
<ClCompile Include="autorep.cpp" />
<ClCompile Include="crashfixer.cpp" />
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="helper.cpp" />
Expand All @@ -172,6 +173,7 @@
<ClCompile Include="windowfixer.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="autorep.h" />
<ClInclude Include="crashfixer.h" />
<ClInclude Include="helper.h" />
<ClInclude Include="hook.h" />
Expand Down
6 changes: 6 additions & 0 deletions WarcraftHelper/WarcraftHelper.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
<ClCompile Include="crashfixer.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="autorep.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="helper.h">
Expand All @@ -77,5 +80,8 @@
<ClInclude Include="windowfixer.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="autorep.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>
54 changes: 54 additions & 0 deletions WarcraftHelper/autorep.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "autorep.h"
#include <time.h>
#include <iostream>

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() {

}
10 changes: 10 additions & 0 deletions WarcraftHelper/autorep.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#include "hook.h"

class AutoRep {
public:
void Start(DWORD m_GamedllBase, Version m_War3Version);
void Stop();
};

3 changes: 3 additions & 0 deletions WarcraftHelper/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand Down
2 changes: 2 additions & 0 deletions WarcraftHelper/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "widescreen.h"
#include "CrashFixer.h"
#include "windowfixer.h"
#include "autorep.h"

class Helper {
public:
Expand All @@ -21,6 +22,7 @@ class Helper {
UnlockFPS *m_UnlockFPS;
CrashFixer *m_CrashFixer;
WindowFixer *m_WindowFixer;
AutoRep *m_AutoRep;

bool IsWar3();
};
Expand Down
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

#### 介绍

魔兽辅助插件,解除地图大小限制,宽屏支持,解锁FPS
魔兽辅助插件,解除地图大小限制,宽屏支持,解锁FPS,自动保存录像

如果你的显示器大于1080p,产生了字体重叠问题,游戏内使用F7键可以刷新窗口,需要窗口化模式。

1.20e和1.24e魔兽建议打上d3d8to9补丁。

录像会自动保存在魔兽replay目录的WHReplay子目录下。

支持版本:1.20e、1.24e和1.27a

使用方法:直接放到魔兽目录下。
Expand Down

0 comments on commit 17a8cef

Please sign in to comment.