1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/win/wrapped_window_proc.h"
7 #include "base/atomicops.h"
8 #include "base/logging.h"
9 #include "base/process/memory.h"
13 base::win::WinProcExceptionFilter s_exception_filter
= NULL
;
20 WinProcExceptionFilter
SetWinProcExceptionFilter(
21 WinProcExceptionFilter filter
) {
22 subtle::AtomicWord rv
= subtle::NoBarrier_AtomicExchange(
23 reinterpret_cast<subtle::AtomicWord
*>(&s_exception_filter
),
24 reinterpret_cast<subtle::AtomicWord
>(filter
));
25 return reinterpret_cast<WinProcExceptionFilter
>(rv
);
28 int CallExceptionFilter(EXCEPTION_POINTERS
* info
) {
29 return s_exception_filter
? s_exception_filter(info
) :
30 EXCEPTION_CONTINUE_SEARCH
;
33 BASE_EXPORT
void InitializeWindowClass(
34 const char16
* class_name
,
41 const char16
* menu_name
,
44 WNDCLASSEX
* class_out
) {
45 class_out
->cbSize
= sizeof(WNDCLASSEX
);
46 class_out
->style
= style
;
47 class_out
->lpfnWndProc
= window_proc
;
48 class_out
->cbClsExtra
= class_extra
;
49 class_out
->cbWndExtra
= window_extra
;
50 class_out
->hInstance
= base::GetModuleFromAddress(window_proc
);
51 class_out
->hIcon
= large_icon
;
52 class_out
->hCursor
= cursor
;
53 class_out
->hbrBackground
= background
;
54 class_out
->lpszMenuName
= menu_name
;
55 class_out
->lpszClassName
= class_name
;
56 class_out
->hIconSm
= small_icon
;
58 // Check if |window_proc| is valid.
59 DCHECK(class_out
->hInstance
!= NULL
);