[Android Software/Hacking General [Developers Only]] k1ll3r8e:
Hey dancer_69,

sure i will try to help u ;)

1st of all use a WPF project not a WinForm project...

Here are my full ADB-Shell window... u still have to replace a few variables, if need help by this just let me know ;)

XAML:

<Window x:Class="HTC_Sensation_Tool_Kit.shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="{DynamicResource ResourceKey=WINDOW_adb_shell}" Height="372" Width="586" ResizeMode="NoResize">
<Grid>
<TextBox x:Name="SHELL_input" HorizontalAlignment="Left" Height="23" TextWrapping="NoWrap" Text="" VerticalAlignment="Top" Width="580" Margin="0,319,0,0" KeyDown="SHELL_input_KeyDown" GotFocus="SHELL_input_GotFocus" LostFocus="SHELL_input_LostFocus"/>
<RichTextBox x:Name="SHELL_output" HorizontalAlignment="Left" Height="314" VerticalAlignment="Top" Width="580" IsReadOnly="True" IsEnabled="True" ScrollViewer.VerticalScrollBarVisibility="Auto" IsDocumentEnabled="True" UndoLimit="0">
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0,2,0,0"/>
<Setter Property="Background" Value="White"/>
</Style>
<Style TargetType="{x:Type Run}">
<Setter Property="Background" Value="White"/>
</Style>
</RichTextBox.Resources>
</RichTextBox>
</Grid>
</Window>

CS:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace HTC_Sensation_Tool_Kit
{
/// <summary>
/// Interaktionslogik für shell.xaml
/// </summary>
public partial class shell : Window
{
private static Process proc = null;
private static bool exited = true;
private string cmdinfo = String.Empty;

public shell()
{
InitializeComponent();
SHELL_output.Document.Blocks.Clear();
proc = new System.Diagnostics.Process();
cmdinfo = FindResource("TOOL_TERMINAL_cmd_box").ToString();
SHELL_input.Text = cmdinfo;
Thread run_processes = new Thread(StartCMD);
run_processes.Start();
this.Closing += WindowClosing;
Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
}

///<summary>
/// Clean exit
///</summary>
private void WindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
{
while (proc.HasExited == false)
{
proc.StandardInput.WriteLine("exit");
}
Main mainWin = (Main)App.Current.MainWindow;
mainWin.ADB_shell.IsEnabled = true;
}

private void RunCMD(string cmd)
{
if (exited == false)
{
proc.StandardInput.WriteLine(cmd);
SHELL_input.Text = String.Empty;
}
}

private void StartCMD()
{
exited = false;
ProcessStartInfo StartInfo = new System.Diagnostics.ProcessStartInfo();
StartInfo.FileName = Main.ADB;
StartInfo.Arguments = "shell";
StartInfo.CreateNoWindow = true;
StartInfo.RedirectStandardInput = true;
StartInfo.RedirectStandardOutput = true;
StartInfo.RedirectStandardError = true;
StartInfo.StandardOutputEncoding = System.Text.Encoding.GetEncoding(437);
StartInfo.StandardErrorEncoding = System.Text.Encoding.GetEncoding(437);
StartInfo.UseShellExecute = false;

proc.OutputDataReceived += (s, e) =>
{
if (String.IsNullOrEmpty(e.Data) == false)
{
System.Windows.Application.Current.Dispatcher.Invoke(new MsgCallback(Msg), new object[] { e.Data });
Thread.Sleep(50);
}
};
proc.ErrorDataReceived += (s, e) =>
{
if (String.IsNullOrEmpty(e.Data) == false)
{
System.Windows.Application.Current.Dispatcher.Invoke(new MsgCallback(Msg), new object[] { e.Data });
Thread.Sleep(50);
}
};
proc.StartInfo = StartInfo;
proc.Start();
proc.BeginOutputReadLine();
proc.BeginErrorReadLine();
proc.StandardInput.WriteLine("id");
while(proc.HasExited == false)
{

}
if (proc.HasExited)
{
exited = true;
}
}

private void SHELL_input_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key.ToString().CompareTo("Return") == 0)
{
e.Handled = true;
RunCMD(SHELL_input.Text);
}
}

private void SHELL_input_GotFocus(object sender, RoutedEventArgs e)
{
if (SHELL_input.Text.CompareTo(cmdinfo) == 0)
{
SHELL_input.Text = String.Empty;
}
}

private void SHELL_input_LostFocus(object sender, RoutedEventArgs e)
{
if (SHELL_input.Text.CompareTo("") == 0)
{
SHELL_input.Text = cmdinfo;
}
}

public void Msg(string msg)
{
SHELL_output.Document.Blocks.Add(new Paragraph(new Run(msg)));
SHELL_output.ScrollToEnd();
}

public delegate void MsgCallback(string msg);
}
}