#[protect]Expand description
Declares how ruwrite is allowed to treat the function or static it is
placed on.
#[protect(immutable)]
fn check_license() -> bool { true }
#[protect(protected)]
static SECRET_KEY: u32 = 0xDEAD_BEEF;Modes, from least to most restrictive:
| Mode | Meaning |
|---|---|
editable | explicitly not protected; the same as writing nothing, spelled out |
immutable | ruwrite refuses every edit that touches it |
protected | immutable, and also included when the program later checks its own integrity (see Executable::integrity_snapshot) |
hide | immutable, and its name is not stored as readable text in the binary and is left out of Executable::functions() / variables(); see the limitations below |
ruwrite reads this declaration back from the compiled executable, so
every edit through it is checked, however it is made: by name, by address,
by raw bytes, or by content ([Executable::find_value]). It is the
program declaring the rule, not ruwrite guessing at one — there is
deliberately no option to bypass it.
What hide does and does not do. It keeps the plain name out of the
.ruwprot record (a hash is stored instead, so ruwrite can still match
the right item without ever holding its readable name) and filters it out
of ruwrite’s own listings. It does not rename the function’s debug or
symbol-table entry, strip its machine code, or defend against
disassembly: a determined reader with objdump still sees it. Build
without debug info and strip symbols for that.
Mark a protected function #[inline(never)] so the compiler keeps one
identifiable copy of it instead of folding it into every caller.