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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#![allow(dead_code)]
#[derive(Debug)]
pub enum FaitheError {
#[cfg(not(feature = "no-std"))]
ErrorCode(windows::Win32::Foundation::WIN32_ERROR),
#[cfg(not(feature = "no-std"))]
WindowsError(windows::core::Error),
ProcessNotFound,
ModuleNotFound,
QueryFailed,
PatternNotFound,
#[cfg(all(windows, not(feature = "no-std")))]
UnknownProtection(u32),
InvalidString,
NonAsciiPattern,
InvalidPattern,
PatternMaskMismatch,
AlreadyResolved,
}
pub(crate) type Result<T> = core::result::Result<T, FaitheError>;
cfg_if::cfg_if! {
if #[cfg(not(feature = "no-std"))] {
impl std::error::Error for FaitheError {}
impl std::fmt::Display for FaitheError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}
impl From<windows::core::Error> for FaitheError {
fn from(e: windows::core::Error) -> Self {
Self::WindowsError(e)
}
}
impl FaitheError {
pub(crate) fn last_error() -> Self {
unsafe { Self::ErrorCode(windows::Win32::Foundation::GetLastError()) }
}
}
}
}