OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SANDBOX_SRC_SIDESTEP_RESOLVER_H__ | 5 #ifndef SANDBOX_SRC_SIDESTEP_RESOLVER_H__ |
6 #define SANDBOX_SRC_SIDESTEP_RESOLVER_H__ | 6 #define SANDBOX_SRC_SIDESTEP_RESOLVER_H__ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "sandbox/win/src/nt_internals.h" | 9 #include "sandbox/win/src/nt_internals.h" |
10 #include "sandbox/win/src/resolver.h" | 10 #include "sandbox/win/src/resolver.h" |
11 | 11 |
12 namespace sandbox { | 12 namespace sandbox { |
13 | 13 |
14 // This is the concrete resolver used to perform sidestep interceptions. | 14 // This is the concrete resolver used to perform sidestep interceptions. |
15 class SidestepResolverThunk : public ResolverThunk { | 15 class SidestepResolverThunk : public ResolverThunk { |
16 public: | 16 public: |
17 SidestepResolverThunk() {} | 17 SidestepResolverThunk() {} |
18 virtual ~SidestepResolverThunk() {} | 18 ~SidestepResolverThunk() override {} |
19 | 19 |
20 // Implementation of Resolver::Setup. | 20 // Implementation of Resolver::Setup. |
21 virtual NTSTATUS Setup(const void* target_module, | 21 NTSTATUS Setup(const void* target_module, |
22 const void* interceptor_module, | 22 const void* interceptor_module, |
23 const char* target_name, | 23 const char* target_name, |
24 const char* interceptor_name, | 24 const char* interceptor_name, |
25 const void* interceptor_entry_point, | 25 const void* interceptor_entry_point, |
26 void* thunk_storage, | 26 void* thunk_storage, |
27 size_t storage_bytes, | 27 size_t storage_bytes, |
28 size_t* storage_used); | 28 size_t* storage_used) override; |
29 | 29 |
30 // Implementation of Resolver::GetThunkSize. | 30 // Implementation of Resolver::GetThunkSize. |
31 virtual size_t GetThunkSize() const; | 31 size_t GetThunkSize() const override; |
32 | 32 |
33 private: | 33 private: |
34 DISALLOW_COPY_AND_ASSIGN(SidestepResolverThunk); | 34 DISALLOW_COPY_AND_ASSIGN(SidestepResolverThunk); |
35 }; | 35 }; |
36 | 36 |
37 // This is the concrete resolver used to perform smart sidestep interceptions. | 37 // This is the concrete resolver used to perform smart sidestep interceptions. |
38 // This means basically a sidestep interception that skips the interceptor when | 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 | 39 // the caller resides on the same dll being intercepted. It is intended as |
40 // a helper only, because that determination is not infallible. | 40 // a helper only, because that determination is not infallible. |
41 class SmartSidestepResolverThunk : public SidestepResolverThunk { | 41 class SmartSidestepResolverThunk : public SidestepResolverThunk { |
42 public: | 42 public: |
43 SmartSidestepResolverThunk() {} | 43 SmartSidestepResolverThunk() {} |
44 virtual ~SmartSidestepResolverThunk() {} | 44 ~SmartSidestepResolverThunk() override {} |
45 | 45 |
46 // Implementation of Resolver::Setup. | 46 // Implementation of Resolver::Setup. |
47 virtual NTSTATUS Setup(const void* target_module, | 47 NTSTATUS Setup(const void* target_module, |
48 const void* interceptor_module, | 48 const void* interceptor_module, |
49 const char* target_name, | 49 const char* target_name, |
50 const char* interceptor_name, | 50 const char* interceptor_name, |
51 const void* interceptor_entry_point, | 51 const void* interceptor_entry_point, |
52 void* thunk_storage, | 52 void* thunk_storage, |
53 size_t storage_bytes, | 53 size_t storage_bytes, |
54 size_t* storage_used); | 54 size_t* storage_used) override; |
55 | 55 |
56 // Implementation of Resolver::GetThunkSize. | 56 // Implementation of Resolver::GetThunkSize. |
57 virtual size_t GetThunkSize() const; | 57 size_t GetThunkSize() const override; |
58 | 58 |
59 private: | 59 private: |
60 // Performs the actual call to the interceptor if the conditions are correct | 60 // Performs the actual call to the interceptor if the conditions are correct |
61 // (as determined by IsInternalCall). | 61 // (as determined by IsInternalCall). |
62 static void SmartStub(); | 62 static void SmartStub(); |
63 | 63 |
64 // Returns true if return_address is inside the module loaded at base. | 64 // Returns true if return_address is inside the module loaded at base. |
65 static bool IsInternalCall(const void* base, void* return_address); | 65 static bool IsInternalCall(const void* base, void* return_address); |
66 | 66 |
67 DISALLOW_COPY_AND_ASSIGN(SmartSidestepResolverThunk); | 67 DISALLOW_COPY_AND_ASSIGN(SmartSidestepResolverThunk); |
68 }; | 68 }; |
69 | 69 |
70 } // namespace sandbox | 70 } // namespace sandbox |
71 | 71 |
72 | 72 |
73 #endif // SANDBOX_SRC_SIDESTEP_RESOLVER_H__ | 73 #endif // SANDBOX_SRC_SIDESTEP_RESOLVER_H__ |
OLD | NEW |