Ejemplo n.º 1
0
        public static NamedPipeServerStream CreatePipe(string name)
        {
            var sa = new SecurityAttributes();

            sa.Length      = Marshal.SizeOf(typeof(SecurityAttributes));
            sa.Inheritable = true;
            Debugger.Debug(LogLevel.Info, $"Created SA: {sa}");

            // Create a YOLO security descriptor to get around Access Denied problems
            // This is a pipe for a game; nothing of value to steal
            SafeSecurityDescriptor securityDescriptor = SafeSecurityDescriptor.FromSDDL("D:(A;OICI;GA;;;WD)");

            Debugger.Debug(LogLevel.Info, $"Got security descriptor: {securityDescriptor}");

            sa.SecurityDescriptor = securityDescriptor.DangerousGetHandle();

            IntPtr pipeHandle = CreateNamedPipe($@"\\.\pipe\{name}", PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE, 1, 64 * 1024, 64 * 1024, 0, sa);

            Debugger.Debug(LogLevel.Info, $"Created pipe: {pipeHandle.ToString("X")}");
            securityDescriptor.Dispose();

            return(new NamedPipeServerStream(PipeDirection.InOut, false, false, new SafePipeHandle(pipeHandle, true)));
        }
Ejemplo n.º 2
0
 public override IntPtr GetDefaultSecurity() => defaultSd.DangerousGetHandle();