pub struct HPROCESS(/* private fields */);
kernel
only.Expand description
Handle to a
process.
Originally just a HANDLE
.
Implementations§
Source§impl HPROCESS
impl HPROCESS
Sourcepub fn OpenProcessToken(
&self,
desired_access: TOKEN,
) -> SysResult<CloseHandleGuard<HACCESSTOKEN>>
Available on crate feature advapi
only.
pub fn OpenProcessToken( &self, desired_access: TOKEN, ) -> SysResult<CloseHandleGuard<HACCESSTOKEN>>
advapi
only.OpenProcessToken
function.
§Examples
use winsafe::{self as w, prelude::*, co};
let htoken = w::HPROCESS::GetCurrentProcess()
.OpenProcessToken(co::TOKEN::ADJUST_PRIVILEGES | co::TOKEN::QUERY)?;
Source§impl HPROCESS
impl HPROCESS
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 HPROCESS
impl HPROCESS
Sourcepub fn CheckRemoteDebuggerPresent(&self) -> SysResult<bool>
pub fn CheckRemoteDebuggerPresent(&self) -> SysResult<bool>
CheckRemoteDebuggerPresent
function.
Sourcepub fn FlushInstructionCache(
&self,
base_address: *mut c_void,
size: usize,
) -> SysResult<()>
pub fn FlushInstructionCache( &self, base_address: *mut c_void, size: usize, ) -> SysResult<()>
FlushInstructionCache
function.
Sourcepub fn GetCurrentProcess() -> HPROCESS
pub fn GetCurrentProcess() -> HPROCESS
GetCurrentProcess
function.
Sourcepub fn GetExitCodeProcess(&self) -> SysResult<u32>
pub fn GetExitCodeProcess(&self) -> SysResult<u32>
GetExitCodeProcess
function.
Sourcepub fn GetGuiResources(&self, flags: GR) -> SysResult<u32>
pub fn GetGuiResources(&self, flags: GR) -> SysResult<u32>
GetGuiResources
function.
Sourcepub fn GetPriorityClass(&self) -> SysResult<PRIORITY_CLASS>
pub fn GetPriorityClass(&self) -> SysResult<PRIORITY_CLASS>
GetPriorityClass
function.
Sourcepub fn GetProcessHandleCount(&self) -> SysResult<u32>
pub fn GetProcessHandleCount(&self) -> SysResult<u32>
GetProcessHandleCount
function.
Sourcepub fn GetProcessId(&self) -> SysResult<u32>
pub fn GetProcessId(&self) -> SysResult<u32>
GetProcessId
function.
Sourcepub fn GetProcessTimes(
&self,
) -> SysResult<(FILETIME, FILETIME, FILETIME, FILETIME)>
pub fn GetProcessTimes( &self, ) -> SysResult<(FILETIME, FILETIME, FILETIME, FILETIME)>
GetProcessTimes
function.
Returns, respectively:
- creation time;
- exit time;
- kernel time;
- user time.
§Examples
use winsafe::{self as w, prelude::*, co};
let hprocess: w::HPROCESS; // initialized somewhere
let (creation, exit, kernel, user) = hprocess.GetProcessTimes()?;
Sourcepub fn IsProcessCritical(&self) -> SysResult<bool>
pub fn IsProcessCritical(&self) -> SysResult<bool>
IsProcessCritical
function.
Sourcepub fn IsWow64Process(&self) -> SysResult<bool>
pub fn IsWow64Process(&self) -> SysResult<bool>
IsWow64Process
function.
Sourcepub fn OpenProcess(
desired_access: PROCESS,
inherit_handle: bool,
process_id: u32,
) -> SysResult<CloseHandleGuard<HPROCESS>>
pub fn OpenProcess( desired_access: PROCESS, inherit_handle: bool, process_id: u32, ) -> SysResult<CloseHandleGuard<HPROCESS>>
OpenProcess
function.
This method will return
ERROR::INVALID_PARAMETER
if you
try to open a system process.
Sourcepub fn QueryFullProcessImageName(
&self,
flags: PROCESS_NAME,
) -> SysResult<String>
pub fn QueryFullProcessImageName( &self, flags: PROCESS_NAME, ) -> SysResult<String>
QueryFullProcessImageName
function.
Sourcepub fn QueryProcessAffinityUpdateMode(&self) -> SysResult<PROCESS_AFFINITY>
pub fn QueryProcessAffinityUpdateMode(&self) -> SysResult<PROCESS_AFFINITY>
QueryProcessAffinityUpdateMode
function.
Sourcepub fn QueryProcessCycleTime(&self) -> SysResult<u64>
pub fn QueryProcessCycleTime(&self) -> SysResult<u64>
QueryProcessCycleTime
function.
Sourcepub fn ReadProcessMemory(
&self,
base_address: *mut c_void,
buffer: &mut [u8],
) -> SysResult<usize>
pub fn ReadProcessMemory( &self, base_address: *mut c_void, buffer: &mut [u8], ) -> SysResult<usize>
ReadProcessMemory
function.
Reads at most buffer.len()
bytes. Returns how many bytes were actually
read.
Sourcepub fn SetPriorityClass(&self, prority_class: PRIORITY_CLASS) -> SysResult<()>
pub fn SetPriorityClass(&self, prority_class: PRIORITY_CLASS) -> SysResult<()>
SetPriorityClass
function.
Sourcepub fn SetProcessAffinityUpdateMode(
&self,
flags: PROCESS_AFFINITY,
) -> SysResult<()>
pub fn SetProcessAffinityUpdateMode( &self, flags: PROCESS_AFFINITY, ) -> SysResult<()>
SetProcessAffinityUpdateMode
function.
Sourcepub fn SetProcessPriorityBoost(
&self,
disable_priority_boost: bool,
) -> SysResult<()>
pub fn SetProcessPriorityBoost( &self, disable_priority_boost: bool, ) -> SysResult<()>
SetProcessPriorityBoost
function.
Sourcepub fn TerminateProcess(&self, exit_code: u32) -> SysResult<()>
pub fn TerminateProcess(&self, exit_code: u32) -> SysResult<()>
TerminateProcess
function.
Sourcepub fn VirtualQueryEx(
&self,
address: Option<*mut c_void>,
) -> SysResult<MEMORY_BASIC_INFORMATION>
pub fn VirtualQueryEx( &self, address: Option<*mut c_void>, ) -> SysResult<MEMORY_BASIC_INFORMATION>
VirtualQueryEx
function.
Sourcepub fn WaitForSingleObject(&self, milliseconds: Option<u32>) -> SysResult<WAIT>
pub fn WaitForSingleObject(&self, milliseconds: Option<u32>) -> SysResult<WAIT>
WaitForSingleObject
function.
Sourcepub fn WriteProcessMemory(
&self,
base_address: *mut c_void,
buffer: &[u8],
) -> SysResult<usize>
pub fn WriteProcessMemory( &self, base_address: *mut c_void, buffer: &[u8], ) -> SysResult<usize>
WriteProcessMemory
function.
Returns how many bytes were actually written.
Source§impl HPROCESS
impl HPROCESS
Sourcepub fn EmptyWorkingSet(&self) -> SysResult<()>
Available on crate feature psapi
only.
pub fn EmptyWorkingSet(&self) -> SysResult<()>
psapi
only.EmptyWorkingSet
function.
Sourcepub fn EnumProcessModules(&self) -> SysResult<Vec<HINSTANCE>>
Available on crate feature psapi
only.
pub fn EnumProcessModules(&self) -> SysResult<Vec<HINSTANCE>>
psapi
only.EnumProcessModules
function.
Sourcepub fn GetMappedFileName(&self, address: *mut c_void) -> SysResult<String>
Available on crate feature psapi
only.
pub fn GetMappedFileName(&self, address: *mut c_void) -> SysResult<String>
psapi
only.GetMappedFileName
function.
Sourcepub fn GetModuleBaseName(
&self,
hmodule: Option<&HINSTANCE>,
) -> SysResult<String>
Available on crate feature psapi
only.
pub fn GetModuleBaseName( &self, hmodule: Option<&HINSTANCE>, ) -> SysResult<String>
psapi
only.GetModuleBaseName
function.
Sourcepub fn GetModuleFileNameEx(
&self,
hmodule: Option<&HINSTANCE>,
) -> SysResult<String>
Available on crate feature psapi
only.
pub fn GetModuleFileNameEx( &self, hmodule: Option<&HINSTANCE>, ) -> SysResult<String>
psapi
only.GetModuleFileNameEx
function.
Sourcepub fn GetModuleInformation(
&self,
hmodule: Option<&HINSTANCE>,
) -> SysResult<MODULEINFO>
Available on crate feature psapi
only.
pub fn GetModuleInformation( &self, hmodule: Option<&HINSTANCE>, ) -> SysResult<MODULEINFO>
psapi
only.GetModuleInformation
function.
Sourcepub fn GetProcessImageFileName(&self) -> SysResult<String>
Available on crate feature psapi
only.
pub fn GetProcessImageFileName(&self) -> SysResult<String>
psapi
only.GetProcessImageFileName
function.
Sourcepub fn GetProcessMemoryInfo(&self) -> SysResult<PROCESS_MEMORY_COUNTERS_EX>
Available on crate feature psapi
only.
pub fn GetProcessMemoryInfo(&self) -> SysResult<PROCESS_MEMORY_COUNTERS_EX>
psapi
only.GetProcessMemoryInfo
function.
Source§impl HPROCESS
impl HPROCESS
Sourcepub unsafe fn SetUserObjectInformation<T>(
&self,
index: UOI,
pv_info: &mut T,
) -> SysResult<()>
Available on crate feature user
only.
pub unsafe fn SetUserObjectInformation<T>( &self, index: UOI, pv_info: &mut T, ) -> SysResult<()>
user
only.SetUserObjectInformation
function.
§Safety
The pv_info
type varies according to index
. If you set it wrong,
you’re likely to cause a buffer overrun.
Sourcepub fn WaitForInputIdle(&self, milliseconds: u32) -> SysResult<SuccessTimeout>
Available on crate feature user
only.
pub fn WaitForInputIdle(&self, milliseconds: u32) -> SysResult<SuccessTimeout>
user
only.WaitForInputIdle
function.