Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6370)

Unified Diff: chrome_elf/create_file/chrome_create_file.cc

Issue 183833004: Make chrome_elf use thunks instead of function pointers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments, add scoped ptr Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome_elf/chrome_elf.gyp ('k') | chrome_elf/create_file/chrome_create_file_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_elf/create_file/chrome_create_file.cc
diff --git a/chrome_elf/create_file/chrome_create_file.cc b/chrome_elf/create_file/chrome_create_file.cc
index 59b15bd0f76adbbf0f6d00116465f60c06deac13..2db6f8d8372f96aaaf44c9a16ef8062c086ca41d 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>(
« no previous file with comments | « chrome_elf/chrome_elf.gyp ('k') | chrome_elf/create_file/chrome_create_file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698