1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//! Process mitigation policy values for use with
//! `PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY` on `UpdateProcThreadAttribute`.
//!
//! The attribute identifier itself is available from the `windows` crate as
//! [`windows::Win32::System::Threading::PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY`].
//! Call sites cast it to `usize` because `UpdateProcThreadAttribute`'s
//! `dwAttribute` parameter is `DWORD_PTR`.
//!
//! The Win32k-syscall-disable mitigation flag below is documented in
//! `winnt.h` but is not generated into the `windows` crate metadata, so it
//! lives here. If a future `windows` crate release adds it, the local
//! constant and helper become redundant and this module can be deleted.
//! These mitigations are applied by the kernel before the child's first
//! user-mode instruction runs, so there is no race window. The
//! parent-applied attribute path (this module) is the documented
//! equivalent of the OS-internal `AIC_AGENTIC_LAUNCH_WIN32K_SYSTEM_CALL_DISABLED`
//! flag used by the BaseContainer PSEC path.
/// `PROCESS_CREATION_MITIGATION_POLICY_WIN32K_SYSTEM_CALL_DISABLE_ALWAYS_ON`
/// from `winnt.h`. When set on the mitigation `DWORD64`, the child cannot
/// make Win32k syscalls.
pub const PROCESS_CREATION_MITIGATION_POLICY_WIN32K_SYSTEM_CALL_DISABLE_ALWAYS_ON: u64 =
0x1u64 << 28;
/// Returns the mitigation `DWORD64` value that disables Win32k syscalls.
///
/// Pass this through `UpdateProcThreadAttribute` with attribute
/// `windows::Win32::System::Threading::PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY`
/// (cast to `usize`). Combine with other mitigation flags via
/// bitwise-OR if/when more are added.