示例#1
0
        public PortMessage ReplyWaitReceive(PortMessage message)
        {
            NtStatus status;
            IntPtr   context;

            using (var buffer = PortMessage.AllocateBuffer())
            {
                MemoryAlloc messageMemory = null;

                if (message != null)
                {
                    messageMemory = message.ToMemory();
                }

                try
                {
                    if ((status = Win32.NtReplyWaitReceivePort(
                             this,
                             out context,
                             messageMemory ?? IntPtr.Zero,
                             buffer
                             )) >= NtStatus.Error)
                    {
                        Win32.ThrowLastError(status);
                    }

                    if (message != null)
                    {
                        message.SetHeader(messageMemory);
                    }
                }
                finally
                {
                    if (messageMemory != null)
                    {
                        messageMemory.Dispose();
                    }
                }

                return(new PortMessage(buffer));
            }
        }
示例#2
0
        public PortMessage ReplyWaitReceive(PortMessage message)
        {
            using (MemoryAlloc buffer = PortMessage.AllocateBuffer())
            {
                MemoryAlloc messageMemory = null;

                if (message != null)
                {
                    messageMemory = message.ToMemory();
                }

                try
                {
                    IntPtr context;

                    Win32.NtReplyWaitReceivePort(
                        this,
                        out context,
                        messageMemory ?? IntPtr.Zero,
                        buffer
                        ).ThrowIf();

                    if (message != null)
                    {
                        message.SetHeader(messageMemory);
                    }
                }
                finally
                {
                    if (messageMemory != null)
                    {
                        messageMemory.Dispose();
                    }
                }

                return(new PortMessage(buffer));
            }
        }
        private MemoryAlloc GetPropertiesInformation()
        {
            NtStatus status;
            int      retLength;

            var data = new MemoryAlloc(0x1000);

            status = Win32.NtQueryInformationTransaction(
                this,
                TransactionInformationClass.TransactionPropertiesInformation,
                data,
                data.Size,
                out retLength
                );

            if (status == NtStatus.BufferTooSmall)
            {
                // Resize the buffer and try again.
                data.Resize(retLength);

                status = Win32.NtQueryInformationTransaction(
                    this,
                    TransactionInformationClass.TransactionPropertiesInformation,
                    data,
                    data.Size,
                    out retLength
                    );
            }

            if (status >= NtStatus.Error)
            {
                data.Dispose();
                Win32.ThrowLastError(status);
            }

            return(data);
        }
示例#4
0
        private MemoryAlloc GetBasicInformation()
        {
            NtStatus status;
            int      retLength;

            var data = new MemoryAlloc(0x1000);

            status = Win32.NtQueryInformationResourceManager(
                this,
                ResourceManagerInformationClass.ResourceManagerBasicInformation,
                data,
                data.Size,
                out retLength
                );

            if (status == NtStatus.BufferTooSmall)
            {
                // Resize the buffer and try again.
                data.Resize(retLength);

                status = Win32.NtQueryInformationResourceManager(
                    this,
                    ResourceManagerInformationClass.ResourceManagerBasicInformation,
                    data,
                    data.Size,
                    out retLength
                    );
            }

            if (status >= NtStatus.Error)
            {
                data.Dispose();
                Win32.ThrowLastError(status);
            }

            return(data);
        }
示例#5
0
        protected override void Close()
        {
            _buffer.Dispose();

            base.Close();
        }