Skip to content

Instantly share code, notes, and snippets.

@ohaiibuzzle
Last active July 5, 2021 05:04
Show Gist options
  • Save ohaiibuzzle/0f4167cae5d4e0d8a2005638eecba687 to your computer and use it in GitHub Desktop.
Save ohaiibuzzle/0f4167cae5d4e0d8a2005638eecba687 to your computer and use it in GitHub Desktop.
Check exactly what Genshin file went boom
Add-Type -AssemblyName System.Windows.Forms
$hash_files = @('.\pkg_version', '.\Audio_English(US)_pkg_version', '.\Audio_Japanese_pkg_version', '.\Audio_Korean_pkg_version', '.\Audio_Chinese_pkg_version')
Write-Host("Select your game folder...")
$FileBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
$FileBrowser.Description = "Select your game folder"
if($FileBrowser.ShowDialog((New-Object System.Windows.Forms.Form -Property @{TopMost = $true })) -eq "OK"){
Set-Location($FileBrowser.SelectedPath)
} else {
return 1
}
$lines = @()
foreach ($file in $hash_files){
if((Test-Path -Path $file -PathType Leaf)){
$lines += Get-Content -Path $file
}
}
$results = New-Object System.Collections.ArrayList
foreach ($line in $lines){
$json = ConvertFrom-Json($line)
if ((Test-Path -Path $json.remoteName -PathType Leaf)){
$actual_hash = Get-FileHash $json.remoteName -Algorithm MD5
if ($json.md5 -ne $actual_hash.Hash.ToLowerInvariant()) {
$obj = [pscustomobject]@{
"File Name" = $json.remoteName
"File Hash" = $json.md5
"Actual Hash" = $actual_hash.Hash.ToLowerInvariant()
"Status" = "Not OK"
}
$results += $obj
Write-Host("$($json.remoteName) Not OK!")
#Pause
} else {
$obj = [pscustomobject]@{
"File Name" = $json.remoteName
"File Hash" = $json.md5
"Actual Hash" = $actual_hash.Hash.ToLowerInvariant()
"Status" = "OK"
}
$results += $obj
Write-Host("$($json.remoteName) OK!")
}
}
}
$results | Sort-Object "File Name" | Out-GridView -Wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment