security/sandbox/win/src/service_resolver.cc

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/sandbox/win/src/service_resolver.cc	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,42 @@
     1.4 +// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#include "sandbox/win/src/service_resolver.h"
     1.9 +
    1.10 +#include "base/logging.h"
    1.11 +#include "base/win/pe_image.h"
    1.12 +
    1.13 +namespace sandbox {
    1.14 +
    1.15 +NTSTATUS ServiceResolverThunk::ResolveInterceptor(
    1.16 +    const void* interceptor_module,
    1.17 +    const char* interceptor_name,
    1.18 +    const void** address) {
    1.19 +  // After all, we are using a locally mapped version of the exe, so the
    1.20 +  // action is the same as for a target function.
    1.21 +  return ResolveTarget(interceptor_module, interceptor_name,
    1.22 +                       const_cast<void**>(address));
    1.23 +}
    1.24 +
    1.25 +// In this case all the work is done from the parent, so resolve is
    1.26 +// just a simple GetProcAddress.
    1.27 +NTSTATUS ServiceResolverThunk::ResolveTarget(const void* module,
    1.28 +                                             const char* function_name,
    1.29 +                                             void** address) {
    1.30 +  DCHECK(address);
    1.31 +  if (NULL == module)
    1.32 +    return STATUS_UNSUCCESSFUL;
    1.33 +
    1.34 +  base::win::PEImage module_image(module);
    1.35 +  *address = module_image.GetProcAddress(function_name);
    1.36 +
    1.37 +  if (NULL == *address) {
    1.38 +    NOTREACHED();
    1.39 +    return STATUS_UNSUCCESSFUL;
    1.40 +  }
    1.41 +
    1.42 +  return STATUS_SUCCESS;
    1.43 +}
    1.44 +
    1.45 +}  // namespace sandbox

mercurial