syscalls-rs

May 22, 2026 · View on GitHub

Rust port of syscalls-cpp: a policy-based framework for crafting undetectable/protected Windows syscalls (x86 / x64).

You mix and match three policies at compile time:

AllocatorWhat it uses
SectionNtCreateSection + SEC_NO_CHANGE
HeapRtlCreateHeap(HEAP_CREATE_ENABLE_EXECUTE)
MemoryNtAllocateVirtualMemory (RW → RX)
Stub generatorWhat it emits
DirectSelf-contained syscall instruction
Gadget (x64)Jumps to a syscall; ret gadget found in ntdll
ExceptionTriggers ud2; resolves via a vectored exception handler
ParserHow it finds syscall numbers
Directoryx64: walks .pdata ordered by RVA; x86: sorts Zw* exports
SignatureScans function prologues with hook detection

Quick start

use core::ffi::c_void;
use syscalls_rs::prelude::*;
use syscalls_rs::shared::{current_process, NTSTATUS};
use syscalls_rs::syscall_id;

type NtAlloc = unsafe extern "system" fn(
    isize, *mut *mut c_void, usize, *mut usize, u32, u32,
) -> NTSTATUS;

let mgr: SectionDirectManager = Manager::new();
assert!(mgr.initialize());

let inv = mgr.invoke(syscall_id!("NtAllocateVirtualMemory")).unwrap();
let f: NtAlloc = unsafe { inv.as_fn() };

Features

  • no_hash — use String syscall keys instead of compile-time u64 hashes (mirrors -DSYSCALLS_NO_HASH).

Requirements

  • Windows x86 or x64 target
  • Rust 1.75+ (for the const fn features used in hash.rs)

License

MIT (same as upstream).