security/sandbox/win/src/service_resolver.cc

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 // Copyright (c) 2006-2010 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/logging.h"
     8 #include "base/win/pe_image.h"
    10 namespace sandbox {
    12 NTSTATUS ServiceResolverThunk::ResolveInterceptor(
    13     const void* interceptor_module,
    14     const char* interceptor_name,
    15     const void** address) {
    16   // After all, we are using a locally mapped version of the exe, so the
    17   // action is the same as for a target function.
    18   return ResolveTarget(interceptor_module, interceptor_name,
    19                        const_cast<void**>(address));
    20 }
    22 // In this case all the work is done from the parent, so resolve is
    23 // just a simple GetProcAddress.
    24 NTSTATUS ServiceResolverThunk::ResolveTarget(const void* module,
    25                                              const char* function_name,
    26                                              void** address) {
    27   DCHECK(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();
    36     return STATUS_UNSUCCESSFUL;
    37   }
    39   return STATUS_SUCCESS;
    40 }
    42 }  // namespace sandbox

mercurial