10#pragma comment(lib, "Crypt32.lib")
11#pragma comment(lib, "Iphlpapi.lib")
17 "GetFileVersionInfoA",
"GetFileVersionInfoByHandle",
"GetFileVersionInfoExA",
"GetFileVersionInfoExW",
18 "GetFileVersionInfoSizeA",
"GetFileVersionInfoSizeExA",
"GetFileVersionInfoSizeExW",
"GetFileVersionInfoSizeW",
19 "GetFileVersionInfoW",
"VerFindFileA",
"VerFindFileW",
"VerInstallFileA",
"VerInstallFileW",
"VerLanguageNameA",
20 "VerLanguageNameW",
"VerQueryValueA",
"VerQueryValueW"
27 freopen_s(&p_cout,
"conout$",
"w", stdout);
28 SetConsoleOutputCP(CP_UTF8);
33 struct _stat64 fileInfo {};
34 if (_wstati64(filename.wstring().c_str(), &fileInfo) != 0)
36 throw std::runtime_error(
"Failed to get last write time.");
38 return fileInfo.st_mtime;
43 namespace fs = std::filesystem;
45 const auto now = std::chrono::system_clock::now();
47 const std::string current_dir = API::Tools::GetCurrentDir();
49 for (
const auto& file : fs::directory_iterator(current_dir +
"/logs"))
53 if (file.path().filename() ==
"ArkApi.log")
56 localtime_s(&tm, &ftime);
59 strftime(time_str, 64,
"%Y-%m-%d-%H-%M", &tm);
61 const std::string new_name =
"ArkApi_" + std::string(time_str) +
".log";
62 std::rename(file.path().generic_string().data(), (current_dir +
"/logs/" + new_name).data());
65 const auto time_point = std::chrono::system_clock::from_time_t(ftime);
67 auto diff = std::chrono::duration_cast<std::chrono::hours>(now - time_point);
68 if (diff.count() >= 24 * 14)
77 namespace fs = std::filesystem;
79 const std::string current_dir = API::Tools::GetCurrentDir();
81 for (
const auto& directory_entry : fs::directory_iterator(current_dir))
83 const auto& path = directory_entry.path();
84 if (is_directory(path))
86 const auto name = path.filename().stem().generic_string();
91 if (name ==
"AtlasApi")
103 namespace fs = std::filesystem;
107 const std::string current_dir = API::Tools::GetCurrentDir();
109 if (!fs::exists(current_dir +
"/logs"))
111 fs::create_directory(current_dir +
"/logs");
119 if (game_name ==
"Ark")
121 else if (game_name ==
"Atlas")
129BOOL WINAPI
DllMain(HINSTANCE hinst_dll, DWORD fdw_reason, LPVOID )
131 if (fdw_reason == DLL_PROCESS_ATTACH)
133 DisableThreadLibraryCalls(hinst_dll);
135 CHAR sys_dir[MAX_PATH];
136 GetSystemDirectoryA(sys_dir, MAX_PATH);
138 char buffer[MAX_PATH];
139 sprintf_s(buffer,
"%s\\version.dll", sys_dir);
147 for (
int i = 0; i < 17; i++)
154 else if (fdw_reason == DLL_PROCESS_DETACH)
void Init(const std::string &plugin_name)
static std::shared_ptr< spdlog::logger > & GetLog()
std::unique_ptr< IBaseApi > game_api
void GetFileVersionInfoSizeW_wrapper()
void VerQueryValueA_wrapper()
void GetFileVersionInfoExW_wrapper()
void VerLanguageNameA_wrapper()
BOOL WINAPI DllMain(HINSTANCE hinst_dll, DWORD fdw_reason, LPVOID)
void GetFileVersionInfoSizeExW_wrapper()
void GetFileVersionInfoA_wrapper()
void VerInstallFileW_wrapper()
void VerLanguageNameW_wrapper()
void VerFindFileW_wrapper()
void GetFileVersionInfoByHandle_wrapper()
void GetFileVersionInfoW_wrapper()
std::time_t GetFileWriteTime(const std::filesystem::path &filename)
void VerInstallFileA_wrapper()
void GetFileVersionInfoExA_wrapper()
void VerQueryValueW_wrapper()
void GetFileVersionInfoSizeExA_wrapper()
void VerFindFileA_wrapper()
void GetFileVersionInfoSizeA_wrapper()