Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7171)

Unified Diff: chrome_elf/hook_util/hook_util.h

Issue 2183263003: [chrome_elf] Big ELF cleanup. Part 1. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update with latest trunk. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome_elf/elf_imports_unittest.cc ('k') | chrome_elf/hook_util/hook_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..91850451e80a7b230ced84b9a5ddf237e19fe0ed
--- /dev/null
+++ b/chrome_elf/hook_util/hook_util.h
@@ -0,0 +1,66 @@
+// 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 {
+
+//------------------------------------------------------------------------------
+// System Service hooking support
+//------------------------------------------------------------------------------
+
+// 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 {
+ public:
+ IATHook();
+ ~IATHook();
+
+ // Intercept a function in an import table of a specific
+ // module. Saves everything needed to Unhook.
+ //
+ // NOTE: Hook can only be called once at a time, to enable 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
+ // new_function New function pointer
+ //
+ // Returns: Windows error code (winerror.h). NO_ERROR if successful.
+ DWORD Hook(HMODULE module,
+ 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:
+ void* intercept_function_;
+ void* original_function_;
+ IMAGE_THUNK_DATA* iat_thunk_;
+
+ DISALLOW_COPY_AND_ASSIGN(IATHook);
+};
+
+} // namespace elf_hook
+
+#endif // CHROME_ELF_HOOK_UTIL_THUNK_GETTER_H_
« no previous file with comments | « chrome_elf/elf_imports_unittest.cc ('k') | chrome_elf/hook_util/hook_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698