Skip to content

Instantly share code, notes, and snippets.

@swwwolf
Last active June 20, 2022 15:59
Show Gist options
  • Save swwwolf/443be80db92f2eb2d2d7 to your computer and use it in GitHub Desktop.
Save swwwolf/443be80db92f2eb2d2d7 to your computer and use it in GitHub Desktop.
typedef NTSTATUS (NTAPI* PSSETCREATEPROCESSNOTIFYROUTINEEX_PROC)(
IN PCREATE_PROCESS_NOTIFY_ROUTINE_EX NotifyRoutine,
IN BOOLEAN Remove);
NTSTATUS SetCreateProcessNotifyRoutine(VOID) {
NTSTATUS status;
UNICODE_STRING szCreateProcessEx = { 0 };
PSSETCREATEPROCESSNOTIFYROUTINEEX_PROC pCreateProcessEx = NULL;
PAGED_CODE();
RtlInitUnicodeString(&szCreateProcessEx, L"PsSetCreateProcessNotifyRoutineEx");
pCreateProcessEx = (PSSETCREATEPROCESSNOTIFYROUTINEEX_PROC)MmGetSystemRoutineAddress(&szCreateProcessEx);
if ( pCreateProcessEx )
status = pCreateProcessEx(CreateProcessNotifyRoutineEx, FALSE);
else
status = PsSetCreateProcessNotifyRoutine(CreateProcessNotifyRoutine, FALSE);
return status;
}
VOID CreateProcessNotifyRoutine(IN HANDLE ParentId, IN HANDLE ProcessId, IN BOOLEAN Create) {
PAGED_CODE();
KdPrint(("CreateProcessNotifyRoutine called with ParentId = 0x%08X, ProcessId = 0x%08X, Create = %d\n", ParentId, ProcessId, Create));
}
VOID CreateProcessNotifyRoutineEx(__inout PEPROCESS Process, __in HANDLE ProcessId, __in_opt PPS_CREATE_NOTIFY_INFO CreateInfo) {
PAGED_CODE();
KdPrint(("CreateProcessNotifyRoutineEx called with Process = 0x%08X, ProcessId = 0x%08X\n", Process, ProcessId));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment