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

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

Issue 109843003: Replace wstring with string16 in sandbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/interception.h ('k') | sandbox/win/src/ipc_unittest.cc » ('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 // For information about interceptions as a whole see 5 // For information about interceptions as a whole see
6 // http://dev.chromium.org/developers/design-documents/sandbox . 6 // http://dev.chromium.org/developers/design-documents/sandbox .
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "sandbox/win/src/interception.h" 10 #include "sandbox/win/src/interception.h"
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/strings/string16.h"
14 #include "base/win/pe_image.h" 15 #include "base/win/pe_image.h"
15 #include "base/win/windows_version.h" 16 #include "base/win/windows_version.h"
16 #include "sandbox/win/src/interception_internal.h" 17 #include "sandbox/win/src/interception_internal.h"
17 #include "sandbox/win/src/interceptors.h" 18 #include "sandbox/win/src/interceptors.h"
18 #include "sandbox/win/src/sandbox.h" 19 #include "sandbox/win/src/sandbox.h"
19 #include "sandbox/win/src/sandbox_utils.h" 20 #include "sandbox/win/src/sandbox_utils.h"
20 #include "sandbox/win/src/service_resolver.h" 21 #include "sandbox/win/src/service_resolver.h"
21 #include "sandbox/win/src/target_interceptions.h" 22 #include "sandbox/win/src/target_interceptions.h"
22 #include "sandbox/win/src/target_process.h" 23 #include "sandbox/win/src/target_process.h"
23 #include "sandbox/win/src/wow64.h" 24 #include "sandbox/win/src/wow64.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return false; 135 return false;
135 136
136 g_interceptions = reinterpret_cast<SharedMemory*>(remote_buffer); 137 g_interceptions = reinterpret_cast<SharedMemory*>(remote_buffer);
137 ResultCode rc = child_->TransferVariable("g_interceptions", 138 ResultCode rc = child_->TransferVariable("g_interceptions",
138 &g_interceptions, 139 &g_interceptions,
139 sizeof(g_interceptions)); 140 sizeof(g_interceptions));
140 return (SBOX_ALL_OK == rc); 141 return (SBOX_ALL_OK == rc);
141 } 142 }
142 143
143 size_t InterceptionManager::GetBufferSize() const { 144 size_t InterceptionManager::GetBufferSize() const {
144 std::set<std::wstring> dlls; 145 std::set<base::string16> dlls;
145 size_t buffer_bytes = 0; 146 size_t buffer_bytes = 0;
146 147
147 std::list<InterceptionData>::const_iterator it = interceptions_.begin(); 148 std::list<InterceptionData>::const_iterator it = interceptions_.begin();
148 for (; it != interceptions_.end(); ++it) { 149 for (; it != interceptions_.end(); ++it) {
149 // skip interceptions that are performed from the parent 150 // skip interceptions that are performed from the parent
150 if (!IsInterceptionPerformedByChild(*it)) 151 if (!IsInterceptionPerformedByChild(*it))
151 continue; 152 continue;
152 153
153 if (!dlls.count(it->dll)) { 154 if (!dlls.count(it->dll)) {
154 // NULL terminate the dll name on the structure 155 // NULL terminate the dll name on the structure
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 buffer = dll_info; 196 buffer = dll_info;
196 197
197 std::list<InterceptionData>::iterator it = interceptions_.begin(); 198 std::list<InterceptionData>::iterator it = interceptions_.begin();
198 for (; it != interceptions_.end();) { 199 for (; it != interceptions_.end();) {
199 // skip interceptions that are performed from the parent 200 // skip interceptions that are performed from the parent
200 if (!IsInterceptionPerformedByChild(*it)) { 201 if (!IsInterceptionPerformedByChild(*it)) {
201 ++it; 202 ++it;
202 continue; 203 continue;
203 } 204 }
204 205
205 const std::wstring dll = it->dll; 206 const base::string16 dll = it->dll;
206 if (!SetupDllInfo(*it, &buffer, &buffer_bytes)) 207 if (!SetupDllInfo(*it, &buffer, &buffer_bytes))
207 return false; 208 return false;
208 209
209 // walk the interceptions from this point, saving the ones that are 210 // walk the interceptions from this point, saving the ones that are
210 // performed on this dll, and removing the entry from the list. 211 // performed on this dll, and removing the entry from the list.
211 // advance the iterator before removing the element from the list 212 // advance the iterator before removing the element from the list
212 std::list<InterceptionData>::iterator rest = it; 213 std::list<InterceptionData>::iterator rest = it;
213 for (; rest != interceptions_.end();) { 214 for (; rest != interceptions_.end();) {
214 if (rest->dll == dll) { 215 if (rest->dll == dll) {
215 if (!SetupInterceptionInfo(*rest, &buffer, &buffer_bytes, dll_info)) 216 if (!SetupInterceptionInfo(*rest, &buffer, &buffer_bytes, dll_info))
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 const InterceptionData& data) const { 349 const InterceptionData& data) const {
349 if (INTERCEPTION_INVALID == data.type) 350 if (INTERCEPTION_INVALID == data.type)
350 return false; 351 return false;
351 352
352 if (INTERCEPTION_SERVICE_CALL == data.type) 353 if (INTERCEPTION_SERVICE_CALL == data.type)
353 return false; 354 return false;
354 355
355 if (data.type >= INTERCEPTION_LAST) 356 if (data.type >= INTERCEPTION_LAST)
356 return false; 357 return false;
357 358
358 std::wstring ntdll(kNtdllName); 359 base::string16 ntdll(kNtdllName);
359 if (ntdll == data.dll) 360 if (ntdll == data.dll)
360 return false; // ntdll has to be intercepted from the parent 361 return false; // ntdll has to be intercepted from the parent
361 362
362 return true; 363 return true;
363 } 364 }
364 365
365 bool InterceptionManager::PatchNtdll(bool hot_patch_needed) { 366 bool InterceptionManager::PatchNtdll(bool hot_patch_needed) {
366 // Maybe there is nothing to do 367 // Maybe there is nothing to do
367 if (!hot_patch_needed && interceptions_.empty()) 368 if (!hot_patch_needed && interceptions_.empty())
368 return true; 369 return true;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 thunk = new Win2kResolverThunk(child_->Process(), relaxed_); 487 thunk = new Win2kResolverThunk(child_->Process(), relaxed_);
487 } else if (os_info->version() >= base::win::VERSION_WIN8) { 488 } else if (os_info->version() >= base::win::VERSION_WIN8) {
488 thunk = new Win8ResolverThunk(child_->Process(), relaxed_); 489 thunk = new Win8ResolverThunk(child_->Process(), relaxed_);
489 } else { 490 } else {
490 thunk = new ServiceResolverThunk(child_->Process(), relaxed_); 491 thunk = new ServiceResolverThunk(child_->Process(), relaxed_);
491 } 492 }
492 #endif 493 #endif
493 494
494 std::list<InterceptionData>::iterator it = interceptions_.begin(); 495 std::list<InterceptionData>::iterator it = interceptions_.begin();
495 for (; it != interceptions_.end(); ++it) { 496 for (; it != interceptions_.end(); ++it) {
496 const std::wstring ntdll(kNtdllName); 497 const base::string16 ntdll(kNtdllName);
497 if (it->dll != ntdll) 498 if (it->dll != ntdll)
498 break; 499 break;
499 500
500 if (INTERCEPTION_SERVICE_CALL != it->type) 501 if (INTERCEPTION_SERVICE_CALL != it->type)
501 break; 502 break;
502 503
503 #if SANDBOX_EXPORTS 504 #if SANDBOX_EXPORTS
504 // We may be trying to patch by function name. 505 // We may be trying to patch by function name.
505 if (NULL == it->interceptor_address) { 506 if (NULL == it->interceptor_address) {
506 const char* address; 507 const char* address;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 ::FreeLibrary(local_interceptor); 542 ::FreeLibrary(local_interceptor);
542 #endif 543 #endif
543 544
544 if (it != interceptions_.end()) 545 if (it != interceptions_.end())
545 return false; 546 return false;
546 547
547 return true; 548 return true;
548 } 549 }
549 550
550 } // namespace sandbox 551 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/interception.h ('k') | sandbox/win/src/ipc_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698