winss
Public Member Functions | Static Public Member Functions | Static Protected Attributes | List of all members
winss::WindowsInterface Class Reference

Wraps the windows functions as an interface so that they can be easily mocked and tested. More...

#include <windows_interface.hpp>

Public Member Functions

 WindowsInterface ()
 Create a new Windows interface. More...
 
 WindowsInterface (const WindowsInterface &)=delete
 No copy. More...
 
 WindowsInterface (WindowsInterface &&)=delete
 No move. More...
 
virtual bool CreateProcess (const char *application_name, char *command_line, SECURITY_ATTRIBUTES *proc_attr, SECURITY_ATTRIBUTES *thread_atttr, bool inherit_handles, DWORD creation_flags, void *env, const char *current_dir, STARTUPINFO *startup_info, PROCESS_INFORMATION *proc_info) const
 CreateProcess More...
 
virtual HANDLE CreateEvent (SECURITY_ATTRIBUTES *event_attributes, bool manual_reset, bool initial_state, char *name) const
 CreateEvent More...
 
virtual bool CreatePipe (PHANDLE read_pipe, PHANDLE write_pipe, LPSECURITY_ATTRIBUTES pipe_attr, DWORD size) const
 CreatePipe More...
 
virtual HANDLE CreateNamedPipe (char *name, DWORD open_mode, DWORD pipe_mode, DWORD max_instances, DWORD out_buffer_size, DWORD in_buffer_size, DWORD default_time_out, LPSECURITY_ATTRIBUTES security_attributes) const
 CreateNamedPipe More...
 
virtual HANDLE CreateFile (char *file_name, DWORD desired_access, DWORD share_mode, LPSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD flags_and_attributes, HANDLE template_file) const
 CreateFile More...
 
virtual HANDLE CreateMutex (LPSECURITY_ATTRIBUTES attributes, bool initial_owner, LPCTSTR name) const
 CreateMutex More...
 
virtual HANDLE OpenMutex (DWORD desired_access, bool inherit, LPCTSTR name) const
 OpenMutex More...
 
virtual bool SetEvent (HANDLE handle) const
 SetEvent More...
 
virtual bool ResetEvent (HANDLE handle) const
 ResetEvent More...
 
virtual bool ConnectNamedPipe (HANDLE handle, LPOVERLAPPED overlapped) const
 ConnectNamedPipe More...
 
virtual bool DisconnectNamedPipe (HANDLE handle) const
 ConnectNamedPipe More...
 
virtual bool GetOverlappedResult (HANDLE handle, LPOVERLAPPED overlapped, LPDWORD bytes, BOOL wait) const
 GetOverlappedResult More...
 
virtual bool ReadFile (HANDLE handle, LPVOID buffer, DWORD to_read, LPDWORD read, LPOVERLAPPED overlapped) const
 ReadFile More...
 
virtual bool WriteFile (HANDLE handle, LPCVOID buffer, DWORD to_write, LPDWORD written, LPOVERLAPPED overlapped) const
 WriteFile More...
 
virtual DWORD WaitForSingleObject (HANDLE handle, DWORD timeout) const
 WaitForSingleObject More...
 
virtual DWORD WaitForMultipleObjects (DWORD handles_count, const HANDLE *handles, bool wait_all, DWORD timeout) const
 WaitForMultipleObjects More...
 
virtual bool DuplicateHandle (HANDLE source_process_handle, HANDLE source_handle, HANDLE target_process_handle, LPHANDLE target_handle, DWORD desired_access, bool inherit_handle, DWORD options) const
 DuplicateHandle More...
 
virtual bool SetHandleInformation (HANDLE object, DWORD mask, DWORD flags) const
 SetHandleInformation More...
 
virtual HANDLE GetStdHandle (DWORD std_handle) const
 GetStdHandle More...
 
virtual bool ReleaseMutex (HANDLE mutex) const
 ReleaseMutex More...
 
virtual bool CloseHandle (HANDLE handle) const
 CloseHandle More...
 
