private static extern IntPtr GetStdHandle(StdHandle std);
private static extern IntPtr GetStdHandle(StdHandle index);
public static extern IntPtr GetStdHandle(StdHandle nStdHandle);
public static extern bool SetStdHandle(StdHandle std, IntPtr handle);
internal static extern IntPtr GetStdHandle( StdHandle std );
private static extern IntPtr GetStdHandle( StdHandle index );
private static extern System.IntPtr GetStdHandle(StdHandle nStdHandle);
public static extern SafeFileHandle GetStdHandle(StdHandle nStdHandle);
public static extern bool SetStdHandle(StdHandle nStdHandle, IntPtr hHandle);
public static extern IntPtr GetStdHandle(StdHandle handleId);
public static extern IntPtr GetStdHandle(StdHandle index);
internal static extern IntPtr GetStdHandle(StdHandle index);
internal static extern SafeFileHandle GetStdHandle(StdHandle nStdHandle);
public StdHandle sceKernelStdoutReopen(string File, HleIoFlags Flags, Vfs.SceMode Mode) { StdOut = (StdHandle)IoFileMgrForUser.sceIoOpen(File, Flags, Mode); //Console.WriteLine("StdOut: {0}", StdOut); return StdOut; }
private static extern SafeFileHandle GetStdHandle(StdHandle nStdHandle);
public StdHandle sceKernelStderrReopen(string File, HleIoFlags Flags, Vfs.SceMode Mode) { StdError = (StdHandle)IoFileMgrForUser.sceIoOpen(File, Flags, Mode); return StdError; }
private void CreateStandardPipe(out SafeFileHandle readHandle, out SafeFileHandle writeHandle, StdHandle standardHandle, bool isInput, bool redirect) { if (redirect) { var security = new SecurityAttributes { bInheritHandle = true }; if (!CreatePipe(out readHandle, out writeHandle, security, DEFAULT_PIPE_BUFFER_SIZE)) { var error = Marshal.GetLastWin32Error(); _debugLogger.Error("AsyncImpersonationProcess ({0}): CreatePipe failed. ErrorCode: {1} ({2})", StartInfo.FileName, error, new Win32Exception(error).Message); return; } if (!SetHandleInformation(isInput ? writeHandle : readHandle, HandleFlags.Inherit, HandleFlags.None)) { var error = Marshal.GetLastWin32Error(); _debugLogger.Error("AsyncImpersonationProcess ({0}): SetHandleInformation failed. ErrorCode: {1} ({2})", StartInfo.FileName, error, new Win32Exception(error).Message); } } else { if (isInput) { writeHandle = new SafeFileHandle(IntPtr.Zero, false); readHandle = GetStdHandle(standardHandle); var error = Marshal.GetLastWin32Error(); // Error code 1008 means "An attempt was made to reference a token that does not exist". This is the case // in particular in the server process because a Windows service does not have a standard output or standard error stream. // This is expected behaviour - not an error. if (error != 0 && error != 1008) _debugLogger.Error("AsyncImpersonationProcess ({0}): GetStdHandle failed. ErrorCode: {1} ({2})", StartInfo.FileName, error, new Win32Exception(error).Message); } else { readHandle = new SafeFileHandle(IntPtr.Zero, false); writeHandle = GetStdHandle(standardHandle); var error = Marshal.GetLastWin32Error(); // Error code 1008 means "An attempt was made to reference a token that does not exist". This is the case // in particular in the server process because a Windows service does not have a standard output or standard error stream. // This is expected behaviour - not an error. if (error != 0 && error != 1008) _debugLogger.Error("AsyncImpersonationProcess ({0}): GetStdHandle failed. ErrorCode: {1} ({2})", StartInfo.FileName, error, new Win32Exception(error).Message); } } }
private static extern bool SetStdHandle(StdHandle nStdHandle, IntPtr hHandle);
public static extern IntPtr GetStdHandle(StdHandle std);