cmd - Is it possible to edit a binary file using Windows command line? -
is there way in windows edit binary file, command line? i.e. way written batch file?
i want able edit single byte, @ known position, in existing file.
this existing question[1] solved, that's linux solution. i'm looking similar windows.
background
there's bug in gta 1 when downloaded steam whereby save-game data file gets corrupted on exit. result, game can played fine first time subsequently crashes. turns out can fixed changing 5th byte in file (i.e. byte @ address 0x04) x00 x06[2].
i can in python easily, e.g.:
with open("player_a.dat", "rb") f: bytes = f.read() bytes = bytes[:4] + '\x06' + bytes[5:] open("player_a.dat", "wb") g: b in bytes: g.write(b)
ideally though i'd rather in batch job following:
- fixes data file
- launches gta
i make works me (using python), wouldn't random other people don't have python (yes know it's easy & install, still). similarly, there freeware available claims this, don't want run random .exe on pc, , don't think else should either. reason, i'd present batch file, people can inspect, , - if they're happy - run themselves.
thanks help!
[1] cli: write byte @ address (hexedit/modify binary command line)
[2] http://forums.steampowered.com/forums/showthread.php?t=1597746
[edit] fixed python script, found didn't work as-is (file.read() returns immutable object, can't update 1 of values).
i think powershell perfect tool task. it's available xp or higher , automatically shipped since windows 7:
just create *.ps
file content:
$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"
note 1 has enable unsigned powershell scripts:
start powershell administrator
run command:
set-executionpolicy remotesigned
you use vbscript script longer because wasn't designed reading binary files (you have use adodb.stream
objects).
here compilation of helper functions: http://www.motobit.com/tips/detpg_read-write-binary-files/
Comments
Post a Comment