EvanZhu0721 / 公开仓库
SBMS
SBMS complete the calculation rules for the default logical desktop topology relationship and the physical dimensions of the displays in the Windows multi-screen collaboration system.
文件
.githubassetsdocsdriverexamplesinstallerLICENSESsrctestsui.gitignore79 Bbuild-driver.ps15.3 KBbuild-installer.ps15.3 KBbuild.rs229 BCargo.lock147.3 KBCargo.toml1.6 KBLICENSE34.3 KBNOTICE.md1.2 KBREADME.md5.9 KBREADME.zh-CN.md5.2 KBrust-toolchain.toml124 Bbuild-driver.ps15.3 KB
1
[CmdletBinding()]2
param(3
[string]$SigningCertificateThumbprint4
)5
6
$ErrorActionPreference = 'Stop'7
Set-StrictMode -Version Latest8
9
$repository = $PSScriptRoot10
$driver = Join-Path $repository 'driver'11
$output = Join-Path $repository 'target\driver'12
$kitsRoot = (Get-ItemProperty -LiteralPath `13
'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots').KitsRoot1014
15
$sdkVersion = Get-ChildItem -LiteralPath (Join-Path $kitsRoot 'Include') -Directory |16
Where-Object {17
[version]::TryParse($_.Name, [ref]([version]$null)) -and18
(Test-Path -LiteralPath (Join-Path $_.FullName 'um\Windows.h')) -and19
(Test-Path -LiteralPath (Join-Path $kitsRoot "Lib\$($_.Name)"))20
} |21
Sort-Object { [version]$_.Name } -Descending |22
Select-Object -First 1 -ExpandProperty Name23
24
if (-not $sdkVersion) {25
throw 'No complete Windows SDK was found.'26
}27
28
$vswhere = Join-Path ${env:ProgramFiles(x86)} `29
'Microsoft Visual Studio\Installer\vswhere.exe'30
$installation = & $vswhere -latest -products * `31
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `32
-property installationPath33
if ($LASTEXITCODE -ne 0 -or -not $installation) {34
throw 'Visual Studio C++ Build Tools were not found.'35
}36
37
$vcvars = Join-Path $installation 'VC\Auxiliary\Build\vcvars64.bat'38
$environmentLines = & $env:ComSpec /d /s /c `39
"call `"$vcvars`" >nul && set"40
if ($LASTEXITCODE -ne 0) {41
throw 'vcvars64.bat failed.'42
}43
foreach ($line in $environmentLines) {44
$separator = $line.IndexOf('=')45
if ($separator -gt 0) {46
[Environment]::SetEnvironmentVariable(47
$line.Substring(0, $separator),48
$line.Substring($separator + 1),49
'Process')50
}51
}52
53
$wdfInclude = Join-Path $kitsRoot 'Include\wdf\umdf\2.25'54
$iddInclude = Join-Path $kitsRoot "Include\$sdkVersion\um\iddcx\1.4"55
$wdfLibrary = Join-Path $kitsRoot 'Lib\wdf\umdf\x64\2.25\WdfDriverStubUm.lib'56
$iddLibrary = Join-Path $kitsRoot `57
"Lib\$sdkVersion\um\x64\iddcx\1.4\IddCxStub.lib"58
$apiValidator = Join-Path $kitsRoot "bin\$sdkVersion\x64\ApiValidator.exe"59
$apiContract = Join-Path $kitsRoot `60
"build\$sdkVersion\universalDDIs\x64\UniversalDDIs.xml"61
$infVerifier = Join-Path $kitsRoot "Tools\$sdkVersion\x64\InfVerif.exe"62
$inf2Cat = Join-Path $kitsRoot "bin\$sdkVersion\x86\Inf2Cat.exe"63
$signTool = Join-Path $kitsRoot "bin\$sdkVersion\x64\signtool.exe"64
65
$required = @(66
$vcvars, $wdfInclude, $iddInclude, $wdfLibrary, $iddLibrary,67
$apiValidator, $apiContract, $infVerifier, $inf2Cat68
)69
foreach ($path in $required) {70
if (-not (Test-Path -LiteralPath $path)) {71
throw "Required build input is missing: $path"72
}73
}74
if ($SigningCertificateThumbprint -and75
-not (Test-Path -LiteralPath $signTool)) {76
throw "Required signing tool is missing: $signTool"77
}78
79
if (Test-Path -LiteralPath $output) {80
Remove-Item -LiteralPath $output -Recurse -Force81
}82
New-Item -ItemType Directory -Path $output | Out-Null83
84
$object = Join-Path $output 'SBMSIndirectDisplay.obj'85
$binary = Join-Path $output 'SBMSIndirectDisplay.dll'86
$inf = Join-Path $output 'SBMSIndirectDisplay.inf'87
88
$compileArguments = @(89
'/nologo', '/c', '/std:c++17', '/EHs-c-', '/guard:cf',90
'/W4', '/WX',91
'/wd4005', '/wd4324',92
'/D_WIN64', '/D_AMD64_', '/DAMD64', '/DUMDF_DRIVER',93
'/DUMDF_VERSION_MAJOR=2', '/DUMDF_VERSION_MINOR=25',94
'/DUMDF_MINIMUM_VERSION_REQUIRED=25', '/DUMDF_USING_NTSTATUS',95
'/D_UNICODE', '/DUNICODE',96
'/DIDDCX_VERSION_MAJOR=1', '/DIDDCX_VERSION_MINOR=4',97
'/DIDDCX_MINIMUM_VERSION_REQUIRED=4',98
"/I$wdfInclude", "/I$iddInclude",99
"/Fo$object", (Join-Path $driver 'Driver.cpp')100
)101
& cl.exe @compileArguments102
if ($LASTEXITCODE -ne 0) {103
throw "cl.exe failed with exit code $LASTEXITCODE"104
}105
106
$linkArguments = @(107
'/nologo', '/DLL', '/guard:cf', '/SUBSYSTEM:WINDOWS,10.0',108
'/OSVERSION:10.0', '/VERSION:10.0',109
"/OUT:$binary", $object, $wdfLibrary, $iddLibrary,110
'onecoreuap.lib', 'd3d11.lib', 'dxgi.lib', 'ntdll.lib'111
)112
& link.exe @linkArguments113
if ($LASTEXITCODE -ne 0) {114
throw "link.exe failed with exit code $LASTEXITCODE"115
}116
117
Copy-Item -LiteralPath (Join-Path $driver 'SBMSIndirectDisplay.inf') `118
-Destination $inf119
120
& $apiValidator "-BinaryPath:$binary" `121
"-SupportedApiXmlFiles:$apiContract" '-StrictCompliance:true'122
if ($LASTEXITCODE -ne 0) {123
throw "ApiValidator failed with exit code $LASTEXITCODE"124
}125
126
foreach ($mode in '/w', '/u', '/h') {127
& $infVerifier $mode $inf128
if ($LASTEXITCODE -ne 0) {129
throw "InfVerif $mode failed with exit code $LASTEXITCODE"130
}131
}132
133
& $inf2Cat "/driver:$output" /os:10_X64134
if ($LASTEXITCODE -ne 0) {135
throw "Inf2Cat failed with exit code $LASTEXITCODE"136
}137
138
if ($SigningCertificateThumbprint) {139
& $signTool sign /sha1 $SigningCertificateThumbprint /fd SHA256 $binary140
if ($LASTEXITCODE -ne 0) {141
throw "Signing the driver DLL failed with exit code $LASTEXITCODE"142
}143
144
$catalog = Join-Path $output 'SBMSIndirectDisplay.cat'145
& $signTool sign /sha1 $SigningCertificateThumbprint /fd SHA256 $catalog146
if ($LASTEXITCODE -ne 0) {147
throw "Signing the catalog failed with exit code $LASTEXITCODE"148
}149
150
foreach ($file in @($binary, $catalog)) {151
& $signTool verify /pa $file152
if ($LASTEXITCODE -ne 0) {153
throw "Signature verification failed for $file"154
}155
}156
}157
158
Write-Host "driver_package=$output"159