docs: refine
BIN
assets/ASLRDemo.png
Normal file
|
After Width: | Height: | Size: 47 KiB |
BIN
assets/ASLROffset.png
Normal file
|
After Width: | Height: | Size: 74 KiB |
BIN
assets/AppLaunchingTime.png
Normal file
|
After Width: | Height: | Size: 184 KiB |
BIN
assets/AutoreleasePoolMoreItem.png
Normal file
|
After Width: | Height: | Size: 119 KiB |
BIN
assets/Block-variableAddress.png
Normal file
|
After Width: | Height: | Size: 469 KiB |
BIN
assets/Facebook-OOM.jpeg
Normal file
|
After Width: | Height: | Size: 75 KiB |
BIN
assets/KVC-get-process.png
Normal file
|
After Width: | Height: | Size: 607 KiB |
BIN
assets/KVC-process.png
Normal file
|
After Width: | Height: | Size: 992 KiB |
BIN
assets/LLVM-Structure.png
Normal file
|
After Width: | Height: | Size: 479 KiB |
BIN
assets/LLVM-phase.png
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
assets/LLVM-segment.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
assets/Mach-OStructure.png
Normal file
|
After Width: | Height: | Size: 404 KiB |
BIN
assets/MachOFileType.png
Normal file
|
After Width: | Height: | Size: 350 KiB |
BIN
assets/MachOInsepect.png
Normal file
|
After Width: | Height: | Size: 2.9 MiB |
BIN
assets/MachOPageZero.png
Normal file
|
After Width: | Height: | Size: 326 KiB |
BIN
assets/MachOText.png
Normal file
|
After Width: | Height: | Size: 341 KiB |
143
assets/MockClassInfo.h
Normal file
@@ -0,0 +1,143 @@
|
||||
//
|
||||
// MockClassInfo.h
|
||||
// TestClass
|
||||
//
|
||||
// Created by MJ Lee on 2018/3/8.
|
||||
// Copyright © 2018年 MJ Lee. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#ifndef MockClassInfo_h
|
||||
#define MockClassInfo_h
|
||||
|
||||
# if __arm64__
|
||||
# define ISA_MASK 0x0000000ffffffff8ULL
|
||||
# elif __x86_64__
|
||||
# define ISA_MASK 0x00007ffffffffff8ULL
|
||||
# endif
|
||||
|
||||
#if __LP64__
|
||||
typedef uint32_t mask_t;
|
||||
#else
|
||||
typedef uint16_t mask_t;
|
||||
#endif
|
||||
typedef uintptr_t cache_key_t;
|
||||
|
||||
struct bucket_t {
|
||||
cache_key_t _key;
|
||||
IMP _imp;
|
||||
};
|
||||
|
||||
struct cache_t {
|
||||
bucket_t *_buckets;
|
||||
mask_t _mask;
|
||||
mask_t _occupied;
|
||||
};
|
||||
|
||||
struct entsize_list_tt {
|
||||
uint32_t entsizeAndFlags;
|
||||
uint32_t count;
|
||||
};
|
||||
|
||||
struct method_t {
|
||||
SEL name;
|
||||
const char *types;
|
||||
IMP imp;
|
||||
};
|
||||
|
||||
struct method_list_t : entsize_list_tt {
|
||||
method_t first;
|
||||
};
|
||||
|
||||
struct ivar_t {
|
||||
int32_t *offset;
|
||||
const char *name;
|
||||
const char *type;
|
||||
uint32_t alignment_raw;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
struct ivar_list_t : entsize_list_tt {
|
||||
ivar_t first;
|
||||
};
|
||||
|
||||
struct property_t {
|
||||
const char *name;
|
||||
const char *attributes;
|
||||
};
|
||||
|
||||
struct property_list_t : entsize_list_tt {
|
||||
property_t first;
|
||||
};
|
||||
|
||||
struct chained_property_list {
|
||||
chained_property_list *next;
|
||||
uint32_t count;
|
||||
property_t list[0];
|
||||
};
|
||||
|
||||
typedef uintptr_t protocol_ref_t;
|
||||
struct protocol_list_t {
|
||||
uintptr_t count;
|
||||
protocol_ref_t list[0];
|
||||
};
|
||||
|
||||
struct class_ro_t {
|
||||
uint32_t flags;
|
||||
uint32_t instanceStart;
|
||||
uint32_t instanceSize; // instance对象占用的内存空间
|
||||
#ifdef __LP64__
|
||||
uint32_t reserved;
|
||||
#endif
|
||||
const uint8_t * ivarLayout;
|
||||
const char * name; // 类名
|
||||
method_list_t * baseMethodList;
|
||||
protocol_list_t * baseProtocols;
|
||||
const ivar_list_t * ivars; // 成员变量列表
|
||||
const uint8_t * weakIvarLayout;
|
||||
property_list_t *baseProperties;
|
||||
};
|
||||
|
||||
struct class_rw_t {
|
||||
uint32_t flags;
|
||||
uint32_t version;
|
||||
const class_ro_t *ro;
|
||||
method_list_t * methods; // 方法列表
|
||||
property_list_t *properties; // 属性列表
|
||||
const protocol_list_t * protocols; // 协议列表
|
||||
Class firstSubclass;
|
||||
Class nextSiblingClass;
|
||||
char *demangledName;
|
||||
};
|
||||
|
||||
#define FAST_DATA_MASK 0x00007ffffffffff8UL
|
||||
struct class_data_bits_t {
|
||||
uintptr_t bits;
|
||||
public:
|
||||
class_rw_t* data() {
|
||||
return (class_rw_t *)(bits & FAST_DATA_MASK);
|
||||
}
|
||||
};
|
||||
|
||||
/* OC对象 */
|
||||
struct mock_objc_object {
|
||||
void *isa;
|
||||
};
|
||||
|
||||
/* 类对象 */
|
||||
struct mock_objc_class : mock_objc_object {
|
||||
Class superclass;
|
||||
cache_t cache;
|
||||
class_data_bits_t bits;
|
||||
public:
|
||||
class_rw_t* data() {
|
||||
return bits.data();
|
||||
}
|
||||
|
||||
mock_objc_class* metaClass() {
|
||||
return (mock_objc_class *)((long long)isa & ISA_MASK);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* MockClassInfo_h */
|
||||
BIN
assets/OSSpinLock-Assemble2.png
Normal file
|
After Width: | Height: | Size: 847 KiB |
BIN
assets/OSSpinLock-Assemble3.png
Normal file
|
After Width: | Height: | Size: 417 KiB |
BIN
assets/OSSpinLock-Assemble4.png
Normal file
|
After Width: | Height: | Size: 178 KiB |
BIN
assets/OSSpinLockAssemble1.png
Normal file
|
After Width: | Height: | Size: 611 KiB |
BIN
assets/RunLoop-RunIssue.png
Normal file
|
After Width: | Height: | Size: 286 KiB |
BIN
assets/RunLoop-SourceCode.png
Normal file
|
After Width: | Height: | Size: 312 KiB |
BIN
assets/RunLoop-Specific.png
Normal file
|
After Width: | Height: | Size: 795 KiB |
BIN
assets/Runtime-AssociatedProperty.png
Normal file
|
After Width: | Height: | Size: 205 KiB |
BIN
assets/TaggedPointerCrash.png
Normal file
|
After Width: | Height: | Size: 531 KiB |
BIN
assets/Thread-deadlock-unfaillock.png
Normal file
|
After Width: | Height: | Size: 908 KiB |
BIN
assets/Thread-deadlock-unfairTrylock.png
Normal file
|
After Width: | Height: | Size: 618 KiB |
35
assets/__forwarding__clean.c
Normal file
@@ -0,0 +1,35 @@
|
||||
int __forwarding__(void *frameStackPointer, int isStret) {
|
||||
id receiver = *(id *)frameStackPointer;
|
||||
SEL sel = *(SEL *)(frameStackPointer + 8);
|
||||
const char *selName = sel_getName(sel);
|
||||
Class receiverClass = object_getClass(receiver);
|
||||
|
||||
// 调用 forwardingTargetForSelector:
|
||||
if (class_respondsToSelector(receiverClass, @selector(forwardingTargetForSelector:))) {
|
||||
id forwardingTarget = [receiver forwardingTargetForSelector:sel];
|
||||
if (forwardingTarget && forwardingTarget != receiver) {
|
||||
return objc_msgSend(forwardingTarget, sel, ...);
|
||||
}
|
||||
}
|
||||
|
||||
// 调用 methodSignatureForSelector 获取方法签名后再调用 forwardInvocation
|
||||
if (class_respondsToSelector(receiverClass, @selector(methodSignatureForSelector:))) {
|
||||
NSMethodSignature *methodSignature = [receiver methodSignatureForSelector:sel];
|
||||
if (methodSignature && class_respondsToSelector(receiverClass, @selector(forwardInvocation:))) {
|
||||
NSInvocation *invocation = [NSInvocation _invocationWithMethodSignature:methodSignature frame:frameStackPointer];
|
||||
|
||||
[receiver forwardInvocation:invocation];
|
||||
|
||||
void *returnValue = NULL;
|
||||
[invocation getReturnValue:&value];
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (class_respondsToSelector(receiverClass,@selector(doesNotRecognizeSelector:))) {
|
||||
[receiver doesNotRecognizeSelector:sel];
|
||||
}
|
||||
|
||||
// The point of no return.
|
||||
kill(getpid(), 9);
|
||||
}
|
||||
BIN
assets/autoreleasepool.png
Normal file
|
After Width: | Height: | Size: 145 KiB |
BIN
assets/block-forwarding.png
Normal file
|
After Width: | Height: | Size: 127 KiB |
BIN
assets/block-memorylayout.png
Normal file
|
After Width: | Height: | Size: 250 KiB |
BIN
assets/block-object-memoery.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
assets/block-structure.png
Normal file
|
After Width: | Height: | Size: 295 KiB |
BIN
assets/block_forwarding.png
Normal file
|
After Width: | Height: | Size: 3.4 MiB |
BIN
assets/block_object_cycle.png
Normal file
|
After Width: | Height: | Size: 286 KiB |
BIN
assets/clang-analysize.png
Normal file
|
After Width: | Height: | Size: 3.6 MiB |
BIN
assets/clang-ast.png
Normal file
|
After Width: | Height: | Size: 2.0 MiB |
BIN
assets/clang-phase.png
Normal file
|
After Width: | Height: | Size: 514 KiB |
BIN
assets/class-isa-superclass.png
Normal file
|
After Width: | Height: | Size: 338 KiB |
BIN
assets/iOS-MemoryLayout.png
Normal file
|
After Width: | Height: | Size: 53 KiB |
BIN
assets/ignoreXcodewarning.png
Normal file
|
After Width: | Height: | Size: 494 KiB |
BIN
assets/objc-isa-mask.png
Normal file
|
After Width: | Height: | Size: 129 KiB |
BIN
assets/objc-isa.png
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
assets/objc-metaclass-superclass.png
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
assets/objc-superclass.png
Normal file
|
After Width: | Height: | Size: 117 KiB |
BIN
assets/osunfairlock-assemble1.png
Normal file
|
After Width: | Height: | Size: 829 KiB |
BIN
assets/osunfairlock-assemble2.png
Normal file
|
After Width: | Height: | Size: 388 KiB |
BIN
assets/osunfairlock-assemble3.png
Normal file
|
After Width: | Height: | Size: 497 KiB |
BIN
assets/osunfairlock-assemble4.png
Normal file
|
After Width: | Height: | Size: 1.0 MiB |
BIN
assets/osunfairlock-assemble5.png
Normal file
|
After Width: | Height: | Size: 389 KiB |
BIN
assets/otoolhelp.png
Normal file
|
After Width: | Height: | Size: 4.9 MiB |
BIN
assets/runtime-categoryattachLists.png
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
assets/runtime-changeisa-demo.png
Normal file
|
After Width: | Height: | Size: 278 KiB |
BIN
assets/runtime-class-ro-t.png
Normal file
|
After Width: | Height: | Size: 121 KiB |
BIN
assets/runtime-class-rw-t.png
Normal file
|
After Width: | Height: | Size: 120 KiB |
BIN
assets/runtime-class.png
Normal file
|
After Width: | Height: | Size: 405 KiB |
BIN
assets/runtime-dynamicCreateClass-demo.png
Normal file
|
After Width: | Height: | Size: 334 KiB |
BIN
assets/runtime-forwarding.png
Normal file
|
After Width: | Height: | Size: 154 KiB |
BIN
assets/runtime-forwardingFailed.png
Normal file
|
After Width: | Height: | Size: 509 KiB |
BIN
assets/runtime-isa-demo.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
assets/runtime-method-encoding.png
Normal file
|
After Width: | Height: | Size: 183 KiB |
BIN
assets/runtime-method-find.png
Normal file
|
After Width: | Height: | Size: 252 KiB |
BIN
assets/runtime-objc_msgSend-ResolveMethod.png
Normal file
|
After Width: | Height: | Size: 77 KiB |
BIN
assets/runtime-objc_msgSend-messageSend.png
Normal file
|
After Width: | Height: | Size: 273 KiB |
BIN
assets/runtime-super-isa-demo.png
Normal file
|
After Width: | Height: | Size: 168 KiB |
BIN
assets/runtime-super.png
Normal file
|
After Width: | Height: | Size: 450 KiB |
BIN
assets/synchronized-asemble.png
Normal file
|
After Width: | Height: | Size: 577 KiB |