Patches
Class FwPatch

java.lang.Object
  extended by Patches.FwPatch

public class FwPatch
extends java.lang.Object


Field Summary
 java.lang.String author
          Your nick.
 java.lang.String author_email
          Your email.
 boolean debugMode
          Set this to true to enable debug mode.
 java.lang.String description
          Patch description shown in window when user clicks on your patch.
 java.lang.String group
          Patch group on tree, if group not exists on tree it will be automatic added to tree.
 boolean hidden
          Used only for special patches, your patch should be always not hidden.
 java.lang.String name
          Patch name show on tree.
 java.util.Collection testedFirmwares
          Tested firmwares.
 java.lang.String version
          Patch version.
 java.lang.String website
          Your website, or link to topic about this patch on forum.
 
Constructor Summary
FwPatch()
           
 
Method Summary
 void addToLog(java.lang.String text)
          Adds text to log, and updates main window with your text.
static int arrayToInt(byte[] value)
          Convert array of 4 bytes to integer value.
static int arrayToInt(byte[] value, int address)
          Convert array to integer value, getting 4 bytes from position specified by address.
static java.lang.String arrayToStr(byte[] array)
          Converts byte array to hexadecimal string.
static java.lang.String arrayToStr(byte[] array, int startPos, int length)
          Converts part of byte array to hexadecimal string.
static byte[] calcThumbBranchWithLink(int jumpAddress, int destAddress)
          Calculates OPCODE for branch with link (BL dest) in Thumb code.
static int calcThumbLDRAdress(byte[] code, int OPCODE_Adress_in_code)
          Returns address what reads LDR instruction.
 void clearLog()
          Log of all patches are cleared on opening firmware automaticly.
static void codeReplaceJump(byte[] code, byte[] jumpId, byte[] jumpDest)
          Replaces JMP instructions in code what will be injected to firmware.
 java.lang.String getLog()
           
static byte[] intToArray(int value)
          Converts integer value to 4 bytes array.
 void patch(Firmware soft)
          Main method of your patch.
static byte[] strToArray(java.lang.String data)
          Converts hexadecimal string to byte array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

author

public java.lang.String author
Your nick.


author_email

public java.lang.String author_email
Your email.


debugMode

public boolean debugMode
Set this to true to enable debug mode. Debug mode is very useful when you are searching pattern (debug shows that pattern occur one or more times).


description

public java.lang.String description
Patch description shown in window when user clicks on your patch.


group

public java.lang.String group
Patch group on tree, if group not exists on tree it will be automatic added to tree.


hidden

public boolean hidden
Used only for special patches, your patch should be always not hidden.


name

public java.lang.String name
Patch name show on tree. Must be unique.


testedFirmwares

public java.util.Collection testedFirmwares
Tested firmwares. You can add one firmware (R373_G_0E.30.44R) or whole platworm by typing first characters of platform name (R373), also you can add firmwares group by typing first characters of version (R373_G_0E.30.44R means 44,48,49 are allowed).


version

public java.lang.String version
Patch version.


website

public java.lang.String website
Your website, or link to topic about this patch on forum.

Constructor Detail

FwPatch

public FwPatch()
Method Detail

addToLog

public void addToLog(java.lang.String text)
Adds text to log, and updates main window with your text.

Parameters:
text - Text what you will show on main window.

arrayToInt

public static int arrayToInt(byte[] value)
Convert array of 4 bytes to integer value.

Parameters:
value - Array of 4 bytes.
Returns:
Integer value.

arrayToInt

public static int arrayToInt(byte[] value,
                             int address)
Convert array to integer value, getting 4 bytes from position specified by address.

Parameters:
value - Array of n bytes.
address - Adress on array where are bytes to convert.
Returns:
Integer value.

arrayToStr

public static java.lang.String arrayToStr(byte[] array)
Converts byte array to hexadecimal string.

Parameters:
array - Byte array.
Returns:
Hexadecimal string.

arrayToStr

public static java.lang.String arrayToStr(byte[] array,
                                          int startPos,
                                          int length)
Converts part of byte array to hexadecimal string.

Parameters:
array - Byte array.
startPos - Start position.
length - How many bytes will be converted.
Returns:
Hexadecimal string.

calcThumbBranchWithLink

public static byte[] calcThumbBranchWithLink(int jumpAddress,
                                             int destAddress)
Calculates OPCODE for branch with link (BL dest) in Thumb code.

Parameters:
jumpAddress - Address in code where this OPCODE will be placed.
destAddress - Destination address.
Returns:
OPCODE - array of 4 bytes.

calcThumbLDRAdress

public static int calcThumbLDRAdress(byte[] code,
                                     int OPCODE_Adress_in_code)
Returns address what reads LDR instruction.

Parameters:
code - Code where is LDR OPCODE.
OPCODE_Adress_in_code - Address to OPCODE.
Returns:
Offset to value what accessing LDR instruction, from begining of code.

clearLog

public void clearLog()
Log of all patches are cleared on opening firmware automaticly.


codeReplaceJump

public static void codeReplaceJump(byte[] code,
                                   byte[] jumpId,
                                   byte[] jumpDest)
Replaces JMP instructions in code what will be injected to firmware.

Parameters:
code - Code what you want inject to firmware.
jumpId - Jump ID (abstract adress given to procedure when you compiling your code).
jumpDest - Destination (real address to procedure what you found on code).

getLog

public java.lang.String getLog()
Returns:
Patch log (used to save log to file).

intToArray

public static byte[] intToArray(int value)
Converts integer value to 4 bytes array.

Parameters:
value - Integer value to be converted.
Returns:
Returns array of 4 bytes.

patch

public void patch(Firmware soft)
Main method of your patch.

Parameters:
soft - Open firmware reference.

strToArray

public static byte[] strToArray(java.lang.String data)
Converts hexadecimal string to byte array.

Parameters:
data - Hexadecimal string.
Returns:
Array of bytes.