From 992103c8f7e22288c3f0160a3e419726a75dcf5d Mon Sep 17 00:00:00 2001 From: Terence Tan Date: Mon, 8 Aug 2016 13:34:44 +0800 Subject: [PATCH] Failed framework dumps are properly registered --- Clutch/.DS_Store | Bin 8196 -> 8196 bytes Clutch/BundleDumpOperation.m | 11 +++++++---- Clutch/Clutch-Prefix.pch | 2 +- Clutch/Framework64Dumper.m | 9 ++++++++- Clutch/FrameworkDumper.m | 4 +++- Clutch/main.m | 9 +++++---- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Clutch/.DS_Store b/Clutch/.DS_Store index 0175540b7eab41decb0f7ae4e330b979a89b6104..041604fb6c618ccbf50a01ac3feee260d5ff2b96 100644 GIT binary patch literal 8196 zcmeHMTWl0n7(QPwFvCPRg;L70go#B2t+-HX8zQpZwjdO2L+`XwXLm+AGM(A%%(h&t z_ECk9sCbFSm?(l0FE4`8H$yaPd@>lt2V?Zb7fsX$V|?*Hb7o5m)c8P56XtBr`OcjG z|IeKH=G!^@&oai4DVm!Yt7VKSR0VR4n(Gu{7xkJ_7L8OAg5nu7vlD(k>v-8~eB*(b zftZ1qftZ1qftZ2$!2s>qq9}9h`_dY>F#|CJHzfn&`Jhu3n2vBtV)*EwCQJbcD`+?@ z)TcZkjL{=ZM>r)h45c|`_JAl9QHlW>PIg_m6Q(1ak|@I&WH>`~W<(hZ!n0GH9=bE6 zCB|*cK+M3k42ayll4V(u+02=hzyFoZJGLLBQkPLyUQxMVp`tF*#D`Zcda!%co9GUV zpy+3e!ccf*n^rdJcNxKGso&#y&UD|%_Sx3N2(NDS+`zD1t1u&UxZie7ZzAIrUDF@# zmh<)7W-vO!mv{w%}sa|hLHBQ#+$C{c__4<~E zdnPCOvx>56Lu1R{!TjV?uf2ZyjWcK8y!eS^0nw9$ExU@9PiIqN`Z*^{7a_c6Fy;8; zUGhyw*~t=9-_2l3yCsonZL4YDF~WJ#xAs|%5!mBan-N(42w&n8fxB{^8(mj_&U1=m zE?KH_hLbCjv(@4_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~UoCAyonGISB#YZgCHSysw?OnPVYj%D>YuIZVMJv8VUM?G%i6P1_-54uj?YZsFZnl!)k zTEV&7pX0%9zmazdBaySqR<4QNdG|e=w%&hfxmvlRs#;MF66>~SK5QEKz6nnKkmhC$ zTQ}_^1LK@`%jmVWF{2XkNJK={u8Jy$bXx8{N9S?6dM+$2b*rM$VQy*98&vDzun1VY zE~@mpw0KqX9UB@IrS}oK`Ks$rx-qUq`z$SESgIb8VNK0SbYNVrUESjkwpJ_A!K^bj zMvHd+v2EL<(Gh;yy_)Oo&lxr?=_`Kj9Xk_kw4{ZuYlz3R={jF%czsb5>k}JfbA6&o zHdOwqs$)$o$#%05mSe}*v+QMdf_=!&v5(jn>>GBOU1h(rYwUOS2m6!#1%{-t+`{R zQ1G@L$r%~Ux%aabC}byfCG=L*laO?Yh%b?>SFfp4>ibBR#?gf|qb}hOLRfgOT~}YP zhK1C4a6=&AG!qAn7W=T=g4y;?5B&AY9e6-6x*^5@;{_mOq6P&x1JtRpL< zM}v3T8)+iYzIOwO-cX=lvy1F!A7VqLcoWsZX1fSwFoX59w zB)WT!L@$?0bUc-}Eyq4WqeW4d1_ZsEXJC<>qL%0XoeO{ezxfjdGXx9-4BWB|psXX+ zk)-7_dumpQueue); NSArray* wow = [_application->_dumpQueue operations]; for (NSOperation* operation in wow) { [[ClutchPrint sharedInstance] printDeveloper:@"operation hash %lu", (unsigned long)operation.hash]; @@ -163,18 +165,19 @@ - (void)main { BOOL result = [_dumper dumpBinary]; - if (result) { + if (result == YES) { dumpCount++; - //SUCCESS(@"Sucessfully dumped %@ segment of %@", [Dumper readableArchFromHeader:macho], originalBinary); + [[ClutchPrint sharedInstance] printDeveloper:@"Sucessfully dumped %@ segment of %@", [Dumper readableArchFromHeader:macho], originalBinary]; } else { - [[ClutchPrint sharedInstance] printError:@"Failed to dump binary %@ with arch %@",originalBinary,[Dumper readableArchFromHeader:macho]]; + [[ClutchPrint sharedInstance] printError:@"Failed to dump %@ with arch %@",originalBinary,[Dumper readableArchFromHeader:macho]]; + [self failedOperation]; } [_handle closeFile]; } if (!dumpCount) { - [[ClutchPrint sharedInstance] printError:@"Failed to dump binary %@", originalBinary]; + [[ClutchPrint sharedInstance] printError:@"Failed to dump %@", originalBinary]; [self failedOperation]; return; diff --git a/Clutch/Clutch-Prefix.pch b/Clutch/Clutch-Prefix.pch index 6cb3535b..ac4b7e0c 100644 --- a/Clutch/Clutch-Prefix.pch +++ b/Clutch/Clutch-Prefix.pch @@ -26,7 +26,7 @@ int diff_ms(struct timeval t1, struct timeval t2); -#define CLUTCH_VERSION_ @"2.0.2" +#define CLUTCH_VERSION_ @"2.0.3" #ifdef DEBUG #define CLUTCH_VERSION [NSString stringWithFormat:@"%@ DEBUG",CLUTCH_VERSION_] diff --git a/Clutch/Framework64Dumper.m b/Clutch/Framework64Dumper.m index a3aeedfd..11bd30b9 100644 --- a/Clutch/Framework64Dumper.m +++ b/Clutch/Framework64Dumper.m @@ -204,6 +204,7 @@ - (BOOL)dumpBinary exit_with_errno (posix_spawnattr_setflags (&attr, flags), "::posix_spawnattr_setflags (&attr, flags) error: "); int dumpResult = posix_spawnp(&pid, argv[0], NULL, &attr, (char* const*)argv, environ); + __block int finalDumpResult = 9999; if (dumpResult == 0) { [[ClutchPrint sharedInstance] printDeveloper: @"Child pid: %i", pid]; @@ -216,6 +217,7 @@ - (BOOL)dumpBinary kill(pid, SIGCONT); if (waitpid(pid, &dumpResult, 0) != -1) { [[ClutchPrint sharedInstance] printColor:ClutchPrinterColorPurple format:@"Child exited with status %u", dumpResult]; + finalDumpResult = dumpResult; } else { perror("waitpid"); } @@ -237,9 +239,14 @@ - (BOOL)dumpBinary [[NSFileManager defaultManager] removeItemAtPath:workingPath error:nil]; - if (dumpResult == 0) + [[ClutchPrint sharedInstance] printDeveloper: @"Final dump result %u", finalDumpResult]; + + if (finalDumpResult == 0) return YES; + + + return NO; } diff --git a/Clutch/FrameworkDumper.m b/Clutch/FrameworkDumper.m index 67951697..e2f010d4 100644 --- a/Clutch/FrameworkDumper.m +++ b/Clutch/FrameworkDumper.m @@ -213,6 +213,7 @@ - (BOOL)dumpBinary exit_with_errno (posix_spawnattr_setflags (&attr, flags), "::posix_spawnattr_setflags (&attr, flags) error: "); int dumpResult = posix_spawnp(&pid, argv[0], NULL, &attr, (char* const*)argv, environ); + __block finalDumpResult = 9999; //it shouldn't be 9999 if (dumpResult == 0) { [[ClutchPrint sharedInstance] printDeveloper: @"Child pid: %i", pid]; @@ -224,6 +225,7 @@ - (BOOL)dumpBinary int dumpResult = 0; if (waitpid(pid, &dumpResult, 0) != -1) { [[ClutchPrint sharedInstance] printDeveloper: @"Child exited with status %u", dumpResult]; + finalDumpResult = dumpResult; } else { perror("waitpid"); } @@ -245,7 +247,7 @@ - (BOOL)dumpBinary - if (dumpResult == 0) + if (finalDumpResult == 0) return YES; return NO; diff --git a/Clutch/main.m b/Clutch/main.m index 33a52036..9aed8dd5 100644 --- a/Clutch/main.m +++ b/Clutch/main.m @@ -165,17 +165,18 @@ int main (int argc, const char * argv[]) if (result) { - [[ClutchPrint sharedInstance] printColor:ClutchPrinterColorPurple format:@"Successfully dumped framework!"]; + [[ClutchPrint sharedInstance] printColor:ClutchPrinterColorPurple format:@"Successfully dumped framework %@!", fmwk.binPath.lastPathComponent]; + exit(0); } else { - [[ClutchPrint sharedInstance] printColor:ClutchPrinterColorPurple format:@"Failed to dumped framework! :("]; - exit(-2); + [[ClutchPrint sharedInstance] printColor:ClutchPrinterColorPurple format:@"Failed to dump framework %@ :(", fmwk.binPath.lastPathComponent]; + exit(2); } } - exit(-1); + exit(1); } switch (flags)