XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEWarframe

【WinUI】基于Warframe游戏本体的公开服务器以及安装器

公开
关注 0 Fork 0 Star 0
UTF-8
#requires -Version 7.0
param(
    [Parameter(Mandatory)][string]$InstallerPath,
    [Parameter(Mandatory)][string]$GameExecutable,
    [string]$ReportDirectory
)
$ErrorActionPreference = 'Stop'
$taskRoot = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
$taskInstaller = [IO.Path]::GetFullPath($InstallerPath)
$taskSource = [IO.Path]::GetFullPath($GameExecutable)
if (-not $ReportDirectory) { $ReportDirectory = Join-Path $taskRoot ('artifacts/installer-check-' + [guid]::NewGuid().ToString('N')) }
$ReportDirectory = [IO.Path]::GetFullPath($ReportDirectory)
if (Test-Path -LiteralPath $ReportDirectory) { throw 'Use a new isolated report directory.' }
New-Item -ItemType Directory -Path $ReportDirectory -Force | Out-Null
$taskGame = Join-Path $ReportDirectory 'game-copy'
New-Item -ItemType Directory -Path $taskGame | Out-Null
$taskExe = Join-Path $taskGame 'Warframe.x64.exe'
Copy-Item -LiteralPath $taskSource -Destination $taskExe
$taskOriginal = [IO.File]::ReadAllBytes($taskExe)
$taskOriginalHash = (Get-FileHash -LiteralPath $taskSource -Algorithm SHA256).Hash
$taskPayload = Join-Path (Split-Path $taskInstaller) 'Bridge'
$taskManifest = Get-Content -Raw -LiteralPath (Join-Path $taskPayload 'payload.json') | ConvertFrom-Json
$taskChecks = [Collections.Generic.List[object]]::new()
Add-Type -TypeDefinition @'
public static class InstallerFixtureBytes {
    public static int Replace(byte[] data, byte[] needle, byte[] replacement) {
        if (needle.Length != replacement.Length) throw new System.ArgumentException();
        int found = 0;
        for (int i=0; i<=data.Length-needle.Length; i++) {
            int n=0; while(n<needle.Length && data[i+n]==needle[n]) n++;
            if(n!=needle.Length) continue;
            System.Array.Copy(replacement,0,data,i,replacement.Length); found++; i+=needle.Length-1;
        }
        return found;
    }
}
'@
function Check([bool]$Condition, [string]$Name) {
    if (-not $Condition) { throw "FAILED: $Name" }
    $taskChecks.Add(@{name=$Name;passed=$true}); Write-Output "PASS $Name"
}
function Run-Installer([string[]]$Arguments, [int]$Expected = 0) {
    $taskLines = & $taskInstaller @Arguments 2>&1
    $taskExitCode = $LASTEXITCODE
    $taskLines | Set-Content -LiteralPath (Join-Path $ReportDirectory ('command-' + [guid]::NewGuid().ToString('N') + '.log')) -Encoding utf8
    if ($taskExitCode -ne $Expected) { throw ('Installer exited with ' + $taskExitCode + ': ' + ($taskLines -join [Environment]::NewLine)) }
    return ($taskLines -join [Environment]::NewLine)
}
function Read-Compatibility {
    return (Run-Installer @('check','--game',$taskGame)) | ConvertFrom-Json
}
$null = Run-Installer @('selftest','--payload',$taskPayload)
Check $true 'NativeAOT callbacks, instruction relocation and rollback self-test'
$taskReport = Read-Compatibility
$taskReport | ConvertTo-Json -Depth 20 | Set-Content -LiteralPath (Join-Path $ReportDirectory 'compatibility.json') -Encoding utf8
Check $taskReport.Compatible 'Actual executable passes required connection binding checks'
Check (@($taskReport.Checks | Where-Object { $_.Required -and $_.Found -ne $_.Expected }).Count -eq 0) 'Every required binding is resolved without reusing old addresses'
Check ($taskReport.Checks.Name -contains 'NrsAnalyze') 'Connectivity binding is reported separately'
$taskLegacy = Join-Path $taskGame 'version.dll'
[IO.File]::WriteAllBytes($taskLegacy, [Text.Encoding]::UTF8.GetBytes('isolated legacy proxy fixture'))
$taskLegacyHash = (Get-FileHash -LiteralPath $taskLegacy -Algorithm SHA256).Hash
$null = Run-Installer @('install','--game',$taskGame,'--server','http://127.0.0.1:8444','--payload',$taskPayload)
$null = Run-Installer @('status','--game',$taskGame)
Check (-not (Test-Path -LiteralPath $taskLegacy)) 'Old proxy is isolated by installation'
$taskState = Get-Content -Raw -LiteralPath (Join-Path $taskGame 'XFEWarframe/installation.json') | ConvertFrom-Json
Check ($taskState.Version -eq $taskManifest.Version -and $taskState.LegacyFiles.Count -eq 1) 'Current component installs with one legacy backup'
Check ((Get-FileHash -LiteralPath $taskExe -Algorithm SHA256).Hash -eq $taskOriginalHash) 'Installation preserves the original game executable'
$null = Run-Installer @('repair','--game',$taskGame,'--server','http://127.0.0.1:8444','--payload',$taskPayload)
$taskRepaired = Get-Content -Raw -LiteralPath (Join-Path $taskGame 'XFEWarframe/installation.json') | ConvertFrom-Json
Check ($taskRepaired.LegacyFiles.Count -eq 1) 'Repair retains the original proxy backup without duplication'
$taskConfigurationPath = Join-Path $taskGame 'XFEWarframe/client.json'
$taskConfiguration = Get-Content -Raw -LiteralPath $taskConfigurationPath | ConvertFrom-Json
Check $taskConfiguration.RestoreAirSlideHeavyAttacks 'Air-slide heavy restoration is enabled on a new installation'
$taskConfiguration.Language = 'en'
$taskConfiguration.DirectX12 = $true
$taskConfiguration.GameServerUrl = 'https://127.0.0.1:8443'
$taskConfiguration.RestoreAirSlideHeavyAttacks = $false
$taskConfiguration | ConvertTo-Json -Depth 20 | Set-Content -LiteralPath $taskConfigurationPath -Encoding utf8
$null = Run-Installer @('repair','--game',$taskGame,'--server','http://127.0.0.1:8444','--payload',$taskPayload)
$taskRetained = Get-Content -Raw -LiteralPath $taskConfigurationPath | ConvertFrom-Json
Check ($taskRetained.Language -eq 'en' -and $taskRetained.DirectX12 -and $taskRetained.GameServerUrl -eq 'https://127.0.0.1:8443') 'Binding repair preserves renderer, language and game endpoint'
Check (-not $taskRetained.RestoreAirSlideHeavyAttacks) 'Binding repair preserves the air-slide heavy opt-out'
$null = Run-Installer @('uninstall','--game',$taskGame)
Check ((Get-FileHash -LiteralPath $taskLegacy -Algorithm SHA256).Hash -eq $taskLegacyHash) 'Uninstall restores the proxy byte-for-byte'
Check (-not (Test-Path -LiteralPath (Join-Path $taskGame 'XFEWarframe/installation.json'))) 'Uninstall removes managed installation state'
$null = Run-Installer @('install','--game',$taskGame,'--server','http://127.0.0.1:8444','--payload',$taskPayload)
$null = Run-Installer @('status','--game',$taskGame)
Check $true 'Clean reinstallation verifies successfully'

