Function obfstr::xref_mut[][src]

pub fn xref_mut<T: ?Sized>(p: &'static mut T, offset: usize) -> &'static mut T

Obfuscates the xref to static data.

The offset can be initialized with random! for a compiletime random value.

static mut FOO: i32 = 42;
let foo = obfstr::xref_mut(unsafe { &mut FOO }, 0x321);

// When looking at the disassembly the reference to `FOO` has been obfuscated.
assert_eq!(foo as *mut _, unsafe { &mut FOO } as *mut _);