Board index » delphi » hex file viewer

hex file viewer


2004-02-05 08:57:42 PM
delphi131
i noticed delphi has bintohex and hextobin commands, and i wondered if these
could be used to convert a binary file into something i could see. but i
must admit, i know little about what 'hex' is, and delphi help doesn't
explain very much.
does anyone have some sample code that uses either of these two commands.
any help would be appreciated...
andy
 
 

Re:hex file viewer

"Andy Awtry" <XXXX@XXXXX.COM>wrote
Quote
I noticed delphi has bintohex and hextobin commands,
and I wondered if these could be used to convert a
binary file into something i could see. But I must admit,
i know little about what 'hex' is, and delphi help doesn't
explain very much.
Andy, Here is a simple routine to show you what hex
is -- I hope.
function ByteToHex(b: byte): string;
const HexDigits: array [0..15] of char = '0123456789ABCDEF';
var i, j: integer;
begin
j := (b and $0F);
i := (b and $F0) shr 4;
Result := HexDigits[i] + HexDigits[j];
end;
Here is an UNTESTED usage of
procedure BinToHex(Buffer, Text: PChar; BufSize: Integer);
var Data: array [0..9] of byte; S: string; pBuf, pStr: PChar; n:
integer;
For i := 0 to 9 do Data[i] := i;
pBuf := @Data;
n := 10;
SetLength(S,n*2);
pStr := PChar(S);
BinToHex(pBuf,pStr,n);
You can do arithmetic, like "pBuf := pBuf + 10"
on PChar variables.
Hope that this helps. Regards, JohnH
 

Re:hex file viewer

Quote
i noticed delphi has bintohex and hextobin commands, and i
wondered if these
could be used to convert a binary file into something i could
see. but i
must admit, i know little about what 'hex' is, and delphi help
doesn't
explain very much.
Orpheus (sourceforge.net/projects/tporpheus/) has a nice
file viewer
with hex mode support.
 

Re:hex file viewer

Ray Andrews writes:
Quote

>i noticed delphi has bintohex and hextobin commands, and i
wondered if these
>could be used to convert a binary file into something i could
see. but i
>must admit, i know little about what 'hex' is, and delphi help
doesn't
>explain very much.

Orpheus (sourceforge.net/projects/tporpheus/) has a nice
file viewer
with hex mode support.
I have written a Hex file viewer editor, in delphi.
You can download take a look at it:
132.234.129.50/Programs/HexEditor.zip
--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia
 

Re:hex file viewer

Charles Hacker writes:
Quote

I have written a Hex file viewer editor, in delphi.

You can download take a look at it:
132.234.129.50/Programs/HexEditor.zip
Thats actually:
132.234.129.50/Programs/HexEditor.zip
--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia
 

Re:hex file viewer

i guess my real question is can i take this binary file that has all my data
on it, and convert it to an ascii file? I'd really prefer to analyze
the data with a delphi program, but i need to be able to see what the data
is. can a 'hex file viewer editor' help me do this? or am i asking for
something that cant be done?
thank you very much for you help on this...
andy
"Charles Hacker" <XXXX@XXXXX.COM>writes
Quote
Charles Hacker writes:
>
>I have written a Hex file viewer editor, in delphi.
>
>You can download take a look at it:
>132.234.129.50/Programs/HexEditor.zip

Thats actually:
132.234.129.50/Programs/HexEditor.zip

--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia
 

Re:hex file viewer

Andy Awtry writes:
Quote

i guess my real question is can i take this binary file that has all my data
on it, and convert it to an ascii file? I'd really prefer to analyze
the data with a delphi program, but i need to be able to see what the data
is. can a 'hex file viewer editor' help me do this? or am i asking for
something that cant be done?
Well okay, it can't really be done.
There is no way specifically to 'convert a binary file to an ascii
file'!
All that can be really done with a binary file, is to view the
hexadecimal numbers stored in the binary file, and possibly have those
hexadeciaml values be converted (where possible) to partial ASCII
characters.
This is what a Hex Viewer / Editor does. It gives one pane with the Hex
values, and another with the attempted hex to ASCII character
conversions.
--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia
 

Re:hex file viewer

Why not just replace the low ASCII (with a dot, a space, or whatever), and
read the output??
Patrick
"Charles Hacker" <XXXX@XXXXX.COM>escribi?en el mensaje
Quote
Andy Awtry writes:
>
>i guess my real question is can i take this binary file that has all my
data
>on it, and convert it to an ascii file? I'd really prefer to
analyze
>the data with a delphi program, but i need to be able to see what the
data
>is. can a 'hex file viewer editor' help me do this? or am i asking for
>something that cant be done?

Well okay, it can't really be done.
There is no way specifically to 'convert a binary file to an ascii
file'!

All that can be really done with a binary file, is to view the
hexadecimal numbers stored in the binary file, and possibly have those
hexadeciaml values be converted (where possible) to partial ASCII
characters.
This is what a Hex Viewer / Editor does. It gives one pane with the Hex
values, and another with the attempted hex to ASCII character
conversions.

--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia
 

Re:hex file viewer

Patrick Veenstra writes:
Quote

Why not just replace the low ASCII (with a dot, a space, or whatever), and
read the output??

Which is what a hex viewer / editor does!
--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia