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

Side by Side Diff: sandbox/win/wow_helper/service64_resolver.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/window.cc ('k') | sandbox/win/wow_helper/wow_helper.vcproj » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/wow_helper/service64_resolver.h" 5 #include "sandbox/win/wow_helper/service64_resolver.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory>
11
10 #include "base/bit_cast.h" 12 #include "base/bit_cast.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "sandbox/win/wow_helper/target_code.h" 13 #include "sandbox/win/wow_helper/target_code.h"
13 14
14 namespace { 15 namespace {
15 #pragma pack(push, 1) 16 #pragma pack(push, 1)
16 17
17 const BYTE kMovEax = 0xB8; 18 const BYTE kMovEax = 0xB8;
18 const BYTE kMovEdx = 0xBA; 19 const BYTE kMovEdx = 0xBA;
19 const USHORT kCallPtrEdx = 0x12FF; 20 const USHORT kCallPtrEdx = 0x12FF;
20 const BYTE kRet = 0xC2; 21 const BYTE kRet = 0xC2;
21 const BYTE kNop = 0x90; 22 const BYTE kNop = 0x90;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 void* thunk_storage, 208 void* thunk_storage,
208 size_t storage_bytes, 209 size_t storage_bytes,
209 size_t* storage_used) { 210 size_t* storage_used) {
210 NTSTATUS ret = Init(target_module, interceptor_module, target_name, 211 NTSTATUS ret = Init(target_module, interceptor_module, target_name,
211 interceptor_name, interceptor_entry_point, 212 interceptor_name, interceptor_entry_point,
212 thunk_storage, storage_bytes); 213 thunk_storage, storage_bytes);
213 if (!NT_SUCCESS(ret)) 214 if (!NT_SUCCESS(ret))
214 return ret; 215 return ret;
215 216
216 size_t thunk_bytes = GetThunkSize(); 217 size_t thunk_bytes = GetThunkSize();
217 scoped_ptr<char[]> thunk_buffer(new char[thunk_bytes]); 218 std::unique_ptr<char[]> thunk_buffer(new char[thunk_bytes]);
218 ServiceFullThunk* thunk = reinterpret_cast<ServiceFullThunk*>( 219 ServiceFullThunk* thunk = reinterpret_cast<ServiceFullThunk*>(
219 thunk_buffer.get()); 220 thunk_buffer.get());
220 221
221 if (!IsFunctionAService(&thunk->original)) 222 if (!IsFunctionAService(&thunk->original))
222 return STATUS_UNSUCCESSFUL; 223 return STATUS_UNSUCCESSFUL;
223 224
224 ret = PerformPatch(thunk, thunk_storage); 225 ret = PerformPatch(thunk, thunk_storage);
225 226
226 if (NULL != storage_used) 227 if (NULL != storage_used)
227 *storage_used = thunk_bytes; 228 *storage_used = thunk_bytes;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 338
338 // and now change the function to intercept, on the child 339 // and now change the function to intercept, on the child
339 if (!::WriteProtectedChildMemory(process_, target_, &local_service, 340 if (!::WriteProtectedChildMemory(process_, target_, &local_service,
340 sizeof(local_service))) 341 sizeof(local_service)))
341 return STATUS_UNSUCCESSFUL; 342 return STATUS_UNSUCCESSFUL;
342 343
343 return STATUS_SUCCESS; 344 return STATUS_SUCCESS;
344 } 345 }
345 346
346 } // namespace sandbox 347 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/window.cc ('k') | sandbox/win/wow_helper/wow_helper.vcproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698