Skip to content

Commit e827eb1

Browse files
committed
fixed bug for x86. this fix #2
1 parent 2bedd3e commit e827eb1

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

ConPtyShell.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public static class ConPtyShell
1515
private const uint EXTENDED_STARTUPINFO_PRESENT = 0x00080000;
1616
private const uint CREATE_NO_WINDOW = 0x08000000;
1717
private const int STARTF_USESTDHANDLES = 0x00000100;
18+
private const int BUFFER_SIZE_PIPE = 1048576;
1819

1920
private const UInt32 INFINITE = 0xFFFFFFFF;
2021
private const uint GENERIC_READ = 0x80000000;
@@ -113,7 +114,7 @@ private struct COORD
113114
private static extern bool CloseHandle(IntPtr hObject);
114115

115116
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
116-
private static extern bool CreatePipe(out IntPtr hReadPipe, out IntPtr hWritePipe, SECURITY_ATTRIBUTES lpPipeAttributes, int nSize);
117+
private static extern bool CreatePipe(out IntPtr hReadPipe, out IntPtr hWritePipe, ref SECURITY_ATTRIBUTES lpPipeAttributes, int nSize);
117118

118119
[DllImport("kernel32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
119120
private static extern IntPtr CreateFile(string lpFileName, uint dwDesiredAccess, uint dwShareMode, IntPtr SecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
@@ -179,9 +180,9 @@ private static void TryParseRowsColsFromSocket(Socket shellSocket, ref uint rows
179180
private static void CreatePipes(ref IntPtr InputPipeRead, ref IntPtr InputPipeWrite, ref IntPtr OutputPipeRead, ref IntPtr OutputPipeWrite){
180181
int securityAttributeSize = Marshal.SizeOf<SECURITY_ATTRIBUTES>();
181182
SECURITY_ATTRIBUTES pSec = new SECURITY_ATTRIBUTES { nLength = securityAttributeSize, bInheritHandle=1, lpSecurityDescriptor=IntPtr.Zero };
182-
if(!CreatePipe(out InputPipeRead, out InputPipeWrite, pSec, 0))
183+
if(!CreatePipe(out InputPipeRead, out InputPipeWrite, ref pSec, BUFFER_SIZE_PIPE))
183184
throw new InvalidOperationException("Could not create the InputPipe");
184-
if(!CreatePipe(out OutputPipeRead, out OutputPipeWrite, pSec, 0))
185+
if(!CreatePipe(out OutputPipeRead, out OutputPipeWrite, ref pSec, BUFFER_SIZE_PIPE))
185186
throw new InvalidOperationException("Could not create the OutputPipe");
186187
}
187188

0 commit comments

Comments
 (0)