Skip to content

Instantly share code, notes, and snippets.

@mattifestation
Created October 21, 2016 21:22
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mattifestation/3403d790bb51dc3ea87c3addf4dd9700 to your computer and use it in GitHub Desktop.
Save mattifestation/3403d790bb51dc3ea87c3addf4dd9700 to your computer and use it in GitHub Desktop.
Helper function for working with registry process mitigation options.
function ConvertTo-ProcessMitigationOption {
[OutputType([String])]
param (
[Switch]
$DEPEnable,
[Switch]
$DEPATLThunkEnable,
[Switch]
$SEHOPEnable,
[Switch]
$ForceRelocateImagesAlwaysOn,
[Switch]
$BottomUpASLRAlwaysOn,
[Switch]
$BottomUpASLRAlwaysOff
)
$OptionIndexTable = @{
DEPEnable = 0
DEPATLThunkEnable = 1
SEHOPEnable = 2
ForceRelocateImagesAlwaysOn = 8
BottomUpASLRAlwaysOn = 15
BottomUpASLRAlwaysOff = 16
}
$Settings = @{
$True = [Char] '1'
$False = [Char] '0'
}
$OptionTemplate = '????????????????????????????????'.ToCharArray()
foreach ($Option in $PSBoundParameters.Keys) {
$OptionTemplate[$OptionIndexTable[$Option]] = $Settings[$PSBoundParameters[$Option].IsPresent]
}
[Array]::Reverse($OptionTemplate)
$OptionTemplate -join ''
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment