- vm_address_t stack;
- _krncall(vm_allocate(task, &stack, size, true));
- vm_address_t data(stack + Stack_);
-
- vm_write(task, data, reinterpret_cast<vm_address_t>(baton), depth);
+ task_dyld_info info;
+#ifdef __arm__
+ union {
+ struct {
+ uint32_t all_image_info_addr;
+ } info_1;
+
+ struct {
+ uint32_t all_image_info_addr;
+ uint32_t all_image_info_size;
+ int32_t all_image_info_format;
+ } info32;
+
+ struct {
+ uint64_t all_image_info_addr;
+ uint64_t all_image_info_size;
+ int32_t all_image_info_format;
+ } info64;
+ } infoXX;
+
+ mach_msg_type_number_t count(sizeof(infoXX) / sizeof(natural_t));
+ _krncall(task_info(task, TASK_DYLD_INFO, reinterpret_cast<task_info_t>(&infoXX), &count));
+
+ bool broken;
+
+ switch (count) {
+ case sizeof(infoXX.info_1) / sizeof(natural_t):
+ broken = true;
+ info.all_image_info_addr = infoXX.info_1.all_image_info_addr;
+ info.all_image_info_size = 0;
+ info.all_image_info_format = TASK_DYLD_ALL_IMAGE_INFO_32;
+ break;
+ case sizeof(infoXX.info32) / sizeof(natural_t):
+ broken = true;
+ info.all_image_info_addr = infoXX.info32.all_image_info_addr;
+ info.all_image_info_size = infoXX.info32.all_image_info_size;
+ info.all_image_info_format = infoXX.info32.all_image_info_format;
+ break;
+ case sizeof(infoXX.info64) / sizeof(natural_t):
+ broken = false;
+ info.all_image_info_addr = infoXX.info64.all_image_info_addr;
+ info.all_image_info_size = infoXX.info64.all_image_info_size;
+ info.all_image_info_format = infoXX.info64.all_image_info_format;
+ break;
+ default:
+ _assert(false);
+ }
+#else
+ mach_msg_type_number_t count(TASK_DYLD_INFO_COUNT);
+ _krncall(task_info(task, TASK_DYLD_INFO, reinterpret_cast<task_info_t>(&info), &count));
+ _assert(count == TASK_DYLD_INFO_COUNT);
+#endif
+ _assert(info.all_image_info_addr != 0);