home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / hed178b.zip / hed.man < prev    next >
Text File  |  1997-03-15  |  15KB  |  477 lines

  1.  
  2.                            Hed version 1.7 beta
  3.  
  4.                         Brief manual (in beta also)
  5.                   
  6.  
  7.  
  8.  
  9.  
  10.                              HED KEY REFERENCE
  11.  
  12. General Commands
  13. ----------------
  14.  
  15.  
  16.  Alt-O          Open file. A wildcard will open all the matching
  17.                 files. Logical drives (partitions) can be opened
  18.                 as well by specifying the drive letter followed
  19.                 by a semicolon (e.g. 'D:').
  20.  
  21.  Alt-Q          Quit file.
  22.  
  23.  Alt-N          Next file.
  24.  
  25.  Alt-P          Previous file. HeD can open multiple files. Use
  26.                 Alt-N, Alt-P to browse through these files.
  27.  
  28.  F3             Abort changes in file.
  29.  
  30.  F2             Save file (write changes).
  31.  
  32.  Alt-F2         Save as under a different filename.
  33.  
  34.  F9             Shell to command prompt.
  35.  
  36.  Alt-F9         Execute program.
  37.  
  38.  Ctrl-F4        Calculator.
  39.  
  40.  Ctrl-M         Record Macro.
  41.  
  42.  Alt-X          Exit.
  43.  
  44.  
  45. Moving around
  46. -------------
  47.  
  48.  
  49.  Home           Go to the beginning of the line.
  50.  
  51.  End            Go to the end of the line.
  52.  
  53.  Ctrl-PageUp    Go to the top of the panel.
  54.  
  55.  Ctrl-PageDown  Go to the end of the panel.
  56.  
  57.  Ctrl-Home      Go to the beginning of the file.
  58.  
  59.  End            Go to the end of the file. An additional right
  60.                 arrow is required to move past the end of the
  61.                 file.
  62.  
  63.  Ctrl-RArrow    Slide the panel to the right.
  64.  
  65.  Ctrl-LArrow    Slide the panel to the left.
  66.  
  67.                 NOTE: When in disassembly mode, HeD will always
  68.                 try to find the original stream of code so as
  69.                 to avoid placing the panel's start in between
  70.                 instructions. Sliding the panel left or right
  71.                 is useful when needed to go to an exact location
  72.                 (e.g. in the middle of an instruction).
  73.  
  74.  Ctrl-G         Go to offset.
  75.  
  76.                 NOTE: HeD accepts arithmetic expressions in any
  77.                 number requester. So, instead of a number you can
  78.                 enter complex expressions. For example:
  79.                 0x100+345*(1<<8).
  80.  
  81.  Alt-G          Go to virtual offset. (More on this on the virtual
  82.                 offset section of this manual).
  83.  
  84.  Ctrl-B         Go back to previous position (undo last goto).
  85.  
  86.  Alt-Shf[0...9] Save position.
  87.  
  88.  Alt-[0...9]    Return to position.
  89.  
  90.  Alt-PgDwn      Go to next change. Will jump to the next byte
  91.                 that has been previously changed. This is useful
  92.                 to keep track of changed data in various places
  93.                 of a large file.
  94.  
  95.  Alt-PgUp       Go to previous change.
  96.  
  97.  
  98.  
  99. Viewing options
  100. ---------------
  101.  
  102.  
  103.  Tab            Switch between ascii and hex panels in normal
  104.                 mode. Switch between hex and instructions while
  105.                 in disassembly mode.
  106.  
  107.  Alt-V          Toggle between hexadecimal and disassembly mode.
  108.  
  109.  Alt-D          Toggle between hexadecimal and decimal offset
  110.                 representation.
  111.  
  112.  Alt-F          Select text filter.
  113.  
  114.  Alt-U          Toggle segment size (16bits or 32bits). This will
  115.                 change the mode the internal assembler and
  116.                 disassembler works. For more information look at
  117.                 "Assembling and Disassembling" section.
  118.  
  119.  
  120. Changing data
  121. -------------
  122.  
  123.  +              Increase number at cursor location.
  124.  
  125.  -              Decrease number.
  126.  
  127.  Del            Undo byte.
  128.  
  129.  Backspace      Move backwards and undo.
  130.  
  131.  Alt-Enter      Insert number at cursor location. The inserted
  132.                 expression will be evaluated and will be placed
  133.                 at the cursor location as a 8, 16 or 32bit number.
  134.  
  135.  F11            Insert character. Selects a character from the
  136.                 ascii character table.
  137.  
  138.  Ctrl-Ins       Copy to HeD's internal clipboard. To select data
  139.                 for copying hold down the Shift key while moving.
  140.                 Data from the clipboard can be pasted into the
  141.                 data panel or in dialog boxes.
  142.  
  143.  Shift-Ins      Paste from internal clipboard.
  144.  
  145.  Alt-Ctrl-Ins   Copy selection to file. Data can be saved as
  146.                 binary, hex or disassembly.
  147.  
  148.  Shift-Ctrl-Ins Paste file into current location.
  149.  
  150.  Ctrl-Del       Undo all changes within selection.
  151.  
  152.  
  153.  
  154. Searching for data
  155. -------------------
  156.  
  157.  
  158.  F5             Find number.
  159.  
  160.  F6             Find text string.
  161.  
  162.  F7             Find hexadecimal data.
  163.  
  164.  F8             Super find. For details about finding look at
  165.                 'Finding & Replacing' section of this documentation.
  166.  
  167.  Alt-F5         Find number and replace.
  168.  
  169.  Alt-F6         Find text and replace.
  170.  
  171.  Alt-F7         Find hex and replace.
  172.  
  173.  Alt-F8         Super find and replace.
  174.  
  175.  Ctrl-F6        Search in assembly text.
  176.  
  177.  Ctrl-F8        Find reference.
  178.  
  179.  
  180.  Shift-F7       Redo last search.
  181.  
  182.  
  183.  
  184.  
  185.                              DIALOG BOXES KEYS
  186.  
  187.  
  188.  Tab            Switch between dialog box controls.
  189.  
  190.  Shift-Tab      Switch between dialog box controls (backwards).
  191.  
  192.  Shift-Ins      Paste data into entry boxes.
  193.  
  194.  Alt-Up         Previous matching selection in list box.
  195.  
  196.  Alt-Down       Next matching selection in list box. You can select a
  197.                 line in a list box by typing the text it contains.
  198.                 Alt-Up Alt-Down will browse through all matching lines.
  199.  
  200.  
  201.  
  202.  
  203.                             FINDING & REPLACING
  204.  
  205.  
  206.  Find hex:
  207.  
  208.  Finds hex data in the file. Enter the hex data to search for or
  209. paste it from the internal clipboard. The keystroke Alt-? will
  210. insert a wildcard. A wildcard in the search pattern matches any
  211. data. A wildcard in the replace pattern will leave anafected the
  212. corresponding byte.
  213.  
  214.  
  215.  Find texts:
  216.  
  217.  Finds text in the file. Case sensitive or insensitive searches
  218. can be specified. Wildcards can be used in a similar way.
  219.  
  220.  
  221.  Find number:
  222.  
  223.  Finds a number in the file. Dword, words or byte sizes may be
  224. specified. HeD uses the little endian notation of the x86 chips.
  225. That is, the bytes are written in memory in order of significance.
  226. For example the number 0x1344 is encoded as 44 13. A number or
  227. an arithmetic expression can be inserted here.
  228.  
  229.  
  230.  Super find:
  231.  
  232.  Superfind is an advanced more flexible way of searching for
  233. data. The search expression consists of a series of wildcards,
  234. each for every byte, separated by a space character.
  235.  
  236.  Wildcards use the ? - [ ] , ! symbols much in the same way used
  237. by the unix shell. The following examples will clarify the use of
  238. these wildcards.
  239.  
  240.   1?h 3Eh 44h
  241.  
  242.    This expression will match a string that has the first
  243.   hex number of the first byte equal to 1 and a second and
  244.   third byte of 3Eh and 44h.
  245.  
  246.    E8h [0-100d]
  247.  
  248.    The first byte should equal E8 (hex) and the second must
  249.   be in the range of 0 to 100 (decimal).
  250.  
  251.    90h !90h
  252.  
  253.    The first byte should equal 90h while the second must
  254.   not equal 90h
  255.  
  256.    1B
  257.  
  258.    Search for 01, not 1B ! The trailing b indicates the
  259.   number is binary.
  260.  
  261.    ???????0b ???????1b
  262.  
  263.    Search for an even number immediately followed by an
  264.   odd number.
  265.  
  266.      1?1d
  267.  
  268.    Matches all decimal numbers having a first and last
  269.   digit of 1.
  270.  
  271.    ![3,5,[10-34]]
  272.  
  273.    Number should not be 3, 5 or in the range of 10
  274.   to 34
  275.  
  276.  
  277.   NOTE: Replace data in super find is simple hex data.
  278.  
  279.  
  280.  
  281.   Find Reference:
  282.  
  283.  Searches the file for branch reference to a specified offset
  284. or to the current location if no offset is specified (use this
  285. if the cursor is at the beginning of a procedure). The first
  286. call to Find Reference will always start from the beginning of
  287. the file. Subsequent calls (Shift-F7) will continue the search
  288. from the last found reference.
  289.  
  290.  The algorithm Find Reference is using is quite simple and it
  291. is based on two simple rules of 386 assembly: the branch offset
  292. is always the last data encoded in a x86 instruction and that
  293. the branch offset is added to the offset of the _next_ instruction.
  294. So Find Reference simply searches for numbers (of the specified
  295. size) whose value added to the offset of the byte following the
  296. number sums up to the requested offset.
  297.  
  298.  In addition find reference can check if the previous byte of
  299. the number found is a valid opcode of a branch instruction (jmp,
  300. call etc).
  301.  
  302.  
  303.  
  304.  
  305.                               LX & PE PARSING
  306.  
  307.  
  308.  HeD can use the information located in executables to correctly
  309. display system calls and instructions that require fixup
  310. translation. HeD so far support two file formats: Linear executables
  311. (LX) used by 32bit OS/2 programs, and portable executables (PE)
  312. used by 32bit Win32s and Win32c programs. Elf binary support will
  313. also be included in feature versions of HeD.
  314.  
  315.  While both PE and LX export names and ordinals in much the same  
  316. way import translation differs considerably. In order to understand
  317. and use PE import information you should read carefully the following
  318. explanation.
  319.  
  320.  
  321.  
  322.                             PE IMPORT EXPANSION
  323.  
  324.  
  325.  In LX binaries a table holds information for all imported entry
  326. points and where they are located within the image. For example,
  327. if a module calls PMSHELL.45 three times, three entries in the
  328. import table point to the offset within the image where these
  329. fixups should be applied.
  330.  
  331.  PE binaries don't enumerate all occurrences of imported entry
  332. points. In fact PE binaries don't have any information about the 
  333. place where imported references should be applied at all. Import 
  334. expansion is done through jump tables. These jump tables are 
  335. filled in by the system loader during execution.
  336.  
  337.  Lets consider the previous example. A module call PMSHELL.45 
  338. three times. Now lets assume that the start of the jump table
  339. is in virtual offset 0x1000 and that PMSHELL.45 is the second
  340. entry in the table, that is offset 0x1004. All call's to 
  341. PMSHELL.45 appear as 'call dword ptr [00001004]'. It's obvious 
  342. that no fixup need be applied since these instructions are
  343. statically linked to the virtual address of the fixup table.
  344.  
  345.  At this point arises problem. HeD needs to know beforehand
  346. all the offsets within the file where fixups are applied.
  347. Imported names in portable executables don't contain fixup
  348. information. Since there appears no other way to do this HeD
  349. scan's the entire file for assembly instruction that use the
  350. import jump table !
  351.  
  352.  This sounds too complicated to be true but it works. It really
  353. does. The whole process takes some time but this shouldn't be a
  354. problem (though running 'HeD \windows\system\*' isn't such a
  355. good idea unless you have very fast CPU and lots of memory).
  356.  
  357.  
  358.  
  359.                               VIRTUAL OFFSETS
  360.  
  361.  
  362.  By selecting Fixups/Show virtual/actual offset, you can select
  363. whether HeD's status line will display actual file offset or
  364. virtual memory offset. Virtual memory offset is the memory
  365. location where the data you are viewing will reside once the
  366. program is loaded. You can go directly to a virtual offset using
  367. Fixups/Go to virtual offset.
  368.  
  369.  Virtual offset can be used to jump to a code offset provided by
  370. a debugger or by a system report. When a module generates an exception
  371. write down the eip number provided in the dialog box. Then load the
  372. module in HeD and go to that virtual offset. You will see the instruction
  373. that generated the exception.
  374.  
  375.  Note: objects in OS/2 LX images may be relocated in different memory
  376. base than the one specified in the LX header. Actual virtual offset
  377. might not always correspond to a correct memory location.
  378.  
  379.  
  380.  
  381.                               IMPORT EXPANSION
  382.  
  383.  
  384.  Import expansion is a mechanism to translate imported ordinals to
  385. the actual names of the imported entry points. HeD has no other way
  386. of finding imported ordinal names other by looking up a database
  387. containing module/ordinal/name information.
  388.  
  389.  The database is a text file containing entries describing ordinal
  390. names. Each entry has the format:
  391.  
  392.  MODULE.#ODRINAL  NAME
  393.  
  394.  The file is called imports.dat and should be placed in HeD's directory.
  395. A default imports.dat file that describes common OS/2 API imports comes
  396. along with HeD.
  397.  
  398.  To enable import name expansion select the Fixups/Load Import Data menu,
  399. or enable loadimports keyword in HeD.cfg.
  400.  
  401.  
  402.  
  403.  
  404.  
  405.                          DISASSEMBLING & ASSEMBLING
  406.  
  407.  
  408.  HeD has build in assembling and Disassembling capabilities. Pressing
  409. Alt-V at any time will switch between hex and disassembling mode.
  410.  
  411.  HeD uses tasms and masm opcode representation. That is the target goes
  412. first and sizes are denoted using 'byte ptr', 'word ptr' and 'dword ptr'
  413. prefixes. A thorough explanation of the 386 instruction encodings is
  414. beyond the scope of this documentation. It is assumed that the user will
  415. have some experience with TD, tasm or masm.
  416.  
  417.  Some additional explanation is required on branches (jumps, calls, jump
  418. under conditions etc). Relative branch targets are calculated and shown as
  419. file offsets. That is the offset shown in a jump statement is not the
  420. actual number that will appear when the module is loaded but it is the
  421. offset within the file where the instruction points to. Effectively,
  422. pressing enter on a branch statement will jump to the target location.
  423. In addition HeD can also follow far inter-object fixed branches using
  424. the information in the LX header (of course LX fixups must first be
  425. loaded).
  426.  
  427.  To enter instructions press space or simply start typing the
  428. instruction and the appropriate dialog will pop up. Hex data can be
  429. entered as well by pressing tab.
  430.  
  431.  
  432.  
  433.  
  434.  
  435.                        KNOWN BUGS / KNOWN LIMITATIONS
  436.  
  437.  
  438.  Limitations and bugs known to the author. Most of these will be
  439. corrected in feature versions:
  440.  
  441.  
  442. - HeD's hex panel is hardwired to 16*16.
  443.  
  444. - HeD's disassembly panel is hardwired to 16 chars height.
  445.  
  446. - HeD can't assemble floating point instructions.
  447.  
  448. - Replacing routines aren't really optimized. Mass replaces of
  449. very frequent appearing data can take quite a long time.
  450.  
  451. - Opcode checking in find reference will not match long conditional
  452. jumps (0F 8*) . Only short conditional (7*) jumps will be mathced.
  453.  
  454.  
  455.  
  456.                               ACKNOWLEDGMENTS
  457.  
  458.  
  459.  Panagiotis Malakoudis. The official HeD beta tester :). Cracking
  460. programs has never been more inspiring.
  461.  
  462.  Peter Fitzsimmons for helping me on a OS/2 programming issue.
  463.  
  464.  All the guys in Team OS/2 Greece for their support.
  465.  
  466.  All of you out there in the internet who send me bug reports
  467. and requests for new features.
  468.  
  469.  
  470. .
  471.  
  472.  
  473.  
  474.  Dimitris Kotsonis
  475.  jnk@fryni.physics.upatras.gr
  476.  
  477.