diff --git a/README.md b/README.md index 69d959e..c39f645 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ OSX users can download `twib_osx64` and `twibd_osx64` from the [latest release]( ## Windows -Windows support is experimental and is being improved. Windows users may download `twib_win64.exe` and `twibd_win64.exe` from the [latest release](https://github.com/misson20000/twili/releases/latest). Boot your switch with Twili installed, then run Zadig and set both of the `TransistorUSB` interfaces to `libusbK`. Run `twibd_win64.exe`, and leave it running in the background. `twib_win64.exe` should be run from the command prompt. +Windows support is experimental and is being improved. Windows users may download `twib_win64.exe` and `twibd_win64.exe` from the [latest release](https://github.com/misson20000/twili/releases/latest). Boot your switch with Twili installed, then install the libusbK-based [driver package](https://github.com/misson20000/twili/tree/master/contrib/windows/driver). Run `twibd_win64.exe`, and leave it running in the background. `twib_win64.exe` should be run from the command prompt. # Building From Source diff --git a/contrib/windows/driver/Bootstrap.ps1 b/contrib/windows/driver/Bootstrap.ps1 new file mode 100644 index 0000000..448b71a --- /dev/null +++ b/contrib/windows/driver/Bootstrap.ps1 @@ -0,0 +1,47 @@ +# +# Twili Driver Bootstrap Script +# +# This script downloads support tooling and libusbK, to set up the +# on-disk hierarchy to support driver installation via twili.inf +# + +$LibusbkUrl = "https://sourceforge.net/projects/libusbk/files/libusbK-release/3.0.7.0/libusbK-3.0.7.0-bin.7z/download" +$LibusbkPrefix = "libusbK-3.0.7.0" +$7zipUrl = "https://www.7-zip.org/a/7z1805.msi" + +New-Item -ItemType Directory tools -ErrorAction Stop | Out-Null +$env:Path += ";.\tools" + +# # # +Write-Output "• Staging 7-Zip" + +$WorkingFilename = [IO.Path]::GetRandomFileName() +$WorkingDirectory = [IO.Path]::GetRandomFileName() +Invoke-WebRequest $7zipUrl -OutFile $WorkingFilename +Start-Process msiexec.exe -Wait -NoNewWindow -ArgumentList @( + "/q","/a",$WorkingFilename,"TARGETDIR=$((Get-Item -Path '.\' -Verbose).FullName)\$WorkingDirectory") +Move-Item .\$WorkingDirectory\Files\7-Zip\7z.??? .\tools +Remove-Item .\$WorkingFilename +Remove-Item .\$WorkingDirectory -Recurse + +# # # +Write-Output "• Staging libusbk" + +New-Item -ItemType Directory @("amd64", "x86") -ErrorAction Stop | Out-Null +$WorkingFilename = [IO.Path]::GetRandomFileName() +$WorkingDirectory = [IO.Path]::GetRandomFileName() +Invoke-WebRequest $LibusbkUrl -OutFile $WorkingFilename -MaximumRedirection 3 -UserAgent "PowerShell/Windows" +Start-Process 7z.exe -Wait -ArgumentList @("x", $WorkingFilename, "-i!*\bin\dll", "-i!*\bin\sys", "-o$WorkingDirectory") + +# # # +Write-Output "• Creating driver directory hierarchy" +Move-Item .\$WorkingDirectory\$LibusbkPrefix-bin\bin\*\x86\* .\x86 +Move-Item .\$WorkingDirectory\$LibusbkPrefix-bin\bin\*\amd64\* .\amd64 + +# # # +Write-Output "• Cleaning up" +Remove-Item .\$WorkingFilename +Remove-Item .\$WorkingDirectory -Recurse + +# # # +Write-Output "✓ Done" diff --git a/contrib/windows/driver/README.md b/contrib/windows/driver/README.md new file mode 100644 index 0000000..0d80a46 --- /dev/null +++ b/contrib/windows/driver/README.md @@ -0,0 +1,32 @@ +# Twili USB Driver Package + +This driver package associates the libtransistor USB device, and its interfaces, with libusbK for use with Twili. + +## Usage + +Before the driver package can be installed, you must download libusbk, create a catalog of its files, and digitally sign the catalog. + +You have two options here: + +1. Use the provided self-signed driver package. +2. Catalog and sign the driver package yourself. + +Pick only one of these options. Temporary internet access is required during bootstrap. + +### Using the provided self-signed driver package + +1. Right-click `Bootstrap.ps1` and click Run with PowerShell. +2. Double-click `twili.cer` and click the Install Certificate button. +3. Follow the Certificate Import Wizard steps to install the certificate into the Local Machine `Trusted Root Certification Authorities` store. +4. Open Device Manager and double-click any of the `TransistorUSB` devices listed under the `Other devices` heading. +5. Click the Update Driver button and browse to the folder containing the provided driver package. +6. Follow on-screen instructions to complete the install. +7. Repeat steps 3-5 for any remaining `TransistorUSB` devices. + +### Catalog and sign the driver package yourself + +1. Right-click `Bootstrap.ps1` and click Run with PowerShell. +2. Download the [Enterprise Windows Driver Kit (EWDK)](https://docs.microsoft.com/en-us/windows-hardware/drivers/develop/using-the-enterprise-wdk) (13GB) +3. Mount the Enterprise WDK image and start a new **elevated** build environment (`LaunchBuildEnv.cmd`). +4. In that environment, navigate to the driver package location in the source tree and execute the signing script (`SignDrivers.cmd`). +5. Follow self-signed driver package installation steps 4-6. diff --git a/contrib/windows/driver/SignDrivers.cmd b/contrib/windows/driver/SignDrivers.cmd new file mode 100644 index 0000000..fdb4f3e --- /dev/null +++ b/contrib/windows/driver/SignDrivers.cmd @@ -0,0 +1,4 @@ +inf2cat /os:7_X86,7_X64,8_X86,8_X64,10_X64,10_X86 /driver:. +makecert -r -pe -ss My -n "CN=ReSwitched (self-signed)" -eku 1.3.6.1.5.5.7.3.3 twili.cer +certmgr.exe /add twili.cer /s /r localMachine root +signtool sign /n ReSwitched twili.cat diff --git a/contrib/windows/driver/twili.cat b/contrib/windows/driver/twili.cat new file mode 100644 index 0000000..3ba4bec Binary files /dev/null and b/contrib/windows/driver/twili.cat differ diff --git a/contrib/windows/driver/twili.cer b/contrib/windows/driver/twili.cer new file mode 100644 index 0000000..8111c1f Binary files /dev/null and b/contrib/windows/driver/twili.cer differ diff --git a/contrib/windows/driver/twili.inf b/contrib/windows/driver/twili.inf new file mode 100644 index 0000000..af77bef Binary files /dev/null and b/contrib/windows/driver/twili.inf differ