Rename some hook related enums:

- UC_ERR_READ_INVALID -> UC_ERR_READ_UNMAPPED
 - UC_ERR_WRITE_INVALID -> UC_ERR_WRITE_UNMAPPED
 - UC_ERR_FETCH_INVALID -> UC_ERR_FETCH_UNMAPPED
 - UC_MEM_READ_INVALID -> UC_MEM_READ_UNMAPPED
 - UC_MEM_WRITE_INVALID -> UC_MEM_WRITE_UNMAPPED
 - UC_MEM_FETCH_INVALID -> UC_MEM_FETCH_UNMAPPED
 - UC_HOOK_MEM_READ_INVALID -> UC_HOOK_MEM_READ_UNMAPPED
 - UC_HOOK_MEM_WRITE_INVALID -> UC_HOOK_MEM_WRITE_UNMAPPED
 - UC_HOOK_MEM_FETCH_INVALID -> UC_HOOK_MEM_FETCH_UNMAPPED
 - UC_HOOK_MEM_INVALID -> UC_HOOK_MEM_UNMAPPED

This also renames some newly added macros to use _INVALID postfix:

 - UC_HOOK_MEM_READ_ERR -> UC_HOOK_MEM_READ_INVALID
 - UC_HOOK_MEM_WRITE_ERR -> UC_HOOK_MEM_WRITE_INVALID
 - UC_HOOK_MEM_FETCH_ERR -> UC_HOOK_MEM_FETCH_INVALID
 - UC_HOOK_MEM_ERR -> UC_HOOK_MEM_INVALID

Fixed all the bindings Java, Go & Python.
This commit is contained in:
Nguyen Anh Quynh
2015-09-30 14:46:55 +08:00
parent 3ca8774f1a
commit 9e64cba6ec
25 changed files with 151 additions and 158 deletions

View File

