PseudoConsoleApi.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. using Microsoft.Win32.SafeHandles;
  2. using System;
  3. using System.Runtime.InteropServices;
  4. namespace MiniTerm.Native
  5. {
  6. /// <summary>
  7. /// PInvoke signatures for win32 pseudo console api
  8. /// </summary>
  9. static class PseudoConsoleApi
  10. {
  11. internal const uint PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE = 0x00020016;
  12. [StructLayout(LayoutKind.Sequential)]
  13. internal struct COORD
  14. {
  15. public short X;
  16. public short Y;
  17. }
  18. [DllImport("kernel32.dll", SetLastError = true)]
  19. internal static extern int CreatePseudoConsole(COORD size, SafeFileHandle hInput, SafeFileHandle hOutput, uint dwFlags, out IntPtr phPC);
  20. [DllImport("kernel32.dll", SetLastError = true)]
  21. internal static extern int ResizePseudoConsole(IntPtr hPC, COORD size);
  22. [DllImport("kernel32.dll", SetLastError = true)]
  23. internal static extern int ClosePseudoConsole(IntPtr hPC);
  24. [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  25. internal static extern bool CreatePipe(out SafeFileHandle hReadPipe, out SafeFileHandle hWritePipe, IntPtr lpPipeAttributes, int nSize);
  26. }
  27. }