pub struct HTHREAD(/* private fields */);
kernel
only.Expand description
Handle to a
thread.
Originally just a HANDLE
.
Implementations§
Source§impl HTHREAD
impl HTHREAD
Sourcepub fn OpenThreadToken(
&self,
desired_access: TOKEN,
open_as_self: bool,
) -> SysResult<CloseHandleGuard<HACCESSTOKEN>>
Available on crate feature advapi
only.
pub fn OpenThreadToken( &self, desired_access: TOKEN, open_as_self: bool, ) -> SysResult<CloseHandleGuard<HACCESSTOKEN>>
advapi
only.OpenThreadToken
function.
Source§impl HTHREAD
impl HTHREAD
Sourcepub const unsafe fn from_ptr(p: *mut c_void) -> Self
pub const unsafe fn from_ptr(p: *mut c_void) -> Self
Constructs a new handle object by wrapping a pointer.
This method can be used as an escape hatch to interoperate with other libraries.
§Safety
Be sure the pointer has the correct type and isn’t owned by anyone else, otherwise you may cause memory access violations.
Sourcepub const unsafe fn raw_copy(&self) -> Self
pub const unsafe fn raw_copy(&self) -> Self
Returns a raw copy of the underlying handle pointer.
§Safety
As the name implies, raw_copy
returns a raw copy of the
handle, so closing one of the copies won’t close the others.
This means a handle can be used after it has been closed, what
can lead to errors and undefined behavior. Even worse: sometimes
Windows reuses handle values, so you can call a method on a
completely different handle type, what can be catastrophic.
However, in some cases the Windows API demands a copy of the
handle – raw_copy
is an escape hatch to fill this gap.
Sourcepub const unsafe fn as_mut(&mut self) -> &mut *mut c_void
pub const unsafe fn as_mut(&mut self) -> &mut *mut c_void
Returns a mutable reference to the underlying raw pointer.
This method can be used as an escape hatch to interoperate with other libraries.
§Safety
This method exposes the raw pointer used by raw Windows calls. It’s an opaque pointer to an internal Windows structure, and no dereferencings should be attempted.
Sourcepub const fn ptr(&self) -> *mut c_void
pub const fn ptr(&self) -> *mut c_void
Returns the underlying raw pointer.
This method exposes the raw pointer used by raw Windows calls. It’s an opaque pointer to an internal Windows structure, and no dereferencings should be attempted.
This method can be used as an escape hatch to interoperate with other libraries.
Source§impl HTHREAD
impl HTHREAD
Sourcepub fn CreateThread(
thread_attrs: Option<&mut SECURITY_ATTRIBUTES<'_>>,
stack_size: usize,
start_addr: *mut c_void,
parameter: *mut c_void,
flags: THREAD_CREATE,
) -> SysResult<(CloseHandleGuard<HTHREAD>, u32)>
pub fn CreateThread( thread_attrs: Option<&mut SECURITY_ATTRIBUTES<'_>>, stack_size: usize, start_addr: *mut c_void, parameter: *mut c_void, flags: THREAD_CREATE, ) -> SysResult<(CloseHandleGuard<HTHREAD>, u32)>
CreateThread
function.
Returns the thread handle and its ID.
Sourcepub fn GetCurrentThread() -> HTHREAD
pub fn GetCurrentThread() -> HTHREAD
GetCurrentThread
function.
Sourcepub fn GetExitCodeThread(&self) -> SysResult<u32>
pub fn GetExitCodeThread(&self) -> SysResult<u32>
GetExitCodeThread
function.
Sourcepub fn GetProcessIdOfThread(&self) -> SysResult<u32>
pub fn GetProcessIdOfThread(&self) -> SysResult<u32>
GetProcessIdOfThread
function.
Sourcepub fn GetThreadId(&self) -> SysResult<u32>
pub fn GetThreadId(&self) -> SysResult<u32>
GetThreadId
function.
Sourcepub fn GetThreadIdealProcessorEx(&self) -> SysResult<PROCESSOR_NUMBER>
pub fn GetThreadIdealProcessorEx(&self) -> SysResult<PROCESSOR_NUMBER>
GetThreadIdealProcessorEx
function.
Sourcepub fn GetThreadIOPendingFlag(&self) -> SysResult<bool>
pub fn GetThreadIOPendingFlag(&self) -> SysResult<bool>
GetThreadIOPendingFlag
function.
Sourcepub fn GetThreadPriorityBoost(&self) -> SysResult<bool>
pub fn GetThreadPriorityBoost(&self) -> SysResult<bool>
GetThreadPriorityBoost
function.
Sourcepub fn GetThreadTimes(
&self,
) -> SysResult<(FILETIME, FILETIME, FILETIME, FILETIME)>
pub fn GetThreadTimes( &self, ) -> SysResult<(FILETIME, FILETIME, FILETIME, FILETIME)>
GetThreadTimes
function.
Returns, respectively:
- creation time;
- exit time;
- kernel time;
- user time.
§Examples
use winsafe::{self as w, prelude::*, co};
let hthread: w::HTHREAD; // initialized somewhere
let (creation, exit, kernel, user) = hthread.GetThreadTimes()?;
Sourcepub fn QueryThreadCycleTime(&self) -> SysResult<u64>
pub fn QueryThreadCycleTime(&self) -> SysResult<u64>
QueryThreadCycleTime
function.
Sourcepub fn ResumeThread(&self) -> SysResult<u32>
pub fn ResumeThread(&self) -> SysResult<u32>
ResumeThread
function.
Sourcepub fn SetThreadIdealProcessor(&self, ideal_processor: u32) -> SysResult<u32>
pub fn SetThreadIdealProcessor(&self, ideal_processor: u32) -> SysResult<u32>
SetThreadIdealProcessor
function.
Returns the previous ideal processor.
Sourcepub fn SetThreadIdealProcessorEx(
&self,
ideal_processor: PROCESSOR_NUMBER,
) -> SysResult<PROCESSOR_NUMBER>
pub fn SetThreadIdealProcessorEx( &self, ideal_processor: PROCESSOR_NUMBER, ) -> SysResult<PROCESSOR_NUMBER>
SetThreadIdealProcessorEx
function.
Returns the previous ideal processor.
Sourcepub fn SetThreadPriorityBoost(
&self,
disable_priority_boost: bool,
) -> SysResult<()>
pub fn SetThreadPriorityBoost( &self, disable_priority_boost: bool, ) -> SysResult<()>
SetThreadPriorityBoost
function.
Sourcepub fn SuspendThread(&self) -> SysResult<u32>
pub fn SuspendThread(&self) -> SysResult<u32>
SuspendThread
function.
Sourcepub fn TerminateThread(&self, exit_code: u32) -> SysResult<()>
pub fn TerminateThread(&self, exit_code: u32) -> SysResult<()>
TerminateThread
function.