Overview
Thesyscall::hashing namespace provides compile-time and runtime string hashing functions used for obfuscating syscall names and API references. The hashing system uses a custom algorithm with compile-time generated seeds to make analysis more difficult.
Namespace
Type Definitions
Hash_t
Compile-Time Seed Generation
getCompileTimeSeed
__TIME__ and __DATE__ macros. This ensures each compilation produces different hash values.
Returns: A unique 64-bit seed value based on compilation timestamp.
Seed Constants
Compile-Time Hashing
calculateHash (null-terminated)
szData- Null-terminated string to hash
calculateHash (with length)
szData- String to hashuLength- Maximum length to hash (stops at null terminator if encountered first)
Runtime Hashing
calculateHashRuntime (null-terminated)
szData- Null-terminated string to hash
calculateHashRuntime (with length)
szData- String to hashuLength- Maximum length to hash (stops at null terminator if encountered first)
calculateHashRuntime (string_view)
std::string_view.
Parameters:
sv- String view to hash
Macros
SYSCALL_ID
SYSCALLS_NO_HASH is defined, returns the string as-is. Otherwise, computes the hash at compile time.
Parameters:
str- String literal to hash
Hash_t (default) or const char* (if SYSCALLS_NO_HASH defined)
Usage:
SYSCALL_ID_RT
SYSCALLS_NO_HASH is defined, returns the string as-is. Otherwise, computes the hash at runtime.
Parameters:
str- String to hash
Hash_t (default) or const char* (if SYSCALLS_NO_HASH defined)
Usage:
Compile Flags
SYSCALLS_NO_HASH
Define this macro to disable hashing and use string names directly. This is useful for debugging.SYSCALL_ID(str)returnsstrSYSCALL_ID_RT(str)returnsstrSyscallKey_tbecomesstd::stringinstead ofHash_t
Algorithm Details
The hashing algorithm uses:- Custom polynomial keys derived from compile-time seed
- XOR operations for mixing
- Bit rotation (
std::rotr) for avalanche effect - Different rotation amounts for each key
- Produce uniform distribution of hash values
- Be fast at both compile-time and runtime
- Generate unique hashes per compilation
- Resist simple pattern analysis
Example
Related
- Type Aliases -
SyscallKey_tdefinition - Native API - Uses hashing for module/export lookup