home *** CD-ROM | disk | FTP | other *** search
/ For Beginners & Professional Hackers / cd.iso / hackers / tools / crack-ut.arj / HEX.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-02-15  |  973 b   |  46 lines

  1. unit Hex;
  2. interface
  3.  
  4.    { Converts hexadecimal numbers to string.
  5.      Copyright (c) 1994 by Sasha Peslyak }
  6.  
  7.    Type
  8.       THexStr=     string[9];
  9.  
  10.    Const
  11.       HexD         :array[0..15] of Char='0123456789ABCDEF';
  12.  
  13.    function HexByte(x                  :Byte)    :THexStr;
  14.    function HexWord(x                  :Word)    :THexStr;
  15.    function HexLong(x                  :LongInt) :THexStr;
  16.    function HexPointer(x               :Pointer) :THexStr;
  17.  
  18. implementation
  19.  
  20.    function HexByte;
  21.    begin
  22.       HexByte:=HexD[(x and $F0) shr 4]+HexD[x and $0F]
  23.    end;
  24.  
  25.    function HexWord;
  26.    begin
  27.       HexWord:=HexByte(Hi(x))+HexByte(Lo(x))
  28.    end;
  29.  
  30.    function HexLong;
  31.    type
  32.       LongRec=
  33.       record
  34.          Lo, Hi    :Word;
  35.       end;
  36.    begin
  37.       HexLong:=HexWord(LongRec(x).Hi)+HexWord(LongRec(x).Lo);
  38.    end;
  39.  
  40.    function HexPointer;
  41.    begin
  42.       HexPointer:=HexWord(seg(x^))+':'+HexWord(ofs(x^))
  43.    end;
  44.  
  45. end.
  46.