2 个版本
| 0.1.1 | 2022年4月14日 | 
|---|---|
| 0.1.0 | 2022年4月14日 | 
#15 in #protection
8KB
98 代码行
crate: protected_integer
一个简单的crate,用于防止某些变量被内存篡改工具修改。
用法
- 
将此crate添加到Cargo.toml中的依赖项 [dependencies] protected_integer = "0.1"
- 
在项目中使用此crate 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);
性能
根据基准测试结果,此crate几乎无成本
详细结果
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)
黑客测试
您可以克隆此仓库并执行以下命令:cargo run --example hacking_test
现在尝试用Cheat Engine黑入进程
依赖项
~775KB
~14K SLoC