2022-11-30 12:05:14 -05:00
|
|
|
#include <Geode/loader/IPC.hpp>
|
2022-11-22 10:21:00 -05:00
|
|
|
#include <Geode/loader/Log.hpp>
|
2022-12-14 06:50:46 -05:00
|
|
|
#include <loader/ModImpl.hpp>
|
|
|
|
#include <loader/LoaderImpl.hpp>
|
2023-01-24 03:28:43 -05:00
|
|
|
#include <Geode/utils/string.hpp>
|
2022-11-22 10:21:00 -05:00
|
|
|
|
2023-03-10 14:33:24 -05:00
|
|
|
using namespace geode::prelude;
|
2022-11-22 10:21:00 -05:00
|
|
|
|
2023-01-24 03:28:43 -05:00
|
|
|
#include <Psapi.h>
|
|
|
|
|
2024-01-12 14:18:24 -05:00
|
|
|
#include "gdTimestampMap.hpp"
|
|
|
|
std::string Loader::Impl::getGameVersion() {
|
|
|
|
if (m_gdVersion.empty()) {
|
|
|
|
auto dosHeader = reinterpret_cast<IMAGE_DOS_HEADER*>(geode::base::get());
|
|
|
|
auto ntHeader = reinterpret_cast<PIMAGE_NT_HEADERS>(geode::base::get() + dosHeader->e_lfanew);
|
|
|
|
auto timestamp = ntHeader->FileHeader.TimeDateStamp;
|
|
|
|
m_gdVersion = timestampToVersion(timestamp);
|
|
|
|
}
|
|
|
|
return m_gdVersion;
|
|
|
|
}
|
|
|
|
|
2023-01-24 03:28:43 -05:00
|
|
|
bool Loader::Impl::userTriedToLoadDLLs() const {
|
|
|
|
static std::unordered_set<std::string> KNOWN_MOD_DLLS {
|
|
|
|
"betteredit-v4.0.5.dll",
|
|
|
|
"betteredit-v4.0.5-min.dll",
|
|
|
|
"betteredit-v4.0.3.dll",
|
|
|
|
"betteredit.dll",
|
|
|
|
"gdshare-v0.3.4.dll",
|
|
|
|
"gdshare.dll",
|
|
|
|
"hackpro.dll",
|
|
|
|
"hackproldr.dll",
|
|
|
|
"quickldr.dll",
|
|
|
|
"minhook.x32.dll",
|
|
|
|
"iconsave.dll",
|
|
|
|
"menuanim.dll",
|
|
|
|
"volumecontrol.dll",
|
|
|
|
"customsplash.dll",
|
|
|
|
"scrollanyinput-v1.1.dll",
|
|
|
|
"alttabfix-v1.0.dll",
|
|
|
|
"sceneswitcher-v1.1.dll",
|
|
|
|
"gdantialiasing.dll",
|
|
|
|
"textureldr.dll",
|
|
|
|
"run-info.dll",
|
|
|
|
};
|
|
|
|
|
|
|
|
bool triedToLoadDLLs = false;
|
|
|
|
|
|
|
|
// Check for .DLLs in mods dir
|
2023-08-02 10:54:17 -04:00
|
|
|
if (auto files = file::readDirectory(dirs::getModsDir(), true)) {
|
2023-01-24 03:28:43 -05:00
|
|
|
for (auto& file : files.unwrap()) {
|
|
|
|
if (file.extension() == ".dll") {
|
|
|
|
triedToLoadDLLs = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check all loaded DLLs in the process
|
|
|
|
std::array<HMODULE, 1024> mods;
|
|
|
|
DWORD needed;
|
|
|
|
auto process = GetCurrentProcess();
|
|
|
|
|
|
|
|
if (EnumProcessModules(process, mods.data(), mods.size(), &needed)) {
|
|
|
|
for (auto i = 0; i < (needed / sizeof(HMODULE)); i++) {
|
|
|
|
std::array<char, MAX_PATH> modName;
|
|
|
|
if (GetModuleFileNameExA(process, mods[i], modName.data(), modName.size())) {
|
|
|
|
if (KNOWN_MOD_DLLS.count(string::trim(string::toLower(
|
|
|
|
ghc::filesystem::path(modName.data()).filename().string()
|
|
|
|
)))) {
|
|
|
|
triedToLoadDLLs = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return triedToLoadDLLs;
|
|
|
|
}
|