public RPC_SERVER_INTERFACE(RpcHandle handle, Ptr <MIDL_SERVER_INFO> pServer, Guid iid)
 {
     this.Length      = (uint)Marshal.SizeOf(typeof(RPC_CLIENT_INTERFACE));
     this.InterfaceId = new RPC_SYNTAX_IDENTIFIER()
     {
         SyntaxGUID    = iid,
         SyntaxVersion = RPC_VERSION.INTERFACE_VERSION
     };
     this.TransferSyntax = new RPC_SYNTAX_IDENTIFIER()
     {
         SyntaxGUID    = RPC_SERVER_INTERFACE.IID_SYNTAX,
         SyntaxVersion = RPC_VERSION.SYNTAX_VERSION
     };
     this.DispatchTable = handle.Pin <RPC_DISPATCH_TABLE>(new RPC_DISPATCH_TABLE()
     {
         DispatchTableCount = 1U,
         DispatchTable      = handle.Pin <RPC_DISPATCH_TABLE_Entry>(new RPC_DISPATCH_TABLE_Entry()
         {
             DispatchMethod = RpcApi.ServerEntry.Handle,
             Zero           = IntPtr.Zero
         }),
         Reserved = IntPtr.Zero
     });
     this.RpcProtseqEndpointCount = 0U;
     this.RpcProtseqEndpoint      = IntPtr.Zero;
     this.DefaultManagerEpv       = IntPtr.Zero;
     this.InterpreterInfo         = pServer.Handle;
     this.Flags = 67108864U;
 }
Ejemplo n.º 2
0
 public RpcClientApi(Guid iid, RpcProtseq protocol, string server, string endpoint)
 {
     this._handle   = (RpcHandle) new RpcClientApi.RpcClientHandle();
     this.IID       = iid;
     this._protocol = protocol;
     this._binding  = RpcClientApi.StringBindingCompose(protocol, server, endpoint, (string)null);
     this.Connect();
 }
Ejemplo n.º 3
0
 public RpcServerApi(Guid iid, int maxCalls, int maxRequestBytes, bool allowAnonTcp)
 {
     this.IID       = iid;
     this._maxCalls = maxCalls;
     this._handle   = (RpcHandle) new RpcServerApi.RpcServerHandle();
     if (Guid.Empty.Equals(iid))
     {
         return;
     }
     RpcServerApi.ServerRegisterInterface(this._handle, this.IID, new RpcExecute(this.RpcEntryPoint), maxCalls, maxRequestBytes, allowAnonTcp);
 }
Ejemplo n.º 4
0
        private Ptr <RPC_SERVER_INTERFACE> Configure(RpcHandle handle, Ptr <MIDL_SERVER_INFO> me, Guid iid, byte[] formatTypes, byte[] formatProc, RpcExecute fnExecute)
        {
            Ptr <RPC_SERVER_INTERFACE> ptr = handle.CreatePtr <RPC_SERVER_INTERFACE>(new RPC_SERVER_INTERFACE(handle, me, iid));

            this.pStubDesc = handle.CreatePtr <MIDL_STUB_DESC>(new MIDL_STUB_DESC(handle, ptr.Handle, formatTypes, true)).Handle;
            IntPtr data = handle.PinFunction <RpcExecute>(fnExecute);

            this.DispatchTable   = handle.Pin <IntPtr>(data);
            this.ProcString      = handle.Pin <byte[]>(formatProc);
            this.FmtStringOffset = handle.Pin <int[]>(new int[1]);
            this.ThunkTable      = IntPtr.Zero;
            this.pTransferSyntax = IntPtr.Zero;
            this.nCount          = IntPtr.Zero;
            this.pSyntaxInfo     = IntPtr.Zero;
            Marshal.StructureToPtr((object)this, me.Handle, false);
            return(ptr);
        }
Ejemplo n.º 5
0
        private static void ServerRegisterInterface(RpcHandle handle, Guid iid, RpcExecute fnExec, int maxCalls, int maxRequestBytes, bool allowAnonTcp)
        {
            int    Flags = 0;
            IntPtr hProc = IntPtr.Zero;

            if (allowAnonTcp)
            {
                Flags = 16;
                hProc = RpcServerApi.hAuthCall.Handle;
            }
            Ptr <RPC_SERVER_INTERFACE> ptr = MIDL_SERVER_INFO.Create(handle, iid, RpcApi.TYPE_FORMAT, RpcApi.FUNC_FORMAT, fnExec);

            if (!allowAnonTcp && maxRequestBytes < 0)
            {
                RpcException.Assert(RpcServerApi.RpcServerRegisterIf(ptr.Handle, IntPtr.Zero, IntPtr.Zero));
            }
            else
            {
                RpcException.Assert(RpcServerApi.RpcServerRegisterIf2(ptr.Handle, IntPtr.Zero, IntPtr.Zero, Flags, maxCalls <= 0 ? (int)byte.MaxValue : maxCalls, maxRequestBytes <= 0 ? 81920 : maxRequestBytes, hProc));
            }

            handle.Handle = ptr.Handle;
        }
