Permalink
Browse files

Initial CMake support

  • Loading branch information...
malexmave committed Dec 15, 2016
1 parent 5831bb6 commit d46c82cf2413897a634275e8c5c2651ebd811878
View
@@ -7,3 +7,4 @@
/app/manifest-merger-release-report.txt
*.iml
*.log
nfcd/.externalNativeBuild/
View
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -1,6 +1,6 @@
#Sat Dec 06 11:48:51 CET 2014
#Thu Dec 15 10:37:20 CET 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
View
@@ -0,0 +1,26 @@
# Sets the minimum version of CMake required to build your native library.
# This ensures that a certain set of CMake features is available to
# your build.
cmake_minimum_required(VERSION 3.4.1)
# Specifies a library name, specifies whether the library is STATIC or
# SHARED, and provides relative paths to the source code. You can
# define multiple libraries by adding multiple add.library() commands,
# and CMake builds them for you. When you build your app, Gradle
# automatically packages shared libraries with your APK.
add_library( # Specifies the name of the library.
nfcgate-native
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/jni/main.cpp
src/main/jni/chip.cpp
src/main/jni/javainterface.cpp
src/main/jni/vendor/adbi/hook.cpp
)
target_link_libraries(nfcgate-native android log)
View
@@ -26,6 +26,11 @@ android {
}
productFlavors {
}
externalNativeBuild {
cmake {
path 'CMakeLists.txt'
}
}
}
dependencies {
@@ -24,7 +24,7 @@ JNIEXPORT void JNICALL Java_tud_seemuh_nfcgate_xposed_Native_setEnabled(JNIEnv*
JNIEXPORT void JNICALL Java_tud_seemuh_nfcgate_xposed_Native_uploadConfiguration(JNIEnv* env, jobject javaThis, jbyte atqa, jbyte sak, jbyteArray _hist, jbyteArray _uid) {
jsize uid_len = env->GetArrayLength(_uid);
jsize hist_len = env->GetArrayLength(_hist);
if(uid_len > sizeof(s_chip_config::uid) || hist_len > sizeof(s_chip_config::hist)) {
if(uid_len > (sizeof(uint8_t) * 64) || hist_len > (sizeof(uint8_t) * 64)) {
jclass Exception = env->FindClass("java/lang/Exception");
env->ThrowNew(Exception, "uid or hist bigger than buffer");
}
@@ -20,9 +20,9 @@ const char *hooklibfile = "/system/lib/libnfc-nci.so";
static void onModuleLoad() __attribute__((constructor));
void onModuleLoad() {
LOGI("onModuleLoad::begin");
//LOGI("onModuleLoad::begin");
hookNative();
LOGI("onModuleLoad::end");
//LOGI("onModuleLoad::end");
}
@@ -23,7 +23,7 @@ void inline hook_cacheflush(unsigned int begin, unsigned int end)
"mov r0, %0\n"
"mov r1, %1\n"
"mov r7, %2\n"
"mov r2, #0x0\n"
"movs r2, #0x0\n"
"svc 0x00000000\n"
:
: "r" (begin), "r" (end), "r" (syscall)
@@ -48,7 +48,7 @@ int hook(struct hook_t *h, unsigned int addr, void *hookf)
unsigned int page_size = sysconf(_SC_PAGESIZE);
unsigned int entry_page_start = ~((page_size) - 1) & (addr);
if(mprotect((void*)entry_page_start, page_size, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) {
log("mprotect: %u", errno);
// log("mprotect: %u", errno);
return -1;
}

0 comments on commit d46c82c

Please sign in to comment.