From: Vibhav Pant <vibhavp@gmail.com> --- dlls/windows.devices.bluetooth/Makefile.in | 2 +- .../bluetoothadapter.c | 23 +++++++++++++++++-- dlls/windows.devices.bluetooth/private.h | 2 ++ .../tests/bluetooth.c | 4 ++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/dlls/windows.devices.bluetooth/Makefile.in b/dlls/windows.devices.bluetooth/Makefile.in index c931ba78706..0e0364f2a3f 100644 --- a/dlls/windows.devices.bluetooth/Makefile.in +++ b/dlls/windows.devices.bluetooth/Makefile.in @@ -1,5 +1,5 @@ MODULE = windows.devices.bluetooth.dll -IMPORTS = combase setupapi +IMPORTS = bluetoothapis combase setupapi SOURCES = \ advertisement.c \ diff --git a/dlls/windows.devices.bluetooth/bluetoothadapter.c b/dlls/windows.devices.bluetooth/bluetoothadapter.c index 6972ec8a906..a769712afbf 100644 --- a/dlls/windows.devices.bluetooth/bluetoothadapter.c +++ b/dlls/windows.devices.bluetooth/bluetoothadapter.c @@ -19,6 +19,7 @@ */ #include "private.h" +#include "winternl.h" #include "roapi.h" #include "setupapi.h" #include "wine/debug.h" @@ -199,6 +200,7 @@ struct bluetoothadapter { IBluetoothAdapter IBluetoothAdapter_iface; HSTRING id; + HANDLE radio; LONG ref; }; @@ -243,6 +245,7 @@ static WINAPI ULONG bluetoothadapter_Release( IBluetoothAdapter *iface ) if (!ref) { WindowsDeleteString( impl->id ); + CloseHandle( impl->radio ); free( impl ); } return ref; @@ -275,8 +278,17 @@ static HRESULT WINAPI bluetoothadapter_get_DeviceId( IBluetoothAdapter *iface, H static HRESULT WINAPI bluetoothadpter_get_BluetoothAddress( IBluetoothAdapter *iface, UINT64 *addr ) { - FIXME( "iface %p, addr %p stub!\n", iface, addr ); - return E_NOTIMPL; + struct bluetoothadapter *impl = impl_from_IBluetoothAdapter( iface ); + BLUETOOTH_RADIO_INFO info = {0}; + DWORD ret; + + TRACE( "iface %p, addr %p\n", iface, addr ); + + info.dwSize = sizeof( info ); + ret = BluetoothGetRadioInfo( impl->radio, &info ); + if (!ret) /* This uses the opposite byte-order of bluetoothapis. */ + *addr = RtlUlonglongByteSwap( info.address.ullLong ) >> 16; + return HRESULT_FROM_WIN32( ret ); } static HRESULT WINAPI bluetoothadapter_get_IsClassicSupported( IBluetoothAdapter *iface, boolean *value ) @@ -343,8 +355,15 @@ static HRESULT create_bluetoothadapter( const WCHAR *path, IBluetoothAdapter **o if (!(impl = calloc( 1, sizeof( *impl ) ))) return E_OUTOFMEMORY; impl->IBluetoothAdapter_iface.lpVtbl = &bluetoothadapter_vtbl; + impl->radio = CreateFileW( path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL ); + if (impl->radio == INVALID_HANDLE_VALUE) + { + free( impl ); + return HRESULT_FROM_WIN32( GetLastError() ); + } if (FAILED((hr = WindowsCreateString( path, wcslen( path ), &impl->id )))) { + CloseHandle( impl->radio ); free( impl ); return hr; } diff --git a/dlls/windows.devices.bluetooth/private.h b/dlls/windows.devices.bluetooth/private.h index 1e7f9a2440c..48cc5c04447 100644 --- a/dlls/windows.devices.bluetooth/private.h +++ b/dlls/windows.devices.bluetooth/private.h @@ -29,6 +29,8 @@ #include "activation.h" #include "bthdef.h" +#include "bthsdpdef.h" +#include "bluetoothapis.h" #define WIDL_using_Windows_Foundation #define WIDL_using_Windows_Foundation_Collections diff --git a/dlls/windows.devices.bluetooth/tests/bluetooth.c b/dlls/windows.devices.bluetooth/tests/bluetooth.c index f1b64277e6f..6ae64780366 100644 --- a/dlls/windows.devices.bluetooth/tests/bluetooth.c +++ b/dlls/windows.devices.bluetooth/tests/bluetooth.c @@ -428,8 +428,8 @@ static void test_BluetoothAdapterStatics(void) address = 0; hr = IBluetoothAdapter_get_BluetoothAddress( adapter1, &address ); - todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr ); - todo_wine ok( address, "got address %#I64x.\n", address ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + ok( address, "got address %#I64x.\n", address ); hr = IBluetoothAdapter_get_IsLowEnergySupported( adapter1, &bool_val ); todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10006