Moving To Discord: https://discord.gg/UmXNvjq

Hello everyone, due to bugs with the forum software that I do not have time to care about, I am going to be shutting down these forums and moving my discussions to Discord instead. I will eventually keep releases here on the site but the forums will be removed sooner or later. I encourage people to join my personal Discord if you have questions, if you are looking for any of my projects, etc.




Registration Code (Part 1): w%kQ6
Registration Code (Part 2): b<#$1[*(cw~
In order to register on this forum, you must use the codes above. Combine them into one code (copy paste).

KoA: Reckoning - Hashing Functions

Information related to the single-player game, Kingdoms of Amalur: Reckoning.
Locked
User avatar
atom0s
Site Admin
Posts: 449
Joined: Sun Jan 04, 2015 11:23 pm
Location: 127.0.0.1
Contact:

KoA: Reckoning - Hashing Functions

Post by atom0s » Wed Dec 25, 2019 8:05 am

Here are the main two functions used for creating string hashes that are using in Reckoning. These are used for things like lookup tables (hash maps) or similar. Reckoning uses hashes a lot to save file space by turning strings into 32bit integer hashes.

This data is based on the v1.0.0.2 Steam executable of the game.
  1. int __cdecl sub_8DDE40(const char *a1, _DWORD *a2)
  2. {
  3.   const char *v2; // ecx@1
  4.   int result; // eax@2
  5.   unsigned int v4; // eax@3
  6.   signed int v5; // edi@3
  7.   unsigned int v6; // ebx@4
  8.   unsigned int v7; // esi@6
  9.   int v8; // ebp@6
  10.   unsigned int v9; // ST1C_4@6
  11.   int v10; // edx@6
  12.   int v11; // [sp+4h] [bp-Ch]@3
  13.   int v12; // [sp+8h] [bp-8h]@3
  14.  
  15.   v2 = a1;
  16.   if ( a1 )
  17.   {
  18.     v12 = 0;
  19.     v11 = 0;
  20.     v4 = strlen(a1);
  21.     v5 = v4 - 1;
  22.     if ( ((v4 - 1) & 0x80000000) == 0 )
  23.     {
  24.       v6 = v4;
  25.       while ( 1 )
  26.       {
  27.         v7 = v2[v6 - 1];
  28.         v8 = v5 % 0x32;
  29.         v9 = tolower(v7);
  30.         v12 += v6 * dword_B747C0[v7 % 0x32] + v7 * dword_B747C0[v5 % 0x32];
  31.         v10 = v6 * dword_B747C0[v9 % 0x32];
  32.         --v5;
  33.         --v6;
  34.         v11 += v10 + v9 * dword_B747C0[v8];
  35.         if ( v5 < 0 )
  36.           break;
  37.         v2 = a1;
  38.       }
  39.     }
  40.     *a2 = v11;
  41.     result = v12;
  42.   }
  43.   else
  44.   {
  45.     result = 0;
  46.   }
  47.   return result;
  48. }
  1. int __usercall sub_8DDC90@<eax>(int result@<eax>, int a2@<ecx>, int a3)
  2. {
  3.   int v3; // ebx@2
  4.   signed int v4; // esi@2
  5.   int v5; // edi@3
  6.   unsigned int v6; // eax@4
  7.   int v7; // ebp@4
  8.   int v8; // eax@4
  9.   int v9; // [sp+0h] [bp-4h]@3
  10.  
  11.   if ( result )
  12.   {
  13.     v3 = 0;
  14.     v4 = a3 - 1;
  15.     if ( a3 - 1 >= 0 )
  16.     {
  17.       v5 = a3;
  18.       v9 = a2 + result;
  19.       do
  20.       {
  21.         v6 = tolower(*(_BYTE *)(v9 + v4));
  22.         v7 = v5 * dword_B747C0[v6 % 0x32];
  23.         v8 = v3 + v6 * dword_B747C0[v4-- % 50];
  24.         --v5;
  25.         v3 = v8 + v7;
  26.       }
  27.       while ( v4 >= 0 );
  28.     }
  29.     result = v3;
  30.   }
  31.   return result;
  32. }
Derp~
Need a great web host? Check out: AnHonestHost.com


Donations can be made via Paypal:
https://www.paypal.me/atom0s
Locked

Who is online

Users browsing this forum: No registered users and 1 guest