| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef SANDBOX_WOW_HELPER_SERVICE64_RESOLVER_H__ | |
| 6 #define SANDBOX_WOW_HELPER_SERVICE64_RESOLVER_H__ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "sandbox/win/src/nt_internals.h" | |
| 12 #include "sandbox/win/src/resolver.h" | |
| 13 | |
| 14 namespace sandbox { | |
| 15 | |
| 16 // This is the concrete resolver used to perform service-call type functions | |
| 17 // inside ntdll.dll (64-bit). | |
| 18 class Service64ResolverThunk : public ResolverThunk { | |
| 19 public: | |
| 20 // The service resolver needs a child process to write to. | |
| 21 explicit Service64ResolverThunk(HANDLE process) | |
| 22 : process_(process), ntdll_base_(NULL) {} | |
| 23 virtual ~Service64ResolverThunk() {} | |
| 24 | |
| 25 // Implementation of Resolver::Setup. | |
| 26 virtual NTSTATUS Setup(const void* target_module, | |
| 27 const void* interceptor_module, | |
| 28 const char* target_name, | |
| 29 const char* interceptor_name, | |
| 30 const void* interceptor_entry_point, | |
| 31 void* thunk_storage, | |
| 32 size_t storage_bytes, | |
| 33 size_t* storage_used); | |
| 34 | |
| 35 // Implementation of Resolver::ResolveInterceptor. | |
| 36 virtual NTSTATUS ResolveInterceptor(const void* module, | |
| 37 const char* function_name, | |
| 38 const void** address); | |
| 39 | |
| 40 // Implementation of Resolver::ResolveTarget. | |
| 41 virtual NTSTATUS ResolveTarget(const void* module, | |
| 42 const char* function_name, | |
| 43 void** address); | |
| 44 | |
| 45 // Implementation of Resolver::GetThunkSize. | |
| 46 virtual size_t GetThunkSize() const; | |
| 47 | |
| 48 protected: | |
| 49 // The unit test will use this member to allow local patch on a buffer. | |
| 50 HMODULE ntdll_base_; | |
| 51 | |
| 52 // Handle of the child process. | |
| 53 HANDLE process_; | |
| 54 | |
| 55 private: | |
| 56 // Returns true if the code pointer by target_ corresponds to the expected | |
| 57 // type of function. Saves that code on the first part of the thunk pointed | |
| 58 // by local_thunk (should be directly accessible from the parent). | |
| 59 virtual bool IsFunctionAService(void* local_thunk) const; | |
| 60 | |
| 61 // Performs the actual patch of target_. | |
| 62 // local_thunk must be already fully initialized, and the first part must | |
| 63 // contain the original code. The real type of this buffer is ServiceFullThunk | |
| 64 // (yes, private). remote_thunk (real type ServiceFullThunk), must be | |
| 65 // allocated on the child, and will contain the thunk data, after this call. | |
| 66 // Returns the apropriate status code. | |
| 67 virtual NTSTATUS PerformPatch(void* local_thunk, void* remote_thunk); | |
| 68 | |
| 69 DISALLOW_COPY_AND_ASSIGN(Service64ResolverThunk); | |
| 70 }; | |
| 71 | |
| 72 } // namespace sandbox | |
| 73 | |
| 74 | |
| 75 #endif // SANDBOX_WOW_HELPER_SERVICE64_RESOLVER_H__ | |
| OLD | NEW |