Merge pull request #626 from diamante0018/fix/main-checks

[Main]: Improve error message
This commit is contained in:
Edo 2022-12-06 14:10:26 +00:00 committed by GitHub
commit fb68e59e08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 19 additions and 44 deletions

View File

@ -56,7 +56,7 @@ namespace Components
UIScript::Add("visitWebsite", []([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info)
{
Utils::OpenUrl(Utils::Cache::GetStaticUrl(""));
Utils::OpenUrl(Utils::Cache::GetUrl(Utils::Cache::Urls[1], {}));
});
Localization::Set("MPUI_CHANGELOG_TEXT", "Loading...");

View File

@ -50,20 +50,6 @@ namespace Components
this->lastRequest.reset();
}
void Node::LoadNodeRemotePreset()
{
std::string nodes = Utils::Cache::GetFile("/iw4/nodes.txt");
if (nodes.empty()) return;
auto nodeList = Utils::String::Split(nodes, '\n');
for (auto& node : nodeList)
{
Utils::String::Replace(node, "\r", "");
Utils::String::Trim(node);
Node::Add(node);
}
}
void Node::LoadNodePreset()
{
Proto::Node::List list;
@ -350,14 +336,6 @@ namespace Components
Scheduler::OnGameInitialized(loadNodes, Scheduler::Pipeline::MAIN);
Network::OnStart([]
{
std::thread([]
{
Node::LoadNodeRemotePreset();
}).detach();
});
Command::Add("listnodes", [](Command::Params*)
{
Logger::Print("Nodes: {}\n", Node::Nodes.size());

View File

@ -41,8 +41,6 @@ namespace Components
static void RunFrame();
static void Synchronize();
static void LoadNodeRemotePreset();
private:
static std::recursive_mutex Mutex;
static std::vector<Entry> Nodes;

View File

@ -55,24 +55,27 @@ BOOL APIENTRY DllMain(HINSTANCE /*hinstDLL*/, DWORD fdwReason, LPVOID /*lpvReser
#ifndef DISABLE_BINARY_CHECK
// Ensure we're working with our desired binary
auto* _module = reinterpret_cast<char*>(0x400000);
auto hash1 = Utils::Cryptography::JenkinsOneAtATime::Compute(_module + 0x1000, 0x2D531F); // .text
auto hash2 = Utils::Cryptography::JenkinsOneAtATime::Compute(_module + 0x2D75FC, 0xBDA04); // .rdata
if ((hash1 != 0x54684DBE
#ifdef DEBUG
&& hash1 != 0x8AADE716
#ifndef DEBUG_BINARY_CHECK
const auto* binary = reinterpret_cast<const char*>(0x6F9358);
if (binary == nullptr || std::strcmp(binary, BASEGAME_NAME) != 0)
#endif
) || hash2 != 0x8030ec53)
{
MessageBoxA(nullptr,
"Failed to load game binary.\n"
"You did not install the iw4x-rawfiles!\n"
"Please use the XLabs launcher to run the game. For support please visit https://xlabs.dev/support_iw4x_client",
"ERROR",
MB_ICONERROR
);
return FALSE;
}
DWORD oldProtect;
VirtualProtect(_module + 0x1000, 0x2D6000, PAGE_EXECUTE_READ, &oldProtect); // Protect the .text segment
#endif
#ifndef DEBUG_BINARY_CHECK
// Install entry point hook
Utils::Hook(0x6BAC0F, Main::EntryPoint, HOOK_JUMP).install()->quick();
#endif
}
else if (fdwReason == DLL_PROCESS_DETACH)
{

View File

@ -173,6 +173,7 @@ using namespace std::literals;
#endif
#define BASEGAME "iw4x"
#define BASEGAME_NAME "iw4mp_ceg.exe"
#define CLIENT_CONFIG "iw4x_config.cfg"
// Resource stuff

View File

@ -11,11 +11,6 @@ namespace Utils
std::string Cache::ValidUrl;
std::mutex Cache::CacheMutex;
std::string Cache::GetStaticUrl(const std::string& path)
{
return Urls[0] + path;
}
std::string Cache::GetUrl(const std::string& url, const std::string& path)
{
return url + path;

View File

@ -5,13 +5,13 @@ namespace Utils
class Cache
{
public:
static std::string GetStaticUrl(const std::string& path);
static const char* Urls[];
static std::string GetUrl(const std::string& url, const std::string& path);
static std::string GetFile(const std::string& path, int timeout = 5000, const std::string& useragent = "IW4x");
private:
static std::mutex CacheMutex;
static const char* Urls[];
static std::string ValidUrl;
static std::string GetUrl(const std::string& url, const std::string& path);
};
}

View File

@ -270,7 +270,7 @@ namespace Utils
return Compute(data.data(), data.size());
}
unsigned int JenkinsOneAtATime::Compute(const char *key, size_t len)
unsigned int JenkinsOneAtATime::Compute(const char *key, std::size_t len)
{
unsigned int hash, i;
for (hash = i = 0; i < len; ++i)