Разобрался сам, примерный код:
ConsoleApi.PROCESS_INFORMATION _p = ConsoleApi.createConsoleTerminal(command);
Thread.Sleep(1000);
bool resultFree = ConsoleApi.FreeConsole();
if (resultFree)
{
Debug.WriteLine("FreeConsole: {0}", true);
}
else
{
Debug.WriteLine("FreeConsole: {0}", false);
}
Debug.WriteLine("Process ID: {0}", _p.dwProcessId);
bool result = ConsoleApi.AttachConsole(_p.dwProcessId);
Debug.WriteLine("AttachConsole: {0}", result);
IntPtr _consoleH = ConsoleApi.GetStdHandle(ConsoleApi.STD_OUTPUT_HANDLE);
ConsoleApi.CONSOLE_SCREEN_BUFFER_INFO _bufferInfo;
bool getInfo = ConsoleApi.GetConsoleScreenBufferInfo(_consoleH, out _bufferInfo);
if (getInfo)
{
Debug.WriteLine("GetConsoleScreenBufferInfo: {0}x{1}", _bufferInfo.dwSize.X, _bufferInfo.dwSize.Y);
}
else
{
Debug.WriteLine("GetConsoleScreenBufferInfo: {0}", false);
}
while(true)
{
IEnumerable<string> rows = ConsoleApi.ReadFromBuffer(_consoleH, 0, 0, _bufferInfo.dwSize.X, _bufferInfo.dwSize.Y);
foreach (string row in rows)
{
Debug.WriteLine(row);
}
Thread.Sleep(1000);
}