# PsSetCreateProcessNotifyRoutineEx

프로세스의 실행을 제어할 수 있는 PsSetCreateProcessNotifyRoutineEx 함수는 새로운 프로세스가 실행 되기 전에 프로세스를 강제로 종료할 수 있는 기능을 지원합니다.

이 함수는 NotifyRoutine, Remove 두개의 인자를 받습니다.

* NofityRoutine : 등록하거나 제거할 PCREATE\_PROCESS\_NOTIFY\_ROUTINE\_EX 루틴에 대한 포인터
* Remove : 지정된 루틴의 생성/제거 여부를 정하는 인자

{% code title="PsSetCreateProcessNotifyRoutineEx 구조체" %}

```cpp
NTSTATUS PsSetCreateProcessNotifyRoutineEx(
  [in] PCREATE_PROCESS_NOTIFY_ROUTINE_EX NotifyRoutine,
  [in] BOOLEAN                           Remove
);
```

{% endcode %}

해당 함수는 다음 NTSTATUS 값 중 하나를 반환합니다.

<table><thead><tr><th width="276">반환 코드</th><th>설명</th></tr></thead><tbody><tr><td>STATUS_SUCCESS</td><td>지정된 루틴이 운영체제에 등록됨</td></tr><tr><td>STATUS_INVALID_PARAMETER</td><td>지정된 루틴이 이미 등록되어있거나, 운영체제가 프로세스 생성 콜백 루틴을 등록하는 제한에 도달</td></tr><tr><td>STATUS_ACCESS_DENIED</td><td>콜백 루틴 포인터가 포함된 이미지의 이미지 헤더에 IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY 설정되지 않음</td></tr></tbody></table>

결과적으로 해당 함수의 리턴 값이 `STATUS_ACCESS_DENIED`라면, 해당 프로세스는 실행되지 않습니다.

Windows Defender에서 악성 행위가 탐지되면 프로세스가 실행되지 않고 즉시 삭제되는 루틴 역시 이 함수를 통해 이뤄집니다.

`PsSetCreateThreadNotifyRoutineEx` 와 `PsSetLoadImageNotifyRoutineEx` 모두 비슷한 역할을 할 수 있으며 세가지 함수는 각각 다음과 같은 테이블에 저장됩니다.

* nt!PspCreateProcessNotifyRoutine
* nt!PspCreateThreadNotifyRoutine
* nt!PspLoadImageNotifyRoutine

## References

{% embed url="<https://learn.microsoft.com/ko-kr/windows-hardware/drivers/ddi/ntddk/nf-ntddk-pssetcreateprocessnotifyroutineex>" %}

{% embed url="<https://learn.microsoft.com/ko-kr/windows-hardware/drivers/ddi/ntddk/nf-ntddk-pssetcreatethreadnotifyroutineex>" %}

{% embed url="<https://learn.microsoft.com/ko-kr/windows-hardware/drivers/ddi/ntddk/nf-ntddk-pssetloadimagenotifyroutineex>" %}

{% embed url="<https://www.ired.team/miscellaneous-reversing-forensics/windows-kernel-internals/subscribing-to-process-creation-thread-creation-and-image-load-notifications-from-a-kernel-driver>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.pentestwiki.com/defense-evasion/undefined/pssetcreateprocessnotifyroutineex.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
