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/sandbox_nt_util.h" | 8 #include "sandbox/win/src/sandbox_nt_util.h" |
9 #include "sandbox/win/src/win_utils.h" | 9 #include "sandbox/win/src/win_utils.h" |
10 | 10 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 if (NULL != storage_used) | 109 if (NULL != storage_used) |
110 *storage_used = thunk_bytes; | 110 *storage_used = thunk_bytes; |
111 | 111 |
112 return ret; | 112 return ret; |
113 } | 113 } |
114 | 114 |
115 size_t ServiceResolverThunk::GetThunkSize() const { | 115 size_t ServiceResolverThunk::GetThunkSize() const { |
116 return sizeof(ServiceFullThunk); | 116 return sizeof(ServiceFullThunk); |
117 } | 117 } |
118 | 118 |
119 NTSTATUS ServiceResolverThunk::CopyThunk(const void* target_module, | |
120 const char* target_name, | |
121 BYTE* thunk_storage, | |
122 size_t storage_bytes, | |
123 size_t* storage_used) { | |
124 NTSTATUS ret = ResolveTarget(target_module, target_name, &target_); | |
125 if (!NT_SUCCESS(ret)) | |
126 return ret; | |
127 | |
128 size_t thunk_bytes = GetThunkSize(); | |
robertshield
2014/03/04 01:47:07
Please address Ricardo's note about size checking
Cait (Slow)
2014/03/04 15:43:56
Done.
| |
129 ServiceFullThunk* thunk = reinterpret_cast<ServiceFullThunk*>(thunk_storage); | |
130 | |
131 if (!IsFunctionAService(&thunk->original)) | |
132 return STATUS_UNSUCCESSFUL; | |
133 | |
134 return ret; | |
135 } | |
136 | |
119 bool ServiceResolverThunk::IsFunctionAService(void* local_thunk) const { | 137 bool ServiceResolverThunk::IsFunctionAService(void* local_thunk) const { |
120 ServiceFullThunk function_code; | 138 ServiceFullThunk function_code; |
121 SIZE_T read; | 139 SIZE_T read; |
122 if (!::ReadProcessMemory(process_, target_, &function_code, | 140 if (!::ReadProcessMemory(process_, target_, &function_code, |
123 sizeof(function_code), &read)) | 141 sizeof(function_code), &read)) |
124 return false; | 142 return false; |
125 | 143 |
126 if (sizeof(function_code) != read) | 144 if (sizeof(function_code) != read) |
127 return false; | 145 return false; |
128 | 146 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 NOTREACHED_NT(); | 202 NOTREACHED_NT(); |
185 return false; | 203 return false; |
186 } | 204 } |
187 | 205 |
188 bool Win2kResolverThunk::IsFunctionAService(void* local_thunk) const { | 206 bool Win2kResolverThunk::IsFunctionAService(void* local_thunk) const { |
189 NOTREACHED_NT(); | 207 NOTREACHED_NT(); |
190 return false; | 208 return false; |
191 } | 209 } |
192 | 210 |
193 } // namespace sandbox | 211 } // namespace sandbox |
OLD | NEW |