nitsch / psmove-pair-win

Small test project for establishing a Bluetooth connection for the Move Motion Controller on Windows
15 stars 6 forks source link

Support for Windows 8.1 x64: Work in Progress #2

Closed betonme closed 9 years ago

betonme commented 9 years ago

First attemp to implement support for Windows 8.1 x64, see Issue #1

Added UACExecutionLevel RequireAdministrator Implemented new function changeRegistry It determines the correct registry path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HidBth\Parameters\Devices+MAC_OF_BTRADIO+MAC_OF_BT_DEVICE and changes VirtuallyCabled from 0 to 1

The registry value is correctly changed but the connection still fails.

nitsch commented 9 years ago

Does setting these values in the registry actually make a difference in Windows 8, i.e. making this tool work there?

betonme commented 9 years ago

Hi, I've only Windows 8.1. Maybe anyone else can test it?

nitsch commented 9 years ago

My question was referring to any Windows 8.x, not 8.0 in particular.

nitsch commented 9 years ago

Tested the additional registry modification on a friend's Windows 8.1 machine. It seems that setting ConnectionAuthenticated to 1 always ends up with the OS claiming to have a successful Bluetooth connection while the Move controller still keeps blinking and never actually establishes that connection. Just setting VirtuallyCabled to 1 (and leaving ConnectionAuthenticated as it is), as described in

https://groups.google.com/d/topic/psmove/TOJlZ_siXSQ

works for me. Can you confirm this?

betonme commented 9 years ago

Yes, after several retries. First run psmovepair.exe until "unplug the psmove". Then run psmove-pair-win.exe. No success after a few attemps? Stop it. Unplug the BT stick. Reconnect it and retry psmove-pair-win.exe. Actually it is not deterministic.

PS: I changed psmove-pair-win.exe to just set VirtuallyCabled to 1.

betonme commented 9 years ago

With the second commit. The procedure seems to be very stable. I can always connect the ps move with just starting the utility and I've to press the ps move button just 3 times.

Please test it, then we can cleanup the code.

nitsch commented 9 years ago

Please test it, then we can cleanup the code.

I do not have the possibility to easily test on Windows 8 available at all time. You better get some people who do. Maybe @cboulay can help with the tests.

cboulay commented 9 years ago

I'm not planning to go to my office with the Windows desktop until Wednesday or Thursday of this week, but I will test when I get there, and I will bring with me a controller that is not yet paired with that box.

Does this registry entry already exist in Windows 7? Do these modifications affect anything in Windows 7?

nitsch commented 9 years ago

I'm not planning to go to my office with the Windows desktop until Wednesday or Thursday of this week, but I will test when I get there, and I will bring with me a controller that is not yet paired with that box.

You should always be able to remove the controllers from the list of Bluetooth devices in Windows to start fresh.

Does this registry entry already exist in Windows 7? Do these modifications affect anything in Windows 7?

Windows 7 (and prior versions) do create these entries in the process of setting up the connection using psmove-pair-win. Having VirtuallyCabled set to 1 is always the outcome of successfully completing that procedure. Windows 8 seems to be the only one so far that needs manual intervention at that point. That is the only difference as far as I can tell.

cboulay commented 9 years ago

Hi, I just tried @betonme 's latest psmove-pair-win on my Windows 8.1 machine. Unfortunately, it ends in BSOD. Here's the text of the output:

No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.

Device: (0)  00:06:f7:97:32:e8  Motion Controller
                          CoD: 0x00002508, CON: 0, REM: 0, AUTH: 0

