-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prototype pty wrapper that maybe works?
- Loading branch information
1 parent
45222be
commit 56f21d7
Showing
2 changed files
with
249 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,100 @@ | ||
namespace ConsoleBuffer | ||
{ | ||
using Microsoft.Win32.SafeHandles; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
public static class NativeMethods | ||
{ | ||
public struct COORD | ||
internal const uint EXTENDED_STARTUPINFO_PRESENT = 0x00080000; | ||
internal const uint PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE = 0x00020016; | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
internal struct COORD | ||
{ | ||
public short X; | ||
public short Y; | ||
} | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] | ||
internal struct STARTUPINFOEX | ||
{ | ||
public STARTUPINFO StartupInfo; | ||
public IntPtr lpAttributeList; | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] | ||
internal struct STARTUPINFO | ||
{ | ||
public Int32 cb; | ||
public string lpReserved; | ||
public string lpDesktop; | ||
public string lpTitle; | ||
public Int32 dwX; | ||
public Int32 dwY; | ||
public Int32 dwXSize; | ||
public Int32 dwYSize; | ||
public Int32 dwXCountChars; | ||
public Int32 dwYCountChars; | ||
public Int32 dwFillAttribute; | ||
public Int32 dwFlags; | ||
public Int16 wShowWindow; | ||
public Int16 cbReserved2; | ||
public IntPtr lpReserved2; | ||
public IntPtr hStdInput; | ||
public IntPtr hStdOutput; | ||
public IntPtr hStdError; | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
internal struct PROCESS_INFORMATION | ||
{ | ||
public IntPtr hProcess; | ||
public IntPtr hThread; | ||
public int dwProcessId; | ||
public int dwThreadId; | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
internal struct SECURITY_ATTRIBUTES | ||
{ | ||
public int nLength; | ||
public IntPtr lpSecurityDescriptor; | ||
public int bInheritHandle; | ||
} | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
internal static extern bool InitializeProcThreadAttributeList(IntPtr lpAttributeList, int dwAttributeCount, int dwFlags, ref IntPtr lpSize); | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
internal static extern bool UpdateProcThreadAttribute(IntPtr lpAttributeList, uint dwFlags, IntPtr attribute, IntPtr lpValue, IntPtr cbSize, | ||
IntPtr lpPreviousValue, IntPtr lpReturnSize); | ||
|
||
[DllImport("kernel32.dll")] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
internal static extern bool CreateProcess(string lpApplicationName, string lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes, | ||
ref SECURITY_ATTRIBUTES lpThreadAttributes, bool bInheritHandles, uint dwCreationFlags, | ||
IntPtr lpEnvironment, string lpCurrentDirectory, [In] ref STARTUPINFOEX lpStartupInfo, | ||
out PROCESS_INFORMATION lpProcessInformation); | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
internal static extern bool DeleteProcThreadAttributeList(IntPtr lpAttributeList); | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
internal static extern bool CloseHandle(IntPtr hObject); | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
internal static extern int CreatePseudoConsole(COORD size, SafeFileHandle hInput, SafeFileHandle hOutput, uint dwFlags, out IntPtr phPC); | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
internal static extern int ResizePseudoConsole(IntPtr hPC, COORD size); | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
internal static extern int ClosePseudoConsole(IntPtr hPC); | ||
|
||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] | ||
internal static extern bool CreatePipe(out SafeFileHandle hReadPipe, out SafeFileHandle hWritePipe, IntPtr lpPipeAttributes, int nSize); } | ||
} |