ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Wed Oct 21, 2020 9:47 pm

All times are UTC




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Mar 31, 2020 1:54 am 

Joined: Thu Aug 07, 2014 10:28 pm
Posts: 310
How would you convert this hash function to quickbms.

Code:
#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


Top
   
PostPosted: Tue Mar 31, 2020 8:46 am 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 11680
Code:
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"


Top
   
PostPosted: Tue Mar 31, 2020 1:24 pm 

Joined: Thu Aug 07, 2014 10:28 pm
Posts: 310
that worked perfect Thanks :)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited