pub struct WindowsThread<'a, Driver>{ /* private fields */ }Expand description
A Windows thread.
A thread in Windows is represented by the _ETHREAD structure,
which contains metadata about its execution state, context, and scheduling.
§Implementation Details
Corresponds to _ETHREAD.
Implementations§
Source§impl<'a, Driver> WindowsThread<'a, Driver>
impl<'a, Driver> WindowsThread<'a, Driver>
Sourcepub fn new(vmi: VmiState<'a, WindowsOs<Driver>>, thread: ThreadObject) -> Self
pub fn new(vmi: VmiState<'a, WindowsOs<Driver>>, thread: ThreadObject) -> Self
Creates a new Windows thread.
Sourcepub fn process(&self) -> Result<WindowsProcess<'a, Driver>, VmiError>
pub fn process(&self) -> Result<WindowsProcess<'a, Driver>, VmiError>
Returns the process object associated with the thread.
§Implementation Details
Corresponds to _KTHREAD.Process.
Sourcepub fn apc_state_index(&self) -> Result<u8, VmiError>
pub fn apc_state_index(&self) -> Result<u8, VmiError>
Returns the index into KTHREAD.ApcStatePointer selecting the
thread’s currently-active APC environment.
-
0(OriginalApcEnvironment): thread is running in its original process. -
1(AttachedApcEnvironment): thread is temporarily attached to a foreign process viaKeStackAttachProcess/KeAttachProcess.The original
KTHREAD.ApcStateis preserved inKTHREAD.SavedApcState.
§Implementation Details
Corresponds to _KTHREAD.ApcStateIndex.
Sourcepub fn is_attached(&self) -> Result<bool, VmiError>
pub fn is_attached(&self) -> Result<bool, VmiError>
Checks if the thread is currently attached to foreign process context.
§Implementation Details
Corresponds to _KTHREAD.ApcStateIndex != 0.
Sourcepub fn current_process(&self) -> Result<WindowsProcess<'a, Driver>, VmiError>
pub fn current_process(&self) -> Result<WindowsProcess<'a, Driver>, VmiError>
Returns the process whose address space the thread is currently executing in.
§Implementation Details
Corresponds to _KTHREAD.ApcState.Process.
Sourcepub fn saved_process(
&self,
) -> Result<Option<WindowsProcess<'a, Driver>>, VmiError>
pub fn saved_process( &self, ) -> Result<Option<WindowsProcess<'a, Driver>>, VmiError>
Returns the thread’s saved home process, or NULL if the thread is not attached.
§Implementation Details
Corresponds to _KTHREAD.SavedApcState.Process.
Sourcepub fn impersonation_token(
&self,
) -> Result<Option<WindowsToken<'a, Driver>>, VmiError>
pub fn impersonation_token( &self, ) -> Result<Option<WindowsToken<'a, Driver>>, VmiError>
Returns the thread’s impersonation token, or None when the
thread is not currently impersonating.
§Implementation Details
Corresponds to _ETHREAD.ClientSecurity.ImpersonationToken, gated
on _ETHREAD.ActiveImpersonationInfo.
Sourcepub fn next_processor(&self) -> Result<VcpuId, VmiError>
pub fn next_processor(&self) -> Result<VcpuId, VmiError>
Sourcepub fn wait_mode(&self) -> Result<WindowsProcessorMode, VmiError>
pub fn wait_mode(&self) -> Result<WindowsProcessorMode, VmiError>
Sourcepub fn wait_reason(&self) -> Result<WindowsThreadWaitReason, VmiError>
pub fn wait_reason(&self) -> Result<WindowsThreadWaitReason, VmiError>
Sourcepub fn teb(&self) -> Result<Option<WindowsTeb<'a, Driver>>, VmiError>
pub fn teb(&self) -> Result<Option<WindowsTeb<'a, Driver>>, VmiError>
Returns the thread’s TEB.
§Implementation Details
Corresponds to _KTHREAD.Teb for the native TEB, and
Teb64 + ROUND_TO_PAGES(sizeof(TEB)) for the WoW64 TEB.
Sourcepub fn native_teb(&self) -> Result<Option<WindowsTeb<'a, Driver>>, VmiError>
pub fn native_teb(&self) -> Result<Option<WindowsTeb<'a, Driver>>, VmiError>
Sourcepub fn trap_frame(
&self,
) -> Result<Option<WindowsTrapFrame<'a, Driver>>, VmiError>
pub fn trap_frame( &self, ) -> Result<Option<WindowsTrapFrame<'a, Driver>>, VmiError>
Returns the thread’s trap frame.
Points to the most recent user-to-kernel transition trap frame for the thread. It records the user-mode register state that was captured when the thread entered the kernel via a syscall, interrupt, or exception.
Can be NULL when the thread is executing purely in kernel mode and has not entered via a user-mode trap.
§Implementation Details
Corresponds to _KTHREAD.TrapFrame.
Sourcepub fn state(&self) -> Result<WindowsThreadState, VmiError>
pub fn state(&self) -> Result<WindowsThreadState, VmiError>
Sourcepub fn kernel_stack(&self) -> Result<Va, VmiError>
pub fn kernel_stack(&self) -> Result<Va, VmiError>
Returns the saved kernel stack pointer for this thread.
For threads that are not currently running, this is the stack pointer value saved during the last context switch (KiSwapContext).
§Implementation Details
Corresponds to _KTHREAD.KernelStack.
Trait Implementations§
Source§impl<'a, Driver> From<WindowsThread<'a, Driver>> for WindowsObject<'a, Driver>
impl<'a, Driver> From<WindowsThread<'a, Driver>> for WindowsObject<'a, Driver>
Source§fn from(value: WindowsThread<'a, Driver>) -> Self
fn from(value: WindowsThread<'a, Driver>) -> Self
Source§impl<'a, Driver> FromWindowsObject<'a, Driver> for WindowsThread<'a, Driver>
impl<'a, Driver> FromWindowsObject<'a, Driver> for WindowsThread<'a, Driver>
Source§fn from_object(
object: WindowsObject<'a, Driver>,
) -> Result<Option<Self>, VmiError>
fn from_object( object: WindowsObject<'a, Driver>, ) -> Result<Option<Self>, VmiError>
WindowsObject into a specific object type.Source§impl<'a, Driver> VmiOsThread<'a, Driver> for WindowsThread<'a, Driver>
impl<'a, Driver> VmiOsThread<'a, Driver> for WindowsThread<'a, Driver>
Source§impl<Driver> VmiVa for WindowsThread<'_, Driver>
impl<Driver> VmiVa for WindowsThread<'_, Driver>
Auto Trait Implementations§
impl<'a, Driver> !RefUnwindSafe for WindowsThread<'a, Driver>
impl<'a, Driver> !Send for WindowsThread<'a, Driver>
impl<'a, Driver> !Sync for WindowsThread<'a, Driver>
impl<'a, Driver> !UnwindSafe for WindowsThread<'a, Driver>
impl<'a, Driver> Freeze for WindowsThread<'a, Driver>
impl<'a, Driver> Unpin for WindowsThread<'a, Driver>
impl<'a, Driver> UnsafeUnpin for WindowsThread<'a, Driver>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.