コード例 #1
0
 public static extern int NtConnectPort(
     out NAlpc.AlpcPortHandle PortHandle,
     string PortName,
     ref SECURITY_QUALITY_OF_SERVICE SecurityQos,
     out IntPtr /*PPORT_VIEW */ ClientView,
     out IntPtr /* PREMOTE_PORT_VIEW */ ServerView,
     ref UInt32 MaxMessageLength,
     out IntPtr ConnectionInformation,
     out IntPtr /*  UInt32*/ ConnectionInformationLength
     );
コード例 #2
0
        public void NtCreatePort_NtAcceptConnectPort()
        {
            var name = "\\" + this.GetType().Name + MethodBase.GetCurrentMethod().Name;

            NAlpc.AlpcPortHandle handle = null;
            var attributes = new OBJECT_ATTRIBUTES();

            NativeMethods.NtCreatePort(out handle, ref attributes, 100, 100, 50);
            var msg = new MY_TRANSFERRED_MESSAGE();

            NAlpc.AlpcPortHandle serverCommunicationPort = null;

            IntPtr optional = IntPtr.Zero;
            int    status   = NativeMethods.NtAcceptConnectPort(out serverCommunicationPort, optional, ref msg.Header, true, optional,
                                                                optional);

            AlpcErrorHandler.Check(status);
            handle.Dispose();
        }
コード例 #3
0
        public void NtCreatePort_NtListenPort()
        {
            var name = "\\" + this.GetType().Name + MethodBase.GetCurrentMethod().Name;

            NAlpc.AlpcPortHandle handle = null;
            var attributes = new OBJECT_ATTRIBUTES();

            NativeMethods.NtCreatePort(out handle, ref attributes, 100, 100, 50);
            var msg  = new MY_TRANSFERRED_MESSAGE();
            var wait = Task.Factory.StartNew(() =>
            {
                var status = NativeMethods.NtListenPort(handle, ref msg.Header);
                Assert.AreNotEqual(0, status);
            });
            var listenBlocksThread = wait.Wait(100);

            Assert.IsFalse(listenBlocksThread);
            handle.Dispose();
        }
コード例 #4
0
        public void NtCreatePort()
        {
            var name = "\\" + this.GetType().Name + MethodBase.GetCurrentMethod().Name;

            NAlpc.AlpcPortHandle handle = null;
            var attributes = new OBJECT_ATTRIBUTES();
            int status     = NativeMethods.NtCreatePort(out handle, ref attributes, 100, 100, 50);

            AlpcErrorHandler.Check(status);

            Assert.AreEqual(Constants.S_OK, status);
            IntPtr realPointer = handle.DangerousGetHandle();

            Assert.AreNotEqual(IntPtr.Zero, realPointer);
            Assert.IsFalse(handle.IsInvalid);
            Assert.IsFalse(handle.IsClosed);
            handle.Dispose();
            Assert.IsTrue(handle.IsClosed);
        }
コード例 #5
0
        public void NtCreate_Listen_AcceptConnect_Connect()
        {
            var name = "\\" + this.GetType().Name + MethodBase.GetCurrentMethod().Name;

            NAlpc.AlpcPortHandle serverConnectionPort = null;
            var  attributes             = new OBJECT_ATTRIBUTES();
            uint maxMessageLenght       = 30;
            int  serverCreatePortStatus = NativeMethods.NtCreatePort(out serverConnectionPort, ref attributes, 50, maxMessageLenght, 10);

            AlpcErrorHandler.Check(serverCreatePortStatus);
            var msg  = new MY_TRANSFERRED_MESSAGE();
            var wait = Task.Factory.StartNew(() =>
            {
                var serverListenPortStatus = NativeMethods.NtListenPort(serverConnectionPort, ref msg.Header);
                AlpcErrorHandler.Check(serverListenPortStatus);
                NAlpc.AlpcPortHandle serverComuicationPort = null;
                IntPtr optional1            = IntPtr.Zero;
                int serverAcceptConnectPort = NativeMethods.NtAcceptConnectPort(out serverComuicationPort, optional1, ref msg.Header, true, optional1,
                                                                                optional1);
                AlpcErrorHandler.Check(serverAcceptConnectPort);
            });
            var listenBlocksThread = wait.Wait(150);


            IntPtr optional = IntPtr.Zero;

            var            SecurityQos = SECURITY_QUALITY_OF_SERVICE.Create(SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation, false, true);
            AlpcPortHandle clientHandle;

            int status = NativeMethods.NtConnectPort(out clientHandle, name, ref SecurityQos, out optional, out optional, ref maxMessageLenght, out optional, out optional);
            var ex     = new Win32Exception(status);
            var err    = Marshal.GetLastWin32Error();
            var ex2    = new Win32Exception(err);

            Assert.IsFalse(listenBlocksThread);
            serverConnectionPort.Dispose();
        }
コード例 #6
0
 public static extern int NtCreatePort(out NAlpc.AlpcPortHandle PortHandle, ref OBJECT_ATTRIBUTES ObjectAttributes, uint MaxConnectionInfoLength, uint MaxMessageLength, uint MaxPoolUsage);