initial
This commit is contained in:
15
tests/test_data.rs
Normal file
15
tests/test_data.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
pub fn test_distance() {
|
||||
|
||||
|
||||
let a = [0u8,2,3];
|
||||
let p1 = &a[0];
|
||||
let p2 = &a[2];
|
||||
assert_eq!(x::distance(p1, p2), 2);
|
||||
assert_eq!(x::distance(p2, p1), 2);
|
||||
assert_eq!(x::distance(p1, p1), 0);
|
||||
}
|
||||
24
tests/test_image_base.rs
Normal file
24
tests/test_image_base.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
#[link(name = "kernel32")]
|
||||
extern "C" {
|
||||
pub fn GetModuleHandleA(module_name: *const i8) -> &'static x::win32::ImageBase;
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "win32")]
|
||||
pub fn test_image_base() {
|
||||
let a = unsafe { GetModuleHandleA(std::ptr::null()) } as *const _ as usize;
|
||||
let b = x::win32::image_base() as *const _ as usize;
|
||||
assert_eq!(a, b, "image_base didn't match");
|
||||
|
||||
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "win32")]
|
||||
pub fn test_image_base2() {
|
||||
let a = unsafe { x::win32::process_executable() } as *const _ as usize;
|
||||
let b = x::win32::image_base() as *const _ as usize;
|
||||
assert_eq!(a, b, "image_base didn't match");
|
||||
}
|
||||
15
tests/test_lazy_import.rs
Normal file
15
tests/test_lazy_import.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use x::IntoUsize;
|
||||
|
||||
x::lazy_import! { "kernel32.dll"
|
||||
pub fn LoadLibraryA(module_name: *const i8) -> &'static x::win32::ImageBase;
|
||||
pub fn GetModuleHandleA(module_name: *const i8) -> &'static x::win32::ImageBase;
|
||||
pub fn GetLastError() -> usize;
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "win32")]
|
||||
pub fn test_exports() {
|
||||
let a = LoadLibraryA(x::cstr!("user32.dll"));
|
||||
println!("{} -> {}",a.into_usize(), unsafe { a.nt_header().optional_header.size_of_image });
|
||||
}
|
||||
Reference in New Issue
Block a user