pwn++  0.1.4
A (toy) Windows & Linux pwn library to play with modern C++.
System.hpp File Reference

Header for pwn::windows::System class This namespace holds functions for global system manipulation. For process specific stuff, use the pwn::windows::Process class. More...

#include "Common.hpp"

Go to the source code of this file.

Functions

Result< PVOID > pwn::System::details::QueryInternal (const SYSTEM_INFORMATION_CLASS, const usize)
 Should not be called directly. More...
 
auto pwn::System::PageSize () -> u32
 Get the page size of the targeted system. More...
 
u32 pwn::System::ProcessId (const HANDLE hProcess=::GetCurrentProcess())
 
auto pwn::System::ParentProcessId (const u32 dwProcessId) -> Result< u32 >
 
auto pwn::System::PidOf (std::wstring_view const targetProcessName) -> Result< std::vector< u32 >>
 
const std::wstring pwn::System::ComputerName ()
 
Result< std::wstring > pwn::System::UserName ()
 
Result< std::wstring > pwn::System::ModuleName (HMODULE hModule)
 
Result< std::wstring > pwn::System::FileName ()
 
std::tuple< u32, u32, u32 > pwn::System::WindowsVersion ()
 Get the Windows version as a tuple of int, or raise an exception. More...
 
template<class T >
Result< std::shared_ptr< T > > pwn::System::Query (SYSTEM_INFORMATION_CLASS SystemInformationClass)
 Query system information. More...
 
Result< std::tuple< u8, u8, u8, u8, u8 > > pwn::System::ProcessorCount ()
 Retrieves the system number of processors and their cache. More...
 
Result< std::vector< RTL_PROCESS_MODULE_INFORMATION > > pwn::System::Modules ()
 Get the kernel modules. More...
 
Result< std::vector< SYSTEM_HANDLE_TABLE_ENTRY_INFO > > pwn::System::Handles ()
 Enumerate all the system handles. More...
 
Result< std::vector< std::tuple< u32, u32 > > > pwn::System::Threads ()
 Enumerate all {ProcessId, ThreadId} currently running. More...
 

Detailed Description

Header for pwn::windows::System class This namespace holds functions for global system manipulation. For process specific stuff, use the pwn::windows::Process class.

Author
hugsy (hugsy.nosp@m.@bla.nosp@m.h.cat)

Function Documentation

◆ ComputerName()

const std::wstring pwn::System::ComputerName ( )
Returns
const std::wstring

◆ FileName()

Result<std::wstring> pwn::System::FileName ( )
Returns
Result<std::wstring>

◆ Handles()

Result<std::vector<SYSTEM_HANDLE_TABLE_ENTRY_INFO> > pwn::System::Handles ( )

Enumerate all the system handles.

Returns
Result<std::vector<SYSTEM_HANDLE_TABLE_ENTRY_INFO>>

◆ ModuleName()

Result<std::wstring> pwn::System::ModuleName ( HMODULE  hModule)
Parameters
hModule
Returns
Result<std::wstring>

◆ Modules()

Result<std::vector<RTL_PROCESS_MODULE_INFORMATION> > pwn::System::Modules ( )

Get the kernel modules.

Returns
Result<std::vector<RTL_PROCESS_MODULE_INFORMATION>>

◆ PageSize()

auto pwn::System::PageSize ( ) -> u32

Get the page size of the targeted system.

Returns
u32

◆ ParentProcessId()

auto pwn::System::ParentProcessId ( const u32  dwProcessId) -> Result< u32 >
Parameters
dwProcessId
Returns
std::optional<u32>

◆ PidOf()

auto pwn::System::PidOf ( std::wstring_view const  targetProcessName) -> Result< std::vector< u32 >>
Parameters
targetProcessName
Returns
Result<std::vector<u32>>

◆ ProcessId()

u32 pwn::System::ProcessId ( const HANDLE  hProcess = ::GetCurrentProcess())
Parameters
hProcess
Returns
u32

◆ ProcessorCount()

Result<std::tuple<u8, u8, u8, u8, u8> > pwn::System::ProcessorCount ( )

Retrieves the system number of processors and their cache.

Returns
If successful, the tuple returns a tuple of (in that order): processor count, logical processor count, number of L1 caches, number of L2 caches and number of L3 caches

◆ Query()

template<class T >
Result<std::shared_ptr<T> > pwn::System::Query ( SYSTEM_INFORMATION_CLASS  SystemInformationClass)

Query system information.

Template Parameters
T
Parameters
SystemInformationClass
Returns
Result<std::shared_ptr<T>>

◆ QueryInternal()

Result<PVOID> pwn::System::details::QueryInternal ( const  SYSTEM_INFORMATION_CLASS,
const  usize 
)

Should not be called directly.

Parameters
SystemInformationClass
Returns
Result<PVOID>

◆ Threads()

Result<std::vector<std::tuple<u32, u32> > > pwn::System::Threads ( )

Enumerate all {ProcessId, ThreadId} currently running.

Returns
Result<std::vector<std::tuple<u32, u32>>>

◆ UserName()

Result<std::wstring> pwn::System::UserName ( )
Returns
Result<std::wstring>

◆ WindowsVersion()

std::tuple<u32, u32, u32> pwn::System::WindowsVersion ( )

Get the Windows version as a tuple of int, or raise an exception.

Returns
PWNAPI