home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / hexfindo.zip / ReadMe.Txt < prev   
Text File  |  2000-11-10  |  8KB  |  158 lines

  1.  
  2.          HexFind - a fast pattern finder for OS/2
  3.  
  4.                   version 2.1 (10/11/2000)
  5.             Copyright 1998 - 2000 by Heinz Repp
  6.  
  7.  
  8. I wrote HexFind mainly because I wanted a program that would
  9. search for any sequence of bytes in any type of file, in contrast
  10. to the grep family or the system's find command which is
  11. restricted to string patterns and files of printable lines.
  12. Therefore the search argument is given to HexFind as a sequence
  13. of bytes in hexadecimal notation, a pair for each byte, and the
  14. positions in the files matching the pattern are output as byte
  15. offsets from the beginning (hexadecimal and decimal).
  16.  
  17. HexFind 2.0 has been completely rewritten with an improved search
  18. algorithm and the ability to search recursively through
  19. subdirectories as well as hidden and system files for patterns
  20. including literal strings and wildcards.
  21.  
  22. Version 2.1 added the ability to search for strings case-
  23. insensitive and a Win32 version.
  24.  
  25. HexFind is invoked with:
  26.  
  27. HexFind <search pattern> [<options>] [<file specs> ...]
  28.  
  29. the search pattern may consist of:
  30. - bytes in hexadecimal notation; every byte must be given as pair
  31.   of hexadecimal digits, e. g. a9, ff, 03 or 00 are valid bytes
  32. - literal strings enclosed in single quotes, e. g. 'string', '34'
  33. - one or more <?>, each representing one byte of arbitrary value
  34.   at any but the last position in the search pattern
  35.  
  36. The search pattern is ONE argument to HexFind, so it must be
  37. either contiguous (not containing any blanks) or enclosed in
  38. double quotes. A valid pattern would be <1b'K'?'xyz'0d0a> or
  39. the equivalent <"1B 'K' ? 'xyz' 0D 0A"> (without the <>).
  40.  
  41. options follow the syntax [-|/][v|r|s|h|i][+|-], in detail:
  42. '-' or '/' as switching character
  43. one of:
  44. 'v' = verbose; if activated HexFind reports every file it
  45.     searches through and a summary of files and bytes searched
  46.     at the end
  47. 'r' = recursive; if activated HexFind searches also all files
  48.     matching the file specifier in all subdirectories of the
  49.     starting directory
  50. 's' = system; if activated also files with the system attribute
  51.     are searched
  52. 'h' = hidden; if activated also files with the hidden attribute
  53.     are searched
  54. 'i' = ignore case; if activated searches for the string part of
  55.     the search pattern case-insensitive
  56. '+' or '-' to activate or deactivate the specified option; '+'
  57.     may be omitted; at start all options are deactivated.
  58.  
  59. Examples of valid options are '/v+', '-h-' or '/R /V'. Case does
  60. not matter, and successive options may be concatenated; so
  61. '/V+ /R+ /S-' is equivalent to '/vrs-'.
  62.  
  63. The options may appear at any position on the command line.
  64. HexFind evaluates the command line in order, so all options are
  65. valid only for the following file specifiers. The command line
  66.  
  67. HexFind /v 'pattern' /v- /r <file1> /r- <file2> /v
  68.  
  69. prints the search pattern as hexadecimal coded bytes, then
  70. searches for the string 'pattern' - without listing the files
  71. searched - in all files matching <file1> in the current directory
  72. and all its subdirectories, then in all files matching <file2>
  73. in the current directory only, and prints at last the summary of
  74. all files searched.
  75.  
  76. Some notes on the case-insensitive search:
  77. the <i>-switch affects only letters (A-Z and a-z) in the string
  78. parts of the pattern (if any), NOT the bytes coded hexadecimal;
  79. so it is possible (but seldom meaningful) to search only for
  80. parts of the pattern case-sensitive. The <i>-switch should
  81. precede the pattern, else there is no effect at all (besides
  82. increasing the search time a little bit). A combination like
  83. HexFind /i+ 'PaTtErN' /i- <files> would also be possible; this
  84. would perform an exact search on the pattern with all letters
  85. lowercase ('pattern').
  86.  
  87. The file specifiers consist of an optional absolute or relative
  88. path and a valid filename including wildcards. If no file
  89. specifier is given, HexFind searches the standard input, allowing
  90. its use with pipes.
  91.  
  92. The search algorithm used uses elements from D. M. Sunday's
  93. 'Quicksearch' and the extensions 'Optimal Mismatch' (described by
  94. Guido Gronek in the German magazine c't 3/95, pp. 278) and
  95. 'Turbosearch' by Michael Tamm (c't 8/97, pp. 292). I developed
  96. it on my own by extending the way that Turbosearch outperforms
  97. Quicksearch and have called it 'Fastsearch'. The elements of
  98. Optimal Mismatch make it robust when used with highly repetitive
  99. patterns and/or files without sacrificing performance
  100. significantly. HexFind uses a static probability table for all
  101. possible byte values found empirically by examining the contents
  102. of my complete hard disk, about 2 Gigabyte of very different
  103. kinds of data. In typical search scenarios my 'raw' algorithm
  104. (without the Optimal Mismatch extension) is up to 10% faster than
  105. Turbosearch, which itself outperforms Quicksearch by another 10%.
  106. Its trick is that it reduces the number of comparisons to zero
  107. most of the time! The inner circle is extremely short, consisting
  108. only of dereferencing a pointer, a conditional branch and one
  109. (pointer + integer) addition.
  110.  
  111. The practical relevance of the very fast search algorithm is
  112. limited because it is not the most time critical part of the
  113. program. The searching routine consumes less than 10% of the
  114. computing time. Most time is needed to open and read the files
  115. into memory. The first version of HexFind tried to address this
  116. by using multiple threads, one to search for matching files and
  117. opening them, one to read them into memory buffers and one to
  118. search those buffers. Unfortunately the gain of multithreading
  119. was very small, mostly outweighed by the overhead necessary for
  120. the inter-thread communication. Numerous experiments showed that
  121. the only way threads could speed things up significantly would be
  122. the use of a separate output thread, especially if there are many
  123. hits. This output thread would use a private queue, but the same
  124. effect can be achieved by redirecting standard output to a pipe.
  125. There are many separate programs already available for this
  126. purpose providing buffering between program output and standard
  127. output (e. g. the buffer program included in Andreas Kaiser's
  128. GTAK/GTAR package). For this reason I left off multithreading
  129. completely in this version of HexFind.
  130.  
  131. HexFind is freeware. You may use it freely, give it away to
  132. friends, post it for download and include it in shareware/
  133. freeware collections on any media provided that there is not more
  134. than a nominal charge for the copying process and the media, and
  135. that the package is left unchanged, including source, executable
  136. and this file. Use it completely at your own risk!
  137.  
  138. The obligatory word at last:
  139. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
  140. EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
  141. IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A
  142. PARTICULAR PURPOSE, OR OF ANY OTHER TYPE, WHETHER EXPRESS OR
  143. IMPLIED, AND TO ANY REMEDY AGAINST ME, WHETHER IN CONTRACT, TORT,
  144. DELICT, QUASI-DELICT OR OTHERWISE. SOME JURISDICTION DO NOT ALLOW
  145. THE EXCLUSION OF CERTAIN IMPLIED WARRANTIES SO THE PRECEDING
  146. EXCLUSIONS MAY NOT APPLY.
  147.  
  148. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT
  149. WILL I BE LIABLE FOR ANY SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
  150. DIRECT OR INDIRECT DAMAGES (INCLUDING WITHOUT LIMITATION LOSS OF
  151. PROFIT) ARISING OUT OF USER'S USE OR INABILITY TO USE THE
  152. SOFTWARE OR ANY INFORMATION ACCOMPANYING IT, WHETHER OR NOT I
  153. HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED
  154. AND ON ANY THEORY OF LIABILITY. THIS EXCLUSION INCLUDES ANY
  155. LIABILITY THAT MAY ARISE OUT OF THIRD-PARTY CLAIMS AGAINST THE
  156. USER. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE
  157. OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
  158.