mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 04:15:39 +00:00
additional update to handle new hooking macros
This commit is contained in:
parent
14a71b5546
commit
4297ba4310
27
bindings/java/unicorn/MemHook.java
Executable file
27
bindings/java/unicorn/MemHook.java
Executable file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
|
||||
Java bindings for the Unicorn Emulator Engine
|
||||
|
||||
Copyright(c) 2015 Chris Eagle
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
version 2 as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
package unicorn;
|
||||
|
||||
public interface MemHook extends ReadHook,WriteHook {
|
||||
|
||||
}
|
||||
|
26
bindings/java/unicorn/Unicorn.java
Normal file → Executable file
26
bindings/java/unicorn/Unicorn.java
Normal file → Executable file
|
@ -519,6 +519,21 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
|
|||
writeList.add(new Tuple(callback, user_data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook registration for UC_HOOK_MEM_WRITE | UC_HOOK_MEM_WRITE hooks. The registered callback function will be
|
||||
* invoked whenever a memory write or read is performed within the address range begin <= addr <= end. For
|
||||
* the special case in which begin > end, the callback will be invoked for ALL memory writes.
|
||||
*
|
||||
* @param callback Implementation of a MemHook interface
|
||||
* @param begin Start address of memory range
|
||||
* @param end End address of memory range
|
||||
* @param user_data User data to be passed to the callback function each time the event is triggered
|
||||
*/
|
||||
public void hook_add(MemHook callback, long begin, long end, Object user_data) throws UnicornException {
|
||||
hook_add((ReadHook)callback, begin, end, user_data);
|
||||
hook_add((WriteHook)callback, begin, end, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook registration for UC_HOOK_MEM_XXX_INVALID and UC_HOOK_MEM_XXX_PROT hooks.
|
||||
* The registered callback function will be invoked whenever a read or write is
|
||||
|
@ -529,11 +544,14 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
|
|||
* @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 {
|
||||
Long handle = eventMemHandles.get(type);
|
||||
//test all of the EventMem related bits in type
|
||||
for (Integer htype : eventMemMap.keySet()) {
|
||||
if ((type & htype) != 0) { //the 'htype' bit is set in type
|
||||
Long handle = eventMemHandles.get(htype);
|
||||
if (handle == null) {
|
||||
eventMemHandles.put(type, registerHook(eng, type));
|
||||
eventMemHandles.put(htype, registerHook(eng, htype));
|
||||
}
|
||||
int cbType = eventMemMap.get(type);
|
||||
int cbType = eventMemMap.get(htype);
|
||||
ArrayList<Tuple> flist = eventMemLists.get(cbType);
|
||||
if (flist == null) {
|
||||
flist = new ArrayList<Tuple>();
|
||||
|
@ -542,6 +560,8 @@ public class Unicorn implements UnicornConst, ArmConst, Arm64Const, M68kConst, S
|
|||
}
|
||||
flist.add(new Tuple(callback, user_data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook registration for UC_HOOK_INSN hooks (x86 IN instruction only). The registered callback
|
||||
|
|
Loading…
Reference in a new issue