@ -72,9 +72,9 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
//required to load native method implementations
static {
System.loadLibrary("unicorn_java"); //loads unicorn.dll or libunicorn.so
eventMemMap.put(UC_HOOK_MEM_READ_INVALID, UC_MEM_READ_INVALID);
eventMemMap.put(UC_HOOK_MEM_WRITE_INVALID, UC_MEM_WRITE_INVALID);
eventMemMap.put(UC_HOOK_MEM_FETCH_INVALID, UC_MEM_FETCH_INVALID);
eventMemMap.put(UC_HOOK_MEM_READ_UNMAPPED, UC_MEM_READ_UNMAPPED);
eventMemMap.put(UC_HOOK_MEM_WRITE_UNMAPPED, UC_MEM_WRITE_UNMAPPED);
eventMemMap.put(UC_HOOK_MEM_FETCH_UNMAPPED, UC_MEM_FETCH_UNMAPPED);
eventMemMap.put(UC_HOOK_MEM_READ_PROT, UC_MEM_READ_PROT);
eventMemMap.put(UC_HOOK_MEM_WRITE_PROT, UC_MEM_WRITE_PROT);
eventMemMap.put(UC_HOOK_MEM_FETCH_PROT, UC_MEM_FETCH_PROT);
@ -140,10 +140,10 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
}
/**
* Invoke all UC_HOOK_MEM_XXX_INVALID andor UC_HOOK_MEM_XXX_PROT callbacks registered
* Invoke all UC_HOOK_MEM_XXX_UNMAPPED andor UC_HOOK_MEM_XXX_PROT callbacks registered
* for a specific Unicorn.
* This function gets invoked from the native C callback registered for
* for UC_HOOK_MEM_XXX_INVALID or UC_HOOK_MEM_XXX_PROT
* for UC_HOOK_MEM_XXX_UNMAPPED or UC_HOOK_MEM_XXX_PROT
*
* @param eng A Unicorn uc_engine* eng returned by uc_open
* @param type The type of event that is taking place
@ -535,12 +535,12 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
}
/**
* Hook registration for UC_HOOK_MEM_XXX_INVALID and UC_HOOK_MEM_XXX_PROT hooks.
* Hook registration for UC_HOOK_MEM_XXX_UNMAPPED and UC_HOOK_MEM_XXX_PROT hooks.
* The registered callback function will be invoked whenever a read or write is
* attempted from an invalid or protected memory address.
*
* @param callback Implementation of a EventMemHook interface
* @param type Type of memory event being hooked such as UC_HOOK_MEM_READ_INVALID or UC_HOOK_MEM_WRITE_PROT
* @param type Type of memory event being hooked such as UC_HOOK_MEM_READ_UNMAPPED or UC_HOOK_MEM_WRITE_PROT
* @param user_data User data to be passed to the callback function each time the event is triggered
*/
public void hook_add(EventMemHook callback, int type, Object user_data) throws UnicornException {

View File

@ -41,26 +41,25 @@ public interface UnicornConst {
public static final int UC_ERR_HANDLE = 3;
public static final int UC_ERR_MODE = 4;
public static final int UC_ERR_VERSION = 5;
public static final int UC_ERR_READ_INVALID = 6;
public static final int UC_ERR_WRITE_INVALID = 7;
public static final int UC_ERR_FETCH_INVALID = 8;
public static final int UC_ERR_CODE_INVALID = 9;
public static final int UC_ERR_HOOK = 10;
public static final int UC_ERR_INSN_INVALID = 11;
public static final int UC_ERR_MAP = 12;
public static final int UC_ERR_WRITE_PROT = 13;
public static final int UC_ERR_READ_PROT = 14;
public static final int UC_ERR_FETCH_PROT = 15;
public static final int UC_ERR_ARG = 16;
public static final int UC_ERR_READ_UNALIGNED = 17;
public static final int UC_ERR_WRITE_UNALIGNED = 18;
public static final int UC_ERR_FETCH_UNALIGNED = 19;
public static final int UC_ERR_READ_UNMAPPED = 6;
public static final int UC_ERR_WRITE_UNMAPPED = 7;
public static final int UC_ERR_FETCH_UNMAPPED = 8;
public static final int UC_ERR_HOOK = 9;
public static final int UC_ERR_INSN_INVALID = 10;
public static final int UC_ERR_MAP = 11;
public static final int UC_ERR_WRITE_PROT = 12;
public static final int UC_ERR_READ_PROT = 13;
public static final int UC_ERR_FETCH_PROT = 14;
public static final int UC_ERR_ARG = 15;
public static final int UC_ERR_READ_UNALIGNED = 16;
public static final int UC_ERR_WRITE_UNALIGNED = 17;
public static final int UC_ERR_FETCH_UNALIGNED = 18;
public static final int UC_MEM_READ = 16;
public static final int UC_MEM_WRITE = 17;
public static final int UC_MEM_FETCH = 18;
public static final int UC_MEM_READ_INVALID = 19;
public static final int UC_MEM_WRITE_INVALID = 20;
public static final int UC_MEM_FETCH_INVALID = 21;
public static final int UC_MEM_READ_UNMAPPED = 19;
public static final int UC_MEM_WRITE_UNMAPPED = 20;
public static final int UC_MEM_FETCH_UNMAPPED = 21;
public static final int UC_MEM_WRITE_PROT = 22;
public static final int UC_MEM_READ_PROT = 23;
public static final int UC_MEM_FETCH_PROT = 24;
@ -68,9 +67,9 @@ public interface UnicornConst {
public static final int UC_HOOK_INSN = 2;
public static final int UC_HOOK_CODE = 4;
public static final int UC_HOOK_BLOCK = 8;
public static final int UC_HOOK_MEM_READ_INVALID = 16;
public static final int UC_HOOK_MEM_WRITE_INVALID = 32;
public static final int UC_HOOK_MEM_FETCH_INVALID = 64;
public static final int UC_HOOK_MEM_READ_UNMAPPED = 16;
public static final int UC_HOOK_MEM_WRITE_UNMAPPED = 32;
public static final int UC_HOOK_MEM_FETCH_UNMAPPED = 64;
public static final int UC_HOOK_MEM_READ_PROT = 128;
public static final int UC_HOOK_MEM_WRITE_PROT = 256;
public static final int UC_HOOK_MEM_FETCH_PROT = 512;

View File

@ -31,9 +31,8 @@ public interface UnicornErrors {
public static final int UC_ERR_VERSION = 6; // Unsupported version (bindings)
public static final int UC_ERR_MEM_READ = 7; // Quit emulation due to invalid memory READ: uc_emu_start()
public static final int UC_ERR_MEM_WRITE = 8; // Quit emulation due to invalid memory WRITE: uc_emu_start()
public static final int UC_ERR_CODE_INVALID = 9; // Quit emulation due to invalid code address: uc_emu_start()
public static final int UC_ERR_HOOK = 10; // Invalid hook type: uc_hook_add()
public static final int UC_ERR_INSN_INVALID = 11; // Quit emulation due to invalid instruction: uc_emu_start()
public static final int UC_ERR_MAP = 12; // Invalid memory mapping: uc_mem_map()
public static final int UC_ERR_HOOK = 9; // Invalid hook type: uc_hook_add()
public static final int UC_ERR_INSN_INVALID = 10; // Quit emulation due to invalid instruction: uc_emu_start()
public static final int UC_ERR_MAP = 11; // Invalid memory mapping: uc_mem_map()
}