bindings: rename uchook to uc_hook, ucengine to uc_engine, uc_hook_t to uc_hook_type

This commit is contained in:
Nguyen Anh Quynh 2015-09-05 11:25:49 +08:00
parent d1bdbd11e7
commit 99824e1d56

View File

@ -52,7 +52,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
// @address: address where the code is being executed // @address: address where the code is being executed
// @size: size of machine instruction being executed // @size: size of machine instruction being executed
// @user_data: user data passed to tracing APIs. // @user_data: user data passed to tracing APIs.
static void cb_hookcode(ucengine *eng, uint64_t address, uint32_t size, void *user_data) { static void cb_hookcode(uc_engine *eng, uint64_t address, uint32_t size, void *user_data) {
JNIEnv *env; JNIEnv *env;
(*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL); (*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL);
jclass clz = (*env)->FindClass(env, "unicorn/Unicorn"); jclass clz = (*env)->FindClass(env, "unicorn/Unicorn");
@ -67,7 +67,7 @@ static void cb_hookcode(ucengine *eng, uint64_t address, uint32_t size, void *us
// @address: address where the code is being executed // @address: address where the code is being executed
// @size: size of machine instruction being executed // @size: size of machine instruction being executed
// @user_data: user data passed to tracing APIs. // @user_data: user data passed to tracing APIs.
static void cb_hookblock(ucengine *eng, uint64_t address, uint32_t size, void *user_data) { static void cb_hookblock(uc_engine *eng, uint64_t address, uint32_t size, void *user_data) {
JNIEnv *env; JNIEnv *env;
(*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL); (*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL);
jclass clz = (*env)->FindClass(env, "unicorn/Unicorn"); jclass clz = (*env)->FindClass(env, "unicorn/Unicorn");
@ -81,7 +81,7 @@ static void cb_hookblock(ucengine *eng, uint64_t address, uint32_t size, void *u
// Callback function for tracing interrupts (for uc_hook_intr()) // Callback function for tracing interrupts (for uc_hook_intr())
// @intno: interrupt number // @intno: interrupt number
// @user_data: user data passed to tracing APIs. // @user_data: user data passed to tracing APIs.
static void cb_hookintr(ucengine *eng, uint32_t intno, void *user_data) { static void cb_hookintr(uc_engine *eng, uint32_t intno, void *user_data) {
JNIEnv *env; JNIEnv *env;
(*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL); (*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL);
jclass clz = (*env)->FindClass(env, "unicorn/Unicorn"); jclass clz = (*env)->FindClass(env, "unicorn/Unicorn");
@ -96,7 +96,7 @@ static void cb_hookintr(ucengine *eng, uint32_t intno, void *user_data) {
// @port: port number // @port: port number
// @size: data size (1/2/4) to be read from this port // @size: data size (1/2/4) to be read from this port
// @user_data: user data passed to tracing APIs. // @user_data: user data passed to tracing APIs.
static uint32_t cb_insn_in(ucengine *eng, uint32_t port, int size, void *user_data) { static uint32_t cb_insn_in(uc_engine *eng, uint32_t port, int size, void *user_data) {
JNIEnv *env; JNIEnv *env;
uint32_t res = 0; uint32_t res = 0;
(*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL); (*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL);
@ -113,7 +113,7 @@ static uint32_t cb_insn_in(ucengine *eng, uint32_t port, int size, void *user_da
// @port: port number // @port: port number
// @size: data size (1/2/4) to be written to this port // @size: data size (1/2/4) to be written to this port
// @value: data value to be written to this port // @value: data value to be written to this port
static void cb_insn_out(ucengine *eng, uint32_t port, int size, uint32_t value, void *user_data) { static void cb_insn_out(uc_engine *eng, uint32_t port, int size, uint32_t value, void *user_data) {
JNIEnv *env; JNIEnv *env;
(*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL); (*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL);
jclass clz = (*env)->FindClass(env, "unicorn/Unicorn"); jclass clz = (*env)->FindClass(env, "unicorn/Unicorn");
@ -125,7 +125,7 @@ static void cb_insn_out(ucengine *eng, uint32_t port, int size, uint32_t value,
} }
// x86's handler for SYSCALL/SYSENTER // x86's handler for SYSCALL/SYSENTER
static void cb_insn_syscall(ucengine *eng, void *user_data) { static void cb_insn_syscall(uc_engine *eng, void *user_data) {
JNIEnv *env; JNIEnv *env;
(*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL); (*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL);
jclass clz = (*env)->FindClass(env, "unicorn/Unicorn"); jclass clz = (*env)->FindClass(env, "unicorn/Unicorn");
@ -142,7 +142,7 @@ static void cb_insn_syscall(ucengine *eng, void *user_data) {
// @size: size of data being read or written // @size: size of data being read or written
// @value: value of data being written to memory, or irrelevant if type = READ. // @value: value of data being written to memory, or irrelevant if type = READ.
// @user_data: user data passed to tracing APIs // @user_data: user data passed to tracing APIs
static void cb_hookmem(ucengine *eng, uc_mem_type type, static void cb_hookmem(uc_engine *eng, uc_mem_type type,
uint64_t address, int size, int64_t value, void *user_data) { uint64_t address, int size, int64_t value, void *user_data) {
JNIEnv *env; JNIEnv *env;
(*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL); (*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL);
@ -171,7 +171,7 @@ static void cb_hookmem(ucengine *eng, uc_mem_type type,
// @value: value of data being written to memory, or irrelevant if type = READ. // @value: value of data being written to memory, or irrelevant if type = READ.
// @user_data: user data passed to tracing APIs // @user_data: user data passed to tracing APIs
// @return: return true to continue, or false to stop program (due to invalid memory). // @return: return true to continue, or false to stop program (due to invalid memory).
static bool cb_eventmem(ucengine *eng, uc_mem_type type, static bool cb_eventmem(uc_engine *eng, uc_mem_type type,
uint64_t address, int size, int64_t value, void *user_data) { uint64_t address, int size, int64_t value, void *user_data) {
JNIEnv *env; JNIEnv *env;
(*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL); (*cachedJVM)->AttachCurrentThread(cachedJVM, (void **)&env, NULL);
@ -193,7 +193,7 @@ static void throwException(JNIEnv *env, uc_err err) {
} }
} }
static ucengine *getEngine(JNIEnv *env, jobject self) { static uc_engine *getEngine(JNIEnv *env, jobject self) {
static int haveFid = 0; static int haveFid = 0;
static jfieldID fid; static jfieldID fid;
if (haveFid == 0) { if (haveFid == 0) {
@ -202,7 +202,7 @@ static ucengine *getEngine(JNIEnv *env, jobject self) {
fid = (*env)->GetFieldID(env, clazz, "eng", "J"); fid = (*env)->GetFieldID(env, clazz, "eng", "J");
haveFid = 1; haveFid = 1;
} }
return (ucengine *)(*env)->GetLongField(env, self, fid); return (uc_engine *)(*env)->GetLongField(env, self, fid);
} }
/* /*
@ -212,7 +212,7 @@ static ucengine *getEngine(JNIEnv *env, jobject self) {
*/ */
JNIEXPORT jlong JNICALL Java_unicorn_Unicorn_open JNIEXPORT jlong JNICALL Java_unicorn_Unicorn_open
(JNIEnv *env, jobject self, jint arch, jint mode) { (JNIEnv *env, jobject self, jint arch, jint mode) {
ucengine *eng = NULL; uc_engine *eng = NULL;
uc_err err = uc_open((uc_arch)arch, (uc_mode)mode, &eng); uc_err err = uc_open((uc_arch)arch, (uc_mode)mode, &eng);
if (err != UC_ERR_OK) { if (err != UC_ERR_OK) {
throwException(env, err); throwException(env, err);
@ -247,7 +247,7 @@ JNIEXPORT jboolean JNICALL Java_unicorn_Unicorn_arch_1supported
*/ */
JNIEXPORT void JNICALL Java_unicorn_Unicorn_close JNIEXPORT void JNICALL Java_unicorn_Unicorn_close
(JNIEnv *env, jobject self) { (JNIEnv *env, jobject self) {
ucengine *eng = getEngine(env, self); uc_engine *eng = getEngine(env, self);
uc_close(eng); uc_close(eng);
} }
@ -258,7 +258,7 @@ JNIEXPORT void JNICALL Java_unicorn_Unicorn_close
*/ */
JNIEXPORT jint JNICALL Java_unicorn_Unicorn_errno JNIEXPORT jint JNICALL Java_unicorn_Unicorn_errno
(JNIEnv *env, jobject self) { (JNIEnv *env, jobject self) {
ucengine *eng = getEngine(env, self); uc_engine *eng = getEngine(env, self);
return (jint)uc_errno(eng); return (jint)uc_errno(eng);
} }
@ -281,7 +281,7 @@ JNIEXPORT jstring JNICALL Java_unicorn_Unicorn_strerror
*/ */
JNIEXPORT void JNICALL Java_unicorn_Unicorn_reg_1write JNIEXPORT void JNICALL Java_unicorn_Unicorn_reg_1write
(JNIEnv *env, jobject self, jint regid, jbyteArray value) { (JNIEnv *env, jobject self, jint regid, jbyteArray value) {
ucengine *eng = getEngine(env, self); uc_engine *eng = getEngine(env, self);
jbyte *array = (*env)->GetByteArrayElements(env, value, NULL); jbyte *array = (*env)->GetByteArrayElements(env, value, NULL);
uc_err err = uc_reg_write(eng, (int)regid, (void *)array); uc_err err = uc_reg_write(eng, (int)regid, (void *)array);
if (err != UC_ERR_OK) { if (err != UC_ERR_OK) {
@ -297,7 +297,7 @@ JNIEXPORT void JNICALL Java_unicorn_Unicorn_reg_1write
*/ */
JNIEXPORT jbyteArray JNICALL Java_unicorn_Unicorn_reg_1read JNIEXPORT jbyteArray JNICALL Java_unicorn_Unicorn_reg_1read
(JNIEnv *env, jobject self, jint regid, jint regsz) { (JNIEnv *env, jobject self, jint regid, jint regsz) {
ucengine *eng = getEngine(env, self); uc_engine *eng = getEngine(env, self);
jbyteArray regval = (*env)->NewByteArray(env, (jsize)regsz); jbyteArray regval = (*env)->NewByteArray(env, (jsize)regsz);
jbyte *array = (*env)->GetByteArrayElements(env, regval, NULL); jbyte *array = (*env)->GetByteArrayElements(env, regval, NULL);
uc_err err = uc_reg_read(eng, (int)regid, (void *)array); uc_err err = uc_reg_read(eng, (int)regid, (void *)array);
@ -316,7 +316,7 @@ JNIEXPORT jbyteArray JNICALL Java_unicorn_Unicorn_reg_1read
JNIEXPORT void JNICALL Java_unicorn_Unicorn_mem_1write JNIEXPORT void JNICALL Java_unicorn_Unicorn_mem_1write
(JNIEnv *env , jobject self, jlong address, jbyteArray bytes) { (JNIEnv *env , jobject self, jlong address, jbyteArray bytes) {
ucengine *eng = getEngine(env, self); uc_engine *eng = getEngine(env, self);
jbyte *array = (*env)->GetByteArrayElements(env, bytes, NULL); jbyte *array = (*env)->GetByteArrayElements(env, bytes, NULL);
jsize size = (*env)->GetArrayLength(env, bytes); jsize size = (*env)->GetArrayLength(env, bytes);
uc_err err = uc_mem_write(eng, (uint64_t)address, (uint8_t *)array, (size_t)size); uc_err err = uc_mem_write(eng, (uint64_t)address, (uint8_t *)array, (size_t)size);
@ -335,7 +335,7 @@ JNIEXPORT void JNICALL Java_unicorn_Unicorn_mem_1write
*/ */
JNIEXPORT jbyteArray JNICALL Java_unicorn_Unicorn_mem_1read JNIEXPORT jbyteArray JNICALL Java_unicorn_Unicorn_mem_1read
(JNIEnv *env, jobject self, jlong address, jlong size) { (JNIEnv *env, jobject self, jlong address, jlong size) {
ucengine *eng = getEngine(env, self); uc_engine *eng = getEngine(env, self);
jbyteArray bytes = (*env)->NewByteArray(env, (jsize)size); jbyteArray bytes = (*env)->NewByteArray(env, (jsize)size);
jbyte *array = (*env)->GetByteArrayElements(env, bytes, NULL); jbyte *array = (*env)->GetByteArrayElements(env, bytes, NULL);
@ -354,7 +354,7 @@ JNIEXPORT jbyteArray JNICALL Java_unicorn_Unicorn_mem_1read
*/ */
JNIEXPORT void JNICALL Java_unicorn_Unicorn_emu_1start JNIEXPORT void JNICALL Java_unicorn_Unicorn_emu_1start
(JNIEnv *env, jobject self, jlong begin, jlong until, jlong timeout, jlong count) { (JNIEnv *env, jobject self, jlong begin, jlong until, jlong timeout, jlong count) {
ucengine *eng = getEngine(env, self); uc_engine *eng = getEngine(env, self);
uc_err err = uc_emu_start(eng, (uint64_t)begin, (uint64_t)until, (uint64_t)timeout, (size_t)count); uc_err err = uc_emu_start(eng, (uint64_t)begin, (uint64_t)until, (uint64_t)timeout, (size_t)count);
if (err != UC_ERR_OK) { if (err != UC_ERR_OK) {
@ -369,7 +369,7 @@ JNIEXPORT void JNICALL Java_unicorn_Unicorn_emu_1start
*/ */
JNIEXPORT void JNICALL Java_unicorn_Unicorn_emu_1stop JNIEXPORT void JNICALL Java_unicorn_Unicorn_emu_1stop
(JNIEnv *env, jobject self) { (JNIEnv *env, jobject self) {
ucengine *eng = getEngine(env, self); uc_engine *eng = getEngine(env, self);
uc_err err = uc_emu_stop(eng); uc_err err = uc_emu_stop(eng);
if (err != UC_ERR_OK) { if (err != UC_ERR_OK) {
@ -384,20 +384,20 @@ JNIEXPORT void JNICALL Java_unicorn_Unicorn_emu_1stop
*/ */
JNIEXPORT jlong JNICALL Java_unicorn_Unicorn_registerHook__JI JNIEXPORT jlong JNICALL Java_unicorn_Unicorn_registerHook__JI
(JNIEnv *env, jclass clz, jlong eng, jint type) { (JNIEnv *env, jclass clz, jlong eng, jint type) {
uchook hh = 0; uc_hook hh = 0;
uc_err err = 0; uc_err err = 0;
switch (type) { switch (type) {
case UC_HOOK_INTR: // Hook all interrupt events case UC_HOOK_INTR: // Hook all interrupt events
if (invokeInterruptCallbacks == 0) { if (invokeInterruptCallbacks == 0) {
invokeInterruptCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeInterruptCallbacks", "(JI)V"); invokeInterruptCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeInterruptCallbacks", "(JI)V");
} }
err = uc_hook_add((ucengine*)eng, &hh, (uc_hook_t)type, cb_hookintr, env); err = uc_hook_add((uc_engine*)eng, &hh, (uc_hook_type)type, cb_hookintr, env);
break; break;
case UC_HOOK_MEM_INVALID: // Hook for all invalid memory access events case UC_HOOK_MEM_INVALID: // Hook for all invalid memory access events
if (invokeMemInvalidCallbacks == 0) { if (invokeMemInvalidCallbacks == 0) {
invokeMemInvalidCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeMemInvalidCallbacks", "(JIJIJ)Z"); invokeMemInvalidCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeMemInvalidCallbacks", "(JIJIJ)Z");
} }
err = uc_hook_add((ucengine*)eng, &hh, (uc_hook_t)type, cb_eventmem, env); err = uc_hook_add((uc_engine*)eng, &hh, (uc_hook_type)type, cb_eventmem, env);
break; break;
} }
return (jlong)hh; return (jlong)hh;
@ -410,7 +410,7 @@ JNIEXPORT jlong JNICALL Java_unicorn_Unicorn_registerHook__JI
*/ */
JNIEXPORT jlong JNICALL Java_unicorn_Unicorn_registerHook__JII JNIEXPORT jlong JNICALL Java_unicorn_Unicorn_registerHook__JII
(JNIEnv *env, jclass clz, jlong eng, jint type, jint arg1) { (JNIEnv *env, jclass clz, jlong eng, jint type, jint arg1) {
uchook hh = 0; uc_hook hh = 0;
uc_err err = 0; uc_err err = 0;
switch (type) { switch (type) {
case UC_HOOK_INSN: // Hook a particular instruction case UC_HOOK_INSN: // Hook a particular instruction
@ -419,18 +419,18 @@ JNIEXPORT jlong JNICALL Java_unicorn_Unicorn_registerHook__JII
if (invokeOutCallbacks == 0) { if (invokeOutCallbacks == 0) {
invokeOutCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeOutCallbacks", "(JIII)V"); invokeOutCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeOutCallbacks", "(JIII)V");
} }
err = uc_hook_add((ucengine*)eng, &hh, (uc_hook_t)type, cb_insn_out, env, arg1); err = uc_hook_add((uc_engine*)eng, &hh, (uc_hook_type)type, cb_insn_out, env, arg1);
case UC_X86_INS_IN: case UC_X86_INS_IN:
if (invokeInCallbacks == 0) { if (invokeInCallbacks == 0) {
invokeInCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeInCallbacks", "(JII)I"); invokeInCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeInCallbacks", "(JII)I");
} }
err = uc_hook_add((ucengine*)eng, &hh, (uc_hook_t)type, cb_insn_in, env, arg1); err = uc_hook_add((uc_engine*)eng, &hh, (uc_hook_type)type, cb_insn_in, env, arg1);
case UC_X86_INS_SYSENTER: case UC_X86_INS_SYSENTER:
case UC_X86_INS_SYSCALL: case UC_X86_INS_SYSCALL:
if (invokeSyscallCallbacks == 0) { if (invokeSyscallCallbacks == 0) {
invokeSyscallCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeSyscallCallbacks", "(J)V"); invokeSyscallCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeSyscallCallbacks", "(J)V");
} }
err = uc_hook_add((ucengine*)eng, &hh, (uc_hook_t)type, cb_insn_syscall, env, arg1); err = uc_hook_add((uc_engine*)eng, &hh, (uc_hook_type)type, cb_insn_syscall, env, arg1);
} }
break; break;
} }
@ -444,38 +444,38 @@ JNIEXPORT jlong JNICALL Java_unicorn_Unicorn_registerHook__JII
*/ */
JNIEXPORT jlong JNICALL Java_unicorn_Unicorn_registerHook__JIJJ JNIEXPORT jlong JNICALL Java_unicorn_Unicorn_registerHook__JIJJ
(JNIEnv *env, jclass clz, jlong eng, jint type, jlong arg1, jlong arg2) { (JNIEnv *env, jclass clz, jlong eng, jint type, jlong arg1, jlong arg2) {
uchook hh = 0; uc_hook hh = 0;
uc_err err = 0; uc_err err = 0;
switch (type) { switch (type) {
case UC_HOOK_CODE: // Hook a range of code case UC_HOOK_CODE: // Hook a range of code
if (invokeCodeCallbacks == 0) { if (invokeCodeCallbacks == 0) {
invokeCodeCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeCodeCallbacks", "(JJI)V"); invokeCodeCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeCodeCallbacks", "(JJI)V");
} }
err = uc_hook_add((ucengine*)eng, &hh, (uc_hook_t)type, cb_hookcode, env, arg1, arg2); err = uc_hook_add((uc_engine*)eng, &hh, (uc_hook_type)type, cb_hookcode, env, arg1, arg2);
break; break;
case UC_HOOK_BLOCK: // Hook basic blocks case UC_HOOK_BLOCK: // Hook basic blocks
if (invokeBlockCallbacks == 0) { if (invokeBlockCallbacks == 0) {
invokeBlockCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeBlockCallbacks", "(JJI)V"); invokeBlockCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeBlockCallbacks", "(JJI)V");
} }
err = uc_hook_add((ucengine*)eng, &hh, (uc_hook_t)type, cb_hookblock, env, arg1, arg2); err = uc_hook_add((uc_engine*)eng, &hh, (uc_hook_type)type, cb_hookblock, env, arg1, arg2);
break; break;
case UC_HOOK_MEM_READ: // Hook all memory read events. case UC_HOOK_MEM_READ: // Hook all memory read events.
if (invokeReadCallbacks == 0) { if (invokeReadCallbacks == 0) {
invokeReadCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeReadCallbacks", "(JJI)V"); invokeReadCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeReadCallbacks", "(JJI)V");
} }
err = uc_hook_add((ucengine*)eng, &hh, (uc_hook_t)type, cb_hookmem, env, arg1, arg2); err = uc_hook_add((uc_engine*)eng, &hh, (uc_hook_type)type, cb_hookmem, env, arg1, arg2);
break; break;
case UC_HOOK_MEM_WRITE: // Hook all memory write events. case UC_HOOK_MEM_WRITE: // Hook all memory write events.
if (invokeWriteCallbacks == 0) { if (invokeWriteCallbacks == 0) {
invokeWriteCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeWriteCallbacks", "(JJIJ)V"); invokeWriteCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeWriteCallbacks", "(JJIJ)V");
} }
err = uc_hook_add((ucengine*)eng, &hh, (uc_hook_t)type, cb_hookmem, env, arg1, arg2); err = uc_hook_add((uc_engine*)eng, &hh, (uc_hook_type)type, cb_hookmem, env, arg1, arg2);
break; break;
case UC_HOOK_MEM_READ_WRITE: // Hook all memory accesses (either READ or WRITE). case UC_HOOK_MEM_READ_WRITE: // Hook all memory accesses (either READ or WRITE).
if (invokeReadWriteCallbacks == 0) { if (invokeReadWriteCallbacks == 0) {
invokeReadWriteCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeReadWriteCallbacks", "(JIJIJ)V"); invokeReadWriteCallbacks = (*env)->GetStaticMethodID(env, clz, "invokeReadWriteCallbacks", "(JIJIJ)V");
} }
err = uc_hook_add((ucengine*)eng, &hh, (uc_hook_t)type, cb_hookmem, env, arg1, arg2); err = uc_hook_add((uc_engine*)eng, &hh, (uc_hook_type)type, cb_hookmem, env, arg1, arg2);
break; break;
} }
return (jlong)hh; return (jlong)hh;
@ -488,11 +488,11 @@ JNIEXPORT jlong JNICALL Java_unicorn_Unicorn_registerHook__JIJJ
*/ */
JNIEXPORT void JNICALL Java_unicorn_Unicorn_hook_1del JNIEXPORT void JNICALL Java_unicorn_Unicorn_hook_1del
(JNIEnv *env, jobject self, jlong hh) { (JNIEnv *env, jobject self, jlong hh) {
ucengine *eng = getEngine(env, self); uc_engine *eng = getEngine(env, self);
//**** TODO remove hook from any internal hook tables as well //**** TODO remove hook from any internal hook tables as well
uc_err err = uc_hook_del(eng, (uchook)hh); uc_err err = uc_hook_del(eng, (uc_hook)hh);
if (err != UC_ERR_OK) { if (err != UC_ERR_OK) {
throwException(env, err); throwException(env, err);
} }
@ -505,7 +505,7 @@ JNIEXPORT void JNICALL Java_unicorn_Unicorn_hook_1del
*/ */
JNIEXPORT void JNICALL Java_unicorn_Unicorn_mem_1map JNIEXPORT void JNICALL Java_unicorn_Unicorn_mem_1map
(JNIEnv *env, jobject self, jlong address, jlong size, jint perms) { (JNIEnv *env, jobject self, jlong address, jlong size, jint perms) {
ucengine *eng = getEngine(env, self); uc_engine *eng = getEngine(env, self);
uc_err err = uc_mem_map(eng, (uint64_t)address, (size_t)size, (uint32_t)perms); uc_err err = uc_mem_map(eng, (uint64_t)address, (size_t)size, (uint32_t)perms);
if (err != UC_ERR_OK) { if (err != UC_ERR_OK) {
@ -520,7 +520,7 @@ JNIEXPORT void JNICALL Java_unicorn_Unicorn_mem_1map
*/ */
JNIEXPORT void JNICALL Java_unicorn_Unicorn_mem_1unmap JNIEXPORT void JNICALL Java_unicorn_Unicorn_mem_1unmap
(JNIEnv *env, jobject self, jlong address, jlong size) { (JNIEnv *env, jobject self, jlong address, jlong size) {
ucengine *eng = getEngine(env, self); uc_engine *eng = getEngine(env, self);
uc_err err = uc_mem_unmap(eng, (uint64_t)address, (size_t)size); uc_err err = uc_mem_unmap(eng, (uint64_t)address, (size_t)size);
if (err != UC_ERR_OK) { if (err != UC_ERR_OK) {
@ -535,7 +535,7 @@ JNIEXPORT void JNICALL Java_unicorn_Unicorn_mem_1unmap
*/ */
JNIEXPORT void JNICALL Java_unicorn_Unicorn_mem_1protect JNIEXPORT void JNICALL Java_unicorn_Unicorn_mem_1protect
(JNIEnv *env, jobject self, jlong address, jlong size, jint perms) { (JNIEnv *env, jobject self, jlong address, jlong size, jint perms) {
ucengine *eng = getEngine(env, self); uc_engine *eng = getEngine(env, self);
uc_err err = uc_mem_protect(eng, (uint64_t)address, (size_t)size, (uint32_t)perms); uc_err err = uc_mem_protect(eng, (uint64_t)address, (size_t)size, (uint32_t)perms);
if (err != UC_ERR_OK) { if (err != UC_ERR_OK) {