Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / sandbox / win / src / sidestep_resolver.h
blobcf03d6e812a06c0a4d35fefa86f3815aa120f349
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"
12 namespace sandbox {
14 // This is the concrete resolver used to perform sidestep interceptions.
15 class SidestepResolverThunk : public ResolverThunk {
16 public:
17 SidestepResolverThunk() {}
18 ~SidestepResolverThunk() override {}
20 // Implementation of Resolver::Setup.
21 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,
26 void* thunk_storage,
27 size_t storage_bytes,
28 size_t* storage_used) override;
30 // Implementation of Resolver::GetThunkSize.
31 size_t GetThunkSize() const override;
33 private:
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 {
42 public:
43 SmartSidestepResolverThunk() {}
44 ~SmartSidestepResolverThunk() override {}
46 // Implementation of Resolver::Setup.
47 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,
52 void* thunk_storage,
53 size_t storage_bytes,
54 size_t* storage_used) override;
56 // Implementation of Resolver::GetThunkSize.
57 size_t GetThunkSize() const override;
59 private:
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__