Orochi Engine String Hash

Doubts, help and support about QuickBMS and other game research tools
chrrox
Posts: 388
Joined: Thu Aug 07, 2014 10:28 pm

Orochi Engine String Hash

Post by chrrox »

How would you convert this hash function to quickbms.

Code: Select all

#include <iostream>
#include <cstdlib>

__int64_t hashMagic(__int64_t a1, unsigned int a2)
{
  unsigned int i;
  unsigned int v4;

  v4 = 37;
  for ( i = 0; i < a2; ++i )
    v4 = *(char *)(a1 + i) + 37 * v4;
   
  return v4;
}

int main()
{
    std::string str ("GAME/SKILL/25310/model/TEXTURE/001/Tex_c");
    __int64_t v1 = (__int64_t)"GAME/SKILL/25310/model/TEXTURE/001/Tex_c";
    int v2 = str.length();
    __int64_t v3 = hashMagic(v1, v2);
    printf("\nHash:""%X",(int) v3);
}



it should output

Hash:75963DE9
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Orochi Engine String Hash

Post by aluigi »

Code: Select all

set VAR string "GAME/SKILL/25310/model/TEXTURE/001/Tex_c"
callfunction hashMagic 1
print "%v4|x%"

startfunction hashMagic
    strlen VARSZ VAR
    math v4 = 37
    for x = 0 < VARSZ
        getvarchr TMP VAR x
        xmath v4 "TMP + 37 * v4"
    next x
endfunction

If you prefer to pass VAR as argument of hashMagic, just rename VAR as hashMagic_ARG1 in the function and call it as "callfunction hashMagic 1 VAR"
chrrox
Posts: 388
Joined: Thu Aug 07, 2014 10:28 pm

Re: Orochi Engine String Hash

Post by chrrox »

that worked perfect Thanks :)