Hi Guys,
I wrote a simple driver to detect process creation, but it is not working on Vista, however it works on XP.
The driver was build through the build environment of XP using the DDK.
Below is the code:
VOID ProcViewProcessCallback(IN HANDLE ParentId, IN HANDLE ProcessId, IN BOOLEAN Create);
void DriverUnload(PDRIVER_OBJECT pDriverObject)
{
DbgPrint("Driver unloading");
if (g_ProcCreateNotificationInstalled == TRUE)
{
//
// Remove the callback
//
NTSTATUS ntStatus = PsSetCreateProcessNotifyRoutine(ProcViewProcessCallback, TRUE);
if (ntStatus == STATUS_UNSUCCESSFUL)
{
DbgPrint ("Failed to remove process create notification\n");
}
else
{
g_ProcCreateNotificationInstalled = TRUE;
}
}
}
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
NTSTATUS ntStatus = STATUS_UNSUCCESSFUL;
DbgPrint ("Driver now loading\n");
DriverObject-\>DriverUnload = DriverUnload;
//
// Set up the callback
//
ntStatus = PsSetCreateProcessNotifyRoutine(ProcViewProcessCallback, FALSE);
if (ntStatus == STATUS_UNSUCCESSFUL)
{
DbgPrint ("Failed to set a process create notification\n");
}
else
{
g_ProcCreateNotificationInstalled = TRUE;
}
return ntStatus;
}
VOID ProcViewProcessCallback(IN HANDLE ParentId, IN HANDLE ProcessId, IN BOOLEAN Create)
{
char wzMsg [256];
if (Create == TRUE)
{
sprintf (wzMsg, "%d - created\n", ProcessId);
}
else
{
sprintf (wzMsg, "%d - deleted\n", ProcessId);
}
DbgPrint (wzMsg);
}
Can someone point out what’s missing over here?
Cheers,
Hitesh