From: Vibhav Pant vibhavp@gmail.com
squash authdevice. --- dlls/bluetoothapis/Makefile.in | 2 +- dlls/bluetoothapis/bluetoothapis.spec | 1 + dlls/bluetoothapis/main.c | 53 +++++++++++++++++++++++++++ dlls/bthprops.cpl/bthprops.cpl.spec | 2 +- include/bluetoothapis.h | 11 ++++++ 5 files changed, 67 insertions(+), 2 deletions(-)
diff --git a/dlls/bluetoothapis/Makefile.in b/dlls/bluetoothapis/Makefile.in index 996c561fc17..ccdf17d2609 100644 --- a/dlls/bluetoothapis/Makefile.in +++ b/dlls/bluetoothapis/Makefile.in @@ -1,6 +1,6 @@ MODULE = bluetoothapis.dll IMPORTLIB = bluetoothapis -IMPORTS = setupapi cfgmgr32 +IMPORTS = setupapi cfgmgr32 user32
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/bluetoothapis/bluetoothapis.spec b/dlls/bluetoothapis/bluetoothapis.spec index 46b1903a7a7..e26932496dc 100644 --- a/dlls/bluetoothapis/bluetoothapis.spec +++ b/dlls/bluetoothapis/bluetoothapis.spec @@ -1,4 +1,5 @@ @ stub BluetoothAddressToString +@ stdcall BluetoothAuthenticateDeviceEx(ptr ptr ptr ptr long) @ stub BluetoothDisconnectDevice @ stdcall BluetoothEnableDiscovery(ptr long) @ stdcall BluetoothEnableIncomingConnections(ptr long) diff --git a/dlls/bluetoothapis/main.c b/dlls/bluetoothapis/main.c index d24a40fd1de..ffe0a4a5870 100644 --- a/dlls/bluetoothapis/main.c +++ b/dlls/bluetoothapis/main.c @@ -945,6 +945,59 @@ DWORD WINAPI BluetoothSendAuthenticationResponseEx( HANDLE handle_radio, BLUETOO
done: ReleaseSRWLockShared( &bluetooth_auth_lock ); + return ret; + } + +DWORD WINAPI BluetoothAuthenticateDeviceEx( HWND parent, HANDLE handle_radio, BLUETOOTH_DEVICE_INFO *device_info, + BLUETOOTH_OOB_DATA_INFO *oob_info, + AUTHENTICATION_REQUIREMENTS auth_req ) +{ + OVERLAPPED ovl = {0}; + BTH_ADDR device_addr; + BOOL success; + DWORD ret, bytes; + + FIXME( "(%p, %p, %p, %p, %d): semi-stub!\n", parent, handle_radio, device_info, oob_info, auth_req ); + + if (!device_info || auth_req < MITMProtectionNotRequired || auth_req > MITMProtectionNotDefined) + return ERROR_INVALID_PARAMETER; + if (device_info->dwSize != sizeof( *device_info )) + return ERROR_REVISION_MISMATCH; + + TRACE( "Initiating pairing with %s\n", debugstr_addr( device_info->Address.rgBytes ) ); + if (!handle_radio) + { + BLUETOOTH_FIND_RADIO_PARAMS find_params = {.dwSize = sizeof( find_params )}; + HBLUETOOTH_RADIO_FIND radio_find; + + radio_find = BluetoothFindFirstRadio( &find_params, &handle_radio ); + ret = GetLastError(); + if (!radio_find) + return ret == ERROR_NO_MORE_ITEMS ? ERROR_NOT_FOUND : ret; + do { + ret = BluetoothAuthenticateDeviceEx( parent, handle_radio, device_info, oob_info, auth_req ); + CloseHandle( handle_radio ); + if (!ret || ret == ERROR_NO_MORE_ITEMS) + break; + } while (BluetoothFindNextRadio( radio_find, &handle_radio )); + + BluetoothFindRadioClose( radio_find ); + return ret; + } + + ovl.hEvent = CreateEventW( NULL, TRUE, FALSE, NULL ); + device_addr = RtlUlonglongByteSwap( device_info->Address.ullLong ) >> 16; + success = DeviceIoControl( handle_radio, IOCTL_WINEBTH_RADIO_START_AUTH, &device_addr, sizeof( device_addr ), + NULL, 0, &bytes, &ovl ); + ret = ERROR_SUCCESS; + if (!success) + { + ret = GetLastError(); + if (ret == ERROR_IO_PENDING) + ret = GetOverlappedResult( handle_radio, &ovl, &bytes, TRUE ); + CloseHandle( ovl.hEvent ); + } + return ret; }
diff --git a/dlls/bthprops.cpl/bthprops.cpl.spec b/dlls/bthprops.cpl/bthprops.cpl.spec index c7606604821..37b52b7f39f 100644 --- a/dlls/bthprops.cpl/bthprops.cpl.spec +++ b/dlls/bthprops.cpl/bthprops.cpl.spec @@ -1,6 +1,6 @@ @ stub BluetoothAddressToString @ stub BluetoothAuthenticateDevice -@ stub BluetoothAuthenticateDeviceEx +@ stdcall -import BluetoothAuthenticateDeviceEx(ptr ptr ptr ptr long) @ stub BluetoothAuthenticateMultipleDevices @ stub BluetoothAuthenticationAgent @ stub BluetoothDisconnectDevice diff --git a/include/bluetoothapis.h b/include/bluetoothapis.h index b97967ec81f..fbc2fca5479 100644 --- a/include/bluetoothapis.h +++ b/include/bluetoothapis.h @@ -140,6 +140,16 @@ typedef enum _BLUETOOTH_AUTHENTICATION_REQUIREMENTS{ BLUETOOTH_MITM_ProtectionNotDefined = 0xff, } BLUETOOTH_AUTHENTICATION_REQUIREMENTS;
+typedef enum _AUTHENTICATION_REQUIREMENTS { + MITMProtectionNotRequired = 0x00, + MITMProtectionRequired = 0x01, + MITMProtectionNotRequiredBonding = 0x02, + MITMProtectionRequiredBonding = 0x03, + MITMProtectionNotRequiredGeneralBonding = 0x04, + MITMProtectionRequiredGeneralBonding = 0x05, + MITMProtectionNotDefined = 0xff +} AUTHENTICATION_REQUIREMENTS; + typedef struct _BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS { BLUETOOTH_DEVICE_INFO deviceInfo; BLUETOOTH_AUTHENTICATION_METHOD authenticationMethod; @@ -243,6 +253,7 @@ typedef BOOL (CALLBACK *PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK)( void *pvParam);
DWORD WINAPI BluetoothAuthenticateDevice(HWND, HANDLE, BLUETOOTH_DEVICE_INFO *, WCHAR *, ULONG); +DWORD WINAPI BluetoothAuthenticateDeviceEx(HWND, HANDLE, BLUETOOTH_DEVICE_INFO *, BLUETOOTH_OOB_DATA_INFO *, AUTHENTICATION_REQUIREMENTS); DWORD WINAPI BluetoothAuthenticateMultipleDevices(HWND, HANDLE, DWORD, BLUETOOTH_DEVICE_INFO *); BOOL WINAPI BluetoothDisplayDeviceProperties(HWND, BLUETOOTH_DEVICE_INFO *); BOOL WINAPI BluetoothEnableDiscovery(HANDLE, BOOL);