1 // Copyright (c) 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 #ifndef SANDBOX_SRC_SIDESTEP_RESOLVER_H__
6 #define SANDBOX_SRC_SIDESTEP_RESOLVER_H__
8 #include "base/basictypes.h"
9 #include "sandbox/win/src/nt_internals.h"
10 #include "sandbox/win/src/resolver.h"
14 // This is the concrete resolver used to perform sidestep interceptions.
15 class SidestepResolverThunk : public ResolverThunk {
17 SidestepResolverThunk() {}
18 virtual ~SidestepResolverThunk() {}
20 // Implementation of Resolver::Setup.
21 virtual NTSTATUS Setup(const void* target_module,
22 const void* interceptor_module,
23 const char* target_name,
24 const char* interceptor_name,
25 const void* interceptor_entry_point,
28 size_t* storage_used);
30 // Implementation of Resolver::GetThunkSize.
31 virtual size_t GetThunkSize() const;
34 DISALLOW_COPY_AND_ASSIGN(SidestepResolverThunk);
37 // This is the concrete resolver used to perform smart sidestep interceptions.
38 // This means basically a sidestep interception that skips the interceptor when
39 // the caller resides on the same dll being intercepted. It is intended as
40 // a helper only, because that determination is not infallible.
41 class SmartSidestepResolverThunk : public SidestepResolverThunk {
43 SmartSidestepResolverThunk() {}
44 virtual ~SmartSidestepResolverThunk() {}
46 // Implementation of Resolver::Setup.
47 virtual NTSTATUS Setup(const void* target_module,
48 const void* interceptor_module,
49 const char* target_name,
50 const char* interceptor_name,
51 const void* interceptor_entry_point,
54 size_t* storage_used);
56 // Implementation of Resolver::GetThunkSize.
57 virtual size_t GetThunkSize() const;
60 // Performs the actual call to the interceptor if the conditions are correct
61 // (as determined by IsInternalCall).
62 static void SmartStub();
64 // Returns true if return_address is inside the module loaded at base.
65 static bool IsInternalCall(const void* base, void* return_address);
67 DISALLOW_COPY_AND_ASSIGN(SmartSidestepResolverThunk);
70 } // namespace sandbox
73 #endif // SANDBOX_SRC_SIDESTEP_RESOLVER_H__