Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Copyright (c) 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 | #ifndef SANDBOX_SRC_SIDESTEP_RESOLVER_H__ |
michael@0 | 6 | #define SANDBOX_SRC_SIDESTEP_RESOLVER_H__ |
michael@0 | 7 | |
michael@0 | 8 | #include "base/basictypes.h" |
michael@0 | 9 | #include "sandbox/win/src/nt_internals.h" |
michael@0 | 10 | #include "sandbox/win/src/resolver.h" |
michael@0 | 11 | |
michael@0 | 12 | namespace sandbox { |
michael@0 | 13 | |
michael@0 | 14 | // This is the concrete resolver used to perform sidestep interceptions. |
michael@0 | 15 | class SidestepResolverThunk : public ResolverThunk { |
michael@0 | 16 | public: |
michael@0 | 17 | SidestepResolverThunk() {} |
michael@0 | 18 | virtual ~SidestepResolverThunk() {} |
michael@0 | 19 | |
michael@0 | 20 | // Implementation of Resolver::Setup. |
michael@0 | 21 | virtual NTSTATUS Setup(const void* target_module, |
michael@0 | 22 | const void* interceptor_module, |
michael@0 | 23 | const char* target_name, |
michael@0 | 24 | const char* interceptor_name, |
michael@0 | 25 | const void* interceptor_entry_point, |
michael@0 | 26 | void* thunk_storage, |
michael@0 | 27 | size_t storage_bytes, |
michael@0 | 28 | size_t* storage_used); |
michael@0 | 29 | |
michael@0 | 30 | // Implementation of Resolver::GetThunkSize. |
michael@0 | 31 | virtual size_t GetThunkSize() const; |
michael@0 | 32 | |
michael@0 | 33 | private: |
michael@0 | 34 | DISALLOW_COPY_AND_ASSIGN(SidestepResolverThunk); |
michael@0 | 35 | }; |
michael@0 | 36 | |
michael@0 | 37 | // This is the concrete resolver used to perform smart sidestep interceptions. |
michael@0 | 38 | // This means basically a sidestep interception that skips the interceptor when |
michael@0 | 39 | // the caller resides on the same dll being intercepted. It is intended as |
michael@0 | 40 | // a helper only, because that determination is not infallible. |
michael@0 | 41 | class SmartSidestepResolverThunk : public SidestepResolverThunk { |
michael@0 | 42 | public: |
michael@0 | 43 | SmartSidestepResolverThunk() {} |
michael@0 | 44 | virtual ~SmartSidestepResolverThunk() {} |
michael@0 | 45 | |
michael@0 | 46 | // Implementation of Resolver::Setup. |
michael@0 | 47 | virtual NTSTATUS Setup(const void* target_module, |
michael@0 | 48 | const void* interceptor_module, |
michael@0 | 49 | const char* target_name, |
michael@0 | 50 | const char* interceptor_name, |
michael@0 | 51 | const void* interceptor_entry_point, |
michael@0 | 52 | void* thunk_storage, |
michael@0 | 53 | size_t storage_bytes, |
michael@0 | 54 | size_t* storage_used); |
michael@0 | 55 | |
michael@0 | 56 | // Implementation of Resolver::GetThunkSize. |
michael@0 | 57 | virtual size_t GetThunkSize() const; |
michael@0 | 58 | |
michael@0 | 59 | private: |
michael@0 | 60 | // Performs the actual call to the interceptor if the conditions are correct |
michael@0 | 61 | // (as determined by IsInternalCall). |
michael@0 | 62 | static void SmartStub(); |
michael@0 | 63 | |
michael@0 | 64 | // Returns true if return_address is inside the module loaded at base. |
michael@0 | 65 | static bool IsInternalCall(const void* base, void* return_address); |
michael@0 | 66 | |
michael@0 | 67 | DISALLOW_COPY_AND_ASSIGN(SmartSidestepResolverThunk); |
michael@0 | 68 | }; |
michael@0 | 69 | |
michael@0 | 70 | } // namespace sandbox |
michael@0 | 71 | |
michael@0 | 72 | |
michael@0 | 73 | #endif // SANDBOX_SRC_SIDESTEP_RESOLVER_H__ |