Chromium Code Reviews| Index: chrome_elf/hook_util/hook_util.h |
| diff --git a/chrome_elf/hook_util/hook_util.h b/chrome_elf/hook_util/hook_util.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b197a516d61bfd22757bb77e732c22251d0c5614 |
| --- /dev/null |
| +++ b/chrome_elf/hook_util/hook_util.h |
| @@ -0,0 +1,63 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_ELF_HOOK_UTIL_THUNK_GETTER_H_ |
| +#define CHROME_ELF_HOOK_UTIL_THUNK_GETTER_H_ |
| + |
| +#include <windows.h> |
| + |
| +#include "base/macros.h" |
| + |
| +namespace sandbox { |
| +class ServiceResolverThunk; |
| +} |
| + |
| +namespace elf_hook { |
| + |
| +//------------------------------------------------------------------------------ |
| +// Systen Service hooking support |
|
robertshield
2016/08/03 04:52:45
s/Systen/System/
penny
2016/08/04 18:55:35
Done.
|
| +//------------------------------------------------------------------------------ |
| + |
| +// Creates a |ServiceResolverThunk| based on the OS version. Ownership of the |
| +// resulting thunk is passed to the caller. |
| +sandbox::ServiceResolverThunk* HookSystemService(bool relaxed); |
| + |
| +//------------------------------------------------------------------------------ |
| +// Import Address Table hooking support |
| +//------------------------------------------------------------------------------ |
| +class IATHook { |
|
robertshield
2016/08/03 04:52:45
It would be pretty cool (and not too much work I t
penny
2016/08/04 18:55:35
Done.
Was going to leave this until I finish remov
|
| + public: |
| + IATHook(); |
| + ~IATHook(); |
| + |
| + // Intercept a function in an import table of a specific |
| + // module. Saves everything needed to Unhook. |
| + // |
| + // Arguments: |
| + // module Module to be intercepted |
| + // imported_from_module Module that exports the 'function_name' |
| + // function_name Name of the API to be intercepted |
|
robertshield
2016/08/03 04:52:45
new_function should be added here for completeness
penny
2016/08/04 18:55:35
Done.
|
| + // |
| + // Returns: Windows error code (winerror.h). NO_ERROR if successful. |
| + DWORD Hook(HMODULE module, |
|
robertshield
2016/08/03 04:52:45
From the implementation, it looks like Hook should
penny
2016/08/04 18:55:35
Done.
|
| + const char* imported_from_module, |
| + const char* function_name, |
| + void* new_function); |
| + |
| + // Unhook the IAT entry. |
| + // |
| + // Returns: Windows error code (winerror.h). NO_ERROR if successful. |
| + DWORD Unhook(); |
| + |
| + private: |
| + HMODULE module_handle_; |
| + void* intercept_function_; |
| + void* original_function_; |
| + IMAGE_THUNK_DATA* iat_thunk_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(elf_hook::IATHook); |
| +}; |
| +} |
| + |
| +#endif // CHROME_ELF_HOOK_UTIL_THUNK_GETTER_H_ |