Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
HookTestContext Class Reference

Resources shared by the cases of one test run, created in the child process. The remote processes are started by Start, before the first case, so what process creation itself triggers (CreateProcess writes to the child's PEB) is reported as setup rather than attributed to a case. More...

#include <hook_test_harness.hpp>

Public Member Functions

 ~HookTestContext ()
void Start ()
 Starts the remote targets. Called by the harness before the first case.
const BYTE * PEImage () const
 A buffer holding a real PE image: this executable's own mapped headers.
HANDLE RemoteProcess () const
 A suspended cmd.exe of the same architecture to use as a remote target.
HANDLE RemoteThread () const
 The suspended main thread of RemoteProcess.
HANDLE Wow64RemoteProcess () const
 A suspended 32-bit cmd.exe, started only by x64 runs: from x64, a WOW64 target has both a 64-bit and a 32-bit PEB.

Static Public Attributes

static constexpr SIZE_T PESize = 0x1000
 The number of PEImage() bytes the cases copy, one page.

Detailed Description

Resources shared by the cases of one test run, created in the child process. The remote processes are started by Start, before the first case, so what process creation itself triggers (CreateProcess writes to the child's PEB) is reported as setup rather than attributed to a case.

Definition at line 46 of file hook_test_harness.hpp.

Constructor & Destructor Documentation

◆ ~HookTestContext()

HookTestContext::~HookTestContext ( )
inline

Definition at line 48 of file hook_test_harness.hpp.

48 {
49 Stop(m_remote);
50 Stop(m_wow64Remote);
51 }

Member Function Documentation

◆ PEImage()

const BYTE * HookTestContext::PEImage ( ) const
inline

A buffer holding a real PE image: this executable's own mapped headers.

Definition at line 65 of file hook_test_harness.hpp.

65{ return (const BYTE*)GetModuleHandleA(NULL); }

◆ RemoteProcess()

HANDLE HookTestContext::RemoteProcess ( ) const
inline

A suspended cmd.exe of the same architecture to use as a remote target.

Definition at line 71 of file hook_test_harness.hpp.

71{ return m_remote.hProcess; }

◆ RemoteThread()

HANDLE HookTestContext::RemoteThread ( ) const
inline

The suspended main thread of RemoteProcess.

Definition at line 74 of file hook_test_harness.hpp.

74{ return m_remote.hThread; }

◆ Start()

void HookTestContext::Start ( )
inline

Starts the remote targets. Called by the harness before the first case.

Definition at line 54 of file hook_test_harness.hpp.

54 {
55 m_remote = StartSuspended("cmd.exe /c exit");
56#ifdef _WIN64
57 char wow64Dir[MAX_PATH];
58 if (GetSystemWow64DirectoryA(wow64Dir, MAX_PATH) != 0) {
59 m_wow64Remote = StartSuspended(std::string("\"") + wow64Dir + "\\cmd.exe\" /c exit");
60 }
61#endif
62 }
#define MAX_PATH
Definition callbacks.h:7
PROCESS_INFORMATION StartSuspended(const std::string &commandLine)
Starts a suspended process. Returns an empty PROCESS_INFORMATION on failure.

References MAX_PATH, and StartSuspended().

Referenced by hook_test_detail::RunChild().

◆ Wow64RemoteProcess()

HANDLE HookTestContext::Wow64RemoteProcess ( ) const
inline

A suspended 32-bit cmd.exe, started only by x64 runs: from x64, a WOW64 target has both a 64-bit and a 32-bit PEB.

Definition at line 78 of file hook_test_harness.hpp.

78{ return m_wow64Remote.hProcess; }

Member Data Documentation

◆ PESize

SIZE_T HookTestContext::PESize = 0x1000
staticconstexpr

The number of PEImage() bytes the cases copy, one page.

Definition at line 68 of file hook_test_harness.hpp.


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