virtual bool GenerateConsoleCtrlEvent (DWORD ctrl_event, DWORD proc_group_id) const
 GenerateConsoleCtrlEvent More...
 
virtual bool GetExitCodeProcess (HANDLE handle, DWORD *exit_code) const
 GetExitCodeProcess More...
 
virtual HANDLE GetCurrentProcess () const
 GetCurrentProcess More...
 
virtual bool TerminateProcess (HANDLE process, UINT exit_code) const
 TerminateProcess More...
 
virtual DWORD GetLastError () const
 GetLastError More...
 
virtual bool SetEnvironmentVariable (LPCTSTR name, LPCTSTR value) const
 SetEnvironmentVariable More...
 
virtual DWORD GetEnvironmentVariable (LPCTSTR name, LPTSTR buffer, DWORD size) const
 GetEnvironmentVariable More...
 
virtual DWORD ExpandEnvironmentStrings (LPCTSTR src, LPTSTR dst, DWORD size) const
 ExpandEnvironmentStrings More...
 
virtual LPTCH GetEnvironmentStrings () const
 GetEnvironmentStrings More...
 
virtual bool FreeEnvironmentStrings (LPTCH lpszEnvironmentBlock) const
 FreeEnvironmentStrings More...
 
virtual bool SetConsoleCtrlHandler (PHANDLER_ROUTINE handler, bool add) const
 SetConsoleCtrlHandler More...
 
virtual RPC_STATUS UuidCreateSequential (GUID *uuid) const
 UuidCreateSequential More...
 
virtual RPC_STATUS UuidCreateNil (GUID *uuid) const
 UuidCreateNil More...
 
virtual RPC_STATUS UuidCompare (GUID *uuid1, GUID *uuid2, RPC_STATUS *status) const
 UuidCompare More...
 
virtual RPC_STATUS UuidToString (const GUID *uuid, unsigned char **string_uuid) const
 UuidToString More...
 
virtual RPC_STATUS UuidFromString (unsigned char *string_uuid, GUID *uuid) const
 UuidFromString More...
 
virtual RPC_STATUS RpcStringFree (unsigned char **rpc_string) const
 RpcStringFree More...
 
virtual bool CryptAcquireContext (HCRYPTPROV *csp, LPCTSTR container, LPCTSTR provider, DWORD type, DWORD flags) const
 CryptAcquireContext More...
 
virtual bool CryptCreateHash (HCRYPTPROV csp, ALG_ID algorithm, HCRYPTKEY key, DWORD flags, HCRYPTHASH *hash) const
 CryptCreateHash More...
 
virtual bool CryptHashData (HCRYPTHASH hash, unsigned char *data, DWORD length, DWORD flags) const
 CryptHashData More...
 
virtual bool CryptGetHashParam (HCRYPTHASH hash, DWORD param, unsigned char *data, DWORD *length, DWORD flags) const
 CryptGetHashParam More...
 
virtual bool CryptDestroyHash (HCRYPTHASH hash) const
 CryptDestroyHash More...
 
virtual bool CryptReleaseContext (HCRYPTPROV csp, DWORD flags) const
 CryptReleaseContext More...
 
WindowsInterfaceoperator= (const WindowsInterface &)=delete
 No copy. More...
 
WindowsInterfaceoperator= (WindowsInterface &&)=delete
 No move. More...
 

Static Public Member Functions

static const WindowsInterfaceGetInstance ()
 Gets the Wdinows interface instance. More...
 

Static Protected Attributes

static std::shared_ptr< WindowsInterfaceinstance
 A singleton Windows instance. More...
 

Detailed Description

Wraps the windows functions as an interface so that they can be easily mocked and tested.

Constructor & Destructor Documentation

winss::WindowsInterface::WindowsInterface ( )
inline
winss::WindowsInterface::WindowsInterface ( const WindowsInterface )
delete

No copy.

winss::WindowsInterface::WindowsInterface ( WindowsInterface &&  )
delete

No move.

Member Function Documentation

