Skip to content

Commit

Permalink
Make sure CreateFile call is not inlined, so EMET doesn't get upset.
Browse files Browse the repository at this point in the history
BUG=348383

Review URL: https://codereview.chromium.org/197863002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256751 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
caitkp@chromium.org committed Mar 13, 2014
1 parent ba703c6 commit a32a804
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions chrome_elf/create_file/chrome_create_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,27 @@ bool PopulateShellFunctions() {

} // namespace

// Turn off optimization to make sure these calls don't get inlined.
#pragma optimize("", off)
// Wrapper method for kernel32!CreateFile, to avoid setting off caller
// mitigation detectors.
HANDLE CreateFileWImpl(LPCWSTR file_name,
DWORD desired_access,
DWORD share_mode,
LPSECURITY_ATTRIBUTES security_attributes,
DWORD creation_disposition,
DWORD flags_and_attributes,
HANDLE template_file) {
return CreateFile(file_name,
desired_access,
share_mode,
security_attributes,
creation_disposition,
flags_and_attributes,
template_file);

}

HANDLE WINAPI CreateFileWRedirect(
LPCWSTR file_name,
DWORD desired_access,
Expand All @@ -105,15 +126,15 @@ HANDLE WINAPI CreateFileWRedirect(
flags_and_attributes,
template_file);
}
return CreateFile(file_name,
desired_access,
share_mode,
security_attributes,
creation_disposition,
flags_and_attributes,
template_file);

return CreateFileWImpl(file_name,
desired_access,
share_mode,
security_attributes,
creation_disposition,
flags_and_attributes,
template_file);
}
#pragma optimize("", on)

int GetRedirectCount() {
return g_redirect_count;
Expand Down

0 comments on commit a32a804

Please sign in to comment.