-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e488736
commit 12da9b2
Showing
4 changed files
with
56 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include <fstream> | ||
#include <string> | ||
|
||
namespace File { | ||
|
||
bool Contain(const char* path, const char* dest) { | ||
std::ifstream infile(path, std::ios::in | std::ios::binary | std::ios::ate); | ||
size_t size = infile.tellg(); | ||
infile.seekg(0, std::ios::beg); | ||
char* buffer = new char[size]; | ||
infile.read(buffer, size); | ||
infile.close(); | ||
std::string alltext(buffer, size); | ||
delete[] buffer; | ||
return alltext.find(dest) != std::string::npos; | ||
} | ||
|
||
char* ReadBytes(const char* path) { | ||
std::ifstream infile(path, std::ios::in | std::ios::binary | std::ios::ate); | ||
size_t size = infile.tellg(); | ||
infile.seekg(0, std::ios::beg); | ||
char* buffer = new char[size]; | ||
infile.read(buffer, size); | ||
infile.close(); | ||
return buffer; | ||
} | ||
|
||
std::string Extract(const char* path, size_t offset, size_t length) { | ||
char* buffer = ReadBytes(path); | ||
if (buffer) { | ||
std::string a(buffer + offset, length); | ||
delete[] buffer; | ||
return a; | ||
} | ||
delete[] buffer; | ||
return nullptr; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
#include <climits> | ||
#include <sstream> | ||
#include <direct.h> | ||
#include "File.hpp" | ||
using namespace std; | ||
|
||
|
||
|
@@ -43,10 +44,6 @@ bool Contain(const char* path, const char* dest) { | |
return alltext.find(dest) != std::string::npos; | ||
} | ||
|
||
bool CheackUnityVersion(const char* path) { | ||
return Contain(path, "2021.3.22f1"); | ||
} | ||
|
||
|
||
//加密混淆核心逻辑 | ||
char* encrtypt_file(char* src, size_t& file_size) { | ||
|
@@ -158,11 +155,6 @@ void OverrideLoader(char* path) { | |
string dest_loaderCpp = dest + "\\unityLibrary\\src\\main\\Il2CppOutputProject\\IL2CPP\\libil2cpp\\vm\\MetadataLoader.cpp"; | ||
string dest_memoryMappedFileH = dest + "\\unityLibrary\\src\\main\\Il2CppOutputProject\\IL2CPP\\libil2cpp\\utils\\MemoryMappedFile.h"; | ||
string dest_memoryMappedFileCpp = dest + "\\unityLibrary\\src\\main\\Il2CppOutputProject\\IL2CPP\\libil2cpp\\utils\\MemoryMappedFile.cpp"; | ||
string unity_version_file1 = localpath + "\\unityLibrary\\src\\main\\resources\\META-INF\\com.android.games.engine.build_fingerprint"; | ||
string unity_version_file2 = localpath + "\\unityLibrary\\build\\il2cpp_armeabi-v7a_ReleasePlus\\il2cpp_cache\\buildstate\\bee-inputdata.json"; | ||
string unity_version_file3 = localpath + "\\unityLibrary\\build\\il2cpp_armeabi-v7a_ReleasePlus\\il2cpp_cache\\buildstate\\bee.dag.json"; | ||
|
||
|
||
if (!file_exist(dest_loaderCpp.c_str())) | ||
{ | ||
Log("error: not found dest loaderCpp"); | ||
|
@@ -178,8 +170,9 @@ void OverrideLoader(char* path) { | |
Log("error: not found dest memoryMapped source file"); | ||
return; | ||
} | ||
if (!CheackUnityVersion(unity_version_file1.c_str()) && !CheackUnityVersion(unity_version_file2.c_str()) && !CheackUnityVersion(unity_version_file3.c_str())) { | ||
Log("error: unity version err."); | ||
if (File::Extract((dest + "\\unityLibrary\\src\\main\\assets\\bin\\Data\\data.unity3d").c_str(), 0x12, 11) != "2021.3.22f1") { | ||
//避免不同版本il2cpp源码不同 导致可能能正常跑起来 但是线上会引发崩溃 | ||
Log("version erro: must be 2021.3.22f1"); | ||
return; | ||
} | ||
|
||
|
@@ -192,12 +185,21 @@ void OverrideLoader(char* path) { | |
workpath = NULL; | ||
} | ||
|
||
|
||
Log("owner: 31games"); | ||
Log("anchor: https://geek7.blog.csdn.net/"); | ||
Log("email: [email protected]"); | ||
Log("override Loader code complete."); | ||
} | ||
|
||
//外部调用 | ||
void EncryptionCode(char* export_android_path) | ||
{ | ||
if (NULL == export_android_path || strcmp(export_android_path, "") == 0) { | ||
Log("export android path is null: %s", export_android_path); | ||
return; | ||
} | ||
|
||
//wait input | ||
string global_metadata_path = export_android_path; | ||
if (NULL == strstr(global_metadata_path.c_str(), "global-metadata.dat")) { | ||
|