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

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

Issue 1849323003: Convert //sandbox to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixup nonsfi_sandbox_unittest.cc Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « sandbox/win/src/sandbox_policy_base.h ('k') | sandbox/win/src/service_resolver_64.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 #include "sandbox/win/src/service_resolver.h" 5 #include "sandbox/win/src/service_resolver.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory>
10
9 #include "base/bit_cast.h" 11 #include "base/bit_cast.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "sandbox/win/src/win_utils.h" 12 #include "sandbox/win/src/win_utils.h"
12 13
13 namespace { 14 namespace {
14 #pragma pack(push, 1) 15 #pragma pack(push, 1)
15 16
16 const BYTE kMovEax = 0xB8; 17 const BYTE kMovEax = 0xB8;
17 const BYTE kMovEdx = 0xBA; 18 const BYTE kMovEdx = 0xBA;
18 const USHORT kMovEdxEsp = 0xD48B; 19 const USHORT kMovEdxEsp = 0xD48B;
19 const USHORT kCallPtrEdx = 0x12FF; 20 const USHORT kCallPtrEdx = 0x12FF;
20 const USHORT kCallEdx = 0xD2FF; 21 const USHORT kCallEdx = 0xD2FF;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 size_t storage_bytes, 169 size_t storage_bytes,
169 size_t* storage_used) { 170 size_t* storage_used) {
170 NTSTATUS ret = Init(target_module, interceptor_module, target_name, 171 NTSTATUS ret = Init(target_module, interceptor_module, target_name,
171 interceptor_name, interceptor_entry_point, 172 interceptor_name, interceptor_entry_point,
172 thunk_storage, storage_bytes); 173 thunk_storage, storage_bytes);
173 if (!NT_SUCCESS(ret)) 174 if (!NT_SUCCESS(ret))
174 return ret; 175 return ret;
175 176
176 relative_jump_ = 0; 177 relative_jump_ = 0;
177 size_t thunk_bytes = GetThunkSize(); 178 size_t thunk_bytes = GetThunkSize();
178 scoped_ptr<char[]> thunk_buffer(new char[thunk_bytes]); 179 std::unique_ptr<char[]> thunk_buffer(new char[thunk_bytes]);
179 ServiceFullThunk* thunk = reinterpret_cast<ServiceFullThunk*>( 180 ServiceFullThunk* thunk = reinterpret_cast<ServiceFullThunk*>(
180 thunk_buffer.get()); 181 thunk_buffer.get());
181 182
182 if (!IsFunctionAService(&thunk->original) && 183 if (!IsFunctionAService(&thunk->original) &&
183 (!relaxed_ || !SaveOriginalFunction(&thunk->original, thunk_storage))) { 184 (!relaxed_ || !SaveOriginalFunction(&thunk->original, thunk_storage))) {
184 return STATUS_UNSUCCESSFUL; 185 return STATUS_UNSUCCESSFUL;
185 } 186 }
186 187
187 ret = PerformPatch(thunk, thunk_storage); 188 ret = PerformPatch(thunk, thunk_storage);
188 189
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 kRet != function_code.ret) { 470 kRet != function_code.ret) {
470 return false; 471 return false;
471 } 472 }
472 473
473 // Save the verified code 474 // Save the verified code
474 memcpy(local_thunk, &function_code, sizeof(function_code)); 475 memcpy(local_thunk, &function_code, sizeof(function_code));
475 return true; 476 return true;
476 } 477 }
477 478
478 } // namespace sandbox 479 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/sandbox_policy_base.h ('k') | sandbox/win/src/service_resolver_64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698