Skip to content

Commit

Permalink
Remove version check, alert user/cancel load if an address can't be f…
Browse files Browse the repository at this point in the history
…ound
  • Loading branch information
emoose committed Oct 10, 2021
1 parent 23ce36d commit a28a156
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 28 deletions.
9 changes: 5 additions & 4 deletions src/Utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ bool AddressManager::SearchAddresses(void* Base, size_t BaseLength)
uint8_t* base = (uint8_t*)Base;
_numValid = 0;

bool foundAll = true;
for (AutoGameAddress* address : _addresses)
{
uint8_t* StartAddr = base;
Expand All @@ -165,10 +166,10 @@ bool AddressManager::SearchAddresses(void* Base, size_t BaseLength)
}

if (address->_matches.size() <= 0)
return false;

_numValid++;
foundAll = false;
else
_numValid++;
}

return true;
return foundAll;
}
8 changes: 8 additions & 0 deletions src/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ class AddressManager
{
return _numValid;
}
std::vector<AutoGameAddress*> GetInvalid()
{
std::vector<AutoGameAddress*> invalid;
for (AutoGameAddress* addr : _addresses)
if (addr->_matches.size() <= 0)
invalid.push_back(addr);
return invalid;
}

inline AutoGameAddress& operator[](std::string_view Name)
{
Expand Down
35 changes: 11 additions & 24 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ uintptr_t mBaseAddress;

#define SDK_VERSION "0.1.27"

const uint32_t Addr_Timestamp = 0x1E0;
const uint32_t Value_Timestamp = 1626315361; // 2021/07/15 02:16:01
const uint32_t Value_Timestamp_patch1 = 1629818287; // 2021/08/24 15:18:07 (no code changes?)

const uint32_t Game_TextSectionChecksum = 0x13ce422f; // patch0 & patch1 share this

// UE4 stuff
AutoGameAddress Addr_GNames( // patch0: 0x14132000D
"GNames",
Expand Down Expand Up @@ -787,27 +781,20 @@ void InitPlugin()

int textSize = 0;
void* textSection = ModuleGetSection((void*)mBaseAddress, ".text", &textSize);
auto checksum = rc_crc32(0, (char*)textSection, textSize);

bool foundAllAddrs = AddressManager::Instance().SearchAddresses(textSection, textSize);
int numFound = AddressManager::Instance().NumValid();

// Check that this is the EXE we were built against...
uint32_t timestamp = *reinterpret_cast<uint32_t*>(mBaseAddress + Addr_Timestamp);
if (timestamp != Value_Timestamp && timestamp != Value_Timestamp_patch1)
if (!foundAllAddrs)
{
// Not a known EXE timestamp, we'll checksum the .text section since some patches are known to just update timestamps...
bool isKnown = false;
if (textSection)
{
auto checksum = rc_crc32(0, (char*)textSection, textSize);
isKnown = checksum == Game_TextSectionChecksum;
}

if (!isKnown)
{
MessageBoxA(0, "Unsupported 'Tales of Arise.exe' version, aborting Arise-SDK load...", "Arise-SDK", 0);
return;
}
auto failedAddrs = AddressManager::Instance().GetInvalid();
std::stringstream msgText;
msgText << "Failed to locate all game-addresses for patching, aborting Arise-SDK load!\r\n\r\n";
msgText << "Failed to locate " << failedAddrs.size() << " addresses: (code checksum: 0x" << std::hex << checksum << std::dec << ", CTRL+C to copy this text)";
for (AutoGameAddress* addr : failedAddrs)
msgText << "\r\n" + addr->Name;

MessageBoxA(0, msgText.str().c_str(), "Arise-SDK", 0);
return;
}

PostProc_Init();
Expand Down
1 change: 1 addition & 0 deletions src/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <algorithm>
#include <sstream>

#include "MinHook/MinHook.h"

Expand Down

0 comments on commit a28a156

Please sign in to comment.