endpoint_sec/event/
event_remote_thread_create.rs

1//! [`EventRemoteThreadCreate`]
2
3use endpoint_sec_sys::es_event_remote_thread_create_t;
4
5use crate::{Process, ThreadState};
6
7/// A process has attempted to create a thread in another process
8#[doc(alias = "es_event_remote_thread_create_t")]
9pub struct EventRemoteThreadCreate<'a> {
10    /// Raw reference
11    pub(crate) raw: &'a es_event_remote_thread_create_t,
12    /// Message version
13    pub(crate) version: u32,
14}
15
16impl<'a> EventRemoteThreadCreate<'a> {
17    /// Process for which the task name port will be retrieved.
18    #[inline(always)]
19    pub fn target(&self) -> Process<'a> {
20        // Safety: 'a tied to self, object obtained through ES
21        Process::new(unsafe { self.raw.target() }, self.version)
22    }
23
24    /// New thread state, present in case of `thread_create_running`, absent in case of `thread_create`.
25    #[inline(always)]
26    pub fn thread_state(&self) -> Option<ThreadState<'a>> {
27        // Safety: 'a tied to self, object obtained through ES
28        unsafe { self.raw.thread_state() }.map(ThreadState::new)
29    }
30}
31
32// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
33unsafe impl Send for EventRemoteThreadCreate<'_> {}
34// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
35unsafe impl Sync for EventRemoteThreadCreate<'_> {}
36
37impl_debug_eq_hash_with_functions!(EventRemoteThreadCreate<'a> with version; target, thread_state);