1819804 Members
3289 Online
109607 Solutions
New Discussion юеВ

Edit binary file

 
SOLVED
Go to solution
j773303
Super Advisor

Edit binary file

Which tool or command can edit binary file?
Thanks.
Hero
20 REPLIES 20
RAC_1
Honored Contributor

Re: Edit binary file

I don't think you can or moreover you should not.

In case you want you should change source code.
There is no substitute to HARDWORK
j773303
Super Advisor

Re: Edit binary file

It is can be shown by xd command.
But I'm not sure which command could modify
the binary file contents. As I know, it could
be modified by UltraEdit tool, how about in
HP UNIX?
Hero
Michael Tully
Honored Contributor

Re: Edit binary file

You can't. A binary file is built by a program compiler from source code. If you need to make changes, you do this to the source code and re-compile it.
Anyone for a Mutiny ?
Rajeev  Shukla
Honored Contributor

Re: Edit binary file

you can edit a binary file by writing a c program which does a direct I/O by using fwrite and fread functions.

Rajeev
T G Manikandan
Honored Contributor

Re: Edit binary file

I have not worked with editing the binary files but you are right,
you can use xd to make dump of the binary file.

open it using any editor and then re-create a new binary file after modifications.


Revert
Ravi_8
Honored Contributor

Re: Edit binary file

Hi,

xd creates Hexadecimal dump of the file which yu can't understand (edit)
never give up
Ravi_8
Honored Contributor

Re: Edit binary file

Hi,

xd creates Hexadecimal dump of the file which yu can't understand (edit) (you can't edit a binary file)
never give up
Christian Gebhardt
Honored Contributor

Re: Edit binary file

The main thing

You can do what you want but,

ONLY EDIT A BACKUP FILE !!!!

Chris
Christian Gebhardt
Honored Contributor

Re: Edit binary file

Hi

of course you can edit binary files with a hex-editor, look at
http://hpux.tn.tudelft.nl/hppd/hpux/Development/Tools/hexedit-0.9.7/

You can change textblocks, outputs, error messages and so on. The main thing is that the internal adresses of the binary may not change.

Chris
Rainer von Bongartz
Honored Contributor

Re: Edit binary file

Take a look at the ELVIS free vi clone
Elvis can edit binary files

http://elvis.the-little-red-haired-girl.org/gettingelvis/index.html

Regards
Rainer
He's a real UNIX Man, sitting in his UNIX LAN making all his UNIX plans for nobody ...
Eugeny Brychkov
Honored Contributor

Re: Edit binary file

I would get this file to my pc and use some utilities to edit it. You know, windows (and sometimes DOS [norton-commander]) offers more 'user-friendly' interface than hpux command line :o)
Eugeny
Tom Jackson
Valued Contributor

Re: Edit binary file

You can edit binary files, but you need to know it's binary format. Getting the format can be a real challenge. It's often very difficult to decypher a binary file format. I have tried to get binary file formats from vendors. Vendors sometime have crazy algorythms to prevent users from using their format.

If you know the format, you will need to use a programming language that supports the data formats contained in the file.

Unless you have a good idea as to the format of the file, I would work with the vendor to determine the file format and language they use to read and write the files. Heck they may even give you an includes with some nice data structures!

hth,

Tom
Frank Slootweg
Honored Contributor
Solution

Re: Edit binary file

For very simple binary edits, using standard HP-UX commands:

vis -n binary_file >text_file
vi text _file # Or other text editor
inv -n text_file >binary_file
T. M. Louah
Esteemed Contributor

Re: Edit binary file

Question for Eugeny Brychkov ... and how are you going to use that Unix-binary file after modifying (open/read/write/save/close) it on Wintho$e machine ?

Little learning is dangerous!
Shannon Petry
Honored Contributor

Re: Edit binary file

The problem is not so easily answered. Is this a binary data file, executable, or library file?

If it's data, you can use a hex editor, but you can still wreck data if you dont know how it's formatted. So while it sounds easy, it's not.

If it's an executable or library file, I would not bother. You will most likely corrupt the file by making any changes to it. Simple text substitution even means that character count in strings MUST match. Adding or subtracting characters will corrupt the file.

Rule of thumb. Work on a backup copy so you dont hoze the original.

Regards,
Shannon
Microsoft. When do you want a virus today?
Gregory Fruth
Esteemed Contributor

Re: Edit binary file

Use emacs. If you want to get fancy,
emacs has a special mode called
hexl-mode.

About the only things you can safely
modify are strings, and perhaps numbers
if you are careful and know a bit about
the internal representation of them.

If it's a C-language program and you trust
that it's using libc strings (and not
roll-your-own strings) you can modify any
string in the file as long as the replacement
string is shorter than or the same length as
the original. The null byte at the end of libc
strings makes this work, even if the
replacement is shorter than the original. If
the replacement is longer than the original
you are out of luck.

Just out of curiosity, why would you want
to do such a thing?

Re: Edit binary file

I've a tool called 'xvi', which can be used on HP-UX and is almost similar to vi. I've attached the binary here. Hope this helps.

rgds,
Ravi B Hiremath

Re: Edit binary file

My previous reply miss the attachment. Here is the attachment.

rgds,
Ravi B Hiremath
Tom Hayward
New Member

Re: Edit binary file

A tool that I've used for editing binary files (specifically, editing header content in data files) is "beav" - binary editor and viewer. You can download it from the HP-Ux Porting & Archive Centre here:

http://hpux.ee.ualberta.ca/hppd/hpux/Editors/beav-14.0.6/

there's know magic in knowledge...
doug hosking
Esteemed Contributor

Re: Edit binary file

'adb -w' provides some ability to edit
binary files. The interface isn't exactly
intuitive, but it can be done.

As previously noted, some text editors can also edit binary files. It would help to know more about the types of files you need to edit and the types of editing you need to do to them.