Support distributor DLL packages and validate Windows player mode
This commit is contained in:
1 parent
65ab1460a8
commit
df415ec828
8 files changed
+191
-16
No files matched your search
@@ -1,7 +1,8 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$GamePackagePrefix, [Parameter(Mandatory=$true)][string]$PackageRoot,
|
||||
[string]$ArchivePath
|
||||
[string]$ArchivePath,
|
||||
[string]$NvidiaDirectory, [string]$NvidiaLicensePath
|
||||
)
|
||||
$ErrorActionPreference='Stop'
|
||||
. (Join-Path $PSScriptRoot 'gpu-target.ps1')
|
||||
@@ -65,9 +66,27 @@ foreach ($launch in @(@{name='START-K.cmd'; arguments='-Preset 11'},@{name='STAR
|
||||
Set-Content -LiteralPath $path -Encoding ASCII
|
||||
$files.Add(@{path=$launch.name; sha256=(Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash; version=$null})
|
||||
}
|
||||
# Publicly supplied original identity, never the binary itself.
|
||||
$ngxCoreSha256='66767018C36B3BAB46398DADE3ADF173DAA3730FDA75965689EA848C9BC4E79B'
|
||||
$bundledNvidia=$null
|
||||
if ($NvidiaDirectory) {
|
||||
# Opt-in for local testing or a distributor with appropriate permission.
|
||||
# A matching hash establishes binary identity, not redistribution rights.
|
||||
if (!$NvidiaLicensePath -or !(Test-Path -LiteralPath $NvidiaLicensePath -PathType Leaf)) {
|
||||
throw 'Bundled NVIDIA files require -NvidiaLicensePath with their applicable license. This option does not establish redistribution permission.'
|
||||
}
|
||||
$core=Join-Path $NvidiaDirectory '_nvngx.dll'
|
||||
$dlss=Join-Path $NvidiaDirectory 'nvngx_dlss.dll'
|
||||
if ((Get-FileHash -LiteralPath $core -Algorithm SHA256).Hash -ne $ngxCoreSha256 -or
|
||||
(Get-FileHash -LiteralPath $dlss -Algorithm SHA256).Hash -ne $baseline.dlssSha256) {
|
||||
throw 'Bundled NVIDIA files must match the validated original NGX and DLSS hashes.'
|
||||
}
|
||||
[void](Stage $core 'files/nvidia/_nvngx.dll')
|
||||
[void](Stage $dlss 'files/nvidia/nvngx_dlss.dll')
|
||||
[void](Stage $NvidiaLicensePath 'licenses/NVIDIA-RTX.txt')
|
||||
$bundledNvidia=@{ngxCore='nvidia/_nvngx.dll'; dlssDll='nvidia/nvngx_dlss.dll'; license='licenses/NVIDIA-RTX.txt'}
|
||||
} elseif ($NvidiaLicensePath) { throw '-NvidiaLicensePath requires -NvidiaDirectory.' }
|
||||
$metadata=[ordered]@{schema=1; packageCommit=$commit; binarySourceCommit=$baseline.d4rCommit;
|
||||
ngxCoreSha256='66767018C36B3BAB46398DADE3ADF173DAA3730FDA75965689EA848C9BC4E79B';
|
||||
ngxCoreSha256=$ngxCoreSha256; bundledNvidia=$bundledNvidia;
|
||||
dependencies=@{optiScalerSourceCommit=$baseline.optiScaler.sourceCommit; zludaSourceCommit=$baseline.zludaBuild.sourceCommit;
|
||||
llvmSource=$baseline.zludaBuild.llvmSource; hipRuntime=$baseline.hipRuntime};
|
||||
commonFiles=$common; targets=$targets; files=$files}
|
||||
@@ -86,4 +105,5 @@ if ($ArchivePath) {
|
||||
}
|
||||
} finally { if ($archive) { $archive.Dispose() }; $stream.Dispose() }
|
||||
}
|
||||
Write-Host "Quick-test package: $PackageRoot (11 targets, automatic GPU selection, no NVIDIA DLLs)"
|
||||
$nvidiaMode=if ($bundledNvidia) { 'bundled NVIDIA files; distributor must have appropriate permission' } else { 'user-supplied NVIDIA files' }
|
||||
Write-Host "Quick-test package: $PackageRoot (11 targets, automatic GPU selection, $nvidiaMode)"
|
||||
@@ -32,6 +32,13 @@ function Copy-Payload([string]$Source, [string]$Destination, [string]$Relative)
|
||||
New-Item -ItemType Directory -Force (Split-Path $path) | Out-Null
|
||||
Copy-Item -LiteralPath (Join-Path $Source $Relative) -Destination $path -Force
|
||||
}
|
||||
function Get-BundledNvidiaFile([string]$Relative) {
|
||||
$directory=Join-Path $PSScriptRoot 'nvidia'
|
||||
$path=[IO.Path]::GetFullPath((Join-Path $PSScriptRoot $Relative))
|
||||
if (!$path.StartsWith($directory+'\',[StringComparison]::OrdinalIgnoreCase) -or
|
||||
!(Test-Path -LiteralPath $path -PathType Leaf)) { throw 'Invalid bundled NVIDIA file. Extract the complete package again.' }
|
||||
return $path
|
||||
}
|
||||
if ($Action -eq 'restore') {
|
||||
$GameExe=Select-LocalFile 'Select the SAME game executable used for the test' '*.exe' $(if ($GameExe) { $GameExe } elseif ($saved) { $saved.game })
|
||||
& (Join-Path $PSScriptRoot 'common/windows-game.ps1') -Action restore -GameExe $GameExe
|
||||
@@ -96,8 +103,16 @@ try {
|
||||
elseif ($reuse) { throw 'Invalid choice. Press Enter or type C on the next run.' }
|
||||
}
|
||||
$GameExe=Select-LocalFile 'Select the actual D3D12 game .exe (not Steam or a launcher)' '*.exe' $(if ($GameExe) { $GameExe } else { $previousGame })
|
||||
$NgxCore=Select-LocalFile 'Select your ORIGINAL NVIDIA _nvngx.dll (32.0.16.1714)' '_nvngx.dll' $(if ($NgxCore) { $NgxCore } elseif ($saved) { $saved.ngxCore })
|
||||
$DlssDll=Select-LocalFile 'Select your NVIDIA nvngx_dlss.dll (310.9.1)' 'nvngx_dlss.dll' $(if ($DlssDll) { $DlssDll } elseif ($saved) { $saved.dlssDll })
|
||||
$bundledCore=$null; $bundledDlss=$null
|
||||
if ($manifest.bundledNvidia) {
|
||||
$bundledCore=Get-BundledNvidiaFile $manifest.bundledNvidia.ngxCore
|
||||
$bundledDlss=Get-BundledNvidiaFile $manifest.bundledNvidia.dlssDll
|
||||
}
|
||||
$status.nvidiaDllSource=@{core=$(if ($NgxCore) { 'explicit' } elseif ($bundledCore) { 'bundled' } else { 'user-supplied' });
|
||||
dlss=$(if ($DlssDll) { 'explicit' } elseif ($bundledDlss) { 'bundled' } else { 'user-supplied' })}
|
||||
if ($bundledCore -and !$NgxCore -and !$DlssDll) { Write-Host 'Using the validated NVIDIA DLL pair included by this package distributor.' }
|
||||
$NgxCore=Select-LocalFile 'Select your ORIGINAL NVIDIA _nvngx.dll (32.0.16.1714)' '_nvngx.dll' $(if ($NgxCore) { $NgxCore } elseif ($bundledCore) { $bundledCore } elseif ($saved) { $saved.ngxCore })
|
||||
$DlssDll=Select-LocalFile 'Select your NVIDIA nvngx_dlss.dll (310.9.1)' 'nvngx_dlss.dll' $(if ($DlssDll) { $DlssDll } elseif ($bundledDlss) { $bundledDlss } elseif ($saved) { $saved.dlssDll })
|
||||
$status.game=$GameExe
|
||||
$status.localDlls=@($NgxCore,$DlssDll | ForEach-Object { $item=Get-Item -LiteralPath $_; @{path=$item.FullName; version=$item.VersionInfo.FileVersion; sha256=(Get-FileHash -LiteralPath $_ -Algorithm SHA256).Hash} })
|
||||
if ((Get-FileHash -LiteralPath $NgxCore -Algorithm SHA256).Hash -ne $manifest.ngxCoreSha256) {
|
||||
|
||||
@@ -36,8 +36,12 @@ function Invoke-Native([string]$Log,[string]$Exe,[string[]]$Arguments) {
|
||||
}
|
||||
function Build([string]$Name,[string[]]$Arguments) {
|
||||
$log=Join-Path $OutputDirectory "build-$Name.log"
|
||||
# PowerShell 5 strips embedded quotes from native arguments; escape them.
|
||||
if (Invoke-Native $log $cxx @($Arguments | ForEach-Object { $_.Replace('"','\"') })) { throw "Build failed: $Name; see $log" }
|
||||
# PowerShell 5 / Legacy native passing strips embedded quotes. PowerShell
|
||||
# 7's Standard/Windows passing preserves them and must not double-escape.
|
||||
if ($PSVersionTable.PSVersion.Major -le 5 -or $PSNativeCommandArgumentPassing -eq 'Legacy') {
|
||||
$Arguments=@($Arguments | ForEach-Object { $_.Replace('"','\"') })
|
||||
}
|
||||
if (Invoke-Native $log $cxx $Arguments) { throw "Build failed: $Name; see $log" }
|
||||
}
|
||||
$results=@()
|
||||
|
||||
|
||||
@@ -54,6 +54,36 @@ Invoke-Child 'restore' @('-Action','restore')
|
||||
foreach ($name in $before.Keys) { if ((Get-FileHash -LiteralPath (Join-Path $game $name)).Hash -ne $before[$name]) { throw 'Original game bytes not restored.' } }
|
||||
if (Test-Path -LiteralPath (Join-Path $game 'd4r')) { throw 'Runtime directory remains after restore.' }
|
||||
$results+=@{case='auto-gfx1201-install-remember-restore'; passed=$true; gpuKernelsExecuted=$false}
|
||||
$manifest=Get-Content -LiteralPath (Join-Path $PackageRoot 'files/package.json') -Raw | ConvertFrom-Json
|
||||
if ($manifest.bundledNvidia) {
|
||||
# Bundled originals take precedence over stale remembered shim selections;
|
||||
# explicit overrides still go through the existing strict negative gates.
|
||||
$exe=Fixture 'bundled auto selection'
|
||||
$saved.ngxCore=Join-Path $PackageRoot 'files/targets/gfx1201/d4r/_nvngx.dll'
|
||||
$saved.dlssDll=$saved.ngxCore
|
||||
$saved | ConvertTo-Json | Set-Content -LiteralPath (Join-Path $PackageRoot 'work/settings.json') -Encoding UTF8
|
||||
Invoke-Child 'bundled-install' @('-Action','install','-GameExe',$exe)
|
||||
$game=Split-Path $exe
|
||||
foreach ($pair in @(@{path='d4r/vendor/_nvngx.dll'; expected=$NgxCore},@{path='d4r/nvngx_dlss.dll'; expected=$DlssDll})) {
|
||||
if ((Get-FileHash -LiteralPath (Join-Path $game $pair.path)).Hash -ne (Get-FileHash -LiteralPath $pair.expected).Hash) { throw 'Bundled original DLL selection failed.' }
|
||||
}
|
||||
$report=Get-ChildItem -LiteralPath (Join-Path $PackageRoot 'results') -Directory | Sort-Object Name -Descending | Select-Object -First 1
|
||||
$status=Get-Content -LiteralPath (Join-Path $report.FullName 'quick-test.json') -Raw | ConvertFrom-Json
|
||||
if ($status.nvidiaDllSource.core -ne 'bundled' -or $status.nvidiaDllSource.dlss -ne 'bundled') { throw 'Bundled DLL provenance is missing.' }
|
||||
Invoke-Child 'bundled-restore' @('-Action','restore','-GameExe',$exe)
|
||||
if (Test-Path -LiteralPath (Join-Path $game 'd4r')) { throw 'Bundled runtime directory remains after restore.' }
|
||||
$results+=@{case='bundled-auto-selection-ignores-stale-choices'; passed=$true; gpuKernelsExecuted=$false}
|
||||
$core=Join-Path (Join-Path $PackageRoot 'files') $manifest.bundledNvidia.ngxCore
|
||||
$original=[IO.File]::ReadAllBytes($core)
|
||||
try {
|
||||
[IO.File]::AppendAllText($core,'tampered bundled fixture')
|
||||
$exe=Fixture 'tampered bundled core'
|
||||
Invoke-Child 'tampered-bundled-core' @('-Action','install','-GameExe',$exe) 1
|
||||
$game=Split-Path $exe
|
||||
if ((Test-Path -LiteralPath (Join-Path $game '.d4r-backup')) -or (Test-Path -LiteralPath (Join-Path $game 'dxgi.dll'))) { throw 'Tampered bundled DLL changed game files.' }
|
||||
$results+=@{case='tampered-bundled-core'; passed=$true; rejectedBeforeGameChanges=$true; gpuKernelsExecuted=$false}
|
||||
} finally { [IO.File]::WriteAllBytes($core,$original) }
|
||||
}
|
||||
# A harmless child refuses attached debuggers and produces an empty stderr.
|
||||
# The default launcher must allow it to exit and must report no DLSS session.
|
||||
$exe=Join-Path (Join-Path $OutputDirectory 'launcher-fixture') 'Fixture.exe'
|
||||
|
||||
Reference in new issue
Block a user