Register the necessary notify routines. @param Detector - Detection instance used to analyze untrusted operations. @param InitializeStatus - Status of initialization. */
| 19 | @param InitializeStatus - Status of initialization. |
| 20 | */ |
| 21 | ImageHistoryFilter::ImageHistoryFilter ( |
| 22 | _In_ PDETECTION_LOGIC Detector, |
| 23 | _Out_ NTSTATUS* InitializeStatus |
| 24 | ) |
| 25 | { |
| 26 | // |
| 27 | // Set the create process notify routine. |
| 28 | // |
| 29 | *InitializeStatus = PsSetCreateProcessNotifyRoutineEx(ImageHistoryFilter::CreateProcessNotifyRoutine, FALSE); |
| 30 | if (NT_SUCCESS(*InitializeStatus) == FALSE) |
| 31 | { |
| 32 | DBGPRINT("ImageHistoryFilter!ImageHistoryFilter: Failed to register create process notify routine with status 0x%X.", *InitializeStatus); |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | // |
| 37 | // Set the load image notify routine. |
| 38 | // |
| 39 | *InitializeStatus = PsSetLoadImageNotifyRoutine(ImageHistoryFilter::LoadImageNotifyRoutine); |
| 40 | if (NT_SUCCESS(*InitializeStatus) == FALSE) |
| 41 | { |
| 42 | DBGPRINT("ImageHistoryFilter!ImageHistoryFilter: Failed to register load image notify routine with status 0x%X.", *InitializeStatus); |
| 43 | return; |
| 44 | } |
| 45 | |
| 46 | FltInitializePushLock(&ImageHistoryFilter::ProcessHistoryLock); |
| 47 | |
| 48 | ImageHistoryFilter::ProcessHistoryHead = RCAST<PPROCESS_HISTORY_ENTRY>(ExAllocatePoolWithTag(PagedPool, sizeof(PROCESS_HISTORY_ENTRY), PROCESS_HISTORY_TAG)); |
| 49 | if (ImageHistoryFilter::ProcessHistoryHead == NULL) |
| 50 | { |
| 51 | DBGPRINT("ImageHistoryFilter!ImageHistoryFilter: Failed to allocate the process history head."); |
| 52 | *InitializeStatus = STATUS_NO_MEMORY; |
| 53 | return; |
| 54 | } |
| 55 | memset(ImageHistoryFilter::ProcessHistoryHead, 0, sizeof(PROCESS_HISTORY_ENTRY)); |
| 56 | InitializeListHead(RCAST<PLIST_ENTRY>(ImageHistoryFilter::ProcessHistoryHead)); |
| 57 | this->ProcessHistorySize = 0; |
| 58 | |
| 59 | // |
| 60 | // Set the detector. |
| 61 | // |
| 62 | ImageHistoryFilter::detector = Detector; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | Clean up the process history linked-list. |
nothing calls this directly
no outgoing calls
no test coverage detected