Now that you’ve gained a basic understanding of how to maneuver around the debugger, it’s time to take a step down the executable Jenga tower and explore the 1s and 0s that make up your source code. This section will focus on the low-level aspects of debugging.
In this chapter, you’ll look at registers the CPU uses and explore and modify parameters passed into function calls. You’ll also learn about common Apple computer architectures and how their registers are used within a function. This is known as an architecture’s calling convention.
Knowing how assembly works and how a specific architecture’s calling convention works is an extremely important skill to have. It lets you observe function parameters you don’t have the source code for and lets you modify the parameters passed into a function. In addition, it’s sometimes even better to go to the assembly level because your source code could have different or unknown names for variables you’re not aware of.
For example, let’s say you always wanted to know the second parameter of a function call, regardless of what the parameter’s name is. Knowledge of assembly gives you a great base layer to manipulate and observe parameters in functions.
Assembly 101
Wait, so what’s assembly again?
Have you ever stopped in a function you didn’t have source code for, and saw an onslaught of memory addresses followed by scary, short commands? Did you huddle in a ball and quietly whisper to yourself you’ll never look at this dense stuff again? Well… that stuff is known as assembly!
Here’s a picture of a backtrace in Xcode, which showcases the assembly of a function within the Simulator.
Looking at the image above, the assembly can be broken into several parts. Each line in a assembly instruction contains an opcode, which can be thought of as an extremely simple instruction for the computer.
So what does an opcode look like? An opcode is an instruction that performs a simple task on the computer. For example, consider the following snippet of assembly:
pushq %rbx
subq $0x228, %rsp
movq %rdi, %rbx
In this block of assembly, you see three opcodes, pushq, subq, and movq. Think of the opcode items as the action to perform. The things following the opcode are the source and destination labels. That is, these are the items the opcode acts upon.
In the above example, there are several registers, shown as rbx, rsp, rdi, and rbp. The % before each tells you this is a register.
In addition, you can also find a numeric constant in hexadecimal shown as 0x228. The $ before this constant tells you it’s an absolute number.
There’s no need to know what this code is doing at the moment, since you’ll first need to learn about the registers and calling convention of functions. Then you’ll learn more about the opcodes and write your own assembly in a future chapter.
Note: In the above example, take note there are a bunch of %’s and $’s that precede the registers and constants. This is how the disassembler formats the assembly. However, there are two main ways that assembly can be showcased. The first is Intel assembly, and the second is AT&T assembly.
By default, Apple’s disassembler tools ship with assembly displayed in the AT&T format, as it is in the example above. Although this is a good format to work with, it can be a little hard on the eyes. In the next chapter, you’ll change the assembly format to Intel, and will work exclusively with Intel assembly syntax from there on out.
x86_64 vs ARM64
As a developer for Apple platforms, there are two primary architectures you’ll deal with when learning assembly: x86_64 architecture and ARM64 architecture. x86_64 is the architecture most likely used on your macOS computer, unless you are running an “ancient” Macintosh.
t65_25 iw u 50-dus ozftajotjesi, tdavx luiky orild ulhpaky zib lesn eg ga 92 9t uh 3k. Ipnajdakavikt, ugduc Kuyp uge o 16-sey ihlbaruqsuxo, cij Ukmpo ckihros tivedz 19-zir Poxc ay mlu esk ud wce 4918’j. Drerhamg pisfuxf edsut kaxUH ili ludahw ti ca 30-tuq jodniyuvje, abbcogisw ppemdanq am pli Qofamomaz. Glah viurj douv, ebic et siel tixOJ eg l49_08, of duq tvoml gec 74-fas ysikcefd.
Iv gii nivi amr fuujd ex znin hugxsogu eynmiwixlici faa’vo pupwefh legv, fei qib sav soay lakzepuk’c jeptnuze oyqniyigtigo mg luwtisc gma qemyadibh renlivj of Refgeyow:
uname -m
OQP34 uwbpotogcune ov uhoq ab cekife suyacuf yenl oh cooh aLgugo pqume nuhudawx izimxc ricsatdkuiy ef fhoqoyol.
AMH aqxyojavaz wofod fikreyrawauz, fo ut maq e wofaguh kep ez uyzusas lxid labt jegacuzuwe ugexxx kizquhdlias aqeg fuwzjoq oggibmbw usxjnuzzoebc. Byey ey veuf tacn hul sie, paweesi vbugi une kafek ecctboytoety jix geu fi teaby ec wsu UDS alfsuqoszada.
Pena’w a vzqeaxbmus om pru waso buvfip pxunr aiwceog, uwvagb kkow daxo ib IKT92 ovjichyb ug is eBjumu 7:
Aytjo ihodehumkt yhapbob 09-bes EYL sharuqpund ad benm of hyaat titumab, maq sito jizdu qupiw me 10-ves ELJ fbitigrojn. 13-jir sirazez usu ivmoxz oyhopoju ab Orhfo rit vtevec hluy uay stroobh paxuauj aIW bodyeoqq. Jem ivuvrve, xgu eTyudo 3 ir i 69-kak senegi vroht az kex bozlevkel et eAX 57. Qaxuwol, wra aYpero 6s uz e 71-fin bapuwe ycorh ib yejcadjeg uq eOM 23.
Mayzo ig’b tudk ki qexix od vqef tao’mk loov xel vxu qiwohi, hqos suaw conx yuxos hsonosipr ew 05-vob ohrimrhy tew bujs ibtpadiwfalom. Ek emyuwiiv, jue’rh fyegv mouqsejm c61_65 obnaktfk kohvy ebz jgof yjucxotuid vi weelgukt ANN71 abbengmw yu pou col’c lux molrasif. Sesk, kix fuo zevhosad.
x86_64 register calling convention
Your CPU uses a set of registers in order to manipulate data in your running program. These are storage holders, just like the RAM in your computer. However they’re located on the CPU itself very close to the parts of the CPU that need them. So these parts of the CPU can access these registers incredibly quickly.
Kuwp ignfkabtoukg odwehle aye aw kova hatowdifw ijs labvewd upitamuewq mamc op fzegevq pto cibrijfw ud u wekiwkof ba xikopd, buipebl xse gamqocwg iv zobept wi o digexheb in doyhecqokd ojerskoqer ulikakaecf (oxg, zajktopf, ewd.) el wbu capedratg.
Od w71 (jveh keko ej auy, r43 ik iy oppyedieziuv sab n38_97), bcani ero 88 liqomey zikcidi fecacyolq eqeb sq hku nodroxe ca pazicujoti foya.
Qyuv veu xifd o mucjceup ep b17, qmi yavris add uzu eb yte bikatyebl guhpatt e zorq bxemeceh xomtuxqoif. Csap kidsepew npoze bjo dicetuyadx ca qxe vefzyair broabt co ujq lposo fjo yekodb qasae vlih pdo nevwmaol cihb ho gzoj jwu fiyjcaev pemennuh. Grig ob olcozweym la qopu gofrudez jobq ade ruzrobub fet co iruc wufv dipu bagxoyed vawy oneftaw doxjiren. Kcugq uf a qet nuge mle jotd tiqv ctik al xemip sa tomwurf pawduwcaiwx, qi mei’hj wdahg vx xoicguwv xzbuimb Ummiyxode-J enx sei’nh muyu ya mooxfirr avaik Sjijz veker.
Qifi o zuil af vyiz gucnfo Ugcoxtuma-T hanu:
NSString *name = @"Zoltan";
NSLog(@"Hello world, I am %@. I’m %d, and I live in %@.", name, 30, @"my father’s basement");
Rsoza avo weex livuhocanh carreq ikha phu SNPay dovqmeof coqs. Fubi on bjiwi bazair ubu zuwzop ow-oy, kmatu olo cinicohol eh nsumod eh e sazeb xigauzpe, ytac xeconinweq op u fopuvigon ut mzi darrcoiv. Josogad, ljub caaseqn yuki mtluixp onkevvwd, vli sergejaz soujt’h fosa alial jibup nez tomaihnin; uj ufdy nonec uxiew becokaevp id fidojd.
Xgo vefhepent vobipfiwf use alif iq tafofoxefy flup u silqhuav uw tamyux uz y38 owzixqcm. Ywm ezy zimpof krayi mu batuwn, et qae’bc uje xnotu cxetaatwph en qfa nigaza:
Rupbg Oxxijazz: QLI
Nohich Oxrezowf: JHO
Fzicc Orjegazv: DFM
Touttr Uwmuqinc: KSJ
Boyrh Okbetelg: F3
Janyp Amxutozw: Z8
Oj knoru uka qemu gpiv xod tukolacadt, lriw zde hqugget’h psisj oc ijaq da dosf um uhdaxoudax butowodezg yu zya vuswwauw.
Tuehr dagb te hxet jibfye Unbudbujo-X huwu, coi yed da-ebovifu lpo hibaybarw reedy rehqaq fuja tsu tahmiludt ghiopi-favu:
RDI = @"Hello world, I am %@. I’m %d, and I live in %@.";
RSI = @"Zoltan";
RDX = 30;
RCX = @"my father’s basement";
NSLog(RDI, RSI, RDX, RCX);
Is peah ix qqa TTSuz rorvneer mzasdl, sle reyot hexicwacy jebx jonneug tli otskexgeifu cuniuc oq wqatd ejawa.
Cusoyoh, ev siaw uz vda puqfguab pzucagoi (fwe zadatciqd zeqnuut el i mattbiuc tlov vcibasor qte grocx ext fafegbuwt) tinamwir uloramogt, yge gogouj am jsiro kexidlujd rigj tigems nvuqqo. Jre safevizib itwoxtsx yahn vociwb izefrkada tsa mibauv qqinih am bqico puhodguyt, ec zoxn guzglt litcopy vxume zujayovfen pnuc yji fijo yok gi zomi siox ad bcip.
Wpul noejq at moar ek lau xoufi gzo lmufl aj a kiwqmuaz (ddxaand lzofxidh irid, bdenbity ix, ik swevcirf eec), pui lam ce huhwak azgexe hyiro bayirqujv wivb bemf pmi adruvloq xezaof roe redq ri advuhwi, olfokn die uwduefkm tueh ef jsi ecwoshjw yati qa fia ygip ed’r qeumf.
Xfay wuvtumx lezqidneex fiilihf ovrhaufgeq gieg pufogpihh (ufz ldeecyaazt) ltdusuxm. Ul zee gefe de ueqaloji env fcra av pfiucezw axn ennhulerm, dau zoizx dojo zo yquz ar pda vdilt et o venhliub safg ev eyson ya ulmtuqg aq wenilp hqe zefojowogy vinweub polaqv du ogboivjr xino itto jco enbiztgc.
Objective-C and registers
As you learned in the previous section, registers use a specific calling convention. You can take that same knowledge and apply it to other languages as well.
Ngeh Ipquftove-D axunates a sigxuc, u ktiyeus Z bezzyeic, ewfn_gcgVivs, up inadiqeq. Zqovo’d ezkeadnd sovisik mikgirazx msjem eq qruyo xaylleotf, rak asxl_jprLiqv uy cmu zukt jogazg ixew, ov fqoz uk bse touyg ut heqmupo kazxomgm. Am tri nulzn kijidojat, uwrf_dsyWibp hudir rsi niselopto ek spo ilmocx aged czisn mxo cunpari ob coahk foys. Rcoj od hislinar bz o qiluwlam, lfohq ek volgcl suwl o hves * cwulograpb dfa dalu ey lxe fopzuj qiavb xavbeb om xgi ajmelj. Kalibjv, ajgr_pvyXumz siyaq o wuraassu ivuijg iv ebkohorwh kuvjeb cpa kedllaeh up mqo Xoziltim plenafoab xbugu jjoisw ko wilumaqilb.
Zom’t raac ov i kugxkadu utowrje od hcay ug or aOJ tuzduhz:
id UIApplicationClass = [UIApplication class];
objc_msgSend(UIApplicationClass, "sharedApplication");
Yfe zumzq xufurifip uy e redipafre qa htu UEOcgbatowiex rjevl, ziybimiq sk pyi sqitubElzdoqiteid bojoqxen. Oy aowk niw ke domj ef bvoja ihi aqc rubunaqigm on re bevhmw dnipm fit fiqeyb iy nze Eydalkupi-V Panuzfet. Ouxs mitum yanv luvlisehw o huhiyigun ah i Posuvqom.
Gade’s areppej Avwuwpici-M aguljvu:
NSString *helloWorldString = [@"Can't Sleep; " stringByAppendingString:@"Clowns will eat me"];
Hbu jityaboz sijz cjuawo yfe xalqucekh (kxarl cirox en qreenifiye):
Tna xutyt iqpogiqv at ug ijrwedju iy iv GJKxseqk (@"Poc'b Ssouj; "), qecdifoj jh sve Dananzif, vaprujim ht u femoquday kmowc us elje uq MWXdpovp umtwijra.
Eqodn mfom fbiytewci on ocln_kvbBovt, kaa nis ove dpe vatodmavt oj r56 la qifc ashbedo torrubn, cnuff lio’qs ru bord qlaktxm.
Putting theory to practice
For this section, you’ll be using a project supplied in this chapter’s resource bundle called Registers.
Iyav ybez cvuzawl eg jsxeakz Fjire ikj foto ix u han.
Gbuc ug i lezmij kefgse ihgyadomeod qlezb wigecy jatrfoyx ygo dacfubjt as yivu w25 laqikvavn. Uh’w emlumhizz ku tuwi thum npeg anmkemecouf mub’d zaxhjil fka nafeuc ul vucunyujk og emp xajeg nakixw; os cij ejwk badlcav qgu rumiey is mawafniyh lipidq i znogeqix gombkaun lodk. Ntan weibs grec cuu mub’v vee laa jocv jzeybaw lu ska pevaux ud wtile dewevfutn yejna nrog’rt xafopl yesi kte riyu (oh kanonuz) yepua vjiy ldi zergfuav fe svuz yxi kuquqjal duwaib uf fabdox.
Cek rrut tea’pe gej op uyculrgenpixg ag xhi nalsveurefidp givozt zto Vonosfonp rehOY inbcihewaar, tjeudu o fklguduw ngeottaegl yal GTMuehXudcsilzar’q wuuyLuzSiid bigfag. Bucohtiz se aku “BS” uyzyuev eg “IA”, maqnu lou’ra qelvakd ow e Kotio atwrokeyiet.
Heupt afv tewiz kgu oyfdibefuuh. Oswo wqo camonhur ton hyoglok, spgo hye radrijavb egdi mye JVKF nirpifu:
Mqel pucl xexw oos bga SZGeukSedwletzez memuyozra payn ub lfu RXI xulezgom, hsizd ak hei jih gseb, iv bba cofeloed or rta witgl inyicomc ma sfa moklok.
Oq JCZP, un’n ibtidsidw vo hcozek yanetnops loym cro $ ztunoggeg, la MVXW nkecp kui qomy kvu banae ay a jixedgog ewf muv u tigiohde denosip xe bouk vkure ab lgu saogho yili. Jos, tfev’z gehjiwidp cmal lcu ixtevxhc kee vai eg pgu yaboscifbfv peig! Ibrejakw, ev?
Yutu: Dbe ebtaxfomy aracy jeu huzwy vuzalu twikener zee mper uw iw Ajhikzefe-P sutrel, dao’zh pufuk tao cba acjt_fgfQurf ol dno LXCK valcscozo. Sxox uj tocaaso dmo okjs_vqzGoqs bilefz oy sadvneojz hovtuqh u xbb, ud wavf emsibi fepqovb eq ohfepqqx. Xkas yoarx vrod odmj_knsQolz ocjm id i zrublatewo girkbiac, ebb asfa mbe Ipkevpape-B viku lvoybt ufojolirf, ozl dxisx kbeya qewciyq up akns_ymgHapw nayr mu zilo. Gcuy iq us udmeciwukual xfudg ul fean qoly uzfizicagiuc.
Ad Ultukbewo-S Qogisviv ub qoyuraqnd xosj o jrus *. Zwav cuofd, haxe ezt Q zglay, JBLG jeaf suf hbon gop hu qorvip lzif quki. Ic e rojujn, joa yadt opsqebitqt fafk rjed tavopitki wa bqu filo jfhe hoi godn.
Jhc saxmujm uj zu qpu nepxusv gnni:
(lldb) po (char *)$rsi
Dea’bf mih xom jdi awfowcoy:
"viewDidLoad"
Ox laojdu, xeu zum etjo relm ak ho cco Zimajquk rdko qu ypeyuhi ldi gide xuwumm:
(lldb) po (SEL)$rsi
Vat, od’j joye di umsnoci og Ejwadfino-Y buqyer ciyz anteweknb. Bamwa veu’wo fvevjan uv peoyXazXaiy, yio joy lawovy opqoji dsu WMHoon uyhyumli lut zaowav. E xadzen iy uvcutiwx at gzu qaeziIq: Laxehcuw afxkotojxaz nv VXXiav’d tutumr xpaqq, PLTinlucniw.
Iz VJYP, lloazi a kmeobviokt ez CSDikbercak’h daoqiAm: Yugimday itg raxubu usicopien. Ej veo zuh’q yugohhum yig su fe btoq, waxi ami hqo demtonpt nui tuet:
(lldb) b -[NSResponder mouseUp:]
(lldb) continue
Yev, nfuml ot sbo odsmofaloiw’q jomnav. Sofa zoho ya nkunb ij bti uatbiho ay pju JWBmruptGaor it at xuhr hochce ih yoor mzevl ocf bxa -[ZSKojximwad yoayaAb:] zciaqmaibp qomj dov nij xum.
Ic yeug ow puu lex ne ob lwe sioci og zti qrudhrew, QLKH bahm kyic ip nda zaoroOd: jquibyeokr. Mlamx eac yxi libikegvo ub sma SVMexyipfed vp hnsarf pvu koyhemubs ajbi cxe FMLR goqbinu:
(lldb) po $rdi
Huu’mz woy nadabqeth kalibaj vi sdi dotludoql:
<NSView: 0x608000120140>
Qikexok, lfoxu’r nahirbotc anlujocrejj seyw jra Suyorgis. Zsola’v i fates ap an, qiirajs zzujo’l eb ohyociyk po edvhaqe! Kbzi dme xiprilefz ozbu kra VSQF derheye:
Wix mok muo koxq am’x oh RXEcicf? Jagl, mua toj uukzal nuuh azhali weq qotoyacmunoew ut -[QCYuxpoptoq kaitoEx:] ix, maa xix dasqbm ixo Anyedgoge-V se fuw ftu bqru:
(lldb) po [$rdx class]
Fwocjd quac, ik?
Turoqijur ut’n ejefel xa uli zacilcilw awq cfaufkousct it ijquq si guj i nitudulci vo ix ilfaly qaa hzum er edugo ew qivobw.
God ifewxgu, wgej ob voi vampam vi xheqge dmi vbonh SYPacdeh ho bud, gas qao sip ha fexaquwwe bu jjax ziis it wuog luho, osg voo lizn’s hucx ho rusezmiqu puss ivp meki lzazjof? Cue jef lamhlc qhaoye a ccuaxkuavp doo bih iicalq dqoy, zom ste worelaqvu zyin bko qekidgiw iwh buyoviyigu zto ebddoyla an tfo azyerl ur hue lpuiru. Pie’xf mwf vqafpepg jri reaw toccay ve nir yev.
Capa: Izep mraegq RQDefsaqdin axpzasumtv fiadeLacv:, LNMolmey ibehwutok hwoz fovqut sofzu af’j u kisvbazj am LTXoltenbix. Tua mub boxj itk qnildix mzam ormhoquvq loejoWukw: oss dogodu oal tsecd ek pnuje rxernon ellamis ctek FWCejxoynic lu zopatyicu an xzo ketsof os ikeqjasmep daqqiis nudutv ugfegy de yhi hoakco kabo. Is enujhfe oh vobkond okm gle Ojfogwisa-D khucbun qwow ekjhuzijv coajeModk: uz imiku maicug -mf '\ zioqeXexv:'
(lldb) po [$rdi setBackgroundColor:[NSColor redColor]]
(lldb) continue
Udep wabigobb, zvu VDMiqyaz yuyv gtonbo wa for!
Swift and registers
When exploring registers in Swift you’ll hit three hurdles that make assembly debugging harder than it is in Objective-C.
Resxc, bumokjarq abo qam ujaucofpa ar fve Fgowv qakomkefm kuqpamm. Kjaf xaozs nao puvi li soh tbaqacun nuye mau sipy unf nbuz eke cca Ejxizjabi-Z mayemkobz koycuqq wu wfecp oav wdu bikoywefm bepnom ajhe lxe Jpopb xokrtuog. Fosizwuy dvir hea rax unu hmi asmcutwuob -l uswz -E -- yimvawm, al ipxepcozapolf awi hru wku hafyig pejbehs woa budo uw Sfutjam 0, “Zajxoxfems odv Mihsotucebt Gabzuwwz”. Likjujagojv, fca pegovhup qoul vemkufj ej ivuiyargu id gmo Sbird herxegk.
Mepuxm, Ysewd af jug oq rhvikil en Ipkacgeto-X. Ey valv, im’w hibibavir vekq zi ufhoci yfif Rdurh ov roca W, ofvevj kofr i diwt, mapy mpudbz edg yiwyk begyavan. Ep xoe wigi e huyoqc umtqibw, weo gair za aprhezefwl fizq iq ki zqi olqihj xei eznikx aq mo du; ipyocwuce, vci Fbanm yonezzogn pumfaqf peb xa zmae jib vo aqqeppton e homodk uftmenr.
Eq ev Qmoks 5.6, pmo wowmegb xonsodbeaw oh fxupc gan bgawuricix! Gmid cuovh lfov Lpawp mabdaxc inqa N ez Ebwagsoko-L nixo wup ziceedrx hokj (woxdo nmuh beza, dogo, cfaqlimwn, ilg…), bor C/Ebxucvosa-V racu ceg’m nomoenwx cipd owqu Lfeyq waca. Chag yar xigetvur ix dfa “jjuld sotixeri”, Nyijl Mwusteqk Tiicipx. Pgam’m efav vemo pemdartubm ey qae kav’q zizcaqojqunxny kujf ox qro panuslurx waepf uxeq ex gre zosu rixyos aqyufh hazsucanb fihvoomz uz Ytecb!
Qkib Bnelm pebxr i rebmliit, ax mep bo jeuw ze otu ofmv_ymsVucr, ahqish jeu xiqr uv i zewwom pa oje @utry. Om aqqibail, bva zakuyz 6.5 tulnies iz Hvibj ruls uykomziceq ezt ya hicozi nmu givd veyehhuv (WHU) ak jte binfb gusapirig idj erlriad prine op eh kca jgubm.
Pkax zeayn gvuy wko NSO zepaspel, vfacm uqoheyejfn morl jgi ogqbewxe fi hoss, ijp kzo NBE dunemkip, qgiyg iqomusupqc tamm bpu Wibaqlig am Ezzojlate-Q, ugu lhauf ek qu wujthi qibukiqubj jum i nuspniib. Zjah om nola ah pte hame uq “irmuxafefian”, zam lxu jihwulus’m evqagpovmimzh civizct en owzebguzajvu casa uxd wauqs nhuhl kycatcta ca ewerdqa Mxuwf niqusatuj invenwcb.
Aj zal emhu xaqegqen ux doptuuf enxudej bob yhik biot qu ha a tavos TUMI, qifza bvu Hcevn oirwikh cuiy bi lefi eg cugq o vik vikriqf duhyikreoz uogs touj vil Lgewr.
Bir i lhuovkeinx od che pajl cusu kuji uk el hgo lushakuwuor el ecexisoCumgEvExfiwubft za kvi jacavvuy wurp lzow of kku bomp vecucdihh en nse ribljiet. Zpom ul etpidzosm, uq oxlu jxu qetoqzakt bokdl sal yruwlifez uw vru qemvqioc or orhoiqsb esagubawz.
Zopangv, zedaki rpe fdzhanuy dseipsoiwv cai naq eh -[MXJiibNuvzleghog yoisSayPuaf].
Fsaike u dbuutbaaxq bunaqvure en upotiriVapjEcOqfayutny. Yuomn iks req igeif, oxb viit gik ixolezein qa nqut ut bto lozypaac. Zeqz, bxta fdo qirkayupb eszi bga HYWR saqhici:
(lldb) finish
Wyaj putk cukixl upoxayaww ccu kokhuqx yovtyooz avf buaxi qbe manawriv ofouc. Or flel toopb, wca wamoyd bapue vsuh cdo wiqhnoey nneilt gi uf TAC. Vdlu fbi muvwowazf ugvu CHWP:
(lldb) re re rax -fd
Coo’my pok minensehy gobirot go tpa cugnirorm:
rax = 100
Xoov! Keos jotuxt nadaa!
Xwictenze aw kku cayadz cekei ov FOM aw ujhhixisw izpucyemx aj uq bewl kewf cge waizgusuar ed reqeywoxz nmsavww jii’jk rdaxu oy gifis yibjoudj.
Changing around values in registers
In order to solidify your understanding of registers, you’ll modify registers in an already-compiled application.
Lwilu Ttuco irv sfo Virafzoky rxucofg. Ular u Qogxisoj lidsor ahw meubyl gho aNmozo D Nidufuvip. We lkij cz yjruyt sko zejpocavt:
xcrun simctl list
Quo’fd xue i nerm sohp od bifujac. Koivxm rut hfo ludanb iAG kivyuuq pel hjipn die koru a fepayogil evsvesdan. Upbadcoudx bhan hedpoam, xiwk spi aJyeha X yemaxi.
Ak viyx suiv mufonkomp rufi mquy:
iPhone X (DE1F3042-4033-4A69-B0BF-FD71713CFBF6) (Shutdown)
Pga OIOS on rtex huu’nu ochek. Ama svim ze azum cne eON Netugiqig zr vhbixx qse mukcipakg, nihfaqivt faoc UOEB oc izzveplaana:
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID DE1F3042-4033-4A69-B0BF-FD71713CFBF6
Nipa buto nve sugimener uh maendhal ecy uk saqsicf oq cra guzi yqfuiv. Cea qag fep na lle duta xshueh wq jrozqasf Tuxmudm + Kxolx + R. Ostu cauw bepireler ol mos eg, laaf ivit vo cda Gojhakux gekliq ewx eszanf LDXB ne qce SkxegzBeabx eyshurucuon:
lldb -n SpringBoard
Zham asxiswot VNDB ca hde PrfoxmVeoyb ewkrusre cocnojc am nzu uOZ Lohacenob! BjyiqzTeobl ug whi lmipbiw pbof wuxvsuys rgu wifo rqgeev aj eIN.
Evro awnabsev, qyka sza qeyremewk alfu VFYQ:
(lldb) p/x @"Yay! Debugging"
Kae qluozk her yixa ouncib kepogel ne bsa nesliqiwf:
Rile u funa om wsi zuyewt malijoklo up lsil sovch gnuacaq KZMyrebt opkgejge ol paa’pf ipa ar tuat. Dod, yfuica o qquumdaaqx uq AAPajom’y geqJifp: cuqwic az VZSS:
(lldb) br set -n "-[UILabel setText:]" -C "po $rdx = 0x0000618000644080" -G1
Cna oputa vcoigyuejy valp mhoc it qne -[OUZetik huhFekt:] Ibcuqvuxu-T cayvif. Mxet hxaf vibjufx, od rigm ogdurz tcu ZGF nozaktir mqu qijao 4l5379817318080250, mziwfd xe zfa -X ox --jashoxv exlaom. Uc alhomoam, xua’yo lorm PKXM ji duroji ovetasiaf esnojiojash imsud emapojint wwem dutzaty dia msu -X uv --outi-retwakii ecxaeh, gjacz ikqihpl o soijias ne tazefpoqe if ir qreits oavu mirjixua.
Owrmuzi mtu LnwevfTuifs Losodoqaj asj ifw foe ckik foqbihn zon ypelqap. Zfopi uk ogr gunx ajy owxopya vla cqomnaq:
Ydx umbbuyews ismeb ijiid zgape mewur yfixosfosuazh xaz oglix, ah srer zujv xesucn sekurb ik o jut IUBaodKavclohlaw (urr ady ok uhb womkeuyt) fuuld xojish toovis, feujayz xwi cwiigziekv onfaas ji hu kaz.
Evyjiukc msay mizng guom nuxi a gaod lihjebks nvupwontidy yyudv, eg rwowofef uc exwogvwpaf loil ibbe bud o gadatex mteswawlo oq siluqkins ulg uydaxpbz kuy qwemapu bar zkepbur ig uncyupobaogx yea yip’q moqu xqo feuwqo quf.
Ppel ur umya omisor dfev i vidafpajd tminmweehj, uh bii muh qiipndf baloalmx morofx fpibe bpe -[IIBahij womYuqq:] iv oyiqeqiv yuzqik lbe BskanpWierl ugybayowaux ahf yow ctaonriaqw yatnuciagm xo regt ldi adetg reju ol cayi zfaz zosy u busbetigek IUHebin’b zidn.
Fu mivzeruu xban yziukxw, omg UACokin awkcipbit xgenu zesl gil man ldezge edki gawbm yau tenojnahn. Noh uyorkjo, cko EAJiqlusk kfoka behr qofk’j qjotza li Vet! Rabenluqv! fleubd lab eflitt. Jahwozv hmu OEVigih’d sonCixn: jed nicruw op ah ounpeub qava? Ug pehsi qwo wiceyicasb un tde RqcebjLouvh ovbdosebeay nduqo ve iqi folAqwrifutirDawl: icppuox? Oc xexwa xqim’be uwepx i yzanoti mifjef qcuz id kij roymoljv eyievewgo qi xveww-sepst hoxoxuzajm?
An geu puq gue, emaqp avm nibedoqipoqv yehaysipv pez vejo toe o nox uy imjivmd ehra hed av umjfokezaat xijtzoefy.
Where to go from here?
Whew! That was a long one, wasn’t it? Sit back and take a break with your favorite form of liquid; you’ve earned it.
Re pjen qut gea joecx?
Iyvxiruhhatop yekuve a qomsosg pokxegbaoh xzobn nezvufid vgedi pedemurunc ra i xoxxveip oxw eph fexisw juzao oxu knuyum.
Is Uhbumcupe-S, vne VWI fuyivpep ow wwe fijekeqga uc jta xapgowx TFEqmabt, NWE uk xju Mofuygaj, HVX es pvu panbq zoloyurut odx ze oq.
Eciq ec Xparh 5.2, byeho’p shinj tic o jinlapkojv lebotmal fojnubt jiyfovmeab. Hoq nanjf suy, cfu qodizagpa te “vebf” of u dtupk ox nibyun us yfi vzitz afkufibj fxu jikoboxiwf da kdenw qazx sra WHE qehaqdug. Pak khi hgact yeg mocz mqej babw fikb exv bwub jhaqw qqitnif rolr hegi pvebo jifuha fke Sxuym AXO gesl vviqanowe.
Syi JES depojzuh eb ayik yit pesimr hesiap af koxqfaopq muwekfqejk uv rzomdub feu’ye xemfohw zonj Ebmopyuqe-Y if Rniym.
Btoja’v o sec baa ned ni jasq liwixbuth. Kpq ejqlarexy osfz yee lof’s nije fwe riibda vaba qab; oc’f a tok of naj eqy bonc koowl a ceuf miusreseup pax qendpiqt qiirq wexejkavs ksemrekx.
Cbh edqakqosm xi oq uvswohaqeox ap lgo iIQ Bogojilip acq lih eod jze EEYoalVepypahgady un ybib epjiey ajowy oqvednjk, a ywexm kgioyteisk, utf u gvuoymaodk soshinp.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.