ã¢ãã¤ã«ãã¡ã¼ã¹ã室ã§iOSã¢ããªã±ã¼ã·ã§ã³ã®éçºãè¡ã£ã¦ãã@yuseinishiyamaã§ãã
ã¯ãã¯ãããã§ã¯æ¥ã ã®æ¥åãå¹çããè¡ãããã®ãã¼ã«ãä½ããå ¬éããã¨ãããã¨ãç©æ¥µçã«è¡ããã¦ãã¾ãã 社å ã®ãªãã¸ããªãæ²ç¤ºæ¿ãæ¢ãã°ã便å©ãªãã¼ã«ãããããè¦ã¤ãããã¨ãã§ãããããªç°å¢ã§ãã
ããããæåã®ãé°ã§ãä½æ¥æéã®ç縮ãèªååã容æã¨ãªããçµæã¨ãã¦ãã¦ã¼ã¶ã¼ã®æ¹ã ã«ä¾¡å¤ãå±ãããã¨ããæ¬è³ªçãªä½æ¥ã«è²»ããæéãå¢ãããã¨ãã§ãã¾ãã
ç§ãå æ¥ãiOSã·ãã¥ã¬ã¼ã¿ãã«ã¹ã¿ãã¤ãºãã¦ä½æ¥å¹çãä¸ããæ©è½ãå®è£ ãã¦ã¿ãã®ã§ããã®æ¹æ³ãç´¹ä»ãããã¾ãã
åä½ç°å¢
以ä¸ã®ç°å¢ã§åä½ç¢ºèªæ¸ã¿ã§ããä»ã®å¤ãã®ç°å¢ã§ãåãã¨æããã¾ãããä¿è¨¼ã§ãã¾ããã
- OSX 10.9.4 + Xcode5
- OSX 10.9.4 + Xcode6
Loadable Bundleã«ã¤ãã¦
iOSã·ãã¥ã¬ã¼ã¿ãæ¡å¼µããããã«ãLoadable Bundle
ãä½æãã¾ããLoadable Bundle
ã¯é常ã®ã¢ããªã±ã¼ã·ã§ã³ã¨åãæ§é ãæã£ã¦ãã¾ããã¤ã¾ããå®è¡å¯è½ãªãã¡ã¤ã«ããªã½ã¼ã¹ãã¡ã¤ã«ãå«ããã£ã¬ã¯ããªã§ããããããé常ã®ã¢ããªã±ã¼ã·ã§ã³ã¨ã¯ç°ãªããmain
é¢æ°ãæã£ã¦ãã¾ãããLoadable Bundle
ã®ãã¼ãã¯ããããå©ç¨ããã¢ããªã±ã¼ã·ã§ã³å´ã®è²¬ä»»ã¨ãªã£ã¦ãã¾ãããã®Loadable Bundle
ã«ã¯ä»¥ä¸ã®ãããªç¨éãããã¾ãã
ã³ã³ãã¼ãã³ãã®é 延ãã¼ããè¡ãã使ç¨ããã¦ããªãã³ã¼ããã¡ã¢ãªä¸ã«å±éãããªãã®ã§ãã¡ã¢ãªã®ç¯ç´ã«ãªãã¾ãã
ä¸é¨ã®ã½ã¼ã¹ã³ã¼ããåå¥ã«ã³ã³ãã¤ã«å¯è½ãªã³ã¼ãã«åããã
ã¢ããªã±ã¼ã·ã§ã³ã«ãã©ã°ã¤ã³æ©è½ãè¨ããã
詳ããã¯ä¸è¨ã®ãªã³ã¯ãåç §ãã¦ãã ããã
EasySIMBLã®ã¤ã³ã¹ãã¼ã«
EasySIMBLãå©ç¨ããã°ãæ¢åã®ã¢ããªã±ã¼ã·ã§ã³ã®å®è¡æã«ãLoadable Bundle
ããã¼ããããã¨ãã§ãã¾ãã
èªåã®ã¯ã©ã¹ããã¼ããããã°ã+ (void)load
ãªã©ãã¨ã³ããªã¼ãã¤ã³ãã¨ãã¦ãæ¢åã®ã¢ããªã±ã¼ã·ã§ã³ãæ¡å¼µãããã¨ãã§ãã¾ãã
ã¤ã³ã¹ãã¼ã«æ¹æ³ã¯
https://github.com/norio-nomura/EasySIMBL
ã®How to install
ã®é
ãåèã«ãã¦ãã ããã
ãã³ãã«ãã¡ã¤ã«ã®ä½ææºå
- Xcodeã®ã¡ãã¥ã¼ãã
File->New->Project
ãé¸æããOSX
ã®ã«ãã´ãªã«ããFramework & Library
å ã®Bundle
ãé¸æãã¾ãã
- ä»»æã®æ
å ±ãå
¥åãã¦ãã ããã
Bundle Extension
ãå¤æ´ããå¿ è¦ã¯ããã¾ããã
- ããã¸ã§ã¯ããä½æãããããã¿ã¼ã²ããã®
Info.plist
ãç·¨éãã¾ãã
Info.plist
ã«SIMBLTargetApplications
ã¨ãããã¼ã追å ãã¾ãããããããæ¡å¼µãããã¢ããªã±ã¼ã·ã§ã³ã®ãã³ãã«IDãæ¡å¼µãå®è¡å¯è½ãªãã¼ã¸ã§ã³ã®æ大å¤ãæå°å¤ãè¨è¼ãã¾ãã
ãããç¹å®ã®ãã¼ã¸ã§ã³ã§ããæ¡å¼µããããªãã¨ããå ´åã¯ãé©å®ãã¼ã¸ã§ã³ã®å¤ãä¿®æ£ãã¦ãã ããã
äºåæºåã¯ä»¥ä¸ã§çµäºã§ãããã ãããã®ç¶æ ã®ãã³ãã«ãçµã¿è¾¼ãã§ãä½ãèµ·ãããªãã®ã§è©¦ãã«ãã°ãåºåã§ããããã«ãã¦ã¿ã¾ãããã
ãã°ãåºåãã
- èªåã®ã¯ã©ã¹ãä½æãããã¼ãæã«ãã°ãåºåããããã«å®è£ ãã¾ãã
EXSSimpleLog.h
#import <Foundation/Foundation.h> @interface EXSSimpleLog : NSObject @end
EXSSimpleLog.m
#import "EXSSimpleLog.h" @implementation EXSSimpleLog + (void)load { NSLog(@">>>>> Injection Succeed!"); } @end
- ãã«ãããSIMBLã®ãã©ã°ã¤ã³ãã£ã¬ã¯ããªã«é ç½®ãã¾ãã
ãã«ãããã¨ã
~/Library/Developer/Xcode/DerivedData/(ã¢ããªå+ããã·ã¥)/Build/Products/Debug
ã«ãã«ãããããã³ãã«ãã¡ã¤ã«ãæ ¼ç´ãããã®ã§ãããã
~/Library/Application Support/SIMBL/Plugins
å ã«ç§»åããã¾ãã
- iOSã·ãã¥ã¬ã¼ã¿ãèµ·åãããã°ã確èªãã¾ã(èµ·åä¸ã®å ´åã¯åèµ·åãã¦ãã ãã)ã
ããã§ãèªåã®ã¯ã©ã¹ããã¼ãããããã¨ã確èªã§ãã¾ãããããããããã ãã§ã¯ã¤ã¾ããªãã§ããã
ã注æãä¸å ·åãåºãå ´å
æ¡å¼µå
容ã«ä¸åããã£ããããã¨ãå½ç¶ã¢ããªã±ã¼ã·ã§ã³ãã¯ã©ãã·ã¥ãã¦ãã¾ãã¾ãããã®å ´åã¯ãEasySIMBLã®ã¢ããªã±ã¼ã·ã§ã³ãéãã¦ä½æããã¢ããªã±ã¼ã·ã§ã³åããããã¯ãUse SIMBL
ã®ã¨ããã«ãããã§ãã¯ããã¯ã¹ããªãã«ãã¦ãã ããã
ã¡ãã¥ã¼ã¸ã®ã¢ã¤ãã 追å
å
ã»ã©ä½æããã¯ã©ã¹ã®ãã¼ãæã«ã¡ãã¥ã¼ãã¼ã®ã¢ã¤ãã ã追å ããã³ã¼ããå®è¡ãã¾ãã
<Cocoa/Cocoa.h>
ãã¤ã³ãã¼ãããã®ãå¿ããªãããã«ãã¦ãã ããã
EXSSimpleLog.m
#import "EXSSimpleLog.h" #import <Cocoa/Cocoa.h> @implementation EXSSimpleLog + (void)load { static EXSSimpleLog *esl; esl = [[EXSSimpleLog alloc] init]; [esl installMenuItem]; } - (void)installMenuItem { NSMenu *appMenu = [[[[NSApplication sharedApplication] mainMenu] itemAtIndex:1] submenu]; NSMenuItem *appMenuItem = [[NSMenuItem alloc] init]; appMenuItem.title = @"My Own Extension"; appMenuItem.target = self; appMenuItem.action = @selector(action:); [appMenuItem setKeyEquivalentModifierMask: NSShiftKeyMask | NSCommandKeyMask]; appMenuItem.keyEquivalent = @"X"; [appMenu addItem:appMenuItem]; } - (IBAction)action:(id)sender { NSLog(@">>>>> Injection Succeed!"); } @end
ãã®ç¶æ ã§ãå度ãã«ããããã³ãã«ããã©ã°ã¤ã³ã®ãã£ã¬ã¯ããªã«è¿½å ããã·ãã¥ã¬ã¼ã¿ãåèµ·åãã¦ã¿ã¾ããããããã¨ãä¸è¨ã®ããã«ãªãã¾ãã
ã¡ãã¥ã¼ã追å ããã¦ãããã¨ã確èªã§ãã¾ãããã®ç¶æ ã§ãã¡ãã¥ã¼ãé¸æããããã·ã§ã¼ãã«ããã³ãã³ããå ¥åãããããã¨ãã°ãåºåãããã¯ãã§ãã
ãããªãæ¡å¼µãããã...
ãã¦ãããã¾ã§ã§ããã°ãæ¡å¼µããã¯ã©ã¹å ã§ã·ã§ã«ã³ãã³ããå®è¡ããããããªã©è²ã ãªæ´»ç¨æ¹æ³ãè¦ãã¦ãã¾ããããããããã ãã§ã¯ä¸ååã§ãã å ´åã«ãã£ã¦ã¯ãiOSã·ãã¥ã¬ã¼ã¿æ¢åã®ã³ã¼ããå¼ã³åºããããiOSã·ãã¥ã¬ã¼ã¿ã®ã³ã¼ããæ¸ãæãããããå¿ è¦ãã§ã¦ããããããã¾ããã 詳細ã¯å²æãã¾ãããObjective-Cã§ã¯å®è¡æã«æ¢åã®ã¡ã½ãããå¥ã®ãã®ã«ç½®ãæããããããã¨ã¯å®¹æã«å®ç¾ã§ãã¾ããããããã©ã®ã¡ã½ãããç½®ãæããã°è¯ãã®ã§ããããï¼ ç½®ãæãã対象ã®ã¡ã½ããã·ã°ããã£ãåãããªããã°ãã©ããããã¨ãã§ãã¾ãã...
class-dumpã®ã¤ã³ã¹ãã¼ã«
ããã§ããã¤ããªãã¡ã¤ã«ããiOSã·ãã¥ã¬ã¼ã¿ã®ã¯ã©ã¹æ
å ±ããã³ããã¦ã¿ã¾ããããclass-dumpã使ç¨ãã¾ãã
class-dump
ã¯Mach-Oå½¢å¼ã®ãã¤ããªãã¡ã¤ã«å
ã«æ ¼ç´ããã¦ããå®è¡ææ
å ±ãåºåããããã®ãã¼ã«ã§ããæ¨æºã§æä¾ããã¦ããotool
ã§ãåæ§ã®ãã¨ãå¯è½ã§ãããclass-dump
ã§ã¯Objective-Cã¹ã¿ã¤ã«ã®å®£è¨æ¹æ³ã«ç½®ãæãã¦åºåãã¦ããããããç°¡åã«èªããã¨ãã§ãã¾ãã
class-dump
ã®ã¤ã³ã¹ãã¼ã«æ¹æ³ã¯è²ã
ããã¾ãããä¸è¨ã®ãã®ãç°¡åã§ãã
- http://stevenygard.com/projects/class-dump/ ãããã¦ã³ãã¼ããã
homebrew
ã使ç¨ãã¦ããå ´åã¯brew install class-dump
ãã
ãã¦ã³ãã¼ãã§ããããä¸è¨ã®ã³ãã³ããå®è¡ãã¦ãã ããã
class-dump /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app/Contents/MacOS/iOS\ Simulator
大éã®å¤æ°åãã¡ã½ãããããã¿ã¤ããåºåãããã¯ãã§ãããããããæ¡å¼µã«å©ç¨ã§ããããªå¤æ°ãã¡ã½ãããæ¨æ¸¬ãããã¨ãã§ãã¾ããiOSã·ãã¥ã¬ã¼ã¿æ¢åã®æ©è½ã§ããããèªåã®æ¡å¼µããå¼ã³åºããããæåãå¤æ´ããããããã¨ãå¯è½ã«ãªãã¾ãã
çµããã«
ãããã§ããã§ããããï¼ã¢ã¤ãã¢ããããã°æ¯è¼çç°¡åã«æ¢åã®ã¢ããªã±ã¼ã·ã§ã³ãæ¡å¼µã§ãããã¨ããåããããã ãããã¨æãã¾ãããã®è¨äºãåèã«ãã¦ãçæ§ããèªèº«ã§ä¾¿å©ãªæ©è½ã追å ãã¦éçºå¹çãããã¦ãã£ã¦ããã ããã°å¹¸ãã§ãã