1 // Copyright (c) 2013 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 "device/bluetooth/bluetooth_init_win.h"
7 #include "base/threading/thread_restrictions.h"
11 // A frame-based exception handler filter function for a handler for exceptions
12 // generated by the Visual C++ delay loader helper function.
13 int FilterVisualCPPExceptions(DWORD exception_code
) {
14 return HRESULT_FACILITY(exception_code
) == FACILITY_VISUALCPP
?
15 EXCEPTION_EXECUTE_HANDLER
: EXCEPTION_CONTINUE_SEARCH
;
21 namespace bluetooth_init_win
{
23 bool HasBluetoothStack() {
28 } has_bluetooth_stack
= HBS_UNKNOWN
;
30 if (has_bluetooth_stack
== HBS_UNKNOWN
) {
31 base::ThreadRestrictions::AssertIOAllowed();
34 hr
= __HrLoadAllImportsForDll("bthprops.cpl");
35 } __except(FilterVisualCPPExceptions(::GetExceptionCode())) {
38 has_bluetooth_stack
= SUCCEEDED(hr
) ? HBS_YES
: HBS_NO
;
41 return has_bluetooth_stack
== HBS_YES
;
44 } // namespace bluetooth_init_win