bool winss::WindowsInterface::CloseHandle ( HANDLE  handle) const
virtual
bool winss::WindowsInterface::ConnectNamedPipe ( HANDLE  handle,
LPOVERLAPPED  overlapped 
) const
virtual
HANDLE winss::WindowsInterface::CreateEvent ( SECURITY_ATTRIBUTES *  event_attributes,
bool  manual_reset,
bool  initial_state,
char *  name 
) const
virtual
HANDLE winss::WindowsInterface::CreateFile ( char *  file_name,
DWORD  desired_access,
DWORD  share_mode,
LPSECURITY_ATTRIBUTES  security_attributes,
DWORD  creation_disposition,
DWORD  flags_and_attributes,
HANDLE  template_file 
) const
virtual
HANDLE winss::WindowsInterface::CreateMutex ( LPSECURITY_ATTRIBUTES  attributes,
bool  initial_owner,
LPCTSTR  name 
) const
virtual
HANDLE winss::WindowsInterface::CreateNamedPipe ( char *  name,
DWORD  open_mode,
DWORD  pipe_mode,
DWORD  max_instances,
DWORD  out_buffer_size,
DWORD  in_buffer_size,
DWORD  default_time_out,
LPSECURITY_ATTRIBUTES  security_attributes 
) const
virtual
bool winss::WindowsInterface::CreatePipe ( PHANDLE  read_pipe,
PHANDLE  write_pipe,
LPSECURITY_ATTRIBUTES  pipe_attr,
DWORD  size 
) const
virtual
bool winss::WindowsInterface::CreateProcess ( const char *  application_name,
char *  command_line,
SECURITY_ATTRIBUTES *  proc_attr,
SECURITY_ATTRIBUTES *  thread_atttr,
bool  inherit_handles,
DWORD  creation_flags,
void *  env,
const char *  current_dir,
STARTUPINFO *  startup_info,
PROCESS_INFORMATION *  proc_info 
) const
virtual
bool winss::WindowsInterface::CryptAcquireContext ( HCRYPTPROV *  csp,
LPCTSTR  container,
LPCTSTR  provider,
DWORD  type,
DWORD  flags 
) const
virtual
bool winss::WindowsInterface::CryptCreateHash ( HCRYPTPROV  csp,
ALG_ID  algorithm,
HCRYPTKEY  key,
DWORD  flags,
HCRYPTHASH *  hash 
) const
virtual
bool winss::WindowsInterface::CryptDestroyHash ( HCRYPTHASH  hash) const
virtual
bool winss::WindowsInterface::CryptGetHashParam ( HCRYPTHASH  hash,
DWORD  param,
unsigned char *  data,
DWORD *  length,
DWORD  flags 
) const
virtual
bool winss::WindowsInterface::CryptHashData ( HCRYPTHASH  hash,
unsigned char *  data,
DWORD  length,
DWORD  flags 
) const
virtual
bool winss::WindowsInterface::CryptReleaseContext ( HCRYPTPROV  csp,
DWORD  flags 
) const
virtual
bool winss::WindowsInterface::DisconnectNamedPipe ( HANDLE  handle) const
virtual
bool winss::WindowsInterface::DuplicateHandle ( HANDLE  source_process_handle,
HANDLE  source_handle,
HANDLE  target_process_handle,
LPHANDLE  target_handle,
DWORD  desired_access,
bool  inherit_handle,
DWORD  options 
) const
virtual
DWORD winss::WindowsInterface::ExpandEnvironmentStrings ( LPCTSTR  src,
LPTSTR  dst,
DWORD  size 
) const
virtual
bool winss::WindowsInterface::FreeEnvironmentStrings ( LPTCH  lpszEnvironmentBlock) const
virtual
bool winss::WindowsInterface::GenerateConsoleCtrlEvent ( DWORD  ctrl_event,
DWORD  proc_group_id 
) const
virtual
HANDLE winss::WindowsInterface::GetCurrentProcess ( ) const
virtual
LPTCH winss::WindowsInterface::GetEnvironmentStrings ( ) const
virtual
DWORD winss::WindowsInterface::GetEnvironmentVariable ( LPCTSTR  name,
LPTSTR  buffer,
DWORD  size 
) const
virtual
bool winss::WindowsInterface::GetExitCodeProcess ( HANDLE  handle,
DWORD *  exit_code 
) const
virtual
const winss::WindowsInterface & winss::WindowsInterface::GetInstance ( )
static

