이상한 개인api 호출 오류

3202 단어
낡은 노트를 정리하면 다음과 같다. CALayer 사유apidoubleBounds가 있는데 이 사유api가 되돌아오는 데이터를 방문하려면 다음 코드를 사용한다.
id valuedoubleBounds = [view.layer performSelector:NSSelectorFromString(@"doubleBounds")];

결과 붕괴 발견, 알림-[CALayer doubleBounds]: unrecognized selector sent to instance 링크에 따라: CALayer.h3 알 수 있다doubleBounds는 아래에 정의된 구조체 데이터를 되돌려주고 역사 기록을 보면 iOS7에서 iOS10까지 이 방법이 계속 존재한다는 것을 알 수 있다CALayer
(struct CADoubleRect { 
  struct CADoublePoint { 
  double x_1_1_1; double x_1_1_2; 
  } x1; 
  struct CADoubleSize { double x_2_1_1; double x_2_1_2;
   } x2; 
})doubleBounds;

저는 비탈옥 환경에서 이 개인api를 호출했습니다. 현재 iOS 10. 테스트를 하고 있습니다.3.3과 iOS7 탈옥 장치가 이api를 호출하면 붕괴됩니다. 이 개인api를 호출하는 것은 필요하지 않지만 왜 이 개인api를 호출하면 오류가 발생하는지 알고 싶습니다.
같은 환경에서 UIView의 사유apirecursiveDescription를 호출하면 전혀 문제가 없다
역방향 게시판에 질문을 했는데 답이 쏟아졌어요. MapKit에 있을 줄은 꿈에도 몰랐어요. 제가 역방향 UIScrollView에 있는 어떤 방법에서 이 방법을 봤기 때문이에요. "image list"명령은 정말 좋은 거예요. 아까 제가 오래된 프로젝트에서 호출id valuedoubleBounds = [self.view.layer performSelector:NSSelectorFromString(@"doubleBounds")];한 건에 문제가 있다는 걸 알았는데 CALayer 대상으로 돌아왔어요. 이것도 믿을 수가 없어요.마지막으로 다음 코드를 통해 실제 값을 얻을 수 있습니다.
SEL selector = NSSelectorFromString(@"doubleBounds");
IMP imp = [self.view.layer methodForSelector:selector];
CGRect (*func)(id, SEL) = (void*)imp;
CGRect doubleBounds = func(self.view.layer, selector);
NSLog(@"doubleBounds is %@", NSStringFromCGRect(doubleBounds));

오래된 프로젝트의 코드를 검색해 보니 과연 한 곳에 #import "MapKit/MapKit.h"라고 쓰여 있었다. 그러나SDWebImage에서 프로젝트 설정에 MapKit.가 추가된 것을 보지 못했다.프레임워크, 새로 만든 프로젝트는 이 프레임워크를 추가해야 붕괴되지 않습니다. 전자는 어느 제3자 프레임워크가 자체로MapKit를 추가한 것으로 추정됩니다.framework
하지만 dladdr로 위치를 정하는 대신의 힌트도 있습니다. 대신은 대신입니다. 키워드가 있으면 됩니다. 새로운 스킬Get:
#import 
#include 
#include 

    Dl_info info;
    if (dladdr(imp, &info)) {
        printf("dli_fname: %s
", info.dli_fname); printf("dli_sname: %s
", info.dli_sname); printf("dli_fbase: %p
", info.dli_fbase); printf("dli_saddr: %p
", info.dli_saddr); } else { printf("error: can't find that symbol.
"); }

결과:
dli_fname: /System/Library/Frameworks/MapKit.framework/MapKit
dli_sname: 
dli_fbase: 0x194256000
dli_saddr: 0x1943c7c0c

만약 self.view.layer를 사용한 후에 단점을 더하면console에서 두드리기:po [CALayer _shortMethodDescription]인쇄된 함수 목록에 표시doubleBounds가 있습니다. 모든 종류 방법, 속성, 실례 방법을 인쇄합니다.
- (void) setDoublePosition:(struct CGPoint)arg1; (0x1943c7c00)
        - (struct CGRect) doubleBounds; (0x1943c7c0c)

다음과 같은 조회를 사용할 수도 있습니다.
(IMP) imp = 0x00000001943c7c0c (MapKit`-[CALayer(MKDoubleLayer) doubleBounds])
(lldb) image lookup -a 0x00000001943c7c0c
      Address: MapKit[0x000000018de53c0c] (MapKit.__TEXT.__text + 1505440)
      Summary: MapKit`-[CALayer(MKDoubleLayer) doubleBounds]

좋은 웹페이지 즐겨찾기