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

Side by Side Diff: sandbox/win/tests/integration_tests/hooking_win_proc.cc

Issue 2944493002: [Windows Sandbox Tests] Process Mitigations. (Closed)
Patch Set: Code review fixes, part 1. Created 3 years, 5 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 unified diff | Download patch
OLDNEW
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 "integration_tests_common.h" 5 #include <windows.h>
6 6
7 #include <windows.h> 7 #include "hooking_win_proc.h"
8
9 namespace {
10
11 constexpr wchar_t g_winproc_class_name[] = L"myWindowClass";
Will Harris 2017/06/28 12:27:55 declare these closest to use, so that would be ins
penny 2017/06/28 22:33:33 Done.
12 constexpr wchar_t g_winproc_window_name[] = L"ChromeMitigationTests";
13
14 } // namespace
8 15
9 LRESULT CALLBACK WndProc(HWND window, 16 LRESULT CALLBACK WndProc(HWND window,
10 UINT message, 17 UINT message,
11 WPARAM w_param, 18 WPARAM w_param,
12 LPARAM l_param) { 19 LPARAM l_param) {
13 // Injected keystroke via PostThreadMessage won't be dispatched to here. 20 // Injected keystroke via PostThreadMessage won't be dispatched to here.
14 // Have to use SendMessage or SendInput to trigger the keyboard hook. 21 // Have to use SendMessage or SendInput to trigger the keyboard hook.
15 switch (message) { 22 switch (message) {
16 case WM_KEYDOWN: 23 case WM_KEYDOWN:
17 break; 24 break;
18 case WM_KEYUP: 25 case WM_KEYUP:
19 break; 26 break;
20 case WM_CLOSE: 27 case WM_CLOSE:
21 ::DestroyWindow(window); 28 ::DestroyWindow(window);
22 break; 29 break;
23 case WM_DESTROY: 30 case WM_DESTROY:
24 ::PostQuitMessage(0); 31 ::PostQuitMessage(0);
25 break; 32 break;
26 default: 33 default:
27 return ::DefWindowProc(window, message, w_param, l_param); 34 return ::DefWindowProc(window, message, w_param, l_param);
28 } 35 }
29 return 0; 36 return 0;
30 } 37 }
31 38
32 int WINAPI WinMain(HINSTANCE instance, 39 int WINAPI WinMain(HINSTANCE instance,
33 HINSTANCE prev_instance, 40 HINSTANCE prev_instance,
34 LPSTR cmd_line, 41 LPSTR cmd_line,
35 int cmd_show) { 42 int cmd_show) {
36 // The parent process should have set up this named event already. 43 // The parent process should have set up this named event already.
37 HANDLE event = ::OpenEventW(EVENT_MODIFY_STATE, FALSE, g_winproc_event); 44 HANDLE event = ::OpenEventW(EVENT_MODIFY_STATE, FALSE,
45 hooking_win_proc::g_winproc_event);
38 if (event == NULL || event == INVALID_HANDLE_VALUE) 46 if (event == NULL || event == INVALID_HANDLE_VALUE)
39 return 1; 47 return 1;
40 48
41 // Step 1: Registering the Window Class. 49 // Step 1: Registering the Window Class.
42 WNDCLASSEX window_class; 50 WNDCLASSEX window_class;
43 window_class.cbSize = sizeof(WNDCLASSEX); 51 window_class.cbSize = sizeof(WNDCLASSEX);
44 window_class.style = 0; 52 window_class.style = 0;
45 window_class.lpfnWndProc = WndProc; 53 window_class.lpfnWndProc = WndProc;
46 window_class.cbClsExtra = 0; 54 window_class.cbClsExtra = 0;
47 window_class.cbWndExtra = 0; 55 window_class.cbWndExtra = 0;
(...skipping 30 matching lines...) Expand all
78 while (::GetMessageW(&message, NULL, 0, 0) > 0) { 86 while (::GetMessageW(&message, NULL, 0, 0) > 0) {
79 ::TranslateMessage(&message); 87 ::TranslateMessage(&message);
80 ::DispatchMessageW(&message); 88 ::DispatchMessageW(&message);
81 } 89 }
82 90
83 ::SetEvent(event); 91 ::SetEvent(event);
84 ::CloseHandle(event); 92 ::CloseHandle(event);
85 93
86 return message.wParam; 94 return message.wParam;
87 } 95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698