Цитата Vovusja:
На самом деле разницы нет, просто другое не знаю. »
|
Vovusja, тогда куда проще будет использовать PowerShell. Что-то наподобие такого (без каких-либо проверок и т.п.):
Код:
![Выделить весь код](images/misc/selectcode.png)
$sSourceFolder = 'C:\Мои проекты\0036\Sample'
$sSourceFileMask = 'Sample.exe'
$sPatchFile = 'C:\Мои проекты\0036\Patch.bin'
$iPosition = 0x100
$aByteTemplate = [System.Byte[]](0x0B, 0x02, 0x09, 0x00)
$aBuffer = New-Object -TypeName System.Byte[] -ArgumentList $aByteTemplate.Length
Get-ChildItem -Path $sSourceFolder -Recurse -File -Include $sSourceFileMask -Force |`
ForEach-Object -Begin {
$aPatchContent = [System.Byte[]](Get-Content -Encoding Byte -Path $sPatchFile)
} -Process {
Write-Host $_.FullName -ForegroundColor Yellow -NoNewline
$oFileStream = $_.Open([System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite)
try {
$oFileStream.Seek($iPosition, [System.IO.SeekOrigin]::Begin) | Out-Null
$oFileStream.Read($aBuffer, 0, $aByteTemplate.Length) | Out-Null
if (([System.Collections.IStructuralEquatable]$aByteTemplate).Equals($aBuffer, [System.Collections.StructuralComparisons]::StructuralEqualityComparer)) {
$oFileStream.Seek($iPosition, [System.IO.SeekOrigin]::Begin) | Out-Null
$oFileStream.Write($aPatchContent, 0, $aPatchContent.Length) | Out-Null
Write-Host "`tOk" -ForegroundColor Green
} else {
Write-Host "`tCan't find bytes template in file content" -ForegroundColor Red
}
} finally {
$oFileStream.Close()
}
}