コード例 #1
0
        private static string StringBindingCompose(RpcProtseq ProtSeq, string NetworkAddr, string Endpoint, string Options)
        {
            IntPtr lpBindingString;

            RpcException.Assert(RpcClientApi.RpcStringBindingCompose((string)null, ProtSeq.ToString(), NetworkAddr, Endpoint, Options, out lpBindingString));
            try
            {
                return(Marshal.PtrToStringUni(lpBindingString));
            }
            finally
            {
                RpcException.Assert(RpcClientApi.RpcStringFree(ref lpBindingString));
            }
        }
コード例 #2
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);
         }
     }
 }
コード例 #3
0
 private void Connect()
 {
     RpcClientApi.BindingFromStringBinding(this._handle, this._binding);
 }
コード例 #4
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);
        }
コード例 #5
0
 private static void BindingFromStringBinding(RpcHandle handle, string bindingString)
 {
     RpcException.Assert(RpcClientApi.RpcBindingFromStringBinding(bindingString, out handle.Handle));
 }