Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320)
[chromium-blink-merge.git] / sandbox / win / src / service_resolver.cc
blob92f21a7c2c9597d3e553df0aabbd6256fc91928e
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "sandbox/win/src/service_resolver.h"
7 #include "base/win/pe_image.h"
8 #include "sandbox/win/src/internal_types.h"
9 #include "sandbox/win/src/sandbox_nt_util.h"
11 namespace sandbox {
13 NTSTATUS ServiceResolverThunk::ResolveInterceptor(
14 const void* interceptor_module,
15 const char* interceptor_name,
16 const void** address) {
17 // After all, we are using a locally mapped version of the exe, so the
18 // action is the same as for a target function.
19 return ResolveTarget(interceptor_module, interceptor_name,
20 const_cast<void**>(address));
23 // In this case all the work is done from the parent, so resolve is
24 // just a simple GetProcAddress.
25 NTSTATUS ServiceResolverThunk::ResolveTarget(const void* module,
26 const char* function_name,
27 void** address) {
28 if (NULL == module)
29 return STATUS_UNSUCCESSFUL;
31 base::win::PEImage module_image(module);
32 *address = module_image.GetProcAddress(function_name);
34 if (NULL == *address) {
35 NOTREACHED_NT();
36 return STATUS_UNSUCCESSFUL;
39 return STATUS_SUCCESS;
42 void ServiceResolverThunk::AllowLocalPatches() {
43 ntdll_base_ = ::GetModuleHandle(kNtdllName);
46 } // namespace sandbox