Пожалуйста, обратите внимание, что пользователь заблокирован
Hi i was trying to build a windows kernel driver targeting x64
This is the source code
The code is compiled successfully , but when load the driver on windows 10 i can't get any debug print on dbgview
iam sure problem is not with debug print , one more thing when i use function PsSetCreateProcessNotifyRoutine it works fine and i can see what process created
So if you have guys experince and can help please share it here .
Thanks
This is the source code
C:
#include <Ntifs.h>
#include <ntddk.h>
#include <wdm.h>
UNICODE_STRING DEVICE_NAME = RTL_CONSTANT_STRING(L"\\Device\\SpotlessDevice");
UNICODE_STRING DEVICE_SYMBOLIC_NAME = RTL_CONSTANT_STRING(L"\\??\\SpotlessDeviceLink");
void sCreateProcessNotifyRoutineEx(PEPROCESS process, HANDLE pid, PPS_CREATE_NOTIFY_INFO createInfo)
{
UNREFERENCED_PARAMETER(process);
UNREFERENCED_PARAMETER(pid);
DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[-] createInfo->CommandLine->Buffer %s", createInfo->CommandLine->Buffer);
if (createInfo != NULL)
{
if (wcsstr(createInfo->CommandLine->Buffer, L"notepad") != NULL)
{
DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[!] Access to launch notepad.exe was denied!");
createInfo->CreationStatus = STATUS_ACCESS_DENIED;
}
}
}
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
UNREFERENCED_PARAMETER(DriverObject);
UNREFERENCED_PARAMETER(RegistryPath);
NTSTATUS status = 0;
// routine that will execute when our driver is unloaded/service is stopped
DriverObject->DriverUnload = DriverUnload;
// routine for handling IO requests from userland
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = HandleCustomIOCTL;
// routines that will execute once a handle to our device's symbolik link is opened/closed
DriverObject->MajorFunction[IRP_MJ_CREATE] = MajorFunctions;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = MajorFunctions;
DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "Driver loaded");
// subscribe to notifications
//PsSetCreateProcessNotifyRoutine(sCreateProcessNotifyRoutine, FALSE);
//PsSetLoadImageNotifyRoutine(sLoadImageNotifyRoutine);
//PsSetCreateThreadNotifyRoutine(sCreateThreadNotifyRoutine);
PsSetCreateProcessNotifyRoutineEx(sCreateProcessNotifyRoutineEx, FALSE);
DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "Listeners isntalled..");
IoCreateDevice(DriverObject, 0, &DEVICE_NAME, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, FALSE, &DriverObject->DeviceObject);
if (!NT_SUCCESS(status))
{
DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "Could not create device %wZ", DEVICE_NAME);
}
else
{
DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "Device %wZ created", DEVICE_NAME);
}
status = IoCreateSymbolicLink(&DEVICE_SYMBOLIC_NAME, &DEVICE_NAME);
if (NT_SUCCESS(status))
{
DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "Symbolic link %wZ created", DEVICE_SYMBOLIC_NAME);
}
else
{
DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "Error creating symbolic link %wZ", DEVICE_SYMBOLIC_NAME);
}
return STATUS_SUCCESS;
}
The code is compiled successfully , but when load the driver on windows 10 i can't get any debug print on dbgview
iam sure problem is not with debug print , one more thing when i use function PsSetCreateProcessNotifyRoutine it works fine and i can see what process created
So if you have guys experince and can help please share it here .
Thanks