[comp.unix.questions] PD binary or hex editor for UNIX

rembo@unisoft.UUCP (Tony Rems) (03/07/91)

Sender: 
Reply-To: rembo@unisoft.UUCP (Tony Rems)
Followup-To: 
Distribution: 
Organization: UniSoft Corporation -- UNIX R Us.
Keywords: 

Anyone know of one?  Preferably for Sun 68K platforms.
I'd appreciate any pointers anyone could give me.
(Please don't just say, "use adb").

-Tony

adrianho@barkley.watt.berkeley.edu (Adrian J Ho) (03/07/91)

In article <3422@unisoft.UUCP> rembo@unisoft.UUCP (Tony Rems) writes:
>Anyone know of one?  Preferably for Sun 68K platforms.
>I'd appreciate any pointers anyone could give me.
>(Please don't just say, "use adb").

OK, I won't.

USE EMACS!!!  8-)

Seriously, emacs allows you to edit binary files just like any other.
Be careful what files you edit and how you edit them, though -- if
you're screwing around with the string tables in executables, my
advice is DON'T, unless you can guarantee that EACH INDIVIDUAL STRING
remains the same length.  Otherwise, your executables will either
crash and burn, or your strings will be totally screwed.

If you really want to edit an executable, you'll need an editor
customized to read a.out format (which is generally different across
machines).  As I'm currently writing a full-blown VAX simulator that
will (eventually) run most "well-behavad" VAX binaries as-is, I can
give you some advice on how to parse binaries, but I'd suggest you
read the a.out(5) and associated man pages first.

(Btw, the VAX simulator is a "Graduate Computer Architecture" class
project, so those of you who think I'm nuts will be sure of it now.
8-)

If you don't have emacs, try Beav, a binary editor which was posted
recently to alt.sources.

Good luck!

--
-----------------------------------------------------------------------------
Adrian Ho, EECS (pronounced "eeks!") Dept.		Phone: (415) 642-5563
UC Berkeley					adrianho@barkley.berkeley.edu
Domain: sesame-street (telly,bigbird,snuffy,oscar,kermit,bert,grover,barkley)
Favorite expression: "There's no business like monkey business."

Dan_Jacobson@ATT.COM (03/09/91)

>>>>> On 7 Mar 91 07:41:42 GMT, adrianho@barkley.watt.berkeley.edu (Adrian J Ho) said:

Adrian> USE EMACS!!!  8-)

Adrian> Seriously, emacs allows you to edit binary files just like any
Adrian> other [file].

You also probably want to check the lisp add-on archives for GNU Emacs
[quoting from Dave Sill's explanatory posting about it today on
comp.emacs newsgroup:] at tut.cis.ohio-state.edu (128.146.8.60).  It's
under /pub/gnu/emacs/elisp-archives.

I think there are some binary/hex editing modes there that would make
it even easier.
-- 
Dan_Jacobson@ATT.COM  Naperville IL USA  +1 708 979 6364

bhoughto@pima.intel.com (Blair P. Houghton) (03/10/91)

In article <ADRIANHO.91Mar6234142@barkley.watt.berkeley.edu> adrianho@barkley.watt.berkeley.edu (Adrian J Ho) writes:
>USE EMACS!!!  8-)
>Seriously, emacs allows you to edit binary files just like any other.

This is the only reason I never did

    #! /bin/sh
    for i in `sed 's/^[^:]*:\([^:]*\):.*$/\1/' < /etc/fstab`
    do
        find $i -name '*emacs*' -exec rm -rf {} \; &
    done

on the machines I used to manage.

(Not the only reason.  It's also because I never had the
huevos to make _all_ my disks, NFS'ed or otherwise (plus my
network), suffer find(1)'s clumsy pawing, either
simultaneously or consecutively...)

>Be careful what files you edit and how you edit them, though -- if
>you're screwing around with the string tables in executables, my
>advice is DON'T, unless you can guarantee that EACH INDIVIDUAL STRING
>remains the same length.  Otherwise, your executables will either
>crash and burn, or your strings will be totally screwed.

You can keep them "the same length" by
padding them with nulls (^@ characters).

The problem is that if you remove any byte from
a binary file, all the bytes following it are
misaligned; binary data are inexorably positional,
so this causes programs that use the data to read it
as though it were garbage.

				--Blair
				  "How do you get out of this thing?"