Skip to content

Commit

Permalink
添加md5验证功能
Browse files Browse the repository at this point in the history
  • Loading branch information
HalcyonAlcedo committed Oct 7, 2021
1 parent a438e03 commit b12c9cd
Show file tree
Hide file tree
Showing 9 changed files with 427 additions and 35 deletions.
3 changes: 2 additions & 1 deletion AlModTemplate.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
<ClCompile Include="impl\d3d11_impl.cpp" />
<ClCompile Include="impl\shared.cpp" />
<ClCompile Include="impl\win32_impl.cpp" />
<ClCompile Include="md5.cpp" />
</ItemGroup>
<ItemGroup>
<Library Include="deps\loader.lib" />
Expand Down Expand Up @@ -221,10 +222,10 @@
<DeploymentContent>false</DeploymentContent>
</ClInclude>
<ClInclude Include="easywsclient.hpp" />
<ClInclude Include="Execution.h" />
<ClInclude Include="impl\d3d11_impl.h" />
<ClInclude Include="impl\shared.h" />
<ClInclude Include="impl\win32_impl.h" />
<ClInclude Include="md5.h" />
<ClInclude Include="Network.h" />
<ClInclude Include="HttpRequest.h" />
<ClInclude Include="LuaData.h" />
Expand Down
7 changes: 6 additions & 1 deletion AlModTemplate.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
<ClCompile Include="deps\Sound\Sound.cpp">
<Filter>源代码\sound</Filter>
</ClCompile>
<ClCompile Include="md5.cpp">
<Filter>源代码</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Library Include="deps\minhook\libMinHook.x64.lib">
Expand All @@ -105,7 +108,6 @@
<ClInclude Include="Base.h">
<Filter>核心数据</Filter>
</ClInclude>
<ClInclude Include="Execution.h" />
<ClInclude Include="Component.h">
<Filter>核心数据</Filter>
</ClInclude>
Expand Down Expand Up @@ -194,6 +196,9 @@
<ClInclude Include="deps\Sound\Sound.h">
<Filter>源代码\sound</Filter>
</ClInclude>
<ClInclude Include="md5.h">
<Filter>源代码</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="asm.asm">
Expand Down
4 changes: 2 additions & 2 deletions Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ namespace Base {
//可设置参数
string ModName = "LuaScript";
string ModAuthor = "Alcedo";
string ModVersion = "v1.2.6";
long long ModBuild = 126009191611;
string ModVersion = "v1.2.7";
long long ModBuild = 127010062307;
string Version = "421471";
}
#pragma endregion
Expand Down
20 changes: 20 additions & 0 deletions Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <io.h>
#include <filesystem>
#include"tlhelp32.h"
#include "md5.h"

using namespace std;
using namespace loader;
Expand Down Expand Up @@ -1018,6 +1019,25 @@ namespace Component {
::CloseHandle(hProcessSnap);
return ProcessList;
}
//获取文件md5
static string getFileMD5(string file)
{
ifstream in(file.c_str(), ios::binary);
if (!in)
return "";

MD5 md5;
std::streamsize length;
char buffer[1024];
while (!in.eof()) {
in.read(buffer, 1024);
length = in.gcount();
if (length > 0)
md5.update(buffer, length);
}
in.close();
return md5.toString();
}
//utf8编码字符串
std::string string_To_UTF8(const std::string& str)
{
Expand Down
29 changes: 0 additions & 29 deletions Execution.h

This file was deleted.

8 changes: 8 additions & 0 deletions LuaScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,12 @@ static int System_GetProcessList(lua_State* pL)
}
return 1;
}
static int System_GetFileMD5(lua_State* pL) {
string file = (string)lua_tostring(pL, 1);
lua_pushstring(pL, Component::getFileMD5(file).c_str());
return 1;
}

#pragma endregion
#pragma region LuaFun
//存入整数变量
Expand Down Expand Up @@ -1945,6 +1951,8 @@ int Lua_Main(string LuaFile)
lua_register(L, "System_Sound_PlaySound", System_Sound_PlaySound);
//获取系统进程列表
lua_register(L, "System_GetProcessList", System_GetProcessList);
//获取文件Md5
lua_register(L, "System_GetFileMD5", System_GetFileMD5);
#pragma endregion
#pragma region Lua
//存入整数变量
Expand Down
3 changes: 1 addition & 2 deletions dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <thread>

#include "Base.h"
#include "Execution.h"
#include "Component.h"
#include "LuaData.h"
#include "ControlProgram.h"
#include "LuaScript.h"
Expand Down Expand Up @@ -71,7 +71,6 @@ __declspec(dllexport) extern bool Load()
ControlProgram::InitConsole();
if (Base::Init()) {
Base::RealTimeUpdate();
//Execution::Main();
if (Base::ModConfig::GameDataInit) {
for (string file_name : Base::LuaHandle::LuaFiles) {
if(Base::LuaHandle::LuaCode[file_name].start)
Expand Down
Loading

0 comments on commit b12c9cd

Please sign in to comment.