Gets the Wdinows interface instance.

Returns
The singleton Windows interface.

References instance.

Referenced by WindowsInterface().

DWORD winss::WindowsInterface::GetLastError ( ) const
virtual
bool winss::WindowsInterface::GetOverlappedResult ( HANDLE  handle,
LPOVERLAPPED  overlapped,
LPDWORD  bytes,
BOOL  wait 
) const
virtual
HANDLE winss::WindowsInterface::GetStdHandle ( DWORD  std_handle) const
virtual
HANDLE winss::WindowsInterface::OpenMutex ( DWORD  desired_access,
bool  inherit,
LPCTSTR  name 
) const
virtual

OpenMutex

Referenced by WindowsInterface().

WindowsInterface& winss::WindowsInterface::operator= ( const WindowsInterface )
delete

No copy.

Referenced by WindowsInterface().

WindowsInterface& winss::WindowsInterface::operator= ( WindowsInterface &&  )
delete

No move.

bool winss::WindowsInterface::ReadFile ( HANDLE  handle,
LPVOID  buffer,
DWORD  to_read,
LPDWORD  read,
LPOVERLAPPED  overlapped 
) const
virtual

ReadFile

Referenced by WindowsInterface().

bool winss::WindowsInterface::ReleaseMutex ( HANDLE  mutex) const
virtual
bool winss::WindowsInterface::ResetEvent ( HANDLE  handle) const
virtual
RPC_STATUS winss::WindowsInterface::RpcStringFree ( unsigned char **  rpc_string) const
virtual
bool winss::WindowsInterface::SetConsoleCtrlHandler ( PHANDLER_ROUTINE  handler,
bool  add 
) const
virtual
bool winss::WindowsInterface::SetEnvironmentVariable ( LPCTSTR  name,
LPCTSTR  value 
) const
virtual
bool winss::WindowsInterface::SetEvent ( HANDLE  handle) const
virtual

SetEvent

Referenced by WindowsInterface().

bool winss::WindowsInterface::SetHandleInformation ( HANDLE  object,
DWORD  mask,
DWORD  flags 
) const
virtual
bool winss::WindowsInterface::TerminateProcess ( HANDLE  process,
UINT  exit_code 
) const
virtual
RPC_STATUS winss::WindowsInterface::UuidCompare ( GUID *  uuid1,
GUID *  uuid2,
RPC_STATUS *  status 
) const
virtual
RPC_STATUS winss::WindowsInterface::UuidCreateNil ( GUID *  uuid) const
virtual
RPC_STATUS winss::WindowsInterface::UuidCreateSequential ( GUID *  uuid) const
virtual
RPC_STATUS winss::WindowsInterface::UuidFromString ( unsigned char *  string_uuid,
GUID *  uuid 
) const
virtual
RPC_STATUS winss::WindowsInterface::UuidToString ( const GUID *  uuid,
unsigned char **  string_uuid 
) const
virtual
DWORD winss::WindowsInterface::WaitForMultipleObjects ( DWORD  handles_count,
const HANDLE *  handles,
bool  wait_all,
DWORD  timeout 
) const
virtual
DWORD winss::WindowsInterface::WaitForSingleObject ( HANDLE  handle,
DWORD  timeout 
) const
virtual
bool winss::WindowsInterface::WriteFile ( HANDLE  handle,
LPCVOID  buffer,
DWORD  to_write,
LPDWORD  written,
LPOVERLAPPED  overlapped 
) const
virtual

WriteFile

Referenced by WindowsInterface().

Member Data Documentation

std::shared_ptr< winss::WindowsInterface > winss::WindowsInterface::instance
staticprotected
Initial value:
=
std::make_shared<winss::WindowsInterface>()

A singleton Windows instance.

Referenced by GetInstance().


The documentation for this class was generated from the following files: