Ejemplo n.º 1
0
	// Sends an AFC packet to iPhone.
	private int AFCSend(byte[] byData, AFCPacketType Type)
	{
		if (iPhone == null || !iPhone.Usable) throw new Exception("No device ready in AFCSend.");
		if (byData == null) throw new Exception("No data passed to AFCSend.");

		long nPacketLength = byData.LongLength + 40;
		byte[] bAugmentedData = new byte[nPacketLength];
		Array.Copy(AFCConst, bAugmentedData, 8);
		Array.Copy(BitConverter.GetBytes(nPacketLength), 0, bAugmentedData, 8, 8);
		// Hack because of AFC inconsistency.
		if (Type == AFCPacketType.FileRefWrite)
			Array.Copy(BitConverter.GetBytes((long)0x30), 0, bAugmentedData, 16, 8);
		else
			Array.Copy(BitConverter.GetBytes(nPacketLength), 0, bAugmentedData, 16, 8);
		Array.Copy(BitConverter.GetBytes(nPacketCounter), 0, bAugmentedData, 24, 8);
		Array.Copy(BitConverter.GetBytes((long)Type), 0, bAugmentedData, 32, 8);
		Array.Copy(byData, 0, bAugmentedData, 40, byData.Length);

		nPacketCounter++;
		return Send(bAugmentedData);
	}
Ejemplo n.º 2
0
	// Wrapper that null-terminates strings being sent as AFC packets.
	private int AFCSend(string sData, AFCPacketType Type)
	{
		if (sData == null) throw new Exception("No data passed to AFCSend.");
		sData += '\x0';
		return AFCSend(System.Text.Encoding.UTF8.GetBytes(sData), Type);
	}