1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use std::os::raw::{c_char, c_void};
use crate::internal;
use std::borrow::Cow;
use std::ffi::CStr;
pub struct EncryptedStringA(pub *const c_char);
impl Drop for EncryptedStringA {
fn drop(&mut self) {
unsafe { internal::VMProtectFreeString(self.0 as *const c_void) };
}
}
impl Into<&CStr> for EncryptedStringA {
fn into(self) -> &'static CStr {
unsafe { CStr::from_ptr(self.0) }
}
}
impl Into<Cow<'_, str>> for EncryptedStringA {
fn into(self) -> Cow<'static, str> {
(self.into(): &CStr).to_string_lossy()
}
}
impl Into<&str> for EncryptedStringA {
fn into(self) -> &'static str {
(self.into(): &CStr).to_str().unwrap()
}
}
impl Into<String> for EncryptedStringA {
fn into(self) -> String {
(self.into(): &str).to_string()
}
}