Skip to content

Commit 7e36d26

Browse files
committed
refactor: rewrite service to new sys crate
Signed-off-by: Yaroslav Bolyukin <[email protected]>
1 parent 4f30f35 commit 7e36d26

File tree

2 files changed

+30
-38
lines changed

2 files changed

+30
-38
lines changed

src/service.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use vmprotect_sys::VMProtectIsDebuggerPresent;
2+
use vmprotect_sys::VMProtectIsProtected;
3+
use vmprotect_sys::VMProtectIsValidImageCRC;
4+
use vmprotect_sys::VMProtectIsVirtualMachinePresent;
5+
6+
/// Check if currently running application is protected by vmprotect
7+
///
8+
/// Dead code will not be elminated
9+
#[inline(always)]
10+
pub fn is_protected() -> bool {
11+
unsafe { VMProtectIsProtected() == 1 }
12+
}
13+
14+
/// Check presence of debugger
15+
#[inline(always)]
16+
pub fn is_debugger_present(check_kernel_mode: bool) -> bool {
17+
unsafe { VMProtectIsDebuggerPresent(if check_kernel_mode { 1 } else { 0 }) == 1 }
18+
}
19+
20+
/// Returns true if running inside virtual machine
21+
#[inline(always)]
22+
pub fn is_virtual_machine() -> bool {
23+
unsafe { VMProtectIsVirtualMachinePresent() == 1 }
24+
}
25+
26+
/// Check if process memory is not damaged/edited
27+
#[inline(always)]
28+
pub fn is_valid_image_crc() -> bool {
29+
unsafe { VMProtectIsValidImageCRC() == 1 }
30+
}

src/service/mod.rs

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)