Update ModHashFromName to always lowercase first
This commit is contained in:
parent
6e976ab67b
commit
dc120752c8
|
@ -259,11 +259,7 @@ void LoopCacheLoad(JSON Root)
|
||||||
|
|
||||||
// Module name
|
// Module name
|
||||||
const char* mod = json_string_value(json_object_get(value, "module"));
|
const char* mod = json_string_value(json_object_get(value, "module"));
|
||||||
|
|
||||||
if(mod && strlen(mod) < MAX_MODULE_SIZE)
|
|
||||||
loopInfo.modhash = ModHashFromName(mod);
|
loopInfo.modhash = ModHashFromName(mod);
|
||||||
else
|
|
||||||
loopInfo.modhash = 0;
|
|
||||||
|
|
||||||
// All other variables
|
// All other variables
|
||||||
loopInfo.start = (duint)json_hex_value(json_object_get(value, "start"));
|
loopInfo.start = (duint)json_hex_value(json_object_get(value, "start"));
|
||||||
|
|
|
@ -886,7 +886,7 @@ bool ModLoad(duint Base, duint Size, const char* FullPath, bool loadSymbols)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate module hash from full file name
|
// Calculate module hash from full file name
|
||||||
info.hash = ModHashFromName(file);
|
info.hash = ModHashFromName(file, false);
|
||||||
|
|
||||||
// Copy the extension into the module struct
|
// Copy the extension into the module struct
|
||||||
{
|
{
|
||||||
|
@ -1100,14 +1100,27 @@ duint ModContentHashFromAddr(duint Address)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
duint ModHashFromName(const char* Module)
|
duint ModHashFromName(const char* Module, bool tolower)
|
||||||
{
|
{
|
||||||
// return MODINFO.hash (based on the name)
|
// return MODINFO.hash (based on the name)
|
||||||
ASSERT_NONNULL(Module);
|
ASSERT_NONNULL(Module);
|
||||||
auto len = int(strlen(Module));
|
auto len = strlen(Module);
|
||||||
if(!len)
|
if(!len)
|
||||||
return 0;
|
return 0;
|
||||||
auto hash = murmurhash(Module, len);
|
|
||||||
|
duint hash = 0;
|
||||||
|
if(tolower)
|
||||||
|
{
|
||||||
|
auto & moduleLower = TLSData::get()->moduleHashLower;
|
||||||
|
moduleLower.clear();
|
||||||
|
for(size_t i = 0; i < len; i++)
|
||||||
|
moduleLower.push_back(StringUtils::ToLower(Module[i]));
|
||||||
|
hash = murmurhash(moduleLower.c_str(), moduleLower.size());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hash = murmurhash(Module, len);
|
||||||
|
}
|
||||||
|
|
||||||
//update the hash cache
|
//update the hash cache
|
||||||
SHARED_ACQUIRE(LockModuleHashes);
|
SHARED_ACQUIRE(LockModuleHashes);
|
||||||
|
|
|
@ -156,7 +156,7 @@ duint ModBaseFromAddr(duint Address);
|
||||||
// Get a unique hash for an address in the module.
|
// Get a unique hash for an address in the module.
|
||||||
// IMPORTANT: If you want to get a hash for the module base, pass the base
|
// IMPORTANT: If you want to get a hash for the module base, pass the base
|
||||||
duint ModHashFromAddr(duint Address);
|
duint ModHashFromAddr(duint Address);
|
||||||
duint ModHashFromName(const char* Module);
|
duint ModHashFromName(const char* Module, bool tolower = true);
|
||||||
duint ModContentHashFromAddr(duint Address);
|
duint ModContentHashFromAddr(duint Address);
|
||||||
duint ModBaseFromName(const char* Module);
|
duint ModBaseFromName(const char* Module);
|
||||||
duint ModSizeFromAddr(duint Address);
|
duint ModSizeFromAddr(duint Address);
|
||||||
|
|
|
@ -36,16 +36,16 @@ void MurmurHash3_x64_128(const void* key, int len, uint32_t seed, void* out);
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
static inline
|
static inline
|
||||||
unsigned long long murmurhash(const void* data, int len)
|
unsigned long long murmurhash(const void* data, size_t len)
|
||||||
{
|
{
|
||||||
unsigned long long hash[2];
|
unsigned long long hash[2];
|
||||||
MurmurHash3_x64_128(data, len, 0x1337, hash);
|
MurmurHash3_x64_128(data, (int)len, 0x1337, hash);
|
||||||
#else //x86
|
#else //x86
|
||||||
static inline
|
static inline
|
||||||
unsigned long murmurhash(const void* data, int len)
|
unsigned long murmurhash(const void* data, size_t len)
|
||||||
{
|
{
|
||||||
unsigned int hash[1];
|
unsigned int hash[1];
|
||||||
MurmurHash3_x86_32(data, len, 0x1337, hash);
|
MurmurHash3_x86_32(data, (int)len, 0x1337, hash);
|
||||||
#endif //_WIN64
|
#endif //_WIN64
|
||||||
return hash[0];
|
return hash[0];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue