C:\Users\piao\Downloads\adbi\hijack\jni
λ ndk-build.cmd
Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-14.
[arm64-v8a] Compile        : hijack <= hijack.c
C:/Users/piao/Downloads/adbi/hijack/jni/../hijack.c:141:22: warning: passing 'unsigned char [16]' to parameter of type 'const char *' converts
      between pointers to integer types with different sign [-Wpointer-sign]
        if (strncmp(ELFMAG, ehdr.e_ident, SELFMAG)) { /* sanity */
                            ^~~~~~~~~~~~
D:/DevelopTools/Android/sdk/ndk-bundle/build//../sysroot/usr/include\string.h:137:44: note: passing argument to parameter '__rhs' here
int strncmp(const char* __lhs, const char* __rhs, size_t __n) __attribute_pure__;
                                           ^
C:/Users/piao/Downloads/adbi/hijack/jni/../hijack.c:529:76: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                if ((*p = ptrace(PTRACE_PEEKTEXT, pid, (void *)(pos+(i*4)), (void *)*p)) < 0)
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
C:/Users/piao/Downloads/adbi/hijack/jni/../hijack.c:764:11: error: use of undeclared identifier 'PTRACE_GETREGS'
                        ptrace(PTRACE_GETREGS, pid, 0, &regs);
                               ^
C:/Users/piao/Downloads/adbi/hijack/jni/../hijack.c:792:9: error: use of undeclared identifier 'PTRACE_GETREGS'
        ptrace(PTRACE_GETREGS, pid, 0, &regs);
               ^
C:/Users/piao/Downloads/adbi/hijack/jni/../hijack.c:873:9: error: use of undeclared identifier 'PTRACE_SETREGS'
        ptrace(PTRACE_SETREGS, pid, 0, &regs);
               ^
2 warnings and 3 errors generated.
make: *** [C:/Users/piao/Downloads/adbi/hijack/obj/local/arm64-v8a/objs/hijack/__/hijack.o] Error 1


解决方法:

在 Android.mk 统计目录 新建 Application.mk 文件,内容如下:

APP_PLATFORM := android-14  // 这句可不加,主要是消除编译警告!!!
APP_ABI := armeabi-v7a

重新编译:

C:\Users\piao\Downloads\adbi\hijack\jni
λ ndk-build.cmd
Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-14.
[armeabi] Compile arm    : hijack <= hijack.c
C:/Users/piao/Downloads/adbi/hijack/jni/../hijack.c:141:22: warning: passing 'unsigned char [16]' to parameter of type 'const char *' converts
      between pointers to integer types with different sign [-Wpointer-sign]
        if (strncmp(ELFMAG, ehdr.e_ident, SELFMAG)) { /* sanity */
                            ^~~~~~~~~~~~
D:/DevelopTools/Android/sdk/ndk-bundle/build//../sysroot/usr/include\string.h:137:44: note: passing argument to parameter '__rhs' here
int strncmp(const char* __lhs, const char* __rhs, size_t __n) __attribute_pure__;
                                           ^
C:/Users/piao/Downloads/adbi/hijack/jni/../hijack.c:529:76: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                if ((*p = ptrace(PTRACE_PEEKTEXT, pid, (void *)(pos+(i*4)), (void *)*p)) < 0)
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
2 warnings generated.
[armeabi] Executable     : hijack
[armeabi] Install        : hijack => libs/armeabi/hijack


注意!!

5.x编译需要在Android.mk加入:

LOCAL_CFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -pie -fPIE


你可能感兴趣的文章

评论区

发表评论

必填

选填

选填

必填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。