Skip to content

Commit

Permalink
win7dep: call GetProcessMitigationPolicy directly
Browse files Browse the repository at this point in the history
Now that we don't support Win7/8, we can call
GetProcessMitigationPolicy directly instead of going through
GetProcAddr.

Bug: 1408307
Change-Id: I67f8b912fa7cd863ab35a8c78182e37bd934dbbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4199978
Reviewed-by: Francois Pierre Doray <fdoray@chromium.org>
Commit-Queue: David Bienvenu <davidbienvenu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1098114}
  • Loading branch information
David Bienvenu authored and Chromium LUCI CQ committed Jan 27, 2023
1 parent 4ae3366 commit 596d15b
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions base/process/process_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -824,19 +824,11 @@ TEST_F(ProcessUtilTest, LaunchAsUser) {
}

MULTIPROCESS_TEST_MAIN(ChildVerifiesCetDisabled) {
auto get_process_mitigation_policy =
reinterpret_cast<decltype(&GetProcessMitigationPolicy)>(::GetProcAddress(
::GetModuleHandleW(L"kernel32.dll"), "GetProcessMitigationPolicy"));

// Not available for Win7 but this process should still work.
if (!get_process_mitigation_policy)
return kSuccess;

// Policy not defined for Win < Win10 20H1 but that's also ok.
// Policy not defined for Win < Win10 20H1 but that's ok.
PROCESS_MITIGATION_USER_SHADOW_STACK_POLICY policy = {};
if (get_process_mitigation_policy(GetCurrentProcess(),
ProcessUserShadowStackPolicy, &policy,
sizeof(policy))) {
if (GetProcessMitigationPolicy(GetCurrentProcess(),
ProcessUserShadowStackPolicy, &policy,
sizeof(policy))) {
if (policy.EnableUserShadowStack)
return 1;
}
Expand Down

0 comments on commit 596d15b

Please sign in to comment.