OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SERVICE_RESOLVER_H__ | 5 #ifndef SANDBOX_SRC_SERVICE_RESOLVER_H__ |
6 #define SANDBOX_SRC_SERVICE_RESOLVER_H__ | 6 #define SANDBOX_SRC_SERVICE_RESOLVER_H__ |
7 | 7 |
8 #include "sandbox/win/src/nt_internals.h" | 8 #include "sandbox/win/src/nt_internals.h" |
9 #include "sandbox/win/src/resolver.h" | 9 #include "sandbox/win/src/resolver.h" |
10 | 10 |
11 namespace sandbox { | 11 namespace sandbox { |
12 | 12 |
13 // This is the concrete resolver used to perform service-call type functions | 13 // This is the concrete resolver used to perform service-call type functions |
14 // inside ntdll.dll. | 14 // inside ntdll.dll. |
15 class ServiceResolverThunk : public ResolverThunk { | 15 class ServiceResolverThunk : public ResolverThunk { |
16 public: | 16 public: |
17 // The service resolver needs a child process to write to. | 17 // The service resolver needs a child process to write to. |
18 ServiceResolverThunk(HANDLE process, bool relaxed) | 18 ServiceResolverThunk(HANDLE process, bool relaxed) |
19 : process_(process), ntdll_base_(NULL), | 19 : process_(process), ntdll_base_(NULL), |
20 relaxed_(relaxed), relative_jump_(0) {} | 20 relaxed_(relaxed), relative_jump_(0) {} |
21 virtual ~ServiceResolverThunk() {} | 21 ~ServiceResolverThunk() override {} |
22 | 22 |
23 // Implementation of Resolver::Setup. | 23 // Implementation of Resolver::Setup. |
24 virtual NTSTATUS Setup(const void* target_module, | 24 NTSTATUS Setup(const void* target_module, |
25 const void* interceptor_module, | 25 const void* interceptor_module, |
26 const char* target_name, | 26 const char* target_name, |
27 const char* interceptor_name, | 27 const char* interceptor_name, |
28 const void* interceptor_entry_point, | 28 const void* interceptor_entry_point, |
29 void* thunk_storage, | 29 void* thunk_storage, |
30 size_t storage_bytes, | 30 size_t storage_bytes, |
31 size_t* storage_used); | 31 size_t* storage_used) override; |
32 | 32 |
33 // Implementation of Resolver::ResolveInterceptor. | 33 // Implementation of Resolver::ResolveInterceptor. |
34 virtual NTSTATUS ResolveInterceptor(const void* module, | 34 NTSTATUS ResolveInterceptor(const void* module, |
35 const char* function_name, | 35 const char* function_name, |
36 const void** address); | 36 const void** address) override; |
37 | 37 |
38 // Implementation of Resolver::ResolveTarget. | 38 // Implementation of Resolver::ResolveTarget. |
39 virtual NTSTATUS ResolveTarget(const void* module, | 39 NTSTATUS ResolveTarget(const void* module, |
40 const char* function_name, | 40 const char* function_name, |
41 void** address); | 41 void** address) override; |
42 | 42 |
43 // Implementation of Resolver::GetThunkSize. | 43 // Implementation of Resolver::GetThunkSize. |
44 virtual size_t GetThunkSize() const; | 44 size_t GetThunkSize() const override; |
45 | 45 |
46 // Call this to set up ntdll_base_ which will allow for local patches. | 46 // Call this to set up ntdll_base_ which will allow for local patches. |
47 virtual void AllowLocalPatches(); | 47 virtual void AllowLocalPatches(); |
48 | 48 |
49 // Verifies that the function specified by |target_name| in |target_module| is | 49 // Verifies that the function specified by |target_name| in |target_module| is |
50 // a service and copies the data from that function into |thunk_storage|. If | 50 // a service and copies the data from that function into |thunk_storage|. If |
51 // |storage_bytes| is too small, then the method fails. | 51 // |storage_bytes| is too small, then the method fails. |
52 virtual NTSTATUS CopyThunk(const void* target_module, | 52 virtual NTSTATUS CopyThunk(const void* target_module, |
53 const char* target_name, | 53 const char* target_name, |
54 BYTE* thunk_storage, | 54 BYTE* thunk_storage, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 DISALLOW_COPY_AND_ASSIGN(ServiceResolverThunk); | 88 DISALLOW_COPY_AND_ASSIGN(ServiceResolverThunk); |
89 }; | 89 }; |
90 | 90 |
91 // This is the concrete resolver used to perform service-call type functions | 91 // This is the concrete resolver used to perform service-call type functions |
92 // inside ntdll.dll on WOW64 (32 bit ntdll on 64 bit Vista). | 92 // inside ntdll.dll on WOW64 (32 bit ntdll on 64 bit Vista). |
93 class Wow64ResolverThunk : public ServiceResolverThunk { | 93 class Wow64ResolverThunk : public ServiceResolverThunk { |
94 public: | 94 public: |
95 // The service resolver needs a child process to write to. | 95 // The service resolver needs a child process to write to. |
96 Wow64ResolverThunk(HANDLE process, bool relaxed) | 96 Wow64ResolverThunk(HANDLE process, bool relaxed) |
97 : ServiceResolverThunk(process, relaxed) {} | 97 : ServiceResolverThunk(process, relaxed) {} |
98 virtual ~Wow64ResolverThunk() {} | 98 ~Wow64ResolverThunk() override {} |
99 | 99 |
100 private: | 100 private: |
101 virtual bool IsFunctionAService(void* local_thunk) const; | 101 bool IsFunctionAService(void* local_thunk) const override; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(Wow64ResolverThunk); | 103 DISALLOW_COPY_AND_ASSIGN(Wow64ResolverThunk); |
104 }; | 104 }; |
105 | 105 |
106 // This is the concrete resolver used to perform service-call type functions | 106 // This is the concrete resolver used to perform service-call type functions |
107 // inside ntdll.dll on WOW64 for Windows 8. | 107 // inside ntdll.dll on WOW64 for Windows 8. |
108 class Wow64W8ResolverThunk : public ServiceResolverThunk { | 108 class Wow64W8ResolverThunk : public ServiceResolverThunk { |
109 public: | 109 public: |
110 // The service resolver needs a child process to write to. | 110 // The service resolver needs a child process to write to. |
111 Wow64W8ResolverThunk(HANDLE process, bool relaxed) | 111 Wow64W8ResolverThunk(HANDLE process, bool relaxed) |
112 : ServiceResolverThunk(process, relaxed) {} | 112 : ServiceResolverThunk(process, relaxed) {} |
113 virtual ~Wow64W8ResolverThunk() {} | 113 ~Wow64W8ResolverThunk() override {} |
114 | 114 |
115 private: | 115 private: |
116 virtual bool IsFunctionAService(void* local_thunk) const; | 116 bool IsFunctionAService(void* local_thunk) const override; |
117 | 117 |
118 DISALLOW_COPY_AND_ASSIGN(Wow64W8ResolverThunk); | 118 DISALLOW_COPY_AND_ASSIGN(Wow64W8ResolverThunk); |
119 }; | 119 }; |
120 | 120 |
121 // This is the concrete resolver used to perform service-call type functions | 121 // This is the concrete resolver used to perform service-call type functions |
122 // inside ntdll.dll on Windows 8. | 122 // inside ntdll.dll on Windows 8. |
123 class Win8ResolverThunk : public ServiceResolverThunk { | 123 class Win8ResolverThunk : public ServiceResolverThunk { |
124 public: | 124 public: |
125 // The service resolver needs a child process to write to. | 125 // The service resolver needs a child process to write to. |
126 Win8ResolverThunk(HANDLE process, bool relaxed) | 126 Win8ResolverThunk(HANDLE process, bool relaxed) |
127 : ServiceResolverThunk(process, relaxed) {} | 127 : ServiceResolverThunk(process, relaxed) {} |
128 virtual ~Win8ResolverThunk() {} | 128 ~Win8ResolverThunk() override {} |
129 | 129 |
130 private: | 130 private: |
131 virtual bool IsFunctionAService(void* local_thunk) const; | 131 bool IsFunctionAService(void* local_thunk) const override; |
132 | 132 |
133 DISALLOW_COPY_AND_ASSIGN(Win8ResolverThunk); | 133 DISALLOW_COPY_AND_ASSIGN(Win8ResolverThunk); |
134 }; | 134 }; |
135 | 135 |
136 } // namespace sandbox | 136 } // namespace sandbox |
137 | 137 |
138 | 138 |
139 #endif // SANDBOX_SRC_SERVICE_RESOLVER_H__ | 139 #endif // SANDBOX_SRC_SERVICE_RESOLVER_H__ |
OLD | NEW |