Methods to hex edit binary files via Powershell

前端 未结 4 432
醉梦人生
醉梦人生 2020-11-30 09:37

Am trying to perform binary hex edit from the command line using only powershell. Have had partial success performing a hex replace with this snip. Problem springs up when

4条回答
  •  时光取名叫无心
    2020-11-30 09:47

    Probably the way most idiomatic to PowerShell would be:

    $offset = 0x3C
    [byte[]]$bytes = Get-Content C:\OldFile.exe -Encoding Byte -Raw
    
    $bytes[$offset++] = 0xFF
    $bytes[$offset++] = 0xFF
    $bytes[$offset] = 0xFF
    
    ,$bytes |Set-Content C:\NewFile.exe -Encoding Byte
    

提交回复
热议问题