device #0: Move Motion Controller detected
radioInfo.address: 5cf370645410
deviceInfo.address: 0006f79732e8
sSubkey: SYSTEM\CurrentControlSet\Services\HidBth\Parameters\Devices\5cf37064541
00006f79732e8
[ERROR 0x00000002] Failed to open registry key: The system cannot find the file
specified.
- checking HID service
- enabling HID service
radioInfo.address: 5cf370645410
deviceInfo.address: 0006f79732e8
sSubkey: SYSTEM\CurrentControlSet\Services\HidBth\Parameters\Devices\5cf37064541
00006f79732e8
[ERROR 0x000000ea] Failed to get registry value: More data is available.
Set VirtuallyCabled: 1
- verifying successful connection RE
radioInfo.address: 5cf370645410
deviceInfo.address: 0006f79732e8
sSubkey: SYSTEM\CurrentControlSet\Services\HidBth\Parameters\Devices\5cf37064541
00006f79732e8
Get VirtuallyCabled: 1
Set VirtuallyCabled: 1
- checking HID service
- verifying successful connection CRE.RE
Device removed - retry

No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.
No Bluetooth devices found.

Then if I press the button again it generates the device-specific text again. If I leave this running for long enough it crashes to BSOD (I think it was something like SYSTEM_THREAD_EXCEPTION_NOT_HANDLED WppRecorder.hpp). Same thing if I try to Ctrl+C out of it.

Also, my other controller that used to connect flawlessly with one button touch no longer connects.

cboulay commented 9 years ago

I was able to reconnect the old controller using the old method (psmovepair, old psmove-pair-win, check the services box, manually edit registry)

My original controller is at address 00:06:f7:18:cd:f3 The new controller that I was trying to connect using this method is at address 00:06:f7:97:32:e8

The non-modified version of psmove-pair-win detects a controller at 00:06:f7:18:cd:f3 even when it is turned off and I am not pushing any buttons. When I press a button on the second controller (already paired with psmovepair.exe, but no other changes), I get the following output from old psmove-pair-win:

  (0)  00:06:f7:18:cd:f3  Motion Controller
                          CoD: 0x00002508, CON: 0, REM: 1, AUTH: 0

device #0: Move Motion Controller detected

  (1)  00:06:f7:97:32:e8  Motion Controller
                          CoD: 0x00002508, CON: 0, REM: 0, AUTH: 0

device #1: Move Motion Controller detected
- checking HID service
- enabling HID service
[ERROR 0x00000424] Failed to enable HID service: The specified service does not
exist as an installed service.
- verifying successful connection

