Developer knowledge network · moderated exchange

UnreliableCode қауымдастығы

Әзірлеушілерді зерттеу, кері инженерия және кодтау қауымдастығы

Knowledge indexТірі
4Categories
919Threads
2.8KЖазбалар
Tutorial

Compile-time API hashing with MurmurHash3 and PEB traversal in C++20

vtable_slayer
Senior Reverser
MEMBER
Өкіл: 215
Қосылу күні: Mar 2018
Хабарламалар: 86
Рахмет: 61
1 ай бұрын · Jul 11, 2026 10:02 AM
#1

Hide Win32 API imports from your binary's Import Address Table:

CPP
constexpr uint32_t HashString(const char* str) {
    uint32_t hash = 0x811c9dc5;
    while (*str) {
        hash ^= (uint8_t)*str++;
        hash *= 0x01000193;
    }
    return hash;
}

// Usage in code:
FARPROC pVirtualAlloc = GetExportByHash(hKernel32, HashString("VirtualAlloc"));

Because HashString is evaluated by the compiler via constexpr, the string "VirtualAlloc" is never compiled into the binary, only the hash 0x4A1F3B20!

hook_doctor
Hooking Specialist
MEMBER
Өкіл: 181
Қосылу күні: Jul 2019
Хабарламалар: 21
Рахмет: 50
1 ай бұрын · Jul 11, 2026 12:43 PM
#2

Pair this with a custom PEB module list iterator to eliminate GetProcAddress and LoadLibrary from imports.

ptr_arithmetic
C++ Wizard
MEMBER
Өкіл: 162
Қосылу күні: May 2018
Хабарламалар: 73
Рахмет: 42
1 ай бұрын · Jul 12, 2026 3:46 AM
#3

Clean FNV-1a constexpr hash. Clean and elegant.