Esempio n. 1
0
        public PortComHandle AcceptConnect(PortMessage message, bool accept)
        {
            NtStatus status;
            IntPtr   portHandle;

            using (var messageMemory = message.ToMemory())
            {
                if ((status = Win32.NtAcceptConnectPort(
                         out portHandle,
                         IntPtr.Zero,
                         messageMemory,
                         accept,
                         IntPtr.Zero,
                         IntPtr.Zero
                         )) >= NtStatus.Error)
                {
                    Win32.Throw(status);
                }

                if (!NativeHandle.IsInvalid(portHandle))
                {
                    return(new PortComHandle(portHandle, true));
                }
                else
                {
                    return(null);
                }
            }
        }
        public static MailslotHandle Create(
            FileAccess access,
            string fileName,
            ObjectFlags objectFlags,
            NativeHandle rootDirectory,
            int quota,
            int maxMessageSize,
            long readTimeout,
            FileCreateOptions createOptions
            )
        {
            ObjectAttributes oa = new ObjectAttributes(fileName, objectFlags, rootDirectory);
            IoStatusBlock    isb;
            IntPtr           handle;

            try
            {
                Win32.NtCreateMailslotFile(
                    out handle,
                    access,
                    ref oa,
                    out isb,
                    createOptions,
                    quota,
                    maxMessageSize,
                    ref readTimeout
                    ).ThrowIf();
            }
            finally
            {
                oa.Dispose();
            }

            return(new MailslotHandle(handle, true));
        }
Esempio n. 3
0
        public static NamedPipeHandle Create(
            FileAccess access,
            string fileName,
            ObjectFlags objectFlags,
            NativeHandle rootDirectory,
            FileShareMode shareMode,
            FileCreationDisposition creationDisposition,
            FileCreateOptions createOptions,
            PipeType type,
            PipeType readMode,
            PipeCompletionMode completionMode,
            int maximumInstances,
            int inboundQuota,
            int outboundQuota,
            long defaultTimeout
            )
        {
            NtStatus         status;
            ObjectAttributes oa = new ObjectAttributes(fileName, objectFlags, rootDirectory);
            IoStatusBlock    isb;
            IntPtr           handle;

            // If a timeout wasn't specified, use a default value.
            if (defaultTimeout == 0)
            {
                defaultTimeout = -50 * Win32.TimeMsTo100Ns; // 50 milliseconds
            }
            try
            {
                if ((status = Win32.NtCreateNamedPipeFile(
                         out handle,
                         access,
                         ref oa,
                         out isb,
                         shareMode,
                         creationDisposition,
                         createOptions,
                         type,
                         readMode,
                         completionMode,
                         maximumInstances,
                         inboundQuota,
                         outboundQuota,
                         ref defaultTimeout
                         )) >= NtStatus.Error)
                {
                    Win32.Throw(status);
                }
            }
            finally
            {
                oa.Dispose();
            }

            return(new NamedPipeHandle(handle, true));
        }
Esempio n. 4
0
 public MailslotHandle(
     string fileName,
     ObjectFlags objectFlags,
     NativeHandle rootDirectory,
     FileShareMode shareMode,
     FileCreateOptions openOptions,
     FileAccess access
     )
     : base(fileName, objectFlags, rootDirectory, shareMode, openOptions, access)
 {
 }
 /// <summary>
 /// Walks the call stack for the thread.
 /// </summary>
 /// <param name="walkStackCallback">A callback to execute.</param>
 /// <param name="architecture">
 /// The type of stack walk. On 32-bit systems, this value is ignored.
 /// On 64-bit systems, this value can be set to I386 to walk the
 /// 32-bit stack.
 /// </param>
 public void WalkStack(WalkStackDelegate walkStackCallback, OSArch architecture)
 {
     // We need to duplicate the handle to get QueryInformation access.
     using (NativeHandle <ThreadAccess> dupThreadHandle = this.Duplicate(OSVersion.MinThreadQueryInfoAccess))
         using (ProcessHandle phandle = new ProcessHandle(
                    FromHandle(dupThreadHandle).GetBasicInformation().ClientId.ProcessId,
                    ProcessAccess.QueryInformation | ProcessAccess.VmRead
                    ))
         {
             this.WalkStack(phandle, walkStackCallback, architecture);
         }
 }
Esempio n. 6
0
        public PortComHandle AcceptConnect(PortMessage message, bool accept)
        {
            IntPtr portHandle;

            using (MemoryAlloc messageMemory = message.ToMemory())
            {
                Win32.NtAcceptConnectPort(
                    out portHandle,
                    IntPtr.Zero,
                    messageMemory,
                    accept,
                    IntPtr.Zero,
                    IntPtr.Zero
                    ).ThrowIf();

                if (!NativeHandle.IsInvalid(portHandle))
                {
                    return(new PortComHandle(portHandle, true));
                }

                return(null);
            }
        }