Can I edit a binary file using the Windows command line?

Is there a way on Windows to edit a binary from the command line? that is, a way that can be written to a batch file?

I want to be able to edit one byte in a known place in an existing file.

This existing issue [1] has been resolved, but it is a Linux solution. I am looking for something similar for windows.

Background

In GTA 1, an error occurs when downloading from Steam, in which the save-game data file is damaged upon exit. As a result, the game can be played for the first time, but subsequently will fail. It turns out that this can be fixed by changing the 5th byte in the file (ie, Byte at 0x04) from x00 to x06 [2].

I can do this in Python easily, for example:

with open("PLAYER_A.DAT", "rb") as f:
    bytes = f.read()
bytes = bytes[:4] + '\x06' + bytes[5:]
with open("PLAYER_A.DAT", "wb") as g:
    for b in bytes: g.write(b)

, , :

  • GTA

-, ( Python), , Python (, , , ). , , , .exe , , - . , , - , - .

!

[1] CLI: (hexedit/modify binary )

[2] http://forums.steampowered.com/forums/showthread.php?t=1597746

[edit] ​​ Python script, , (file.read() , ).

+5
2

, PowerShell - . XP Windows 7:

*.ps :

$bytes = [System.IO.File]::ReadAllBytes("PLAYER_A.DAT");
$bytes[4] = 0x06;

[System.IO.File]::WriteAllBytes("PLAYER_A.DAT", $bytes);
& "C:\Path-To-GTA1-Exe-File.exe"

, PowerShell:

  • PowerShell

  • : Set-ExecutionPolicy RemoteSigned


VBScript, script , ( ADODB.Stream).

: http://www.motobit.com/tips/detpg_read-write-binary-files/

+9

, ? (start → target-1/target/target + 1 → end), COPY .

DOS ( Windows), , SPLITS.EXE . COPY - , , .

, googling " dos" ...

+1

All Articles