Chromium Code Reviews| Index: sandbox/win/tests/integration_tests/hooking_dll.cc |
| diff --git a/sandbox/win/tests/integration_tests/hooking_dll.cc b/sandbox/win/tests/integration_tests/hooking_dll.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d100d254b8131fea5d97384d134d7636e8b5d1fb |
| --- /dev/null |
| +++ b/sandbox/win/tests/integration_tests/hooking_dll.cc |
| @@ -0,0 +1,28 @@ |
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
|
Will Harris
2016/04/04 00:15:09
no (c)
penny
2016/04/11 22:11:59
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <windows.h> |
| +#include <stdio.h> |
| + |
| +#pragma data_seg(".shared") |
| +BOOL hook_called = false; |
|
Will Harris
2016/04/04 00:15:09
why is this linker-fu needed?
penny
2016/04/11 22:11:59
Fair question. I've added some detailed comments.
|
| +#pragma data_seg() |
| +#pragma comment(linker, "/SECTION:.shared,RWS") |
| + |
| +extern "C" __declspec(dllexport) BOOL WasHookCalled() { |
| + return hook_called; |
| +} |
| + |
| +extern "C" __declspec(dllexport) LRESULT |
| + HookProc(int code, WPARAM wParam, LPARAM lParam) { |
| + // Supported versions of Windows do not require the HHOOK to be passed along. |
| + hook_called = true; |
| + return CallNextHookEx(NULL, code, wParam, lParam); |
| +} |
| + |
| +BOOL WINAPI DllMain(__in HINSTANCE hinstDLL, |
| + __in DWORD reason, |
| + __in LPVOID lpvReserved) { |
| + return TRUE; |
| +} |