OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdio.h> | 5 #include <stdio.h> |
6 #include <windows.h> | 6 #include <windows.h> |
7 | 7 |
8 #define _DLL_EXPORTING | |
9 #include "integration_tests_common.h" | 8 #include "integration_tests_common.h" |
10 | 9 |
11 // This data section creates a common area that is accessible | 10 // This data section creates a common area that is accessible |
12 // to all instances of the DLL (in every process). They map to | 11 // to all instances of the DLL (in every process). They map to |
13 // the same physical memory location. | 12 // the same physical memory location. |
14 // **Note that each instance of this DLL runs in the context of | 13 // **Note that each instance of this DLL runs in the context of |
15 // the process it's injected into, so things like pointers and | 14 // the process it's injected into, so things like pointers and |
16 // addresses won't work. | 15 // addresses won't work. |
17 // **Note that any variables must be initialized to put them in | 16 // **Note that any variables must be initialized to put them in |
18 // the specified segment, otherwise they will end up in the | 17 // the specified segment, otherwise they will end up in the |
(...skipping 28 matching lines...) Expand all Loading... |
47 // but I'm doing it here to show the shared use of the HHOOK variable in | 46 // but I'm doing it here to show the shared use of the HHOOK variable in |
48 // the shared data segment. It is set by the instance of the DLL in the | 47 // the shared data segment. It is set by the instance of the DLL in the |
49 // main test process. | 48 // main test process. |
50 return CallNextHookEx(hook, code, w_param, l_param); | 49 return CallNextHookEx(hook, code, w_param, l_param); |
51 } | 50 } |
52 | 51 |
53 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) { | 52 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) { |
54 if (reason == DLL_PROCESS_ATTACH) { | 53 if (reason == DLL_PROCESS_ATTACH) { |
55 // The testing process should have set up this named event already | 54 // The testing process should have set up this named event already |
56 // (if the test needs this event to be signaled). | 55 // (if the test needs this event to be signaled). |
57 event = ::OpenEventW(EVENT_MODIFY_STATE, FALSE, g_hook_event); | 56 event = ::OpenEventW(EVENT_MODIFY_STATE, FALSE, sandbox::g_hook_event); |
58 } | 57 } |
59 | 58 |
60 if (reason == DLL_PROCESS_DETACH) | 59 if (reason == DLL_PROCESS_DETACH && event != nullptr) |
61 ::CloseHandle(event); | 60 ::CloseHandle(event); |
62 | 61 |
63 return TRUE; | 62 return TRUE; |
64 } | 63 } |
OLD | NEW |