Ejemplo n.º 6
0
        public MIDL_STUB_DESC(RpcHandle handle, IntPtr interfaceInfo, byte[] formatTypes, bool serverSide)
        {
            this.RpcInterfaceInformation = interfaceInfo;
            this.pfnAllocate             = RpcApi.AllocPtr.Handle;
            this.pfnFree                     = RpcApi.FreePtr.Handle;
            this.pAutoBindHandle             = serverSide ? IntPtr.Zero : handle.Pin <IntPtr>(new IntPtr());
            this.apfnNdrRundownRoutines      = new IntPtr();
            this.aGenericBindingRoutinePairs = new IntPtr();
            this.apfnExprEval                = new IntPtr();
            this.aXmitQuintuple              = new IntPtr();
            this.pFormatTypes                = handle.Pin <byte[]>(formatTypes);
            this.fCheckBounds                = 1;
            this.Version                     = 327682U;
            this.pMallocFreeStruct           = new IntPtr();
            this.MIDLVersion                 = 117441012;
            IntPtr num;

            if (!serverSide)
            {
                num = handle.Pin <COMM_FAULT_OFFSETS>(new COMM_FAULT_OFFSETS()
                {
                    CommOffset  = (short)-1,
                    FaultOffset = (short)-1
                });
            }
            else
            {
                num = IntPtr.Zero;
            }
            this.CommFaultOffsets      = num;
            this.aUserMarshalQuadruple = new IntPtr();
            this.NotifyRoutineTable    = new IntPtr();
            this.mFlags          = new IntPtr(1);
            this.CsRoutineTables = new IntPtr();
            this.ProxyServerInfo = new IntPtr();
            this.pExprInfo       = new IntPtr();
        }
Ejemplo n.º 7
0
        private static byte[] InvokeRpc(RpcHandle handle, Guid iid, byte[] input)
        {
            Ptr <MIDL_STUB_DESC> ptr1;

            if (!handle.GetPtr <Ptr <MIDL_STUB_DESC> >(out ptr1))
            {
                ptr1 = handle.CreatePtr <MIDL_STUB_DESC>(new MIDL_STUB_DESC(handle, handle.Pin <RPC_CLIENT_INTERFACE>(new RPC_CLIENT_INTERFACE(iid)), RpcApi.TYPE_FORMAT, false));
            }
            int    ResponseSize = 0;
            IntPtr Response;
            IntPtr num;

            using (Ptr <byte[]> ptr2 = new Ptr <byte[]>(input))
            {
                if (RpcApi.Is64BitProcess)
                {
                    try
                    {
                        num = RpcClientApi.NdrClientCall2x64(ptr1.Handle, RpcApi.FUNC_FORMAT_PTR.Handle, handle.Handle, input.Length, ptr2.Handle, out ResponseSize, out Response);
                    }
                    catch (SEHException ex)
                    {
                        throw;
                    }
                }
                else
                {
                    using (Ptr <int[]> ptr3 = new Ptr <int[]>(new int[10]))
                    {
                        ptr3.Data[0] = handle.Handle.ToInt32();
                        ptr3.Data[1] = input.Length;
                        ptr3.Data[2] = ptr2.Handle.ToInt32();
                        ptr3.Data[3] = ptr3.Handle.ToInt32() + 24;
                        ptr3.Data[4] = ptr3.Handle.ToInt32() + 32;
                        ptr3.Data[5] = 0;
                        ptr3.Data[6] = 0;
                        ptr3.Data[8] = 0;
                        try
                        {
                            num = RpcClientApi.NdrClientCall2x86(ptr1.Handle, RpcApi.FUNC_FORMAT_PTR.Handle, ptr3.Handle);
                        }
                        catch (SEHException ex)
                        {
                            throw;
                        }
                        ResponseSize = ptr3.Data[6];
                        Response     = new IntPtr(ptr3.Data[8]);
                    }
                }
                GC.KeepAlive((object)ptr2);
            }

            RpcException.Assert(num.ToInt32());
            byte[] destination = new byte[ResponseSize];
            if (ResponseSize > 0 && Response != IntPtr.Zero)
            {
                Marshal.Copy(Response, destination, 0, destination.Length);
            }
            RpcApi.Free(Response);
            return(destination);
        }
Ejemplo n.º 8
0
 private static void BindingSetAuthInfo(RpcProtectionLevel level, RpcAuthentication[] authTypes, RpcHandle handle, string serverPrincipalName, NetworkCredential credentails)
 {
     if (credentails == null)
     {
         foreach (RpcAuthentication AuthnSvc in authTypes)
         {
             int num = (int)RpcClientApi.RpcBindingSetAuthInfo2(handle.Handle, serverPrincipalName, level, AuthnSvc, IntPtr.Zero, 0U);
         }
     }
     else
     {
         SEC_WINNT_AUTH_IDENTITY AuthIdentity = new SEC_WINNT_AUTH_IDENTITY(credentails);
         foreach (RpcAuthentication AuthnSvc in authTypes)
         {
             int num = (int)RpcClientApi.RpcBindingSetAuthInfo(handle.Handle, serverPrincipalName, level, AuthnSvc, ref AuthIdentity, 0U);
         }
     }
 }
Ejemplo n.º 9
0
 private static void BindingFromStringBinding(RpcHandle handle, string bindingString)
 {
     RpcException.Assert(RpcClientApi.RpcBindingFromStringBinding(bindingString, out handle.Handle));
 }
Ejemplo n.º 10
0
        internal static Ptr <RPC_SERVER_INTERFACE> Create(RpcHandle handle, Guid iid, byte[] formatTypes, byte[] formatProc, RpcExecute fnExecute)
        {
            Ptr <MIDL_SERVER_INFO> ptr = handle.CreatePtr <MIDL_SERVER_INFO>(new MIDL_SERVER_INFO());

            return(new MIDL_SERVER_INFO().Configure(handle, ptr, iid, formatTypes, formatProc, fnExecute));
        }