Skip to main content

hopper_unsafe_region

Macro hopper_unsafe_region 

Source
macro_rules! hopper_unsafe_region {
    ( $label:literal, $body:block ) => { ... };
}
Expand description

Auditable raw-pointer boundary.

Wraps a block that needs unsafe in a named Hopper macro so an auditor can grep hopper_unsafe_region! and find every raw reinterpretation in the tree with one command. The macro expands to a plain unsafe { ... } block: zero runtime cost, identical codegen, but the invocation site is nameable and documented.

Usage:

let cleared = hopper::hopper_unsafe_region!("clear rewards via raw ptr", {
    let ptr = ctx.as_mut_ptr(0)?;
    (ptr.add(24) as *mut u64).write_unaligned(0);
    0u64
});

The label is a compile-time string literal. It is discarded by the expansion but serves as inline documentation an auditor reads alongside the unsafe body.