param( [string]$Root = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path ) $ErrorActionPreference = 'Stop' function Pass($message) { Write-Host "[OK] $message" -ForegroundColor Green } function Fail($message) { throw "[FAIL] $message" } function Require-File($relative) { $path = Join-Path $Root $relative if (!(Test-Path -LiteralPath $path -PathType Leaf)) { Fail "Missing file: $relative" } Pass "Found $relative" } Push-Location $Root try { if (Test-Path -LiteralPath (Join-Path $Root 'PokerGameSetup.exe')) { Require-File 'PokerGameSetup.exe' } if (Test-Path -LiteralPath (Join-Path $Root 'dist\Assembler Casino.exe')) { Require-File 'dist\Assembler Casino.exe' } else { Require-File 'Assembler Casino.exe' } if (Test-Path -LiteralPath (Join-Path $Root 'dist\Uninstall Assembler Casino.exe')) { Require-File 'dist\Uninstall Assembler Casino.exe' } else { Require-File 'Uninstall Assembler Casino.exe' } Require-File 'bin\poker.exe' Require-File 'assets\icons\casino.ico' Require-File 'assets\animations\hakari_dance.ans' Require-File 'assets\animations\dbd_hook.ans' $dbdRelative = if (Test-Path -LiteralPath (Join-Path $Root 'tools\previews\preview_dbd_hook.bat')) { 'tools\previews\preview_dbd_hook.bat' } else { 'tools\preview_dbd_hook.bat' } Require-File $dbdRelative Require-File 'docs\README_RELEASE.txt' Require-File 'docs\RELEASE_CHECKLIST.txt' Require-File 'docs\KNOWN_LIMITATIONS.txt' Require-File 'docs\SECURITY_NOTES.txt' Require-File 'docs\ROADMAP.txt' Require-File 'docs\ONLINE_RADMIN.txt' foreach ($mambo in @( 'assets\animations\mambo1.ans', 'assets\animations\mambo2.ans', 'assets\animations\mambo3.ans', 'assets\animations\mambo4.ans' )) { if (Test-Path -LiteralPath (Join-Path $Root $mambo) -PathType Leaf) { Fail "Removed MAMBO animation still exists: $mambo" } } Pass 'MAMBO animation files are removed from assets' $dbdBat = Get-Content -LiteralPath (Join-Path $Root $dbdRelative) -Raw if ($dbdBat -match 'Clear-Host') { Fail 'DBD helper still uses Clear-Host' } Pass 'DBD helper does not use Clear-Host' $asmBytes = [IO.File]::ReadAllBytes((Join-Path $Root 'poker.asm')) $cp1251 = [Text.Encoding]::GetEncoding(1251) $asmText = $cp1251.GetString($asmBytes) foreach ($needle in @( 'SAVE_SIGN_SIZE equ 276', 'SAVE_FILE_SIZE equ 312', 'CalcSaveSignature PROC', 'mov DWORD PTR [saveBuffer+SAVE_SIGN_SIZE], eax', 'cmp charsRead,SAVE_FILE_SIZE', 'includelib ws2_32.lib' )) { if ($asmText.IndexOf($needle) -lt 0) { Fail "Missing source marker: $needle" } } Pass 'Save signature and library markers exist in poker.asm' if ($asmText -match 'MAMBO|mambo|PlayMambo') { Fail 'MAMBO markers still exist in poker.asm' } Pass 'MAMBO markers are removed from poker.asm' $launcherSource = Join-Path $Root 'build\AssemblerCasinoLauncher.cs' if (!(Test-Path -LiteralPath $launcherSource -PathType Leaf)) { Fail 'Missing launcher source: build\AssemblerCasinoLauncher.cs' } $launcherText = Get-Content -LiteralPath $launcherSource -Raw -Encoding UTF8 $expectedPokerHash = $null if ($launcherText -match 'ExpectedPokerSha256 = "([A-Fa-f0-9]{64})"') { $expectedPokerHash = $matches[1].ToUpperInvariant() } if ([string]::IsNullOrWhiteSpace($expectedPokerHash)) { Fail 'Launcher source does not contain a fixed poker.exe SHA-256 hash' } $pokerSha = [Security.Cryptography.SHA256]::Create() try { $actualPokerHash = [BitConverter]::ToString($pokerSha.ComputeHash([IO.File]::ReadAllBytes((Join-Path $Root 'bin\poker.exe')))).Replace('-', '').ToUpperInvariant() } finally { $pokerSha.Dispose() } if ($actualPokerHash -ne $expectedPokerHash) { Fail "Launcher poker.exe SHA-256 mismatch. Expected $expectedPokerHash, actual $actualPokerHash" } Pass 'Launcher poker.exe SHA-256 matches current bin\poker.exe' $modernStamp = Join-Path $Root 'build\installer\PokerGameSetup\PackageStamp.cs' $legacySetup = Join-Path $Root 'build\PokerGameSetupGui.cs' $expectedHash = $null $isModern = $false if (Test-Path -LiteralPath $modernStamp -PathType Leaf) { $stampText = Get-Content -LiteralPath $modernStamp -Raw -Encoding UTF8 if ($stampText -match 'IndexSha256 = "([A-Fa-f0-9]{64})"') { $expectedHash = $matches[1].ToLowerInvariant() $isModern = $true } } if (!$isModern -and (Test-Path -LiteralPath $legacySetup -PathType Leaf)) { $setupSourceText = Get-Content -LiteralPath $legacySetup -Raw -Encoding UTF8 if ($setupSourceText -match 'ExpectedPayloadSha256 = "([A-Fa-f0-9]{64})"') { $expectedHash = $matches[1].ToUpperInvariant() } } if ([string]::IsNullOrWhiteSpace($expectedHash)) { Fail 'Installer source does not contain a fixed SHA-256 package/index hash' } Add-Type -AssemblyName System.IO.Compression Add-Type -AssemblyName System.IO.Compression.FileSystem $setupPath = Join-Path $Root 'PokerGameSetup.exe' if (Test-Path -LiteralPath $setupPath) { $fs = [IO.File]::OpenRead($setupPath) try { if ($fs.Length -ge 32) { $fs.Position = $fs.Length - 32 $br = New-Object IO.BinaryReader($fs, [Text.Encoding]::UTF8) $payloadOffset = $br.ReadInt64() $indexLen = $br.ReadInt64() $magicBytes = $br.ReadBytes(16) $magicStr = [Text.Encoding]::ASCII.GetString($magicBytes) if ($magicStr -eq "CASINO-PACK-V2!`n") { $indexPos = $fs.Length - 32 - $indexLen $fs.Position = $indexPos $indexBytes = $br.ReadBytes([int]$indexLen) $sha = [Security.Cryptography.SHA256]::Create() $actualIndexHash = [BitConverter]::ToString($sha.ComputeHash($indexBytes)).Replace('-', '').ToLowerInvariant() $sha.Dispose() if ($actualIndexHash -ne $expectedHash.ToLowerInvariant()) { Fail "Installer XML index SHA-256 mismatch. Expected $expectedHash, actual $actualIndexHash" } Pass 'Installer XML index SHA-256 matches embedded hash' [xml]$indexXml = [Text.Encoding]::UTF8.GetString($indexBytes) $gameNode = $indexXml.SelectSingleNode('//game') if ($null -eq $gameNode) { Fail 'Missing node in installer XML index' } $gameOffset = [long]$gameNode.GetAttribute('offset') $gameLen = [long]$gameNode.GetAttribute('length') $gameBytes = [long]$gameNode.GetAttribute('bytes') $fs.Position = $payloadOffset + $gameOffset $gameZipBytes = New-Object byte[] ([int]$gameLen) [void]$fs.Read($gameZipBytes, 0, [int]$gameLen) $ms = New-Object IO.MemoryStream(,$gameZipBytes) $zip = New-Object IO.Compression.ZipArchive($ms, [IO.Compression.ZipArchiveMode]::Read) try { $names = @($zip.Entries | ForEach-Object FullName) foreach ($entry in @( 'Assembler Casino.exe', 'Uninstall Assembler Casino.exe', 'bin/poker.exe', 'assets/icons/casino.ico', 'tools/preview_dbd_hook.bat', 'tools/release_smoke_check.ps1', 'docs/README_RELEASE.txt', 'docs/RELEASE_CHECKLIST.txt', 'docs/KNOWN_LIMITATIONS.txt', 'docs/SECURITY_NOTES.txt', 'docs/ROADMAP.txt', 'docs/ONLINE_RADMIN.txt' )) { if ($names -notcontains $entry) { Fail "Installer payload missing: $entry" } } if ($names -contains 'Assembler Casino.bat') { Fail 'Installer payload still contains old Assembler Casino.bat' } if ($names | Where-Object { $_ -like 'tools/generated_frames/*' }) { Fail 'Installer payload contains generated preview frames/tools' } Pass "Installer payload OK ($($names.Count) files)" } finally { $zip.Dispose() $ms.Dispose() } $modelNode = $indexXml.SelectSingleNode('//model') if ($null -ne $modelNode) { Pass "Installer bundles offline neural model: $($modelNode.GetAttribute('path')) ($([math]::Round([long]$modelNode.GetAttribute('bytes')/1e9, 2)) GB)" } $isModern = $true } } if (!$isModern) { $headLen = [int][Math]::Min([long]2097152, $fs.Length) $head = New-Object byte[] ($headLen) $fs.Position = 0 [void]$fs.Read($head, 0, $head.Length) $marker = [Text.Encoding]::UTF8.GetBytes('<>') $idx = -1 for ($i = 0; $i -le $head.Length - $marker.Length; $i++) { if ($head[$i] -ne $marker[0]) { continue } $ok = $true for ($j = 1; $j -lt $marker.Length; $j++) { if ($head[$i + $j] -ne $marker[$j]) { $ok = $false; break } } if ($ok) { $idx = $i; break } } if ($idx -lt 0) { Fail 'Installer payload marker not found' } $fs.Position = $idx + $marker.Length $zipBytes = New-Object byte[] ($fs.Length - $fs.Position) [void]$fs.Read($zipBytes, 0, $zipBytes.Length) $ms = New-Object IO.MemoryStream(,$zipBytes) $zip = New-Object IO.Compression.ZipArchive($ms, [IO.Compression.ZipArchiveMode]::Read) try { $names = @($zip.Entries | ForEach-Object FullName) foreach ($entry in @( 'Assembler Casino.exe', 'Uninstall Assembler Casino.exe', 'bin/poker.exe', 'assets/icons/casino.ico', 'tools/preview_dbd_hook.bat', 'tools/release_smoke_check.ps1', 'docs/README_RELEASE.txt', 'docs/RELEASE_CHECKLIST.txt', 'docs/KNOWN_LIMITATIONS.txt', 'docs/SECURITY_NOTES.txt', 'docs/ROADMAP.txt', 'docs/ONLINE_RADMIN.txt' )) { if ($names -notcontains $entry) { Fail "Installer payload missing: $entry" } } if ($names -contains 'Assembler Casino.bat') { Fail 'Installer payload still contains old Assembler Casino.bat' } if ($names | Where-Object { $_ -like 'tools/generated_frames/*' }) { Fail 'Installer payload contains generated preview frames/tools' } Pass "Installer payload OK ($($names.Count) files)" } finally { $zip.Dispose() $ms.Dispose() } $sha = [Security.Cryptography.SHA256]::Create() $actualHash = [BitConverter]::ToString($sha.ComputeHash($zipBytes)).Replace('-', '').ToUpperInvariant() $sha.Dispose() if ($actualHash -ne $expectedHash) { Fail "Installer payload SHA-256 mismatch. Expected $expectedHash, actual $actualHash" } Pass 'Installer payload SHA-256 matches embedded hash' } } finally { $fs.Dispose() } } else { Pass 'PokerGameSetup.exe not present (skipping installer binary payload check)' } Write-Host '' Write-Host 'Release smoke check passed.' -ForegroundColor Cyan } finally { Pop-Location }