Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS x86_x64 InlineHook hook C函数无效果! #144

Open
HOOKDLL opened this issue Apr 22, 2021 · 5 comments
Open

macOS x86_x64 InlineHook hook C函数无效果! #144

HOOKDLL opened this issue Apr 22, 2021 · 5 comments

Comments

@HOOKDLL
Copy link

HOOKDLL commented Apr 22, 2021

经过几天研究,我是 M1 用户
采用 cmake/ios.toolchain.cmake -DPLATFORM=MAC 生成 x86_x64 静态库.a
`# build macos x86_64
output_dir_name=auto-build-workspace/darwin-macos-x86_64-build
compress_dir_array="$compress_dir_array $output_dir_name"
echo "prepare build ${output_dir_name}"

mkdir -p ${CURRENT_DIR}/${output_dir_name}
cmake -S . -B ${output_dir_name} -DCMAKE_BUILD_TYPE=Release
-DCMAKE_TOOLCHAIN_FILE=cmake/ios.toolchain.cmake
-DPLATFORM=MAC -DARCHS="x86_64" -DCMAKE_SYSTEM_PROCESSOR=x86_64
-DENABLE_BITCODE=0 -DENABLE_ARC=0 -DENABLE_VISIBILITY=1 -DDEPLOYMENT_TARGET=10.1
-DDOBBY_GENERATE_SHARED=OFF -DGenerateDarwinFramework=OFF -DDOBBY_DEBUG=OFF
cmake --build ${output_dir_name} --parallel 4 --target dobby

mkdir -p ${summary_output_dir_name}/darwin/macos_x86_64
cp -r ${output_dir_name}/${darwin_library_name} ${summary_output_dir_name}/darwin/macos_x86_64`

`
测试代码:

static int (*orig_isNGiw32TGSAb)(double a1);

int myisNGiw32TGSAb(double a1){
NSLog(@"[+] hook isNGiw32TGSAb hooked");
return 1;
}

intptr_t imageSilde = image_addr("Alf Framework.framework");

if(imageSilde != 0){

    void *mainProgramHandle = dlopen(NULL, RTLD_NOW);

    int64_t *patch_2 = (int64_t *)dlsym(mainProgramHandle , "isNGiw32TGSAb");
    NSLog(@"[+] isNGiw32TGSAb:0x%x ====",patch_2);
            
    int bb = DobbyHook((void *)patch_2,(int*)myisNGiw32TGSAb, (void **)&orig_isNGiw32TGSAb);
    if (bb == 0) {
        NSLog(@"[+] hook myisNGiw32TGSAb success :%d",bb);
    } else {
        NSLog(@"[+] hook myisNGiw32TGSAb fail :%d",bb);
    }
        
}`

导入工程 macOS x86_x64 hook C函数无效果!
同样代码 macOS amd64 架构有效果
请问大佬 Dobby 是支持 macOS x86_x64 架构?还是代码 bug ?

@jmpews
Copy link
Owner

jmpews commented Apr 22, 2021

我这里是没有问题的.

@HOOKDLL
Copy link
Author

HOOKDLL commented Apr 23, 2021

我这里是没有问题的.

经测试 intel 芯片的 macOS x86_x64 实体机 InlineHook hook C 函数生效了。
之前测试 x86_x64 不通过,我是用 apple Rosetta2 转换运行的 x86_x64, InlineHook hook C 函数确实失败了。
望大佬测试支持一下,Rosetta 转换下 hook C 函数确实失败了! 谢谢。

@jmpews
Copy link
Owner

jmpews commented Apr 23, 2021

ok 好的 我试下 (请问这是什么需求?

@HOOKDLL
Copy link
Author

HOOKDLL commented Apr 23, 2021

ok 好的 我试下 (请问这是什么需求?

image
这是苹果自家处理器 M1 Rosetta 转换层翻译执行 intel x86_x64 指令,有些老程序没有编绎 arm64 时,是通过 Rosetta 得到执行,有些需求:如果我是hook这老程序,就我所说的 hook C 函数会失效!所以需要你看看,谢谢。

@1021811501
Copy link

遇到同样问题,求教如何解决 @jmpews @HOOKDLL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants