diff options
author | caitkp@chromium.org <caitkp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-18 21:01:10 +0000 |
---|---|---|
committer | caitkp@chromium.org <caitkp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-18 21:01:10 +0000 |
commit | 37f2029c42d56e0d7a868eda1e2f2c62897fb9b0 (patch) | |
tree | 32e03a7d0b05b0e1a3e0ef9c7644f1746e0b5ef9 /chrome_elf/create_file/chrome_create_file.cc | |
parent | a34f61ee4f3ebc44edc4d144f892841c1e99619a (diff) | |
download | chromium_src-37f2029c42d56e0d7a868eda1e2f2c62897fb9b0.zip chromium_src-37f2029c42d56e0d7a868eda1e2f2c62897fb9b0.tar.gz chromium_src-37f2029c42d56e0d7a868eda1e2f2c62897fb9b0.tar.bz2 |
Make chrome_elf use thunks instead of function pointers.
1. Add functionality to ServiceResolverThunk to copy a thunk without patching.
2. Move chrome_elf thunk-handling code to a common location.
3. Use a thunk instead of a f'n ptr for redirects.
BUG=334379
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=255151
Review URL: https://codereview.chromium.org/183833004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_elf/create_file/chrome_create_file.cc')
-rw-r--r-- | chrome_elf/create_file/chrome_create_file.cc | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/chrome_elf/create_file/chrome_create_file.cc b/chrome_elf/create_file/chrome_create_file.cc index 59b15bd..2db6f8d 100644 --- a/chrome_elf/create_file/chrome_create_file.cc +++ b/chrome_elf/create_file/chrome_create_file.cc @@ -10,6 +10,7 @@ #include "chrome_elf/chrome_elf_constants.h" #include "chrome_elf/chrome_elf_util.h" #include "chrome_elf/ntdll_cache.h" +#include "sandbox/win/src/interception_internal.h" #include "sandbox/win/src/nt_internals.h" namespace { @@ -205,13 +206,22 @@ HANDLE CreateFileNTDLL( if (flags_and_attributes & FILE_FLAG_OPEN_NO_RECALL) flags |= FILE_OPEN_NO_RECALL; - if (!g_ntdll_lookup["NtCreateFile"] || - !g_ntdll_lookup["RtlInitUnicodeString"]) { + if (!g_ntdll_lookup["RtlInitUnicodeString"]) return INVALID_HANDLE_VALUE; - } - NtCreateFileFunction create_file = - reinterpret_cast<NtCreateFileFunction>(g_ntdll_lookup["NtCreateFile"]); + NtCreateFileFunction create_file; + char thunk_buffer[sizeof(sandbox::ThunkData)] = {}; + + if (g_nt_thunk_storage.data[0] != 0) { + create_file = reinterpret_cast<NtCreateFileFunction>(&g_nt_thunk_storage); + // Copy the thunk data to a buffer on the stack for debugging purposes. + memcpy(&thunk_buffer, &g_nt_thunk_storage, sizeof(sandbox::ThunkData)); + } else if (g_ntdll_lookup["NtCreateFile"]) { + create_file = + reinterpret_cast<NtCreateFileFunction>(g_ntdll_lookup["NtCreateFile"]); + } else { + return INVALID_HANDLE_VALUE; + } RtlInitUnicodeStringFunction init_unicode_string = reinterpret_cast<RtlInitUnicodeStringFunction>( |