OLD | NEW |
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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "sandbox/win/src/win_utils.h" | 8 #include "sandbox/win/src/win_utils.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 size_t storage_bytes, | 152 size_t storage_bytes, |
153 size_t* storage_used) { | 153 size_t* storage_used) { |
154 NTSTATUS ret = Init(target_module, interceptor_module, target_name, | 154 NTSTATUS ret = Init(target_module, interceptor_module, target_name, |
155 interceptor_name, interceptor_entry_point, | 155 interceptor_name, interceptor_entry_point, |
156 thunk_storage, storage_bytes); | 156 thunk_storage, storage_bytes); |
157 if (!NT_SUCCESS(ret)) | 157 if (!NT_SUCCESS(ret)) |
158 return ret; | 158 return ret; |
159 | 159 |
160 relative_jump_ = 0; | 160 relative_jump_ = 0; |
161 size_t thunk_bytes = GetThunkSize(); | 161 size_t thunk_bytes = GetThunkSize(); |
162 scoped_array<char> thunk_buffer(new char[thunk_bytes]); | 162 scoped_ptr<char[]> thunk_buffer(new char[thunk_bytes]); |
163 ServiceFullThunk* thunk = reinterpret_cast<ServiceFullThunk*>( | 163 ServiceFullThunk* thunk = reinterpret_cast<ServiceFullThunk*>( |
164 thunk_buffer.get()); | 164 thunk_buffer.get()); |
165 | 165 |
166 if (!IsFunctionAService(&thunk->original) && | 166 if (!IsFunctionAService(&thunk->original) && |
167 (!relaxed_ || !SaveOriginalFunction(&thunk->original, thunk_storage))) | 167 (!relaxed_ || !SaveOriginalFunction(&thunk->original, thunk_storage))) |
168 return STATUS_UNSUCCESSFUL; | 168 return STATUS_UNSUCCESSFUL; |
169 | 169 |
170 ret = PerformPatch(thunk, thunk_storage); | 170 ret = PerformPatch(thunk, thunk_storage); |
171 | 171 |
172 if (NULL != storage_used) | 172 if (NULL != storage_used) |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 return false; | 411 return false; |
412 } | 412 } |
413 | 413 |
414 // Save the verified code | 414 // Save the verified code |
415 memcpy(local_thunk, &function_code, sizeof(function_code)); | 415 memcpy(local_thunk, &function_code, sizeof(function_code)); |
416 | 416 |
417 return true; | 417 return true; |
418 } | 418 } |
419 | 419 |
420 } // namespace sandbox | 420 } // namespace sandbox |
OLD | NEW |