(P.S. I would decrease the spacing above the device #0 line so it is clear it belongs to the preceding statement and not the following one.)

My guess right now is that psmove-pair-win does not work to add a second controller in Windows 8.1. I will try to fully remove the first controller and try again.

cboulay commented 9 years ago

I removed all controllers and verified no registry entries for these controllers.

I then tried the new psmove-pair-win. The text was the same as 2 posts above, I couldn't copy it because I got BSOD again. After rebooting, the controller connected as soon as I pressed the PS button.

Then I ran the new psmove-pair-win again for my 'old' controller. It worked. I had to cycle through pressing the PS button 5 times. Now both controllers are connected. (I tested and it didn't matter if the 'new' controller was currently connected or not.)

I've tried removing the controllers then using the new psmove-pair-win again on both and I cannot reproduce the BSOD.

nitsch commented 9 years ago

Ugh, this sounds like some more testing on (other?) Windows 8 machines is in order.

BTW, have you also tried testing with only the first commit of this pull request? Just for comparison.

cboulay commented 9 years ago

No, I'm sorry. I didn't think to do that. I'll be back at that computer on Thursday. I might have time then.

betonme commented 9 years ago

@cboulay. Thanks for testing it. Actually I've only one PS Move device and a BSOD has not occured yet.

@nitsch The prints tell me, that it is the second version.

betonme commented 9 years ago

@cboulay Can You check the Windows Event Viewer regarding more information about the previous BSOD?

Can You comment out line 633 BluetoothRemoveDevice(&deviceInfo.Address); Can You pair Your device? BSOD? Thanks

cboulay commented 9 years ago

I had a really busy day so was unable to test. I don't expect to be back at that computer until next week. Sorry about that. You should probably recruit somebody else with Windows 8.1 to test.

cboulay commented 9 years ago

I can't reproduce the blue screen error even without commenting out that line. Here's the output of the old crash from WinDbg.

10: kd> !analyze -v
*******************************************************************************
*                                                                             *
*                        Bugcheck Analysis                                    *
*                                                                             *
*******************************************************************************

SYSTEM_THREAD_EXCEPTION_NOT_HANDLED (7e)
This is a very common bugcheck.  Usually the exception address pinpoints
the driver/function that caused the problem.  Always note this address
as well as the link date of the driver/image that contains this address.
Arguments:
Arg1: ffffffffc0000005, The exception code that was not handled
Arg2: fffff8017f94e9da, The address that the exception occurred at
Arg3: ffffd000cb7867a8, Exception Record Address
Arg4: ffffd000cb785fb0, Context Record Address

Debugging Details:
------------------

EXCEPTION_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.

FAULTING_IP: 
WppRecorder!WppAutoLogTrace+192
fffff801`7f94e9da 488b88b0000000  mov     rcx,qword ptr [rax+0B0h]

EXCEPTION_RECORD:  ffffd000cb7867a8 -- (.exr 0xffffd000cb7867a8)
ExceptionAddress: fffff8017f94e9da (WppRecorder!WppAutoLogTrace+0x0000000000000192)
   ExceptionCode: c0000005 (Access violation)
  ExceptionFlags: 00000000
NumberParameters: 2
   Parameter[0]: 0000000000000000
   Parameter[1]: 00000000000000b0
Attempt to read from address 00000000000000b0

CONTEXT:  ffffd000cb785fb0 -- (.cxr 0xffffd000cb785fb0;r)
rax=0000000000000000 rbx=fffff8018382b0d8 rcx=0000000000000000
rdx=0000000000000100 rsi=0000000000000004 rdi=fffff8018382a3a8
rip=fffff8017f94e9da rsp=ffffd000cb7869e0 rbp=0000000000000000
 r8=0000000000000004  r9=fffff8018382a3a8 r10=0000000000000020
r11=fffff8018382b158 r12=fffff8018382a3a8 r13=fffff803dfb32200
r14=0000000000000000 r15=ffffe000d6b524c0
iopl=0         nv up ei pl nz na pe nc
cs=0010  ss=0018  ds=002b  es=002b  fs=0053  gs=002b             efl=00010202
WppRecorder!WppAutoLogTrace+0x192:
fffff801`7f94e9da 488b88b0000000  mov     rcx,qword ptr [rax+0B0h] ds:002b:00000000`000000b0=????????????????
Last set context:
rax=0000000000000000 rbx=fffff8018382b0d8 rcx=0000000000000000
rdx=0000000000000100 rsi=0000000000000004 rdi=fffff8018382a3a8
rip=fffff8017f94e9da rsp=ffffd000cb7869e0 rbp=0000000000000000
 r8=0000000000000004  r9=fffff8018382a3a8 r10=0000000000000020
r11=fffff8018382b158 r12=fffff8018382a3a8 r13=fffff803dfb32200
r14=0000000000000000 r15=ffffe000d6b524c0
iopl=0         nv up ei pl nz na pe nc
cs=0010  ss=0018  ds=002b  es=002b  fs=0053  gs=002b             efl=00010202
WppRecorder!WppAutoLogTrace+0x192:
fffff801`7f94e9da 488b88b0000000  mov     rcx,qword ptr [rax+0B0h] ds:002b:00000000`000000b0=????????????????
Resetting default scope

PROCESS_NAME:  System

CURRENT_IRQL:  0

ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.

EXCEPTION_PARAMETER1:  0000000000000000

EXCEPTION_PARAMETER2:  00000000000000b0

READ_ADDRESS: unable to get nt!MmNonPagedPoolStart
unable to get nt!MmSizeOfNonPagedPoolInBytes
 00000000000000b0 

FOLLOWUP_IP: 
WppRecorder!WppAutoLogTrace+192
fffff801`7f94e9da 488b88b0000000  mov     rcx,qword ptr [rax+0B0h]

BUGCHECK_STR:  AV

DEFAULT_BUCKET_ID:  NULL_CLASS_PTR_DEREFERENCE

ANALYSIS_VERSION: 6.3.9600.17298 (debuggers(dbg).141024-1500) amd64fre

LAST_CONTROL_TRANSFER:  from fffff80183817170 to fffff8017f94e9da

STACK_TEXT:  
ffffd000`cb7869e0 fffff801`83817170 : ffffd000`cb786a50 fffff801`8382e109 00000000`00000000 fffff803`dfb32200 : WppRecorder!WppAutoLogTrace+0x192
ffffd000`cb786a40 fffff801`8381c9ca : 00000000`00000000 ffffe000`dd137e60 ffffe000`d8637050 00000000`00000006 : hidbth!WPP_RECORDER_SF_D+0xc0
ffffd000`cb786a90 fffff803`df92ba8c : ffffe000`dd137e60 00000000`00000000 fffff801`8381c8f0 ffffe000`d8637050 : hidbth!HidBthUnpairDevice+0xda
ffffd000`cb786ae0 fffff803`df92b3ac : fffff803`df9909d0 fffff803`df92ba0c ffffe000`dd137e60 ffffe000`d6b52380 : nt!IopProcessWorkItem+0x80
ffffd000`cb786b50 fffff803`df958280 : 00000000`00000000 ffffe000`d6b52380 00000000`00000080 ffffe000`d6b52380 : nt!ExpWorkerThread+0x28c
ffffd000`cb786c00 fffff803`df9d6fc6 : ffffd000`cb4c0180 ffffe000`d6b52380 ffffd000`cb4cc4c0 00000000`00000000 : nt!PspSystemThreadStartup+0x58
ffffd000`cb786c60 00000000`00000000 : ffffd000`cb787000 ffffd000`cb781000 00000000`00000000 00000000`00000000 : nt!KiStartSystemThread+0x16

SYMBOL_STACK_INDEX:  0

SYMBOL_NAME:  WppRecorder!WppAutoLogTrace+192

FOLLOWUP_NAME:  MachineOwner

MODULE_NAME: WppRecorder

IMAGE_NAME:  WppRecorder.sys

DEBUG_FLR_IMAGE_TIMESTAMP:  5215f87c

STACK_COMMAND:  .cxr 0xffffd000cb785fb0 ; kb

BUCKET_ID_FUNC_OFFSET:  192

FAILURE_BUCKET_ID:  AV_WppRecorder!WppAutoLogTrace

BUCKET_ID:  AV_WppRecorder!WppAutoLogTrace

ANALYSIS_SOURCE:  KM

FAILURE_ID_HASH_STRING:  km:av_wpprecorder!wppautologtrace

FAILURE_ID_HASH:  {af626803-cf44-1940-a8f8-55006a87ada8}

Followup: MachineOwner
---------
cboulay commented 9 years ago

I've used this a dozen times now and recommended it to a few others. No reports of BSOD. But I do find that I need to run psmovepair.exe at least once before running this (I think to write the calibration file to the home directory).

nitsch commented 9 years ago

But I do find that I need to run psmovepair.exe at least once before running this (I think to write the calibration file to the home directory).

You probably need to run psmovepair once to make the computer's BDADDR known to the host. It won't work without that and I did not implement this part in psmove-pair-win (as stated in the README).

cboulay commented 9 years ago

I just wanted to draw your attention to a post in the google group about the need for this to be integrated into psmovepair. @betonme , are you up for that?

betonme commented 9 years ago

I agree. It would be nice to have just one tool for pairing.

@nitsch Should the psmove-pair-win functionality integrated into the original psmovepair?

nitsch commented 9 years ago

@nitsch Should the psmove-pair-win functionality integrated into the original psmovepair?

Of course. And it already is (at least for the current state that supports Windows <= 7) as you will find out when looking at the psmoveapi source code. The sole purpose of the psmove-pair-win tool was to make testing and experimenting easier by stripping it down to the actual pairing.

nitsch commented 9 years ago

I finally had the opportunity to test this a little on Windows 8. It seems to work pretty well but needs quite some clean-up up as well. I added this as new branch win8-support an will merge it once that clean-up is done.