push some bullcrap

This commit is contained in:
Starlet Leonhart 2019-06-29 12:13:36 -04:00
parent 89346359cd
commit faad5a7c72
4 changed files with 27 additions and 1 deletions

View File

@ -3,6 +3,8 @@ project(Lightswitch VERSION 1 LANGUAGES CXX)
set_property(GLOBAL PROPERTY CMAKE_CXX_STANDARD 17 PROPERTY CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(source_DIR ${CMAKE_SOURCE_DIR}/src/main/cpp)
include_directories(${source_DIR}/include)
add_library(lightswitch SHARED ${source_DIR}/lightswitch.cpp)
target_link_libraries(lightswitch ${source_DIR}/lib/${ANDROID_ABI}/libunicorn.a)

View File

@ -0,0 +1,5 @@
#include "cpu.h"
namespace Core {
}

View File

@ -0,0 +1,10 @@
#pragma once
#include <unicorn/unicorn.h>
namespace Core {
class Cpu {
private:
uc_engine *uc;
};
}

View File

@ -20,13 +20,20 @@ static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user
syslog(LOG_DEBUG, ">>> Tracing instruction at 0x%" PRIx64 ", instruction size = 0x%x\n", size);
}
static void hook_intr(uc_engine *uc, uint32_t intno, void *user_data)
{
if (intno == 2) {
}
}
extern "C" JNIEXPORT jstring JNICALL
Java_gq_cyuubi_lightswitch_MainActivity_stringFromJNI(
JNIEnv *env,
jobject /* this */) {
uc_engine *uc;
uc_err err;
uc_hook trace1, trace2;
uc_hook trace1, trace2, intr;
int64_t x11 = 0x12345678; // X11 register
int64_t x13 = 0x10000 + 0x8; // X13 register
@ -58,6 +65,8 @@ Java_gq_cyuubi_lightswitch_MainActivity_stringFromJNI(
// tracing one instruction at ADDRESS with customized callback
uc_hook_add(uc, &trace2, UC_HOOK_CODE, (void*)hook_code, NULL, ADDRESS, ADDRESS);
uc_hook_add(uc, &intr, UC_HOOK_INTR, (void*)hook_intr, NULL, 1, 0);
// emulate machine code in infinite time (last param = 0), or when
// finishing all the code.
err = uc_emu_start(uc, ADDRESS, ADDRESS + sizeof(ARM_CODE) -1, 0, 0);