HexVeil is a comprehensive code protection library for Windows applications, designed to prevent reverse engineering, debugging, and analysis.
// Polymorphic function protection
void* protected_func = hexveil_generate_polymorphic_stub(original_function);
// Advanced string protection
ProtectedString* secure_str = hexveil_encrypt_string_ex("critical data");
char* decrypted = hexveil_decrypt_string(secure_str);
// Control flow obfuscation
HEXVEIL_FLATTEN_BEGIN(1)
HEXVEIL_FLATTEN_CASE(1, {
// Protected code block 1
__next_state = 2;
})
HEXVEIL_FLATTEN_CASE(2, {
// Protected code block 2
__next_state = 0;
})
HEXVEIL_FLATTEN_END()
// Code mutation
hexveil_mutate_code_block(function_ptr, size);
void* mutated = hexveil_randomize_instructions(function_ptr, size);
// Anti-analysis
HEXVEIL_BREAK_ANALYSIS();
HEXVEIL_FAKE_PATH();
HEXVEIL_ANTIDEBUG();
Basic usage example:
#include "hexveil.h"
int main() {
HEXVEIL_PROTECT_ALL(); // Enable all protections
HEXVEIL_TRY {
// Your protected code here
}
HEXVEIL_EXCEPT {
// Handle tampering
}
return 0;
}
git clone https://github.com/Enigmatikk/hexveil
cd hexveil
gcc test.c -o test.exe -I. -O2 -Wall
// Initialize all protections
HEXVEIL_PROTECT_ALL();
// Protect specific function
HEXVEIL_PROTECT_FUNCTION(function_name);
// String encryption
const char* protected_str = hexveil_encrypt_string_safe("secret");
// Anti-debug check
if(hexveil_detect_debugger_safe()) {
ExitProcess(1);
}
// Memory protection
hexveil_protect_code_section();
hexveil_corrupt_pe_headers();
• Windows x86/x64 support only
• Some features require administrator rights
• May trigger antivirus software
• Not suitable for kernel-mode drivers