Exemplo n.º 1
0
DeviceStatus Device::fileRelayRequest(FileRelaySource source) {
    if (this->mFileRelay == NULL) {
        if (file_relay_client_start_service(this->mDevice, &this->mFileRelay, NULL) != FILE_RELAY_E_SUCCESS) {
            return StatusError;
        }
    }
    char const * tSource[2] = {
        FRSource[(int)source].c_str(),
        NULL
    };
    idevice_connection_t conn = NULL;
    if (file_relay_request_sources(this->mFileRelay, (char const**)tSource, &conn) != FILE_RELAY_E_SUCCESS) {
        return StatusError;
    }
    return StatusOK;
}
Exemplo n.º 2
0
int main(int argc, char **argv) {
	idevice_t phone = NULL;
	lockdownd_client_t client = NULL;
    uint16_t port = 0;

    char* crashLogFile;

    if(argc != 2) {
    	print_usage(argc, argv);
    	return -1;
    }
    crashLogFile = argv[1];

	if (idevice_new(&phone, NULL) != IDEVICE_E_SUCCESS) {
		printf("No device found, is it plugged in?\n");
		return -1;
	}

	if (lockdownd_client_new_with_handshake(phone, &client, "idevicecrashlog") !=  LOCKDOWN_E_SUCCESS) {
		fprintf(stderr, "Could not connect to lockdownd. Exiting.\n");
		return -1;
	}

	if ((lockdownd_start_service(client, "com.apple.mobile.file_relay", &port) !=
		 LOCKDOWN_E_SUCCESS) || !port) {
		fprintf(stderr, "Could not start com.apple.mobile.file_relay!\n");
		return -1;
	}

	const char *sources[] = {"CrashReporter", NULL};
	idevice_connection_t dump = NULL;
	file_relay_client_t frc = NULL;

	if (file_relay_client_new(phone, port, &frc) != FILE_RELAY_E_SUCCESS) {
		printf("could not connect to file_relay service!\n");
		return -1;
	}

	if (file_relay_request_sources(frc, sources, &dump) != FILE_RELAY_E_SUCCESS) {
		printf("could not get sources\n");
		return -1;
	}

	if (!dump) {
		printf("did not get connection!\n");
		return -1;
	}


	uint32_t cnt = 0;
	uint32_t len = 0;
	char buf[4096];
	char* dumpTmpFile = tmpnam(NULL);
	FILE *f = fopen(dumpTmpFile, "w");
	//receiving file
	while (idevice_connection_receive(dump, buf, 4096, &len) == IDEVICE_E_SUCCESS) {
		fwrite(buf, 1, len, f);
		cnt += len;
		len = 0;
	}
	fclose(f);

	extract_file(dumpTmpFile, crashLogFile);

	lockdownd_client_free(client);
}