| 115 | } |
| 116 | |
| 117 | bool HookProcessor::CanSetWindowsHook(HWND window_handle) { |
| 118 | int driver_bitness = 32; |
| 119 | HANDLE driver_process_handle = ::GetCurrentProcess(); |
| 120 | if (Is64BitProcess(driver_process_handle)) { |
| 121 | driver_bitness = 64; |
| 122 | } |
| 123 | ::CloseHandle(driver_process_handle); |
| 124 | |
| 125 | DWORD process_id; |
| 126 | DWORD thread_id = ::GetWindowThreadProcessId(window_handle, &process_id); |
| 127 | HANDLE browser_process_handle = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, process_id); |
| 128 | int browser_bitness = 32; |
| 129 | if (Is64BitProcess(browser_process_handle)) { |
| 130 | browser_bitness = 64; |
| 131 | } |
| 132 | |
| 133 | if (driver_bitness != browser_bitness) { |
| 134 | LOG(WARN) << "Unable to set Windows hook procedure. Driver is a " |
| 135 | << driver_bitness << "-bit process, but browser is a " |
| 136 | << browser_bitness << "-bit process."; |
| 137 | } |
| 138 | return driver_bitness == browser_bitness; |
| 139 | } |
| 140 | |
| 141 | bool HookProcessor::Is64BitProcess(HANDLE process_handle) { |
| 142 | if (!RegistryUtilities::Is64BitWindows()) { |
no test coverage detected