| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 CHROME_ELF_HOOK_UTIL_THUNK_GETTER_H_ | |
| 6 #define CHROME_ELF_HOOK_UTIL_THUNK_GETTER_H_ | |
| 7 | |
| 8 #include <windows.h> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 | |
| 12 namespace sandbox { | |
| 13 class ServiceResolverThunk; | |
| 14 } | |
| 15 | |
| 16 namespace elf_hook { | |
| 17 | |
| 18 //------------------------------------------------------------------------------ | |
| 19 // System Service hooking support | |
| 20 //------------------------------------------------------------------------------ | |
| 21 | |
| 22 // Creates a |ServiceResolverThunk| based on the OS version. Ownership of the | |
| 23 // resulting thunk is passed to the caller. | |
| 24 sandbox::ServiceResolverThunk* HookSystemService(bool relaxed); | |
| 25 | |
| 26 //------------------------------------------------------------------------------ | |
| 27 // Import Address Table hooking support | |
| 28 //------------------------------------------------------------------------------ | |
| 29 class IATHook { | |
| 30 public: | |
| 31 IATHook(); | |
| 32 ~IATHook(); | |
| 33 | |
| 34 // Intercept a function in an import table of a specific | |
| 35 // module. Saves everything needed to Unhook. | |
| 36 // | |
| 37 // NOTE: Hook can only be called once at a time, to enable Unhook(). | |
| 38 // | |
| 39 // Arguments: | |
| 40 // module Module to be intercepted | |
| 41 // imported_from_module Module that exports the 'function_name' | |
| 42 // function_name Name of the API to be intercepted | |
| 43 // new_function New function pointer | |
| 44 // | |
| 45 // Returns: Windows error code (winerror.h). NO_ERROR if successful. | |
| 46 DWORD Hook(HMODULE module, | |
| 47 const char* imported_from_module, | |
| 48 const char* function_name, | |
| 49 void* new_function); | |
| 50 | |
| 51 // Unhook the IAT entry. | |
| 52 // | |
| 53 // Returns: Windows error code (winerror.h). NO_ERROR if successful. | |
| 54 DWORD Unhook(); | |
| 55 | |
| 56 private: | |
| 57 void* intercept_function_; | |
| 58 void* original_function_; | |
| 59 IMAGE_THUNK_DATA* iat_thunk_; | |
| 60 | |
| 61 DISALLOW_COPY_AND_ASSIGN(IATHook); | |
| 62 }; | |
| 63 | |
| 64 } // namespace elf_hook | |
| 65 | |
| 66 #endif // CHROME_ELF_HOOK_UTIL_THUNK_GETTER_H_ | |
| OLD | NEW |