MCPcopy Index your code
hub / github.com/b1tg/rust-windows-shellcode / compare_raw_str

Function compare_raw_str

shellcode/src/utils.rs:45–66  ·  view source on GitHub ↗
(s: *const T, u: *const T)

Source from the content-addressed store, hash-verified

43use num_traits::Num;
44
45pub fn compare_raw_str<T>(s: *const T, u: *const T) -> bool
46where
47 T: Num,
48{
49 unsafe {
50 let u_len = (0..).take_while(|&i| !(*u.offset(i)).is_zero()).count();
51 let u_slice = core::slice::from_raw_parts(u, u_len);
52
53 let s_len = (0..).take_while(|&i| !(*s.offset(i)).is_zero()).count();
54 let s_slice = core::slice::from_raw_parts(s, s_len);
55
56 if s_len != u_len {
57 return false;
58 }
59 for i in 0..s_len {
60 if s_slice[i] != u_slice[i] {
61 return false;
62 }
63 }
64 return true;
65 }
66}
67
68fn compare_str_u8(s: &str, u: *const u8) -> bool {
69 unsafe {

Callers 2

get_module_by_nameFunction · 0.85
get_func_by_nameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected