3 #include "../Include/Winheaders.h"
4 #include "../Include/Types.h"
5 #include "../../BlackBoneDrv/BlackBoneDef.h"
14 typedef std::map < std::pair<ptr_t, uint32_t>, ptr_t > mapMemoryMap;
19 ptr_t targetSharedPage;
39 BLACKBONE_API ~DriverControl();
41 BLACKBONE_API
static DriverControl& Instance();
48 BLACKBONE_API NTSTATUS
EnsureLoaded(
const std::wstring& path = L
"" );
55 BLACKBONE_API NTSTATUS
Reload( std::wstring path = L
"" );
61 BLACKBONE_API NTSTATUS
Unload();
69 BLACKBONE_API NTSTATUS
DisableDEP( DWORD pid );
86 BLACKBONE_API NTSTATUS
PromoteHandle( DWORD pid, HANDLE handle, DWORD access );
97 BLACKBONE_API NTSTATUS
AllocateMem( DWORD pid, ptr_t& base, ptr_t& size, DWORD type, DWORD protection,
bool physical =
false );
107 BLACKBONE_API NTSTATUS
FreeMem( DWORD pid, ptr_t base, ptr_t size, DWORD type );
117 BLACKBONE_API NTSTATUS
ReadMem( DWORD pid, ptr_t base, ptr_t size, PVOID buffer );
127 BLACKBONE_API NTSTATUS
WriteMem( DWORD pid, ptr_t base, ptr_t size, PVOID buffer );
137 BLACKBONE_API NTSTATUS
ProtectMem( DWORD pid, ptr_t base, ptr_t size, DWORD protection );
147 BLACKBONE_API NTSTATUS
MapMemory( DWORD pid,
const std::wstring& pipeName,
bool mapSections,
MapMemoryResult& result );
176 BLACKBONE_API NTSTATUS
UnmapMemoryRegion( DWORD pid, ptr_t base, uint32_t size );
190 const std::wstring& path,
192 uint32_t initRVA = 0,
193 const std::wstring& initArg = L
"",
202 BLACKBONE_API NTSTATUS
MMapDriver(
const std::wstring& path );
211 BLACKBONE_API NTSTATUS
ConcealVAD( DWORD pid, ptr_t base, uint32_t size );
217 BLACKBONE_API
inline bool loaded()
const {
return _hDriver != INVALID_HANDLE_VALUE; }
220 DriverControl(
const DriverControl& ) =
delete;
221 DriverControl& operator = (
const DriverControl&) =
delete;
229 NTSTATUS LoadDriver(
const std::wstring& svcName,
const std::wstring& path );
236 NTSTATUS UnloadDriver(
const std::wstring& svcName );
244 LSTATUS PrepareDriverRegEntry(
const std::wstring& svcName,
const std::wstring& path );
247 HANDLE _hDriver = INVALID_HANDLE_VALUE;
251 inline DriverControl& Driver() {
return DriverControl::Instance(); }
BLACKBONE_API NTSTATUS UnmapMemoryRegion(DWORD pid, ptr_t base, uint32_t size)
Unmap single memory region If unmapped region size is smaller than the size specified during map...
Definition: DriverControl.cpp:228
BLACKBONE_API bool loaded() const
Check if driver is loaded
Definition: DriverControl.h:217
BLACKBONE_API NTSTATUS Unload()
Unload driver
Definition: DriverControl.cpp:105
BLACKBONE_API NTSTATUS MMapDriver(const std::wstring &path)
Manually map another system driver into system space
Definition: DriverControl.cpp:516
BLACKBONE_API NTSTATUS ProtectProcess(DWORD pid, bool enable)
Change process protection flag
Definition: DriverControl.cpp:275
BLACKBONE_API NTSTATUS MapMemoryRegion(DWORD pid, ptr_t base, uint32_t size, MapMemoryRegionResult &result)
Maps single memory region into current process
Definition: DriverControl.cpp:170
BLACKBONE_API NTSTATUS AllocateMem(DWORD pid, ptr_t &base, ptr_t &size, DWORD type, DWORD protection, bool physical=false)
Allocate virtual memory
Definition: DriverControl.cpp:325
BLACKBONE_API NTSTATUS EnsureLoaded(const std::wstring &path=L"")
Try to load driver if it isn't loaded
Definition: DriverControl.cpp:38
BLACKBONE_API NTSTATUS Reload(std::wstring path=L"")
Reload driver
Definition: DriverControl.cpp:60
BLACKBONE_API NTSTATUS PromoteHandle(DWORD pid, HANDLE handle, DWORD access)
Change handle access rights
Definition: DriverControl.cpp:297
BLACKBONE_API NTSTATUS ConcealVAD(DWORD pid, ptr_t base, uint32_t size)
Make VAD region appear as PAGE_NO_ACESS to NtQueryVirtualMemory
Definition: DriverControl.cpp:547
BLACKBONE_API NTSTATUS InjectDll(DWORD pid, const std::wstring &path, InjectType itype, uint32_t initRVA=0, const std::wstring &initArg=L"", bool wait=true)
Inject DLL into arbitrary process
Definition: DriverControl.cpp:482
Definition: DriverControl.h:16
BLACKBONE_API NTSTATUS UnmapMemory(DWORD pid)
Unmap memory of the target process from current
Definition: DriverControl.cpp:203
BLACKBONE_API NTSTATUS FreeMem(DWORD pid, ptr_t base, ptr_t size, DWORD type)
Free virtual memory
Definition: DriverControl.cpp:363
BLACKBONE_API NTSTATUS ReadMem(DWORD pid, ptr_t base, ptr_t size, PVOID buffer)
Read process memory
Definition: DriverControl.cpp:394
BLACKBONE_API NTSTATUS WriteMem(DWORD pid, ptr_t base, ptr_t size, PVOID buffer)
Write process memory
Definition: DriverControl.cpp:423
BLACKBONE_API NTSTATUS ProtectMem(DWORD pid, ptr_t base, ptr_t size, DWORD protection)
Change memory protection
Definition: DriverControl.cpp:452
Definition: DriverControl.h:35
BLACKBONE_API NTSTATUS DisableDEP(DWORD pid)
Disable DEP for process Has no effect on native x64 processes
Definition: DriverControl.cpp:254
Definition: AsmHelper32.cpp:6
Definition: DriverControl.h:25
BLACKBONE_API NTSTATUS MapMemory(DWORD pid, const std::wstring &pipeName, bool mapSections, MapMemoryResult &result)
Maps target process memory into current process
Definition: DriverControl.cpp:125