Skip to content

Instantly share code, notes, and snippets.

@floam
Last active April 20, 2016 21:45
Show Gist options
  • Save floam/e92f1203ff9de5e603a4dbbe00c97779 to your computer and use it in GitHub Desktop.
Save floam/e92f1203ff9de5e603a4dbbe00c97779 to your computer and use it in GitHub Desktop.
int sub_1000246de(int arg0, int arg1) {
r12 = arg0;
var_50 = r12;
if ((*(int8_t *)(r12 + 0x3f0) & 0x1) != 0x0) goto loc_100024d70;
loc_100024705:
var_40 = r12 + 0x3f8;
rdx = "%s: shutting down";
sub_100027eae(*0x1000445a8, 0x0, rdx, r12 + 0x3f8, r8, r9, stack[2035]);
if (r12 == *0x100045198) {
r13 = 0x100044a80;
r15 = dispatch_source_create(__dispatch_source_type_timer, 0x0, 0x0, sub_1000050f9());
rax = sign_extend_64(*(int32_t *)0x100044574);
rax = dispatch_time(0x0, rax * 0x3b9aca00);
dispatch_source_set_timer(r15, rax, 0xffffffffffffffff, 0x0);
dispatch_set_context(r15, *0x100045198);
dispatch_source_set_event_handler_f(r15, 0x100024d7c);
dispatch_resume(r15);
if (*(int32_t *)0x100044a80 != 0x0) {
rbx = dispatch_source_create(__dispatch_source_type_timer, 0x0, 0x1, sub_1000050f9());
rax = sign_extend_64(*(int32_t *)0x100044a80);
rax = dispatch_time(0x0, rax * 0x3b9aca00);
dispatch_source_set_timer(rbx, rax, 0xffffffffffffffff, 0x0);
dispatch_set_context(rbx, r15);
dispatch_source_set_event_handler_f(rbx, 0x100024dae);
dispatch_resume(rbx);
}
rbx = dispatch_queue_create("com.apple.xpc.launchd.system-override", 0x0);
rdx = sub_100024e6f;
dispatch_async_f(rbx, 0x0, rdx);
dispatch_release(rbx);
dispatch_semaphore_signal(*0x1000451b0);
r12 = r13;
}
*(r12 + 0x100) = mach_absolute_time();
*(int8_t *)(r12 + 0x3f0) = *(int8_t *)(r12 + 0x3f0) | 0x2;
r13 = "Removing unexpected event endpoint: %s";
rax = 0x0;
goto loc_100024874;
loc_100024874:
var_48 = rax;
rbx = *(r12 + rax * 0x8 + 0x260);
if (rbx == 0x0) goto loc_100024a62;
loc_100024889:
var_30 = rbx;
r8 = rbx + 0x458;
var_38 = r8;
rdx = "%s: removing unmanaged service: %s";
sub_100027eae(*0x1000445a8, 0x0, rdx, var_40, r8, r9, stack[2035]);
loc_10001ec42(r12, rbx, rdx);
r15 = r12;
r14 = "Removing unexpected non-dynamic endpoint: %s";
if (*(rbx + 0x88) != 0x0) {
rdx = "Unmanaged service with non-dynamic endpoints: %s";
sub_100017415(r15, 0x3, rdx, var_38, r8, r9, stack[2035]);
rbx = *(var_30 + 0x88);
if (rbx != 0x0) {
do {
r12 = *(rbx + 0x10);
rdx = r14;
sub_100017415(r15, 0x3, rdx, rbx + 0x90, r8, r9, stack[2035]);
loc_10003029b(rbx, 0x3);
rbx = r12;
} while (r12 != 0x0);
}
}
r14 = "%s: removing unmanaged endpoint: %s";
if (*(var_30 + 0xa0) != 0x0) {
rdx = "Unmanaged service with event endpoints: %s";
sub_100017415(r15, 0x3, rdx, var_38, r8, r9, stack[2035]);
rbx = *(var_30 + 0xa0);
if (rbx != 0x0) {
do {
r12 = *(rbx + 0x10);
rdx = r13;
sub_100017415(r15, 0x3, rdx, rbx + 0x90, r8, r9, stack[2035]);
loc_10003029b(rbx, 0x3);
rbx = r12;
} while (r12 != 0x0);
}
}
rbx = *(var_30 + 0x90);
r15 = var_40;
if (rbx != 0x0) {
do {
r12 = *(rbx + 0x10);
r8 = rbx + 0x90;
rdx = r14;
sub_100027eae(*0x1000445a8, 0x0, rdx, r15, r8, r9, stack[2035]);
loc_10003029b(rbx, 0x0);
rbx = r12;
} while (r12 != 0x0);
}
rbx = *(var_30 + 0x98);
r14 = "%s: removing unmanaged pid-local endpoint: %s";
if (rbx != 0x0) {
do {
r12 = *(rbx + 0x10);
r8 = rbx + 0x90;
rdx = r14;
sub_100027eae(*0x1000445a8, 0x0, rdx, r15, r8, r9, stack[2035]);
loc_10003029b(rbx, 0x0);
rbx = r12;
} while (r12 != 0x0);
}
rsi = var_30;
if (sign_extend_64(*(int16_t *)(rsi + 0xf4)) >= 0x3) goto loc_100024d58;
loc_100024a3a:
r12 = var_50;
loc_10001ee11(r12, rsi, rdx);
rax = var_48;
rbx = *(r12 + rax * 0x8 + 0x260);
r13 = "Removing unexpected event endpoint: %s";
if (rbx != 0x0) goto loc_100024889;
loc_100024a62:
rax = rax + 0x1;
if (rax < 0x7) goto loc_100024874;
loc_100024a6f:
r15 = *(r12 + 0x138);
rbx = "%s: removing semi-active service: %s";
r14 = var_40;
goto loc_100024a82;
loc_100024a82:
if (r15 == 0x0) goto loc_100024ac9;
loc_100024a87:
r13 = *(r15 + 0x40);
r8 = r15 + 0x458;
rdx = rbx;
sub_100027eae(*0x1000445a8, 0x0, rdx, r14, r8, r9, stack[2035]);
rax = loc_1000218ef(r12, r15, rdx);
r15 = r13;
if (rax == 0x0) goto loc_100024a82;
loc_100024abd:
sub_10002a31e("failure to remove semi-active service");
goto loc_100024ac9;
loc_100024ac9:
r15 = "%s: removing active service: %s";
rax = 0x0;
goto loc_100024ad2;
loc_100024ad2:
var_30 = rax;
r13 = *(r12 + rax * 0x8 + 0x1f8);
goto loc_100024af7;
loc_100024af7:
if (r13 == 0x0) goto loc_100024b39;
loc_100024afc:
rbx = r13;
r13 = *(rbx + 0x30);
r8 = rbx + 0x458;
rdx = r15;
sub_100027eae(*0x1000445a8, 0x0, rdx, r14, r8, r9, stack[2035]);
rax = loc_1000218ef(r12, rbx, rdx);
if ((rax == 0x0) || (rax == 0x24)) goto loc_100024af7;
loc_100024b37:
rax = sub_100024ae0();
return rax;
loc_100024b39:
rax = var_30 + 0x1;
if (rax != 0xd) goto loc_100024ad2;
loc_100024b46:
r15 = 0x0;
r13 = 0x0;
goto loc_100024b4c;
loc_100024b4c:
rsi = *(r12 + r13 * 0x8 + 0x140);
if (rsi == 0x0) goto loc_100024b7f;
loc_100024b59:
rbx = *(rsi + 0x50);
if ((*(int16_t *)(rsi + 0xf4) != 0x0) || (loc_1000218ef(r12, rsi, rdx) == 0x0)) goto loc_100024b77;
loc_100024d64:
sub_10002a31e("failed to remove inactive service");
goto loc_100024d70;
loc_100024d70:
sub_10002b875(*0x100044438, 0x0, "%s", "Lord Gilbert, Baron of England by the grace of his majesty, King Henry\nII, seized upon the person of a priest of the Holy Church and\nunlawfully did hold him in custody. Furthermore, in the presence of\nLord Gilbert, and by his command, his men seized upon t…", r8, r9, sub_10002a31e("multiple invocations of death handler for domain"));
stack[2031] = rsp - 0x8;
stack[2030] = r15;
sub_100016188("multiple invocations of death handler for domain", 0x0);
sub_10002b0f7();
rbx = mach_absolute_time();
sub_10002d0a4("shutdown-stall", 0x10005, "Generating report...");
r15 = sub_10000199c(rbx);
rax = sub_10000199c(rbx);
rdx = HIQWORD((rax >> 0x9) * 0x44b82fa09b5a53);
sub_10002b0f7();
rax = *0x100045198;
rax = dispatch_time(0x0, (r15 + rbx - *(rax + 0x100)) + sign_extend_64(*(int32_t *)0x100044574) * 0x3b9aca00);
rax = dispatch_source_set_timer("multiple invocations of death handler for domain", rax, 0xffffffffffffffff, 0x0);
return rax;
loc_100024b77:
rsi = rbx;
if (rbx != 0x0) goto loc_100024b59;
loc_100024b7f:
r13 = r13 + 0x1;
if (r13 < 0x17) goto loc_100024b4c;
loc_100024b88:
do {
rdi = *(r12 + r15 * 0x8 + 0x298);
if (rdi != 0x0) {
do {
rbx = *(rdi + 0x20);
if (*(rdi + 0x48) != 0x0) {
sub_100021808(rdi, rsi, rdx);
}
rdi = rbx;
} while (rbx != 0x0);
}
r15 = r15 + 0x1;
} while (r15 != 0x1f);
rax = *(r12 + 0xd0);
if ((rax != 0x0) && (*(rax + 0x3c8) == r12)) {
*(rax + 0x3c8) = 0x0;
}
for (rbx = *(r12 + 0x130); rbx != 0x0; rbx = *(rbx + 0x10)) {
sub_1000245ce(rbx, rsi);
}
*(int8_t *)(r12 + 0x3f0) = *(int8_t *)(r12 + 0x3f0) | 0x1;
rdi = *(r12 + 0x90);
if (rdi != 0x0) {
dispatch_set_context(rdi, rdi);
dispatch_source_cancel(*(r12 + 0x90));
*(r12 + 0x90) = 0x0;
*(int32_t *)(r12 + 0x80) = 0x0;
}
rdi = *(r12 + 0x88);
rax = 0x1000445a8;
if (rdi != 0x0) {
if ((*(int8_t *)(r12 + 0x3f1) & 0x80) != 0x0) {
rdi = *rax;
sub_100027eae(rdi, 0x0, "%s: uncorking exec source for disposal", r14, r8, r9, stack[2035]);
dispatch_resume(*(r12 + 0x88));
*(int8_t *)(r12 + 0x3f1) = *(int8_t *)(r12 + 0x3f1) & 0x7f;
rdi = *(r12 + 0x88);
}
dispatch_release(rdi);
*(r12 + 0x88) = 0x0;
}
rbx = *(r12 + 0xb8);
r13 = r12;
if (rbx != 0x0) {
r15 = "Bad link elm %p prev->next != elm";
r12 = "Bad link elm %p next->prev != elm";
do {
r14 = *rbx;
loc_10002ec25(*(int32_t *)(rbx + 0x10), *(rbx + 0x18));
rax = *rbx;
if ((rax != 0x0) && (*(rax + 0x8) != rbx)) {
panic(r12);
}
if (**(rbx + 0x8) != rbx) {
panic(r15);
}
rax = *rbx;
if (rax != 0x0) {
*(rax + 0x8) = *(rbx + 0x8);
}
**(rbx + 0x8) = rax;
*rbx = 0xffffffffffffffff;
*(rbx + 0x8) = 0xffffffffffffffff;
rbx = r14;
} while (r14 != 0x0);
}
rbx = r13;
if ((rbx == *0x100045198) && (*0x1000451c8 != 0x0)) {
dispatch_release(*0x1000451c8);
}
rdi = rbx;
rax = sub_10001fa01(rdi);
return rax;
loc_100024d58:
sub_10002a31e("extra activation on unmanaged service");
goto loc_100024d64;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment