/// <summary> /// Connect to the VM in the given process id on the given device. /// </summary> public void Connect(IDevice device, int pid, MapFile mapFile) { // Disconnect any pending connections Disconnect(); // Cleanup process = null; this.mapFile = mapFile; this.pid = pid; // Setup forward var port = GetFreePort(); var adb = new Adb(); adb.ForwardJdwp(device, port, pid); // Establish connection connection = new JdwpConnection(new IPEndPoint(IPAddress.Parse("127.0.0.1"), port), ChunkHandler, pid, PacketHandler); connection.Disconnect += OnConnectionDisconnect; // Notify ConnectedChanged.Fire(this); }