A Windows kernel-mode driver to perform read/write operations. It handles direct IRP requests generated
with DeviceIoControl()
.
The driver uses Windows Driver Model routines.
Build the WdmMemoryReadWriteDriver
project and (optionally) the TestWdmMemoryReadWriteDriver
project with Visual Studio.
Then, to be able to load the driver, you should enable test signing on your target computer:
bcdedit.exe -set TESTSIGNING ON
After that you have several options:
Press the Right Mouse Button on .\x64\Release\WdmMemoryReadWriteDriver\WdmMemoryReadWriteDriver.inf
, then choose Install
button.
sc.exe create WdmMemoryReadWriteDriver type= kernel binpath= <full\path\to\WdmMemoryReadWriteDriver.sys> DisplayName= WdmMemoryReadWriteDriver`
sc.exe start WdmMemoryReadWriteDriver`
Start remote PS session to your target computer and use
cd .\Deployment\
.\DeployDriver.ps1 <TargetPSSession> <TargetSessionPath>
or, if you want additionally to perfrom the test, run
cd .\Deployment\
.\DeployAndTest.ps1 <TargetPSSession> <TargetSessionPath>
To make sure that the driver is running properly on you computer, just execute ready-to-use script:
cd .\TestWdmMemoryReadWriteDriver\
.\TestDriver.ps1
If everything is fine, you should spot Success!
message on your terminal.
Using the driver:
- Sending request to driver to read from specfied process memory:
DRIVER_COPY_MEMORY copyInfo = { 0 };
copyInfo.ProcessId = GetProcessId(hProcess);
copyInfo.Source = (ULONGLONG)lpBaseAddress;
copyInfo.Target = (ULONGLONG)lpBuffer;
copyInfo.Size = nSize;
copyInfo.IsWrite = FALSE;
// Sending request to driver
DeviceIoControl(
hDevice,
IOCTL_DRIVER_COPY_MEMORY,
©Info,
sizeof(copyInfo),
©Info,
sizeof(copyInfo),
lpNumberOfBytesReturned,
NULL);
- Sending request to driver to write to specified process memory:
DRIVER_COPY_MEMORY copyInfo = { 0 };
copyInfo.ProcessId = GetProcessId(hProcess);
copyInfo.Source = (ULONGLONG)lpBuffer;
copyInfo.Target = (ULONGLONG)lpBaseAddress;
copyInfo.Size = nSize;
copyInfo.IsWrite = TRUE;
// Sending request to driver
DeviceIoControl(
hDevice,
IOCTL_DRIVER_COPY_MEMORY,
©Info,
sizeof(copyInfo),
©Info,
sizeof(copyInfo),
lpNumberOfBytesReturned,
NULL);
You can take a look into TestWdmMemoryReadWriteDriver
if you want to receive ready-to-use ReadProcessMemoryDrivered()
and WriteProcessMemoryDrivered()
functions.
PRs are accepted.