# ============================================================================== # Shiny Store - Instalador Oficial de Jogos Steam (Offline + Online-Fix Auto) # Vitrine Oficial: https://shiny-store.ggnext.com.br/ # Suporte Discord: https://discord.gg/AujQedR7X7 # ============================================================================== $ErrorActionPreference = "Stop" # Garante TLS 1.2 no Windows PowerShell 5.1 try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 } catch { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 } $WorkerBaseUrl = "https://shinykeys.xyz" $StorePublicUrl = "https://shiny-store.ggnext.com.br/" $SupportDiscordUrl = "https://discord.gg/AujQedR7X7" function Write-Banner { Clear-Host Write-Host "======================================================================" -ForegroundColor Cyan Write-Host " SHINY STORE - STEAM " -ForegroundColor White Write-Host " Instalador Automatico de Jogos e Pacotes " -ForegroundColor Gray Write-Host "----------------------------------------------------------------------" -ForegroundColor Cyan Write-Host " Vitrine Oficial : $StorePublicUrl" -ForegroundColor Yellow Write-Host " Suporte Discord : $SupportDiscordUrl" -ForegroundColor Yellow Write-Host "======================================================================" -ForegroundColor Cyan Write-Host "" } function Get-SteamInstallPath { $regPaths = @( @{ Path = "HKCU:\Software\Valve\Steam"; Name = "SteamPath" }, @{ Path = "HKCU:\Software\Valve\Steam"; Name = "SteamExe" }, @{ Path = "HKLM:\SOFTWARE\WOW6432Node\Valve\Steam"; Name = "InstallPath" }, @{ Path = "HKLM:\SOFTWARE\Valve\Steam"; Name = "InstallPath" } ) foreach ($entry in $regPaths) { try { $props = Get-ItemProperty -Path $entry.Path -Name $entry.Name -ErrorAction SilentlyContinue if ($props -and $props.($entry.Name)) { $val = [string]$props.($entry.Name) if ($entry.Name -eq "SteamExe") { $val = Split-Path -Parent $val } $normalized = $val.Replace("/", "\").TrimEnd("\") if (Test-Path $normalized) { return $normalized } } } catch {} } $fallbacks = @( "C:\Program Files (x86)\Steam", "C:\Program Files\Steam" ) foreach ($fb in $fallbacks) { if (Test-Path $fb) { return $fb } } return $null } function Get-SteamId64 { param([Parameter(Mandatory = $true)][string]$SteamPath) $loginUsersPath = Join-Path $SteamPath "config\loginusers.vdf" if (Test-Path -LiteralPath $loginUsersPath) { try { $raw = Get-Content -LiteralPath $loginUsersPath -Raw -Encoding UTF8 $blocks = [regex]::Matches($raw, '"([0-9]{17})"\s*\{([^}]*)\}') $bestId = $null $bestRecent = $false foreach ($block in $blocks) { $id = $block.Groups[1].Value $body = $block.Groups[2].Value $isRecent = $body -match '"MostRecent"\s+"1"' if (-not $bestId -or ($isRecent -and -not $bestRecent)) { $bestId = $id $bestRecent = [bool]$isRecent } } if ($bestId) { return $bestId } } catch {} } try { $activeProps = Get-ItemProperty -Path "HKCU:\Software\Valve\Steam\ActiveProcess" -Name "ActiveUser" -ErrorAction SilentlyContinue if ($activeProps -and [int64]$activeProps.ActiveUser -gt 0) { return [string](76561197960265728L + [int64]$activeProps.ActiveUser) } } catch {} return $null } function Get-ApiErrorMessage { param($ErrorRecord) $errMsg = $ErrorRecord.Exception.Message $rawBody = $null if ($ErrorRecord.ErrorDetails -and $ErrorRecord.ErrorDetails.Message) { $rawBody = $ErrorRecord.ErrorDetails.Message } elseif ($ErrorRecord.Exception.Response) { try { $stream = $ErrorRecord.Exception.Response.GetResponseStream() if ($stream) { $reader = New-Object System.IO.StreamReader($stream) $rawBody = $reader.ReadToEnd() $reader.Dispose() } } catch {} } if ($rawBody) { try { $parsedErr = $rawBody | ConvertFrom-Json if ($parsedErr.error) { return [string]$parsedErr.error } } catch { return $rawBody } } return $errMsg } function Get-SteamLibraryFolders { param([Parameter(Mandatory = $true)][string]$SteamPath) $libraries = New-Object System.Collections.Generic.List[string] $libraries.Add($SteamPath) $vdfPath = Join-Path $SteamPath "steamapps\libraryfolders.vdf" if (Test-Path $vdfPath) { $content = Get-Content -LiteralPath $vdfPath -Raw -Encoding UTF8 # Formato moderno: "path" "D:\\SteamLibrary" $pathMatches = [regex]::Matches($content, '"path"\s+"([^"]+)"') foreach ($m in $pathMatches) { $libPath = $m.Groups[1].Value.Replace("\\", "\").TrimEnd("\") if ((Test-Path $libPath) -and (-not $libraries.Contains($libPath))) { $libraries.Add($libPath) } } # Formato legado: "1" "D:\\SteamLibrary" $legacyMatches = [regex]::Matches($content, '"\d+"\s+"([A-Za-z]:\\\\[^"]+)"') foreach ($m in $legacyMatches) { $libPath = $m.Groups[1].Value.Replace("\\", "\").TrimEnd("\") if ((Test-Path $libPath) -and (-not $libraries.Contains($libPath))) { $libraries.Add($libPath) } } } return $libraries } function Get-SteamGameInstallDir { param( [Parameter(Mandatory = $true)][System.Collections.Generic.List[string]]$Libraries, [Parameter(Mandatory = $true)][string]$AppId ) foreach ($lib in $Libraries) { $acfPath = Join-Path $lib ("steamapps\appmanifest_{0}.acf" -f $AppId) if (Test-Path $acfPath) { $acfContent = Get-Content -LiteralPath $acfPath -Raw -Encoding UTF8 $m = [regex]::Match($acfContent, '"installdir"\s+"([^"]+)"') if ($m.Success) { $installDirName = $m.Groups[1].Value.Trim() $candidate = Join-Path $lib ("steamapps\common\{0}" -f $installDirName) if (Test-Path $candidate) { return $candidate } } } } return $null } function Invoke-FileDownload { param( [Parameter(Mandatory = $true)][string]$Url, [Parameter(Mandatory = $true)][string]$DestinationPath ) $parent = Split-Path -Parent $DestinationPath if (-not (Test-Path $parent)) { New-Item -ItemType Directory -Path $parent -Force | Out-Null } $ProgressPreference = "SilentlyContinue" Invoke-WebRequest -Uri $Url -OutFile $DestinationPath -UseBasicParsing } function Install-ManifestPackage { param( [Parameter(Mandatory = $true)][string]$ZipPath, [Parameter(Mandatory = $true)][string]$SteamPath, [Parameter(Mandatory = $true)][string]$TempRoot ) $extractDir = Join-Path $TempRoot "manifest_extracted" if (Test-Path $extractDir) { Remove-Item -LiteralPath $extractDir -Recurse -Force } New-Item -ItemType Directory -Path $extractDir -Force | Out-Null Expand-Archive -LiteralPath $ZipPath -DestinationPath $extractDir -Force $depotCacheDir = Join-Path $SteamPath "depotcache" $stPluginDir = Join-Path $SteamPath "config\stplug-in" $luaDir = Join-Path $SteamPath "config\lua" $steamAppsDir = Join-Path $SteamPath "steamapps" New-Item -ItemType Directory -Path $depotCacheDir -Force | Out-Null New-Item -ItemType Directory -Path $steamAppsDir -Force | Out-Null $structuredFolders = @("depotcache", "config", "steamapps") $hasStructuredLayout = $false foreach ($folderName in $structuredFolders) { $srcFolder = Join-Path $extractDir $folderName if (Test-Path $srcFolder) { $hasStructuredLayout = $true $dstFolder = Join-Path $SteamPath $folderName New-Item -ItemType Directory -Path $dstFolder -Force | Out-Null Copy-Item -Path (Join-Path $srcFolder "*") -Destination $dstFolder -Recurse -Force } } if (-not $hasStructuredLayout) { $allFiles = Get-ChildItem -LiteralPath $extractDir -File -Recurse foreach ($file in $allFiles) { $ext = $file.Extension.ToLowerInvariant() if ($ext -eq ".manifest") { Copy-Item -LiteralPath $file.FullName -Destination (Join-Path $depotCacheDir $file.Name) -Force } elseif ($ext -eq ".lua") { New-Item -ItemType Directory -Path $stPluginDir -Force | Out-Null New-Item -ItemType Directory -Path $luaDir -Force | Out-Null Copy-Item -LiteralPath $file.FullName -Destination (Join-Path $stPluginDir $file.Name) -Force Copy-Item -LiteralPath $file.FullName -Destination (Join-Path $luaDir $file.Name) -Force } elseif ($ext -eq ".st") { New-Item -ItemType Directory -Path $stPluginDir -Force | Out-Null Copy-Item -LiteralPath $file.FullName -Destination (Join-Path $stPluginDir $file.Name) -Force } elseif ($ext -eq ".acf") { Copy-Item -LiteralPath $file.FullName -Destination (Join-Path $steamAppsDir $file.Name) -Force } else { Copy-Item -LiteralPath $file.FullName -Destination (Join-Path $depotCacheDir $file.Name) -Force } } } } function Apply-OnlineFixAutomatic { param( [Parameter(Mandatory = $true)][string]$ZipPath, [Parameter(Mandatory = $true)][string]$GameDir, [Parameter(Mandatory = $true)][string]$AppId ) Add-Type -AssemblyName System.IO.Compression.FileSystem # Backup silencioso dos arquivos originais que serao substituidos pelo Online-Fix $backupRoot = Join-Path $GameDir ("_shiny_backup_offline\{0}" -f $AppId) $zipArchive = [System.IO.Compression.ZipFile]::OpenRead($ZipPath) try { foreach ($entry in $zipArchive.Entries) { # Ignora entradas de diretorio if ([string]::IsNullOrEmpty($entry.Name)) { continue } $relativePath = $entry.FullName.Replace("/", "\").TrimStart("\") $targetFile = Join-Path $GameDir $relativePath if (Test-Path -LiteralPath $targetFile -PathType Leaf) { $backupFile = Join-Path $backupRoot $relativePath # Preserva o primeiro backup offline original sem sobrescreve-lo em reaplicacoes if (-not (Test-Path -LiteralPath $backupFile)) { $backupParent = Split-Path -Parent $backupFile if (-not (Test-Path -LiteralPath $backupParent)) { New-Item -ItemType Directory -Path $backupParent -Force | Out-Null } Copy-Item -LiteralPath $targetFile -Destination $backupFile -Force } } } } finally { $zipArchive.Dispose() } # Extracao direta na pasta do jogo com Expand-Archive nativo do Windows (ZIP sem senha) Expand-Archive -LiteralPath $ZipPath -DestinationPath $GameDir -Force } # ============================================================================== # Fluxo Principal # ============================================================================== Write-Banner Write-Host "[1/4] Detectando instalacao, bibliotecas e conta Steam..." -ForegroundColor Cyan $SteamPath = Get-SteamInstallPath if (-not $SteamPath) { Write-Host "[ERRO] Steam nao encontrada neste computador. Instale a Steam e tente novamente." -ForegroundColor Red exit 1 } $SteamLibraries = Get-SteamLibraryFolders -SteamPath $SteamPath $SteamId = Get-SteamId64 -SteamPath $SteamPath Write-Host ("[OK] Steam detectada em: {0} ({1} biblioteca(s) localizada(s))" -f $SteamPath, $SteamLibraries.Count) -ForegroundColor Green if ($SteamId) { Write-Host ("[OK] SteamID64 detectado: {0}" -f $SteamId) -ForegroundColor Green } else { Write-Host "[INFO] Nao foi possivel detectar o SteamID64 automaticamente." -ForegroundColor Yellow $SteamId = (Read-Host " Informe seu SteamID64").Trim() if ([string]::IsNullOrWhiteSpace($SteamId)) { Write-Host "[ERRO] SteamID64 e obrigatorio para vincular e resgatar a chave." -ForegroundColor Red exit 1 } } Write-Host "" Write-Host "Para liberar e instalar seu jogo, informe o codigo recebido na compra:" -ForegroundColor White Write-Host "" $LicenseCode = (Read-Host " Codigo da Chave (SHINY-XXXXX-XXXXX)").Trim().ToUpperInvariant() if ([string]::IsNullOrWhiteSpace($LicenseCode)) { Write-Host "" Write-Host "[ERRO] Codigo da chave e obrigatorio." -ForegroundColor Red exit 1 } if ($LicenseCode -notmatch '^SHINY-[A-Z0-9]{5}-[A-Z0-9]{5}$') { Write-Host "" Write-Host "[ERRO] Formato invalido. Use o padrao SHINY-XXXXX-XXXXX." -ForegroundColor Red exit 1 } Write-Host "" Write-Host "[2/4] Validando e resgatando chave na Shiny Store..." -ForegroundColor Cyan $payloadJson = @{ code = $LicenseCode steamId = $SteamId } | ConvertTo-Json -Compress try { $redeem = Invoke-RestMethod ` -Uri "$WorkerBaseUrl/api/redeem-key" ` -Method Post ` -ContentType "application/json; charset=utf-8" ` -Body $payloadJson } catch { $errMsg = Get-ApiErrorMessage -ErrorRecord $_ Write-Host "[ERRO] Nao foi possivel validar a chave: $errMsg" -ForegroundColor Red Write-Host " Suporte Discord: $SupportDiscordUrl" -ForegroundColor Yellow exit 1 } if (-not $redeem.ok -or -not $redeem.token -or -not $redeem.appId) { Write-Host "[ERRO] Resposta invalida do servidor de entrega." -ForegroundColor Red exit 1 } $Token = [string]$redeem.token $AppId = [string]$redeem.appId $Title = if ($redeem.title) { [string]$redeem.title } elseif ($redeem.productTitle) { [string]$redeem.productTitle } else { "Steam App $AppId" } $HasManifest = [bool]$redeem.hasManifest $HasOnlineFix = [bool]$redeem.hasOnlineFix Write-Host ("[OK] Chave {0} validada! Jogo: {1} (AppID: {2})" -f $LicenseCode, $Title, $AppId) -ForegroundColor Green $SessionTempDir = Join-Path $env:TEMP ("shiny-store-install-" + [Guid]::NewGuid().ToString("N").Substring(0, 8)) New-Item -ItemType Directory -Path $SessionTempDir -Force | Out-Null $OnlineFixAppliedCount = 0 $OnlineFixPendingDownloadCount = 0 try { Write-Host "" Write-Host "[3/4] Baixando e aplicando pacotes do jogo..." -ForegroundColor Cyan $gameTmpDir = Join-Path $SessionTempDir $AppId New-Item -ItemType Directory -Path $gameTmpDir -Force | Out-Null Write-Host "" Write-Host (" -> {0} (AppID: {1})" -f $Title, $AppId) -ForegroundColor White # Etapa A: Manifesto / Pacote principal (manifests/{appId}.zip) if ($HasManifest) { $manifestUrl = "$WorkerBaseUrl/api/download/manifest/${AppId}?token=$([Uri]::EscapeDataString($Token))" $manifestZip = Join-Path $gameTmpDir "manifest.zip" Write-Host (" Baixando e extraindo manifests/{0}.zip..." -f $AppId) -ForegroundColor Gray Invoke-FileDownload -Url $manifestUrl -DestinationPath $manifestZip Install-ManifestPackage -ZipPath $manifestZip -SteamPath $SteamPath -TempRoot $gameTmpDir Write-Host " [OK] Pacote de manifesto instalado na Steam." -ForegroundColor Green } else { Write-Host (" [INFO] Pacote manifests/{0}.zip nao encontrado no repositorio; seguindo..." -f $AppId) -ForegroundColor DarkGray } # Etapa B: Online-Fix (onlinefix/{appId}.zip) caso disponivel if ($HasOnlineFix) { $onlineFixUrl = "$WorkerBaseUrl/api/download/onlinefix/${AppId}?token=$([Uri]::EscapeDataString($Token))" $onlineFixZip = Join-Path $gameTmpDir "onlinefix.zip" Write-Host (" Baixando pacote adicional onlinefix/{0}.zip..." -f $AppId) -ForegroundColor Gray Invoke-FileDownload -Url $onlineFixUrl -DestinationPath $onlineFixZip $gameInstallDir = Get-SteamGameInstallDir -Libraries $SteamLibraries -AppId $AppId if ($gameInstallDir) { Apply-OnlineFixAutomatic -ZipPath $onlineFixZip -GameDir $gameInstallDir -AppId $AppId $OnlineFixAppliedCount++ Write-Host (" [OK] Online-Fix extraido em: {0} (backup offline salvo)." -f $gameInstallDir) -ForegroundColor Green } else { # Jogo ainda nao foi baixado pela Steam: guarda pacote pronto para reaplicacao automatica $stagingDir = Join-Path $SteamPath ("_shiny_onlinefix_pronto\{0}" -f $AppId) New-Item -ItemType Directory -Path $stagingDir -Force | Out-Null Copy-Item -LiteralPath $onlineFixZip -Destination (Join-Path $stagingDir "onlinefix_${AppId}.zip") -Force $OnlineFixPendingDownloadCount++ Write-Host " [INFO] Pasta do jogo nao encontrada na Steam ainda. Conclua o download pela Steam e rode este instalador novamente com a mesma chave para aplicar o Online-Fix automaticamente." -ForegroundColor Yellow } } else { Write-Host " [OK] Setup Offline concluido." -ForegroundColor Green } } finally { if (Test-Path $SessionTempDir) { Remove-Item -LiteralPath $SessionTempDir -Recurse -Force -ErrorAction SilentlyContinue } } Write-Host "" Write-Host "[4/4] Finalizacao" -ForegroundColor Cyan Write-Host "======================================================================" -ForegroundColor Green Write-Host " Instalacao concluida com sucesso! Reinicie a Steam para atualizar." -ForegroundColor Green Write-Host "======================================================================" -ForegroundColor Green Write-Host "" Write-Host "AVISO IMPORTANTE (TRANSPARENCIA SHINY STORE):" -ForegroundColor Yellow Write-Host " - O foco principal dos jogos disponibilizados na Shiny Store e o" -ForegroundColor White Write-Host " MODO OFFLINE (Campanha / Single-Player)." -ForegroundColor White if ($OnlineFixAppliedCount -gt 0 -or $OnlineFixPendingDownloadCount -gt 0) { Write-Host " - Um recurso adicional de Modo Online (Online-Fix) foi identificado" -ForegroundColor White Write-Host " e processado automaticamente junto ao seu jogo, porem recursos" -ForegroundColor White Write-Host " Online/Multijogador PODEM OU NAO FUNCIONAR conforme atualizacoes" -ForegroundColor White Write-Host " da Steam ou do proprio jogo." -ForegroundColor White } else { Write-Host " - Recursos Online/Multijogador, quando disponiveis, podem ou nao" -ForegroundColor White Write-Host " funcionar conforme atualizacoes da Steam ou do proprio jogo." -ForegroundColor White } Write-Host "" Write-Host " Vitrine Oficial : $StorePublicUrl" -ForegroundColor Cyan Write-Host " Suporte Discord : $SupportDiscordUrl" -ForegroundColor Cyan Write-Host ""