Anno 1800 Mod Loader V0.8.0 (改)(358944d)
本帖最后由 sst311212 于 2021-4-21 01:39 编辑感謝 [email protected] 提供的原始碼修改
**** Hidden Message *****
diff --git a/libs/python35/src/main.cc b/libs/python35/src/main.cc
index 63208df..fc0c6a9 100644
--- a/libs/python35/src/main.cc
+++ b/libs/python35/src/main.cc
@@ -28,70 +28,6 @@ namespace fs = std::filesystem;
// Global events instance
static Events events;
-static std::string GetLatestVersion()
-{
- char data = {0};
-
- // initialize WinInet
- HINTERNET hInternet =
- ::InternetOpen(TEXT("Anno 1800 Mod Loader"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
- if (hInternet != nullptr) {
- // 5 second timeout for now
- DWORD timeout = 5 * 1000;
- autoresult= InternetSetOption(hInternet, INTERNET_OPTION_RECEIVE_TIMEOUT, &timeout,
- sizeof(timeout));
- InternetSetOption(hInternet, INTERNET_OPTION_SEND_TIMEOUT, &timeout, sizeof(timeout));
- InternetSetOption(hInternet, INTERNET_OPTION_CONNECT_TIMEOUT, &timeout, sizeof(timeout));
-
- // open HTTP session
- HINTERNET hConnect =
- ::InternetConnectA(hInternet, "xforce.dev", INTERNET_DEFAULT_HTTPS_PORT, 0, 0,
- INTERNET_SERVICE_HTTP, 0, 0);
- if (hConnect != nullptr) {
- HINTERNET hRequest = ::HttpOpenRequestA(
- hConnect, "GET", "/anno1800-mod-loader/latest.json", 0, 0, 0,
- INTERNET_FLAG_SECURE | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD, 0);
- if (hRequest != nullptr) {
- // send request
- const auto was_sent = ::HttpSendRequest(hRequest, nullptr, 0, nullptr, 0);
-
- if (was_sent) {
- DWORD status_code = 0;
- DWORD status_code_size = sizeof(status_code);
- HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER,
- &status_code, &status_code_size, 0);
-
- if (status_code != 200) {
- throw std::runtime_error("Failed to read version info");
- }
- for (;;) {
- // reading data
- DWORD bytes_read;
- const auto was_read =
- ::InternetReadFile(hRequest, data, sizeof(data) - 1, &bytes_read);
-
- // break cycle if error or end
- if (was_read == FALSE || bytes_read == 0) {
- if (was_read == FALSE) {
- throw std::runtime_error("Failed to read version info");
- }
- break;
- }
-
- // saving result
- data = 0;
- }
- }
- ::InternetCloseHandle(hRequest);
- }
- ::InternetCloseHandle(hConnect);
- }
- ::InternetCloseHandle(hInternet);
- }
-
- return data;
-}
-
static std::once_flag hooking_once_flag;
static bool checked_hooking = false;
HANDLE CreateFileW_S(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
@@ -127,9 +63,15 @@ FARPROC GetProcAddress_S(HMODULE hModule, LPCSTR lpProcName)
// those would have usually been in the import table.
// This means we are ready to do some hooking
// But only do hooking once.
- std::call_once(hooking_once_flag, []() { events.DoHooking(); });
if ((uintptr_t)lpProcName > 0x1000) {
+ if (lpProcName == std::string("BinkStartAsyncThread")) {
+ std::call_once(hooking_once_flag, []() {
+ spdlog::info("GetProcAddress hook once trigger");
+ EnableExtenalFileLoading(events);
+ events.DoHooking();
+ });
+ }
if (lpProcName == std::string("CreateFileW")) {
return (FARPROC)CreateFileW_S;
}
@@ -227,103 +169,17 @@ bool set_import(const std::string& name, uintptr_t func)
return result;
}
-HANDLE GetParentProcess()
-{
- HANDLE Snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
-
- PROCESSENTRY32 ProcessEntry = {};
- ProcessEntry.dwSize = sizeof(PROCESSENTRY32);
-
- if (Process32First(Snapshot, &ProcessEntry)) {
- DWORD CurrentProcessId = GetCurrentProcessId();
-
- do {
- if (ProcessEntry.th32ProcessID == CurrentProcessId)
- break;
- } while (Process32Next(Snapshot, &ProcessEntry));
- }
-
- CloseHandle(Snapshot);
-
- return OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, ProcessEntry.th32ParentProcessID);
-}
-
-static void CheckVersion()
-{
- // Version Check
- try {
- auto body = GetLatestVersion();
- const auto& data = nlohmann::json::parse(body);
- const auto& version_str = data["version"].get<std::string>();
-
- static int32_t current_version = {VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION};
-
- int32_t latest_version = {0};
- std::sscanf(version_str.c_str(), "%d.%d.%d", &latest_version, &latest_version,
- &latest_version);
-
- if (std::lexicographical_compare(current_version, current_version + 3, latest_version,
- latest_version + 3)) {
- std::string msg = "Verion " + version_str + " of " + VER_FILE_DESCRIPTION_STR
- + " is available for download.\n\n";
- msg.append("Do you want to go to the release page on GitHub?\n(THIS IS "
- "HIGHLY RECOMMENDED!!!)");
-
- if (MessageBoxA(NULL, msg.c_str(), VER_FILE_DESCRIPTION_STR,
- MB_ICONQUESTION | MB_YESNO | MB_SYSTEMMODAL)
- == IDYES) {
- auto result =
- ShellExecuteA(nullptr, "open",
- "https://github.com/xforce/anno1800-mod-loader/releases/latest",
- nullptr, nullptr, SW_SHOWNORMAL);
- result = result;
- TerminateProcess(GetCurrentProcess(), 0);
- }
- }
- } catch (...) {
- // TODO(alexander): Logging
- }
-}
-
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH: {
DisableThreadLibraryCalls(hModule);
- {
- auto parent_handle = GetParentProcess();
- wchar_t process_name = {0};
- DWORD process_name_size= 1024;
- QueryFullProcessImageNameW(parent_handle, 0, process_name, &process_name_size);
- std::filesystem::path process_file_path(process_name);
-
- if (_wcsicmp(process_file_path.filename().wstring().c_str(),
- L"UbisoftGameLauncher.exe")
- != 0
- && _wcsicmp(process_file_path.filename().wstring().c_str(),
- L"UbisoftGameLauncher64.exe")
- != 0
- && _wcsicmp(process_file_path.filename().wstring().c_str(),
- L"Anno1800_plus.exe")
- != 0
- && _wcsicmp(process_file_path.filename().wstring().c_str(),
- L"Anno1800.exe")
- != 0) {
- return TRUE;
- }
- }
-
+ AllocConsole();
#if defined(INTERNAL_ENABLED)
EnableDebugging(events);
#endif
- std::wstring command_line(GetCommandLineW());
- if (command_line.find(L"gamelauncher_wait_handle") != std::wstring::npos
- && command_line.find(L"upc_uplay_id") != std::wstring::npos) {
- return TRUE;
- }
-
{
wchar_t process_name = {0};
DWORD process_name_size= 1024;
@@ -341,8 +197,6 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
}
events.DoHooking.connect([]() {
- CheckVersion();
-
// Let's start loading the list of files we want to have
HMODULE module;
if (GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
@@ -385,7 +239,6 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
});
- EnableExtenalFileLoading(events);
// TODO(alexander): Add code that can load other dll libraries here
// that offer more features later on
set_import("GetProcAddress", (uintptr_t)GetProcAddress_S);
沙发 ^_~https://cdn.jsdelivr.net/gh/hishis/forum-master/public/images/patch.gif 终于可以用MOD了{:3_94:}thank you 学习版可用吗?
学习版可用吗? qscgu135 发表于 2021-1-9 07:51
学习版可用吗?
非学习版肯定不能用这个 正版你直接用原始的MOD加载器不就行了
这个只是针对EMPRESS的学习版修改 让学习版可以用而已
终于可以用MOD了 :):):):)学习版可以用而已 66666666666666666666
66666666666 ,如果您要查看本帖隐藏内容
发呆深V是最菜撒旦撒发暗示
111111111111111111
感谢!!分享!! 6666666666
6666666666666 可以用了吗
这个必须有
111111111111111111111111
1111111111111111
esfesfsrgsrgsrgsrg
顶顶顶顶顶顶顶顶顶顶
66666666666666
wscmdyzk 发表于 2021-1-9 07:53
非学习版肯定不能用这个 正版你直接用原始的MOD加载器不就行了
这个只是针对EMPRESS的学习版修改 让学习 ...
膜拜大佬,360度,无死角的那种。。。。。。。。 可以用了? 感谢感谢
感谢分享!!! dddddddddddd
谢谢分享,mod的如何使用?
擦,赶紧试试,我改卡片改得快吐了。:D