Example #1
0
 private uint RpcEntryPoint(IntPtr clientHandle, uint szInput, IntPtr input, out uint szOutput, out IntPtr output)
 {
     output   = IntPtr.Zero;
     szOutput = 0U;
     try
     {
         byte[] numArray = new byte[szInput];
         Marshal.Copy(input, numArray, 0, numArray.Length);
         byte[] source;
         using (RpcClientInfo rpcClientInfo = new RpcClientInfo(clientHandle))
             source = this.Execute((IRpcClientInfo)rpcClientInfo, numArray);
         if (source == null)
         {
             return(1715);
         }
         szOutput = (uint)source.Length;
         output   = RpcApi.Alloc(szOutput);
         Marshal.Copy(source, 0, output, source.Length);
         return(0);
     }
     catch (Exception ex)
     {
         RpcApi.Free(output);
         output   = IntPtr.Zero;
         szOutput = 0U;
         return(2147500037);
     }
 }
Example #2
0
 private void RevertToSelf()
 {
     if (this._impersonating)
     {
         // ISSUE: reference to a compiler-generated method
         RpcException.Assert(RpcClientInfo.RpcRevertToSelfEx(this._clientHandle));
     }
     this._impersonating = false;
 }
Example #3
0
 public IDisposable Impersonate()
 {
     if (this._impersonating)
     {
         return((IDisposable) new RpcClientInfo.IgnoreOnDispose());
     }
     if (!this.IsAuthenticated)
     {
         throw new UnauthorizedAccessException();
     }
     // ISSUE: reference to a compiler-generated method
     RpcException.Assert(RpcClientInfo.RpcImpersonateClient(this._clientHandle));
     this._impersonating = true;
     return((IDisposable) new RpcClientInfo.RpcImpersonationContext(this));
 }
Example #4
0
 public RpcImpersonationContext(RpcClientInfo client)
 {
     this._client = client;
 }
Example #5
0
        private RPC_CALL_ATTRIBUTES_V2 GetCallInfo()
        {
            if ((int)this._callAttrs.Version != 0)
            {
                return(this._callAttrs);
            }
            RPC_CALL_ATTRIBUTES_V2 attributes = new RPC_CALL_ATTRIBUTES_V2();

            attributes.Version = 2U;
            attributes.Flags   = RPC_CALL_ATTRIBUTES_FLAGS.RPC_QUERY_NO_AUTH_REQUIRED;
            RpcError rpcError1 = RpcClientInfo.RpcServerInqCallAttributes(this._clientHandle, ref attributes);

            if (rpcError1 == RpcError.RPC_S_INVALID_ARG)
            {
                attributes.Version = 1U;
                rpcError1          = RpcClientInfo.RpcServerInqCallAttributes(this._clientHandle, ref attributes);
            }
            if (rpcError1 == RpcError.RPC_S_OK)
            {
                this._callAttrs       = attributes;
                this._isAuthenticated = false;
                attributes.Flags      = RPC_CALL_ATTRIBUTES_FLAGS.RPC_QUERY_IS_CLIENT_LOCAL | RPC_CALL_ATTRIBUTES_FLAGS.RPC_QUERY_NO_AUTH_REQUIRED;
                RpcError rpcError2;
                if ((rpcError2 = RpcClientInfo.RpcServerInqCallAttributes(this._clientHandle, ref attributes)) == RpcError.RPC_S_OK)
                {
                    this._callAttrs.IsClientLocal = attributes.IsClientLocal;
                    if (this._callAttrs.ProtocolSequence == RpcProtoseqType.LRPC)
                    {
                        attributes.Flags = RPC_CALL_ATTRIBUTES_FLAGS.RPC_QUERY_CLIENT_PID;
                        if ((rpcError2 = RpcClientInfo.RpcServerInqCallAttributes(this._clientHandle, ref attributes)) == RpcError.RPC_S_OK)
                        {
                            this._callAttrs.ClientPID = attributes.ClientPID;
                        }
                    }
                }
                if (this._callAttrs.ProtocolSequence != RpcProtoseqType.LRPC)
                {
                    using (Ptr <byte[]> ptr1 = new Ptr <byte[]>(new byte[1024]))
                    {
                        RPC_CALL_LOCAL_ADDRESS_V1 data = new RPC_CALL_LOCAL_ADDRESS_V1();
                        data.Version       = 1U;
                        data.Buffer        = ptr1.Handle;
                        data.BufferSize    = 1024;
                        data.AddressFormat = RpcLocalAddressFormat.Invalid;
                        this._callAttrs    = attributes;
                        using (Ptr <RPC_CALL_LOCAL_ADDRESS_V1> ptr2 = new Ptr <RPC_CALL_LOCAL_ADDRESS_V1>(data))
                        {
                            attributes.CallLocalAddress = ptr2.Handle;
                            attributes.Flags            = RPC_CALL_ATTRIBUTES_FLAGS.RPC_QUERY_CALL_LOCAL_ADDRESS | RPC_CALL_ATTRIBUTES_FLAGS.RPC_QUERY_NO_AUTH_REQUIRED;
                            if ((rpcError2 = RpcClientInfo.RpcServerInqCallAttributes(this._clientHandle, ref attributes)) == RpcError.RPC_S_OK)
                            {
                                this._clientAddress = new byte[ptr2.Data.BufferSize];
                                Array.Copy((Array)ptr1.Data, (Array)this._clientAddress, this._clientAddress.Length);
                            }
                        }
                    }
                }
                using (Ptr <byte[]> ptr = new Ptr <byte[]>(new byte[1024]))
                {
                    attributes.ClientPrincipalName             = ptr.Handle;
                    attributes.ClientPrincipalNameBufferLength = 1024;
                    attributes.Flags = RPC_CALL_ATTRIBUTES_FLAGS.RPC_QUERY_CLIENT_PRINCIPAL_NAME;
                    if ((rpcError2 = RpcClientInfo.RpcServerInqCallAttributes(this._clientHandle, ref attributes)) == RpcError.RPC_S_OK)
                    {
                        this._clientPrincipalName = Marshal.PtrToStringUni(ptr.Handle);
                        if (!string.IsNullOrEmpty(this._clientPrincipalName))
                        {
                            this._isAuthenticated = true;
                            if ((int)attributes.Version == 1)
                            {
                                this._callAttrs.IsClientLocal = RpcCallClientLocality.Local;
                            }
                        }
                    }
                }
            }
            return(this._callAttrs);
        }