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

Unified Diff: sandbox/win/tests/integration_tests/hooking_dll.cc

Issue 2944493002: [Windows Sandbox Tests] Process Mitigations. (Closed)
Patch Set: Code review fixes, part 2. Created 3 years, 6 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
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
index f275ae6e940208bc65b71ddeced35199cb7827a7..4dffe047d6630013a41855e22532f60c811fcc9d 100644
--- a/sandbox/win/tests/integration_tests/hooking_dll.cc
+++ b/sandbox/win/tests/integration_tests/hooking_dll.cc
@@ -5,8 +5,8 @@
#include <stdio.h>
#include <windows.h>
-#define _DLL_EXPORTING
-#include "integration_tests_common.h"
+#define BUILDING_DLL
+#include "hooking_dll.h"
// This data section creates a common area that is accessible
// to all instances of the DLL (in every process). They map to
@@ -24,10 +24,11 @@ bool hook_called = false;
#pragma comment(linker, "/SECTION:.hook,RWS")
namespace {
-
HANDLE event = NULL;
}
+namespace hooking_dll {
+
void SetHook(HHOOK hook_handle) {
hook = hook_handle;
@@ -50,14 +51,16 @@ LRESULT HookProc(int code, WPARAM w_param, LPARAM l_param) {
return CallNextHookEx(hook, code, w_param, l_param);
}
+} // namespace hooking_dll
+
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) {
if (reason == DLL_PROCESS_ATTACH) {
// The testing process should have set up this named event already
// (if the test needs this event to be signaled).
- event = ::OpenEventW(EVENT_MODIFY_STATE, FALSE, g_hook_event);
+ event = ::OpenEventW(EVENT_MODIFY_STATE, FALSE, hooking_dll::g_hook_event);
}
- if (reason == DLL_PROCESS_DETACH)
+ if (reason == DLL_PROCESS_DETACH && event != nullptr)
::CloseHandle(event);
return TRUE;
« no previous file with comments | « sandbox/win/tests/integration_tests/hooking_dll.h ('k') | sandbox/win/tests/integration_tests/hooking_win_proc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698