Created
October 21, 2016 21:22
-
-
Save mattifestation/3403d790bb51dc3ea87c3addf4dd9700 to your computer and use it in GitHub Desktop.
Helper function for working with registry process mitigation options.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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