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

Function compare_str_u8

shellcode/src/utils.rs:68–84  ·  view source on GitHub ↗
(s: &str, u: *const u8)

Source from the content-addressed store, hash-verified

66}
67
68fn compare_str_u8(s: &str, u: *const u8) -> bool {
69 unsafe {
70 let len = (0..).take_while(|&i| *u.offset(i) != 0).count();
71 let slice = core::slice::from_raw_parts(u, len);
72 let s_len = s.len();
73 if len != s_len {
74 return false;
75 }
76 let ss = s.as_bytes();
77 for i in 0..len {
78 if slice[i] != ss[i] as u8 {
79 return false;
80 }
81 }
82 return true;
83 }
84}
85
86fn str_to_i8(s: &str) -> *const i8 {
87 s.as_bytes().as_ptr() as *const i8

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected