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

XFEWorkflow

【WinUI】XFE基于windows的工作流

公开
关注 0 Fork 0 Star 0
UTF-8
param([Parameter(Mandatory)][string]$Output)
$ErrorActionPreference = 'Stop'
$wecomArchive = Join-Path (Split-Path $PSScriptRoot) 'vendor/wecom/python-frida-win-x64.zip'
$wecomMarker = Join-Path $Output '.runtime.sha256'
$wecomHashStream = [IO.File]::OpenRead($wecomArchive)
$wecomHasher = [Security.Cryptography.SHA256]::Create()
try { $wecomHash = [BitConverter]::ToString($wecomHasher.ComputeHash($wecomHashStream)).Replace('-', '') }
finally { $wecomHasher.Dispose(); $wecomHashStream.Dispose() }
if ($wecomHash -ne 'A071E1A9EF5578F153605B62A40B9DDF2F6FCB2D9CB3F01E777EA0EBA09584FD') { throw 'Bundled WeCom runtime SHA256 mismatch.' }
if ((Test-Path -LiteralPath $wecomMarker) -and (Get-Content -LiteralPath $wecomMarker -Raw).Trim() -eq $wecomHash -and (Test-Path -LiteralPath (Join-Path $Output 'python/python.exe'))) { exit 0 }
New-Item -ItemType Directory -Force -Path $Output | Out-Null
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression') | Out-Null
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') | Out-Null
$wecomOutputRoot = [IO.Path]::GetFullPath($Output).TrimEnd('\','/') + [IO.Path]::DirectorySeparatorChar
$wecomZip = [IO.Compression.ZipFile]::OpenRead($wecomArchive)
try {
    foreach ($wecomEntry in $wecomZip.Entries) {
        $wecomDestination = [IO.Path]::GetFullPath((Join-Path $wecomOutputRoot $wecomEntry.FullName))
        if (!$wecomDestination.StartsWith($wecomOutputRoot, [StringComparison]::OrdinalIgnoreCase)) { throw 'Runtime extraction path escapes output.' }
        if ($wecomEntry.FullName.EndsWith('/')) { [IO.Directory]::CreateDirectory($wecomDestination) | Out-Null; continue }
        [IO.Directory]::CreateDirectory([IO.Path]::GetDirectoryName($wecomDestination)) | Out-Null
        [IO.Compression.ZipFileExtensions]::ExtractToFile($wecomEntry, $wecomDestination, $true)
    }
} finally { $wecomZip.Dispose() }
Set-Content -LiteralPath $wecomMarker -Value $wecomHash -Encoding ascii