cradle_plugin_api/ffi.rs
1/// Type definition for the API version check function
2pub type CradleCheckApiVerFn = extern "C" fn() -> u32;
3/// Type definition for the API cleanup function
4pub type CradleCleanupFn = extern "C" fn();
5
6/// FFI-safe agent event
7#[repr(C)]
8pub struct FfiEvent {
9 /// Event kind
10 pub kind: u32,
11 /// Target PID
12 pub pid: u32,
13 /// Target handle
14 pub process: isize,
15 /// Newly loaded DLL name pointer
16 pub dll_name: *const std::os::raw::c_char,
17 /// Newly loaded DLL base address
18 pub dll_base: usize,
19 /// Thread ID
20 pub tid: u32,
21 /// Thread Handle
22 pub thread_handle: isize,
23 /// Identified debug string
24 pub dbg_string: *const u8,
25 /// Target binary path
26 pub target_path: *const u8,
27 /// Target bytes pointer
28 pub target_bytes: *const u8,
29 /// Target bytes length
30 pub target_bytes_len: usize,
31}
32
33/// Process created event constant
34pub const EVENT_PROCESS_CREATED: u32 = 1;
35/// DLL loaded event constant
36pub const EVENT_DLL_LOADED: u32 = 2;
37/// Initial breakpoint event constant
38pub const EVENT_INITIAL_BREAKPOINT: u32 = 3;
39/// Process execution finished event constant
40pub const EVENT_FINISHED: u32 = 4;
41/// Thread created event constant
42pub const EVENT_THREAD_CREATED: u32 = 5;
43/// Thread finished event constant
44pub const EVENT_THREAD_FINISHED: u32 = 6;
45/// Debug string event constant
46pub const EVENT_DEBUG_STRING: u32 = 7;
47/// Agent initialized event constant
48pub const EVENT_AGENT_INITIALIZED: u32 = 8;
49/// Agent finished execution event constant
50pub const EVENT_AGENT_FINISHED: u32 = 9;
51#[repr(C)]
52/// FFI-safe version of the check result array
53pub struct FfiResultArray {
54 /// Pointer to data
55 pub ptr: *mut FfiCheckResult,
56 /// Size of data
57 pub len: usize,
58}
59
60#[repr(C)]
61/// FFI-safe version of [`cradle_shared::CheckResult`]
62pub struct FfiCheckResult {
63 /// Plugin name ptr
64 pub plugin: *mut std::os::raw::c_char,
65 /// Check name ptr
66 pub check: *mut std::os::raw::c_char,
67 /// Severity level
68 pub severity: u32,
69 /// Message ptr
70 pub message: *mut std::os::raw::c_char,
71 /// Details ptr
72 pub details: *mut std::os::raw::c_char,
73}