protected_integer 0.1.1

A simple crate, that protects some variables from being modified by memory tampering tools.
Documentation
  • Coverage
  • 69.23%
    9 out of 13 items documented3 out of 10 items with examples
  • Size
  • Source code size: 12.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.93 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 22s Average build duration of successful builds.
  • all releases: 22s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • lihe07/protected_integer
    7 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • lihe07

Crate: protected_integer

A simple crate, that protects some variables from being modified by memory tampering tools.

Usage

  1. Add this crate to dependencies in Cargo.toml

    [dependencies]
    
    protected_integer = "0.1"
    
    
  2. Use this crate in your project

    use protected_integer::{ProtectedInteger, State};
    
    let mut my_number = ProtectedInteger::new(114514); // initialize this variable
    
    // Check and get the value
    match my_number.get() {
        State::Untampered(num) => {
            println!("The variable has not been tampered with");
        }
        State::Tampered(num) => {
            println!("The variable was tampered with, but the backup variable was not");
            println!("The restored value is {}", num);
        }
    }
    
    // change the value
    my_number.set(1919810);
    

Performance

According to benchmark result, this crate is almost zero-cost

Detailed result:

running 3 tests
test tests::basic_mutations ... ignored
test tests::bench_getting ... bench:           0 ns/iter (+/- 0)
test tests::bench_setting ... bench:           4 ns/iter (+/- 0)

Hacking test

You can clone this repo and execute cargo run --example hacking_test

Now trying to hack the process with Cheat Engine