diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-30 15:34:11 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-30 15:34:11 +0000 |
commit | 9ceda77323dcc335680d3cb47b0b76e2821199ad (patch) | |
tree | f5280e2a394d7d66a035b57d2c6b835bcbd7057b /chrome_frame/event_hooker.cc | |
parent | cf993864f9e684fb2e58f5b89d669ae680feefd9 (diff) | |
download | chromium_src-9ceda77323dcc335680d3cb47b0b76e2821199ad.zip chromium_src-9ceda77323dcc335680d3cb47b0b76e2821199ad.tar.gz chromium_src-9ceda77323dcc335680d3cb47b0b76e2821199ad.tar.bz2 |
Add a helper process to Chrome Frame to allow for non-administrative installs. The helper process registers a hook dll that performs the necessary BHO injection instead of registering it in HKLM.
BUG=53127
TEST=Non-admin CF installs work.
Review URL: http://codereview.chromium.org/3158036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57860 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/event_hooker.cc')
-rw-r--r-- | chrome_frame/event_hooker.cc | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/chrome_frame/event_hooker.cc b/chrome_frame/event_hooker.cc new file mode 100644 index 0000000..839b3ad --- /dev/null +++ b/chrome_frame/event_hooker.cc @@ -0,0 +1,58 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome_frame/event_hooker.h" + +#include <crtdbg.h> +#include "chrome_frame/bho_loader.h" + +EXTERN_C IMAGE_DOS_HEADER __ImageBase; + +EventHooker::EventHooker() +: window_creation_hook_(NULL) {} + +EventHooker::~EventHooker() { + StopHook(); +} + +bool EventHooker::StartHook() { + if ((NULL != window_creation_hook_)) { + return false; + } + + window_creation_hook_ = SetWinEventHook(EVENT_OBJECT_CREATE, + EVENT_OBJECT_CREATE, + reinterpret_cast<HMODULE>( + &__ImageBase), + WindowCreationHookProc, + 0, + 0, + WINEVENT_INCONTEXT); + if (NULL == window_creation_hook_) { + return false; + } + return true; +} + +void EventHooker::StopHook() { + if (NULL != window_creation_hook_) { + UnhookWinEvent(window_creation_hook_); + window_creation_hook_ = NULL; + } +} + +VOID CALLBACK EventHooker::WindowCreationHookProc(HWINEVENTHOOK hook, + DWORD event, + HWND window, + LONG object_id, + LONG child_id, + DWORD event_tid, + DWORD event_time) { + _ASSERTE((EVENT_OBJECT_CREATE == event) || + (EVENT_OBJECT_PARENTCHANGE == event)); + if (OBJID_WINDOW == object_id) { + BHOLoader::GetInstance()->OnHookEvent(event, window); + } +} + |