jmpews / Dobby

a lightweight, multi-platform, multi-architecture hook framework.
Apache License 2.0
4k stars 833 forks source link

the replacing method uses the same x8 register as the need hooked method, which causes an error, how resolve it? #190

Open iOSPrincekin opened 2 years ago

iOSPrincekin commented 2 years ago

env:iOS13.3.1 arm64 iphone6s Xcode13.3.1 Hi: I hook a method that uses the x8 register in its body, let's call it method_A, I hook it using DobbyX by replacing it with the new function dobby_method_A, in the dobby_method_A body disassembler, it also uses the x8 register, so when back to method_A, its x8 register had changed, so it case error!

I don't know why method_A and its replace method use the same x8 register, I read and debug the two methods disassembler, and it shows that not set the original x8 register value back, It's possible the method_A does something protect? how to solve it?

any help would be appreciated!

jmpews commented 2 years ago
  1. is the function signature special? ex: x8 used for struct param?
  2. which interface using? DobbyHook or DobbyInstrument?

iOSPrincekin @.***> 于2022年8月2日周二 19:38写道:

env:iOS13.3.1 arm64 iphone6s Xcode13.3.1 Hi: I hook a method that uses the x8 register in its body, let's call it method_A, I hook it using DobbyX by replacing it with the new function dobby_method_A, in the dobby_method_A body disassembler, it also uses the x8 register, so when back to method_A, its x8 register had changed, so it case error!

I don't know why method_A and its replace method use the same x8 register, I read and debug the two methods disassembler, and it shows that not set the original x8 register value back, It's possible the method_A does something protect? how to solve it?

any help would be appreciated!

— Reply to this email directly, view it on GitHub https://github.com/jmpews/Dobby/issues/190, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDSANNC5PQIZRJICQ33SWDVXECBVANCNFSM55K2H7IA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

iOSPrincekin commented 2 years ago

the method_A function second argument is std::string type, and I used DobbyHook interface

codingsf commented 5 months ago

macos or ios use x8 register for transftering this pointer, and proxy function use x8 register to call original function . this lead to crash