头文件导入:
typedef long long s64;
typedef unsigned long long u64;
typedef s64 Int;
typedef u64 Bool;
struct Swift::String
{
u64 _countAndFlagsBits;
void *_object;
};
union Swift_ElementAny {
Swift::String stringElement;
};
struct Swift_Any {
Swift_ElementAny element;
u64 unknown;
s64 type;
};
struct Swift_ArrayAny {
s64 length;
Swift_Any *items;
};
https://github.com/doronz88/swift_reversing
https://github.com/doronz88/ida-scripts/blob/main/swift.py
Swift <=> OC的兼容层
小gadget(片段)
; void sub_101A34B60()
sub_101A34B60
MOV X0, X20 ; id
B _objc_release
; End of function sub_101A34B60
因为_objc_release的参数只要X0。修复为:
void __usercall sub_101A34B60(__int64 a1@<X20>)
根据swift官方文档,X20是self。所以这是内存引用计数-1。