bayangan1991 / PYXInput

Python Library for Creating and Analysing XInput devices
https://pypi.python.org/pypi/PYXInput
MIT License
87 stars 22 forks source link

Better way of attaching a new device #4

Closed rodjun closed 6 years ago

rodjun commented 7 years ago

The vXbox api has a function called PlugInNext, which plugs creates a device in the next avaible slot, currently the code just assumes that all devices are free when you start it which is bad because other programs can be using slots, also there is no error checking so you can't really know if attaching worked or not

bayangan1991 commented 7 years ago

Very good point! I will get on to it when I have the chance.

rodjun commented 7 years ago

Thanks, i also have a question about your setup: What windows version are you using? I'm currently on windows 10 1703 and it seems to be impossible to get vXbox working, i can't even install scpvbus because the sig is wrong and windows wont accept it, only version of scpvbus that works is the one that comes with scptoolkit but this apparently is incompatible with vXbox. I really want to get this working because it would make my project way simpler, this single project would substitute vjoy, x360ce, pygame and pyvjoy.

rodjun commented 7 years ago

If i can get it to work i can implement this and improve some other stuff and make a pull request

bayangan1991 commented 7 years ago

So I am running Windows 10 1607 64Bit.

Can you show me the output from your scpvbus install?

On another note. I have changed how the available ids are determined. I couldn't find the PlugInNext method you mention but I was able to use the dll to grab them threadsafe.

I am updating the pip install now, but you can safely install from the git repo.

rodjun commented 7 years ago

Output from console: devcon.exe install ScpVBus.inf Root\ScpVBus Device node created. Install is complete when drivers are installed... Updating drivers for Root\ScpVBus from C:\Users\rodju\Desktop\ScpVBus-x64\ScpVBus.inf. devcon.exe failed.

output from setupapi.dev.log: https://gist.github.com/rodjun/7b66444efd8b0bc257eaf5d0dd79e6c2

Important lines about the signature:

!!! sig: Driver package INF file hash is not present in catalog file. Filename = scpvbus.inf, Error = 0xE000024B !!! sig: Driver package appears to be tampered, and Code Integrity is enforced. !!! sig: Driver package failed signature validation. Error = 0xE000024B

Apparently someone else had this problem http://vjoystick.sourceforge.net/site/index.php/forum/4-Help/1227-scpvbus-failure-to-install and the only fix is enabling test signing, which requires disabling secure boot

rodjun commented 7 years ago

Found more info, apparently windows 10 stopped installing self-signed driver on the anniversary update (1607), but only for people who installed the OS on that version, if you upgrade to that version it's still fine, which i did, but i also upgraded to the creators update (1703) and this one probably messes things up.

https://blogs.msdn.microsoft.com/windows_hardware_certification/2016/07/26/driver-signing-changes-in-windows-10-version-1607/

http://www.drivethelife.com/windows-10/driver-signature-issue-on-windows-10-anniversary.html

The good fix would be for shaul to sign his driver with microsoft, but i'm not sure if that's easy or even possible for a small dev.

bayangan1991 commented 7 years ago

When i have the chance ill have a crack at fixing this. Scpvbus is open source. I can always rebuild it.

bayangan1991 commented 7 years ago

Hey @rodjun, I have been looking at using nefarius's ViGEm repo.

It is promising because the driver's themselves are signed but I am having issues using the different virtualisation dll.

I was able to reliably bluescreen my computer though, which was neat.

I'll update here if I make any breakthroughs

rodjun commented 7 years ago

That looks pretty good, output is the last problem in my project, the best option is pyxinput which i added support to yesterday https://github.com/rodjun/general_selfdriving_ai/commit/4591b57ca15ec93b5b03d33629f206c3ec8bae69 https://github.com/rodjun/general_selfdriving_ai/commit/baccbc4008af4535f7334b62537b4b40e21b5b0c but it may require people to disable secureboot (i had to), so there's no perfect and easy to install solution right now for output.

getbrainerror commented 4 years ago

Hey i successfully installed the driver on windows 10 by signing the driver with a self sign certificate. After signing the driver, you would just need to import the public cert to "Trusted Publisher" and "Trusted Root Certification Authorities". I would add a PR, but i think the repository owner should own the private key for the certificate.

Instructions:

Prerequisite:

Create Self Sign Certificate

Start Powershell

$cert = New-SelfSignedCertificate -Subject "Cert Subject” -Type CodeSigningCert -CertStoreLocation cert:\LocalMachine\My

$CertPassword = ConvertTo-SecureString -String “P@ss0wrd” -Force –AsPlainText

Export-PfxCertificate -Cert $cert -FilePath C:\DriverCert\private.pfx -Password $CertPassword
Export-Certificate -Cert $cert -FilePath C:\DriverCert\public.cer

Create Catalog File for Driver Package

cd C:\Program Files (x86)\Windows Kits\10\bin\x86 inf2cat.exe /driver:"C:\DriverCert\ScpVBus-x64" /os:10_X64 /verbose

Sign Driver

cd C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64

signtool sign /f C:\DriverCert\private.pfx /p P@ss0wrd /t http://timestamp.verisign.com/scripts/timstamp.dll /v C:\DriverCert\ScpVBus-x64\scpvbus.cat

image

bayangan1991 commented 4 years ago

Hey @getbrainerror thanks for your effort.

When I get the chance I will look at signing the drivers and updating the repo.

I'll try and keep both version working though because I am just some random on the internet, probably not a great idea to go installing trusted root certificates from me.

getbrainerror commented 4 years ago

14 I think this could be a good way to implement a self sign certificate. Only the user itself would have access to the private key.