<#
to execute, open powershell and type :
.\patch.ps1
if you get "cannot be loaded because the execution of scripts is disabled on this system", execute this first
Set-ExecutionPolicy RemoteSigned
#>
Class MiniPatcher {
static Patch(){
[string] $c = Get-Location;
[string] $fpath = [IO.Path]::Combine($c, 'nkv.Automator.exe');
[string] $oMD5 = '251C93F89A7A2B8569F9B7B5EA55C87D';
[long[]] $numArray = 0x00912D28, 0x00912D29, 0x00912D2A, 0x00912D2D, 0x00912D2E, 0x00912D2F, 0x00912D30, 0x00912D31, 0x00912D32, 0x00912D35, 0x00912D36, 0x00912D37, 0x00912D38, 0x00912D3B, 0x00912D3C, 0x00912D3D, 0x00912D40, 0x00912D41, 0x00912D42, 0x00912D43, 0x00912D46, 0x00912D47, 0x00912D48, 0x00912D4B, 0x00912D4C, 0x00912D4D, 0x00912D50, 0x00912D51, 0x00912D52, 0x00912D54, 0x00912D55, 0x00912D58, 0x00912D59, 0x00912D5A, 0x00912D5D, 0x00912D5E, 0x00912D5F, 0x00919DD0, 0x00919DD1, 0x00919DD2, 0x00919DD3, 0x00919DD4, 0x00919DD5, 0x00919DD6, 0x00919DD7, 0x00919DD9, 0x00919DDA, 0x00919DDB, 0x00919DDC, 0x00919DDE, 0x00919DDF, 0x00919DE0, 0x00919DE3, 0x00919DE4, 0x00919DE5, 0x00919DE6, 0x00919DE7, 0x00919DE8, 0x00919DE9, 0x00919DEA, 0x00919DED, 0x00919DEE, 0x00919DEF, 0x00919DF0, 0x00919DF1, 0x00919DF2, 0x00919DF3, 0x00919DF4, 0x00919DF5, 0x00919DF7, 0x00919DF8, 0x00919DF9, 0x00919DFA, 0x00919DFB, 0x00919DFC, 0x00919DFD, 0x00919DFE, 0x00919E00, 0x00919E01, 0x00919E02, 0x00919E03, 0x00919E05, 0x00919E06, 0x00919E07, 0x00919E08, 0x00919E09, 0x00919E0A, 0x00919E0B, 0x00919E0D, 0x00919E0E, 0x00919E0F, 0x00919E10, 0x00919E11, 0x00919E13, 0x00919E14, 0x00919E15, 0x00919E16, 0x00919E17, 0x00919E18, 0x00919E1A, 0x00919E1B, 0x00919E1C, 0x00919E1D, 0x00919E1E, 0x00919E20, 0x00919E21, 0x00919E22, 0x00919E23, 0x00919E25, 0x00919E26, 0x00919E27, 0x00919E28, 0x00919E29, 0x00919E2B, 0x00919E2C, 0x00919E2D, 0x00919E2E, 0x00919E30, 0x00919E31, 0x00919E32, 0x00919E33, 0x00919E35, 0x00919E36, 0x00919E60, 0x00919E61, 0x00919E62, 0x00919E64, 0x00919E65, 0x00919E66, 0x00919E67, 0x00919E69, 0x00919E6A, 0x00919E6B, 0x00919E6C, 0x00919E6D, 0x00919E6F, 0x00919E70, 0x00919E71, 0x00919E72, 0x00919E74, 0x00919E75, 0x00919E76, 0x00919E77, 0x00919E79, 0x00919E7A, 0x00919E7B, 0x00919E7C, 0x00919E7D, 0x00919E7F, 0x00919E80, 0x00919E81, 0x00919E82, 0x00919E84, 0x00919E85, 0x00919E86, 0x00919E87, 0x00919E88, 0x00919E8A, 0x00919E8B, 0x00919E8C, 0x00919E8D, 0x00919E8E, 0x00919E90, 0x00919E91, 0x00919E92, 0x00919E93, 0x00919E96, 0x00919E97, 0x00919E98, 0x00919E99, 0x00919E9A, 0x00919E9B, 0x00919E9C, 0x00919E9D, 0x00919EA0, 0x00919EA1, 0x00919EA2, 0x00919EA3, 0x00919EA4, 0x00919EA5, 0x00919EA6, 0x00919EA7, 0x00919EA8, 0x00919EAA, 0x00919EAB, 0x00919EAC, 0x00919EAD, 0x00919EAE, 0x00919EAF, 0x00919EB0, 0x00919EB1, 0x00919EB3, 0x00919EB4, 0x00919EB5, 0x00919EB6, 0x00919EB8, 0x00919EB9;
[byte[]] $buffer = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x73, 0x90, 0x01, 0x00, 0x0A, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00;
if (-not([System.IO.File]::Exists($fpath)))
{
Write-Host "Couldnt find file : $([System.IO.Path]::GetFileName($fpath))";
}
else {
try {
#hash
$hash = Get-FileHash $fpath -Algorithm MD5;
if ($hash.Hash -ne $oMD5) {
Write-Host 'CRC Verification : failed!' -ForegroundColor red;
}
else {
Write-Host 'CRC Verification : OK' -ForegroundColor green;
Write-Host 'Opening file for patch...' -ForegroundColor gray;
[System.IO.FileStream] $fs = New-Object System.IO.FileStream $fpath, ([System.IO.FileMode]::Open), ([System.IO.FileAccess]::ReadWrite), ([System.IO.FileShare]::ReadWrite)
[int] $i=0
for ($i = 0; $i -lt $numArray.Length; $i++)
{
$fs.Seek($numArray[$i], [System.IO.SeekOrigin]::Begin);
$fs.WriteByte($buffer[$i]);
}
$fs.Close();
Write-Host $numArray.Length 'byte(s) successfully patched!' -ForegroundColor green;
}
}
catch {
Write-Host "`nAn error occurred:`n$_" -ForegroundColor black -BackgroundColor red;
#Write-Host $_;
}
}
}
}
cls;
Write-Host "`n .__ __ `n__ _ _| |__ ____ | | __ ____ ______ _ ________`n\ \/ \/ / | \ / _ \| |/ // \ / _ \ \/ \/ / ___/`n \ /| Y ( <_> ) <| | ( <_> ) /\___ \ `n \/\_/ |___| /\____/|__|_ \___| /\____/ \/\_//____ >`n \/ \/ \/ \/ `n" -ForegroundColor white -BackgroundColor blue;
Write-Host 'Automator.PHPRestAPIGenerator v4.9' -ForegroundColor cyan;
Write-Host '________________________________________________________';
Write-Host 'greets to th3pt';
Write-Host ;
[MiniPatcher]::Patch();
Write-Host ;
Read-Host -Prompt 'Press enter to exit..';