# Simulate a later build losing optional signatures. Only the disposable copy
# is changed; no game is launched and the user's selected directory is read-only.
$taskFuture = [byte[]]$taskOriginal.Clone()
foreach ($taskAnchor in @('NRS Server ', '/NetTest/Firewall')) {
    $taskNeedle = [Text.Encoding]::ASCII.GetBytes($taskAnchor + [char]0)
    $taskReplacement = [byte[]]$taskNeedle.Clone(); $taskReplacement[0] = [byte][char]'X'
    $null = [InstallerFixtureBytes]::Replace($taskFuture, $taskNeedle, $taskReplacement)
}
$taskLevel = [Convert]::FromHexString('4433C5413BC073')
$taskCount = [InstallerFixtureBytes]::Replace($taskFuture, $taskLevel, [byte[]]@(0x90,0x90,0x90,0x90,0x90,0x90,0x90))
Check ($taskCount -gt 0) 'Future-build fixture changes the optional mastery signature'
[IO.File]::WriteAllBytes($taskExe, $taskFuture)
$taskOptional = Read-Compatibility
Check ($taskOptional.Compatible -and $taskOptional.Warnings.Count -gt 0 -and -not $taskOptional.Addresses.PSObject.Properties['LevelCap']) 'Unavailable optional binding does not reject the whole installation'
Check (-not $taskOptional.Addresses.PSObject.Properties['NrsAnalyze']) 'Unverified connectivity entry is omitted instead of guessing an address'
$null = Run-Installer @('repair','--game',$taskGame,'--server','http://127.0.0.1:8444','--payload',$taskPayload)
$null = Run-Installer @('status','--game',$taskGame)
Check $true 'Reduced-capability installation and integrity verification succeed'

# Core protocol functions remain mandatory even when optional functions degrade.
$taskCritical = [byte[]]$taskOriginal.Clone()
$taskRsa = [Convert]::FromHexString('498B41084C8B5008')
Check ([InstallerFixtureBytes]::Replace($taskCritical, $taskRsa, [byte[]]@(0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90)) -gt 0) 'Unknown-core fixture changes the actual RSA binding'
[IO.File]::WriteAllBytes($taskExe, $taskCritical)
$taskStateBeforeFailure = (Get-FileHash -LiteralPath (Join-Path $taskGame 'XFEWarframe/installation.json') -Algorithm SHA256).Hash
$taskFailure = Run-Installer @('repair','--game',$taskGame,'--server','http://127.0.0.1:8444','--payload',$taskPayload) -Expected 1
Check ($taskFailure -match 'RsaEncrypt') 'Missing core binding is rejected with its specific name'
Check ((Get-FileHash -LiteralPath (Join-Path $taskGame 'XFEWarframe/installation.json') -Algorithm SHA256).Hash -eq $taskStateBeforeFailure) 'Rejected repair preserves the previous installation'
[IO.File]::WriteAllBytes($taskExe, $taskOriginal)
$null = Run-Installer @('repair','--game',$taskGame,'--server','http://127.0.0.1:8444','--payload',$taskPayload)
$null = Run-Installer @('status','--game',$taskGame)
Check ((Get-FileHash -LiteralPath $taskSource -Algorithm SHA256).Hash -eq $taskOriginalHash) 'User game executable remains unchanged after every check'
@{passed=$true;gameVersion=$taskReport.Version;gameSha256=$taskOriginalHash;bridgeVersion=$taskManifest.Version;
    scope='Actual EXE copy, install/repair/uninstall, optional and mandatory binding failure; no game launch or desktop input';
    checks=$taskChecks} | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath (Join-Path $ReportDirectory 'result.json') -Encoding utf8
Write-Output "Installer verification results: $ReportDirectory"