bytedance / bhook

:fire: ByteHook is an Android PLT hook library which supports armeabi-v7a, arm64-v8a, x86 and x86_64.
https://github.com/bytedance/bhook/tree/main/doc#readme
MIT License
2.05k stars 315 forks source link

After updating Android Studio, typedef now fail: error: unexpected type name 'read_t': expected expression #96

Open CunningLogic opened 3 months ago

CunningLogic commented 3 months ago

bytehook Version

v1.0.10

Android OS Version

12.0

Android ABIs

arm64-v8a

Device Manufacturers and Models

Google Pixel 6

Describe the Bug

Android Studio Jellyfish | 2023.3.1 Host Linux NDK = 25.0.8775105 25.1.8937393 25.2.9519653 26.1.10909125 27.0.11718014

After upgrading Android Studio and bytehook I am now running into an error that worked previously.

typedef ssize_t (*read_t)(int, unsigned char*, size_t);

static ssize_t read_proxy_auto(int fd, unsigned char *buf, size_t count) {
    ssize_t ret = BYTEHOOK_CALL_PREV(read_proxy_auto, read_t, fd, buf, count);

    BYTEHOOK_POP_STACK();
    return ret;

}

Execution failed for task ':app:buildCMakeDebug[arm64-v8a]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory `/home/jcase/AndroidStudioProjects/Rainor/app/.cxx/Debug/6l356c5k/arm64-v8a'
  [1/2] Building CXX object CMakeFiles/chub.dir/chub.cpp.o
  FAILED: CMakeFiles/chub.dir/chub.cpp.o 
  /home/jcase/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android26 --sysroot=/home/jcase/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Dchub_EXPORTS -isystem /home/jcase/.gradle/caches/transforms-4/dbcf50b851546548b06bc88378547ded/transformed/bytehook-1.0.10/prefab/modules/bytehook/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -fno-limit-debug-info  -fPIC -MD -MT CMakeFiles/chub.dir/chub.cpp.o -MF CMakeFiles/chub.dir/chub.cpp.o.d -o CMakeFiles/chub.dir/chub.cpp.o -c /home/jcase/AndroidStudioProjects/Rainor/app/src/main/cpp/chub.cpp
  /home/jcase/AndroidStudioProjects/Rainor/app/src/main/cpp/chub.cpp:38:55: error: unexpected type name 'read_t': expected expression
      ssize_t ret = BYTEHOOK_CALL_PREV(read_proxy_auto, read_t, fd, buf, count);
                                                        ^
  1 error generated.
  ninja: build stopped: subcommand failed.