pub struct MitigationPlan { /* private fields */ }Expand description
Builder for mitigation application.
Implementations§
Source§impl MitigationPlan
impl MitigationPlan
Sourcepub fn enable(self, mitigation: ProcessMitigation) -> Self
pub fn enable(self, mitigation: ProcessMitigation) -> Self
Enable one mitigation in this plan.
Sourcepub fn apply_to_current(&self) -> Result<()>
pub fn apply_to_current(&self) -> Result<()>
Apply all configured mitigations to the current process.
Sourcepub fn emit_compile_time(&self)
pub fn emit_compile_time(&self)
Emit compile-time linker directives for enabled mitigations.
This method prints cargo:rustc-link-arg directives to stdout, intended for use
in a build.rs script. Each linker directive enables binary-level protections on
the compiled executable.
§Supported Mitigations
Only mitigations with direct binary-level equivalents emit directives:
MicrosoftSignedOnly→/DEPENDENTLOADFLAG:0x800+/INTEGRITYCHECKDisableDynamicCode→/guard:cf(Control Flow Guard)RestrictPayload→/HIGHENTROPYVA(High Entropy ASLR)
The following are runtime-only and produce no compile-time output:
BlockRemoteImages,PreferSystem32Images,BlockChildProcessCreation
§Example (in build.rs)
use windows_erg::mitigation::{MitigationPlan, ProcessMitigation};
let plan = MitigationPlan::new()
.enable(ProcessMitigation::DisableDynamicCode)
.enable(ProcessMitigation::MicrosoftSignedOnly);
plan.emit_compile_time();Sourcepub fn emit_compile_time_with_compat(&self, enable_compat: bool)
pub fn emit_compile_time_with_compat(&self, enable_compat: bool)
Emit compile-time linker directives with optional CET Shadow Stack support.
Similar to [emit_compile_time], but optionally adds /CETCOMPAT for
hardware-enforced stack protection (Control-flow Enforcement Technology).
Requires Windows 11+ and compatible CPU.
§Arguments
enable_compat- Iftrue, additionally emits/CETCOMPAT
§Example (in build.rs)
use windows_erg::mitigation::{MitigationPlan, ProcessMitigation};
let plan = MitigationPlan::new()
.enable(ProcessMitigation::DisableDynamicCode);
plan.emit_compile_time_with_compat(true);Trait Implementations§
Source§impl Clone for MitigationPlan
impl Clone for MitigationPlan
Source§fn clone(&self) -> MitigationPlan
fn clone(&self) -> MitigationPlan
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more