// Jackson Coxson #include #include #include #include #include #include #include using namespace IdeviceFFI; int main(int argc, char** argv) { idevice_init_logger(Debug, Disabled, NULL); // Usage: // springboardservices orientation // springboardservices icon // springboardservices wallpaper homescreen // springboardservices wallpaper lockscreen if (argc < 2) { std::cerr << "Usage:\n" << " " << argv[0] << " orientation\n" << " " << argv[0] << " icon \n" << " " << argv[0] << " wallpaper homescreen \n" << " " << argv[0] << " wallpaper lockscreen \n"; return 2; } std::string command = argv[1]; auto mux = UsbmuxdConnection::default_new(0).expect("failed to connect to usbmuxd"); auto devices = mux.get_devices().expect("failed to list devices"); if (devices.empty()) { std::cerr << "no devices connected\n"; return 1; } auto& dev = devices[0]; auto udid = dev.get_udid(); if (udid.is_none()) { std::cerr << "device has no UDID\n"; return 1; } auto mux_id = dev.get_id(); if (mux_id.is_none()) { std::cerr << "device has no mux id\n"; return 1; } auto addr = UsbmuxdAddr::default_new(); const uint32_t tag = 0; const std::string label = "springboardservices-client"; auto provider = Provider::usbmuxd_new(std::move(addr), tag, udid.unwrap(), mux_id.unwrap(), label) .expect("failed to create provider"); auto springboard = SpringBoardServices::connect(provider).expect("failed to connect to springboardservices"); if (command == "orientation") { auto orientation = springboard.get_interface_orientation().expect("failed to get orientation"); std::cout << static_cast(orientation) << "\n"; return 0; } if (command == "icon") { if (argc != 4) { std::cerr << "Usage:\n" << " " << argv[0] << " icon \n"; return 2; } std::string bundle_id = argv[2]; std::string out_path = argv[3]; auto icon = springboard.get_icon(bundle_id).expect("failed to get icon"); std::ofstream out(out_path, std::ios::binary); if (!out.is_open()) { std::cerr << "failed to open output file: " << out_path << "\n"; return 1; } out.write(reinterpret_cast(icon.data()), static_cast(icon.size())); out.close(); std::cout << "Icon saved to " << out_path << " (" << icon.size() << " bytes)\n"; return 0; } if (command == "wallpaper") { if (argc != 4) { std::cerr << "Usage:\n" << " " << argv[0] << " wallpaper homescreen \n" << " " << argv[0] << " wallpaper lockscreen \n"; return 2; } std::string wallpaper_type = argv[2]; std::string out_path = argv[3]; std::vector wallpaper; if (wallpaper_type == "homescreen") { wallpaper = springboard.get_home_screen_wallpaper_preview() .expect("failed to get homescreen wallpaper preview"); } else if (wallpaper_type == "lockscreen") { wallpaper = springboard.get_lock_screen_wallpaper_preview() .expect("failed to get lockscreen wallpaper preview"); } else { std::cerr << "Invalid wallpaper type: " << wallpaper_type << "\n"; return 2; } std::ofstream out(out_path, std::ios::binary); if (!out.is_open()) { std::cerr << "failed to open output file: " << out_path << "\n"; return 1; } out.write(reinterpret_cast(wallpaper.data()), static_cast(wallpaper.size())); out.close(); std::cout << "Wallpaper saved to " << out_path << " (" << wallpaper.size() << " bytes)\n"; return 0; } std::cerr << "Unknown command: " << command << "\n"; return 2; }