2012-05-29 6 views
0

헥스 편집을 자동화하고 싶습니다. 16 진수 편집기는 HxD.exe입니다. HxD.exe를 편집 할 exe와 같은 폴더에 복사합니다. 내가 어떤 종류의 원하는 : 개방 hxd.exe 개방 etc.exe 변화를 0004A0-0004A3 00 00 80 3 층 00 00 40 3 층박쥐 파일 만들기

내가 어떻게 할 수 있습니까?

답변

0

HxD.exe의 세부 사항을 알지 못하면 정확히 말하기 어렵습니다. 그러나 Windows PowerShell을 사용하여 주변 작업을 수행 할 수 있습니다. 예를 들어 :

는 현재 디렉토리 컨텍스트를 변경하면, 당신은 또한이 같은 프로세스의 작업 디렉토리를 설정할 수 있습니다 대신에
# Assuming hxd.exe and <SourceFile> exist in c:\MyFolder 
Set-Location -Path:c:\MyFolder; 
# 
Start-Process -FilePath:hxd.exe -ArgumentList:'-hxd args -go here'; 

: 어떻게 hxd.exe 작품에

Start-Process -WorkingDirectory:c:\MyFolder -FilePath:hxd.exe -ArgumentList:'-hxd args -go here'; 

따라, 당신은 또한 수 있습니다 이 당신에게 올바른 방향으로 밀어 준다

$SourceFile = 'c:\MyFolder\sourcefile.bin'; 
$HxD = 'c:\path\to\hxd.exe'; 
Start-Process -FilePath $HxD -ArgumentList ('-SourceFile "{0}" -Range 0004A0-0004A3' -f $SourceFile); 

희망 : 임의의 폴더에 hxd.exe을 배치하고 절대 경로를 사용하여 소스 파일에 전달할 수.

0

HxD 웹 사이트에 나열된 명령 줄 옵션이 표시되지 않으므로 파일을 편집하는 것이 사용하는 프로그램보다 더 중요하다고 가정 할 때 순수한 PowerShell 대안을 제공 할 것입니다.

<# 
.Parameter FileName 
The name of the file to open for editing. 

.Parameter EditPosition 
The position in the file to start writing to. 

.Parameter NewBytes 
The array of new bytes to write, starting at $EditPosition 
#> 
param(
    $FileName, 
    $EditPosition, 
    [Byte[]]$NewBytes 
) 
$FileName = (Resolve-Path $FileName).Path 
if([System.IO.File]::Exists($FileName)) { 
    $File = $null 
    try { 
     $File = [System.IO.File]::Open($FileName, [System.IO.FileMode]::Open) 
     $File.Position = $EditPosition 
     $File.Write($NewBytes, 0, $NewBytes.Length) 
    } finally { 
     if($File -ne $null) { 
      try { 
       $File.Close() 
       $File = $null 
      } catch {} 
     } 
    } 
} else { 
    Write-Error "$Filename does not exist" 
} 

이 그런 다음 예는 다음과 같이 작동합니다 :

.\Edit-Hex.ps1 -FileName c:\temp\etc.exe -EditPosition 0x4a0 -NewBytes 00,00,0x40,0x3f 
편집 (그리고 사용 가능한 PowerShell을 가지고) ...

을 편집 - Hex.ps1라는 파일에 다음을 복사

새 값은 배열을 만들기 위해 쉼표로 구분 된 목록으로 입력해야하며 기본적으로 값은 십진수로 해석되므로 십진수로 변환하거나 0x00 형식을 사용하여 16 진수를 입력해야합니다.

이 방법이 효과가 없다면 적절한 래퍼를 만들 수 있도록 HxD의 명령 줄 옵션을 제공하는 것이 좋습니다.

관련 문제