mirror of
https://github.com/thomasxm/BOAZ_beta
synced 2026-06-06 16:54:29 +00:00
31 lines
591 B
C
31 lines
591 B
C
#include <Utils.h>
|
|
#include <Macros.h>
|
|
|
|
SEC( text, B ) UINT_PTR HashString( LPVOID String, UINT_PTR Length )
|
|
{
|
|
ULONG Hash = 5381;
|
|
PUCHAR Ptr = String;
|
|
|
|
do
|
|
{
|
|
UCHAR character = *Ptr;
|
|
|
|
if ( ! Length )
|
|
{
|
|
if ( !*Ptr ) break;
|
|
}
|
|
else
|
|
{
|
|
if ( (ULONG) ( Ptr - (PUCHAR)String ) >= Length ) break;
|
|
if ( !*Ptr ) ++Ptr;
|
|
}
|
|
|
|
if ( character >= 'a' )
|
|
character -= 0x20;
|
|
|
|
Hash = ( ( Hash << 5 ) + Hash ) + character;
|
|
++Ptr;
|
|
} while ( TRUE );
|
|
|
|
return Hash;
|
|
} |