security/sandbox/win/src/service_resolver.cc

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 #include "sandbox/win/src/service_resolver.h"
michael@0 6
michael@0 7 #include "base/logging.h"
michael@0 8 #include "base/win/pe_image.h"
michael@0 9
michael@0 10 namespace sandbox {
michael@0 11
michael@0 12 NTSTATUS ServiceResolverThunk::ResolveInterceptor(
michael@0 13 const void* interceptor_module,
michael@0 14 const char* interceptor_name,
michael@0 15 const void** address) {
michael@0 16 // After all, we are using a locally mapped version of the exe, so the
michael@0 17 // action is the same as for a target function.
michael@0 18 return ResolveTarget(interceptor_module, interceptor_name,
michael@0 19 const_cast<void**>(address));
michael@0 20 }
michael@0 21
michael@0 22 // In this case all the work is done from the parent, so resolve is
michael@0 23 // just a simple GetProcAddress.
michael@0 24 NTSTATUS ServiceResolverThunk::ResolveTarget(const void* module,
michael@0 25 const char* function_name,
michael@0 26 void** address) {
michael@0 27 DCHECK(address);
michael@0 28 if (NULL == module)
michael@0 29 return STATUS_UNSUCCESSFUL;
michael@0 30
michael@0 31 base::win::PEImage module_image(module);
michael@0 32 *address = module_image.GetProcAddress(function_name);
michael@0 33
michael@0 34 if (NULL == *address) {
michael@0 35 NOTREACHED();
michael@0 36 return STATUS_UNSUCCESSFUL;
michael@0 37 }
michael@0 38
michael@0 39 return STATUS_SUCCESS;
michael@0 40 }
michael@0 41
michael@0 42 } // namespace sandbox

mercurial