Class FCMatcher

java.lang.Object
  extended by FCMatcher

public final class FCMatcher
extends java.lang.Object


Field Summary
static int MINWINDOWPARAM
           
static int WINDOWPARAM
           
 
Method Summary
static boolean iswindowmatch(java.lang.String progname, int w, ByteArray windowarr, ByteArray program)
           
static void validatewindowparams(int w, ByteArray windowarr)
          The following matcher iswindowmatch() can fail with programs that store data internally dynamically.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WINDOWPARAM

public static final int WINDOWPARAM
See Also:
Constant Field Values

MINWINDOWPARAM

public static final int MINWINDOWPARAM
See Also:
Constant Field Values
Method Detail

validatewindowparams

public static void validatewindowparams(int w,
                                        ByteArray windowarr)
                                 throws FeralcoreException
The following matcher iswindowmatch() can fail with programs that store data internally dynamically. It allows the PC to be at any word in the program. This check by itself can yield false hits since not all programs consist entirely of single word instructions. Some instructions have multiple words and during execution the PC jumps from the opword over the immediates to the next opword. The window is drawn evenly around the PC as follows. There are w words before the word under the PC, 1 word under the PC, w words after the word under the PC. The window is 2w+1 words. If the program is an odd number of bytes then the matcher disregards the last byte. So, let the program be n words long.

case (1): if n ≤ 2w+1: if n ≥ w+1 then leave w alone. However, if n < w+1 then redefine the window size such that w+1 = n. By this point n is at least w+1 so the PC must be in the program if w+1 words of the program is still in the (possibly new) window. Make sure that w+1 consecutive words in the window is in the program. The program is short and can stradle the PC so this case does not reduce to case 2 below. The PC could be a the start of the program, so then the last w+1 words of the window are in the program. The PC could be at the end of the program, so then the first w+1 words of the window are in the program.

case (2): if n > 2w+1: Make sure that either the first w+1 or the last w+1 words of the window are in the program as a substring. If the PC is at the first or last instruction of the program then only w+1 words in the window are guaranteed to match.

Throws:
FeralcoreException

iswindowmatch

public static boolean iswindowmatch(java.lang.String progname,
                                    int w,
                                    ByteArray windowarr,
                                    ByteArray program)
                             throws FeralcoreException
Throws:
FeralcoreException