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

Side by Side Diff: sandbox/win/src/sandbox_nt_util.cc

Issue 84063004: Restructure sandbox code to reduce dependencies pulled in by intercept code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix presubmit warning. Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sandbox/win/src/sandbox_nt_util.h ('k') | sandbox/win/src/sandbox_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sandbox/win/src/sandbox_nt_util.h" 5 #include "sandbox/win/src/sandbox_nt_util.h"
6 6
7 #include "base/win/pe_image.h" 7 #include "base/win/pe_image.h"
8 #include "sandbox/win/src/sandbox_factory.h" 8 #include "sandbox/win/src/sandbox_factory.h"
9 #include "sandbox/win/src/target_services.h" 9 #include "sandbox/win/src/target_services.h"
10 10
11 namespace sandbox { 11 namespace sandbox {
12 12
13 // This is the list of all imported symbols from ntdll.dll. 13 // This is the list of all imported symbols from ntdll.dll.
14 SANDBOX_INTERCEPT NtExports g_nt = { NULL }; 14 SANDBOX_INTERCEPT NtExports g_nt;
15 15
16 } // namespace sandbox 16 } // namespace sandbox
17 17
18 namespace { 18 namespace {
19 19
20 #if defined(_WIN64) 20 #if defined(_WIN64)
21 void* AllocateNearTo(void* source, size_t size) { 21 void* AllocateNearTo(void* source, size_t size) {
22 using sandbox::g_nt; 22 using sandbox::g_nt;
23 23
24 // Start with 1 GB above the source. 24 // Start with 1 GB above the source.
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 TouchMemory(buffer, size, intent); 201 TouchMemory(buffer, size, intent);
202 } __except(EXCEPTION_EXECUTE_HANDLER) { 202 } __except(EXCEPTION_EXECUTE_HANDLER) {
203 return false; 203 return false;
204 } 204 }
205 return true; 205 return true;
206 } 206 }
207 207
208 NTSTATUS CopyData(void* destination, const void* source, size_t bytes) { 208 NTSTATUS CopyData(void* destination, const void* source, size_t bytes) {
209 NTSTATUS ret = STATUS_SUCCESS; 209 NTSTATUS ret = STATUS_SUCCESS;
210 __try { 210 __try {
211 if (SandboxFactory::GetTargetServices()->GetState()->InitCalled()) { 211 g_nt.memcpy(destination, source, bytes);
212 memcpy(destination, source, bytes);
213 } else {
214 const char* from = reinterpret_cast<const char*>(source);
215 char* to = reinterpret_cast<char*>(destination);
216 for (size_t i = 0; i < bytes; i++) {
217 to[i] = from[i];
218 }
219 }
220 } __except(EXCEPTION_EXECUTE_HANDLER) { 212 } __except(EXCEPTION_EXECUTE_HANDLER) {
221 ret = GetExceptionCode(); 213 ret = GetExceptionCode();
222 } 214 }
223 return ret; 215 return ret;
224 } 216 }
225 217
226 // Hacky code... replace with AllocAndCopyObjectAttributes. 218 // Hacky code... replace with AllocAndCopyObjectAttributes.
227 NTSTATUS AllocAndCopyName(const OBJECT_ATTRIBUTES* in_object, 219 NTSTATUS AllocAndCopyName(const OBJECT_ATTRIBUTES* in_object,
228 wchar_t** out_name, uint32* attributes, 220 wchar_t** out_name, uint32* attributes,
229 HANDLE* root) { 221 HANDLE* root) {
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 UNREFERENCED_PARAMETER(type); 585 UNREFERENCED_PARAMETER(type);
594 return buffer; 586 return buffer;
595 } 587 }
596 588
597 void __cdecl operator delete(void* memory, void* buffer, 589 void __cdecl operator delete(void* memory, void* buffer,
598 sandbox::AllocationType type) { 590 sandbox::AllocationType type) {
599 UNREFERENCED_PARAMETER(memory); 591 UNREFERENCED_PARAMETER(memory);
600 UNREFERENCED_PARAMETER(buffer); 592 UNREFERENCED_PARAMETER(buffer);
601 UNREFERENCED_PARAMETER(type); 593 UNREFERENCED_PARAMETER(type);
602 } 594 }
OLDNEW
« no previous file with comments | « sandbox/win/src/sandbox_nt_util.h ('k') | sandbox/win/src/sandbox_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698