summaryrefslogtreecommitdiffstats
path: root/base/message_pump_win.cc
diff options
context:
space:
mode:
authoralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-17 23:09:09 +0000
committeralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-17 23:09:09 +0000
commit4afa819cc67f1161ec04b23e56b8283152a3b727 (patch)
tree2dcc554cf006a2d9c762e39930912f0caa3221c8 /base/message_pump_win.cc
parentced29a71e4b701010a4de6a0de67f79842858853 (diff)
downloadchromium_src-4afa819cc67f1161ec04b23e56b8283152a3b727.zip
chromium_src-4afa819cc67f1161ec04b23e56b8283152a3b727.tar.gz
chromium_src-4afa819cc67f1161ec04b23e56b8283152a3b727.tar.bz2
Making sure that base::MessagePumpForUI from different modules are isolated from each other.
This is a minimal version of the original fix that was reverted by https://src.chromium.org/viewvc/chrome?view=rev&revision=137542. This version does not contain any protection against shatter attacks. BUG=124091 Review URL: https://chromiumcodereview.appspot.com/10407011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137765 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_win.cc')
-rw-r--r--base/message_pump_win.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/base/message_pump_win.cc b/base/message_pump_win.cc
index 9484b29..fc65d84 100644
--- a/base/message_pump_win.cc
+++ b/base/message_pump_win.cc
@@ -8,6 +8,7 @@
#include "base/message_loop.h"
#include "base/metrics/histogram.h"
+#include "base/process_util.h"
#include "base/win/wrapped_window_proc.h"
namespace base {
@@ -82,13 +83,13 @@ int MessagePumpWin::GetCurrentDelay() const {
//-----------------------------------------------------------------------------
// MessagePumpForUI public:
-MessagePumpForUI::MessagePumpForUI() {
+MessagePumpForUI::MessagePumpForUI() : instance_(NULL) {
InitMessageWnd();
}
MessagePumpForUI::~MessagePumpForUI() {
DestroyWindow(message_hwnd_);
- UnregisterClass(kWndClass, GetModuleHandle(NULL));
+ UnregisterClass(kWndClass, instance_);
}
void MessagePumpForUI::ScheduleWork() {
@@ -230,17 +231,16 @@ void MessagePumpForUI::DoRunLoop() {
}
void MessagePumpForUI::InitMessageWnd() {
- HINSTANCE hinst = GetModuleHandle(NULL);
-
WNDCLASSEX wc = {0};
wc.cbSize = sizeof(wc);
wc.lpfnWndProc = base::win::WrappedWindowProc<WndProcThunk>;
- wc.hInstance = hinst;
+ wc.hInstance = base::GetModuleFromAddress(wc.lpfnWndProc);
wc.lpszClassName = kWndClass;
+ instance_ = wc.hInstance;
RegisterClassEx(&wc);
message_hwnd_ =
- CreateWindow(kWndClass, 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hinst, 0);
+ CreateWindow(kWndClass, 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, instance_, 0);
DCHECK(message_hwnd_);
}