示例#1
0
 public RpcImpersonationContext(RpcClientInfo client)
 {
     _client = client;
 }
示例#2
0
        private void RpcEntryPoint2(IntPtr pAsyncState, IntPtr clientHandle, uint szInput, IntPtr input, out uint szOutput, out IntPtr output)
        {
            Console.WriteLine("RpcEntryPoint2");

              output = IntPtr.Zero;
              szOutput = 0;

              try
              {
            byte[] bytesIn = new byte[szInput];
            Marshal.Copy(input, bytesIn, 0, bytesIn.Length);

            byte[] bytesOut;
            using (RpcClientInfo client = new RpcClientInfo(clientHandle))
            {
              bytesOut = ExecuteAsync(client, pAsyncState, bytesIn);
            }
            if (bytesOut == null)
            {
              var result = (IntPtr)RpcError.RPC_S_NOT_LISTENING;
              RpcApi.RpcAsyncCompleteCall(pAsyncState, ref result);
              return;
            }

            szOutput = (uint)bytesOut.Length;
            output = RpcApi.Alloc(szOutput);
            Marshal.Copy(bytesOut, 0, output, bytesOut.Length);

            var result2 = (IntPtr)RpcError.RPC_S_OK;
            RpcApi.RpcAsyncCompleteCall(pAsyncState, ref result2);
            return;
              }
              catch (Exception ex)
              {
            RpcApi.Free(output);
            output = IntPtr.Zero;
            szOutput = 0;

            Log.Error(ex);
            var result = (IntPtr)RpcError.RPC_S_OK;
            RpcApi.RpcAsyncCompleteCall(pAsyncState, ref result);
            return;
              }
        }
示例#3
0
        private void RpcEntryPoint2(IntPtr pAsyncState, IntPtr clientHandle, uint szInput, IntPtr input, IntPtr szOutput, IntPtr output)
        {
            try
              {
            byte[] bytesIn = new byte[szInput];
            Marshal.Copy(input, bytesIn, 0, bytesIn.Length);
            var asyncContext = new AsyncContextImpl(pAsyncState, szOutput, output);
            try
            {
              using (RpcClientInfo client = new RpcClientInfo(clientHandle))
              {
            ExecuteAsync(client, asyncContext, bytesIn);
              }
            }
            catch (Exception e)
            {
              if (asyncContext.status == AsyncContextStatus.InProgress)
              {
            asyncContext.completeCall((uint) RpcError.RPC_E_FAIL);
              }
            }
              }
              catch (Exception ex)
              {
            if (IntPtr.Zero != output)
            {
              RpcApi.Free(Marshal.ReadIntPtr(output));
            }
            Marshal.WriteIntPtr(output, IntPtr.Zero);
            Marshal.WriteInt32(szOutput, 0);

            Log.Error(ex);

            var result = (IntPtr) RpcError.RPC_E_FAIL;
            RpcApi.RpcAsyncCompleteCall(pAsyncState, ref result);
            return;
              }
        }
示例#4
0
        private uint RpcEntryPoint(IntPtr clientHandle, uint szInput, IntPtr input, out uint szOutput, out IntPtr output)
        {
            output = IntPtr.Zero;
              szOutput = 0;

              try
              {
            byte[] bytesIn = new byte[szInput];
            Marshal.Copy(input, bytesIn, 0, bytesIn.Length);

            byte[] bytesOut;
            using (RpcClientInfo client = new RpcClientInfo(clientHandle))
            {
              bytesOut = Execute(client, bytesIn);
            }
            if (bytesOut == null)
            {
              return (uint)RpcError.RPC_S_NOT_LISTENING;
            }

            szOutput = (uint)bytesOut.Length;
            output = RpcApi.Alloc(szOutput);
            Marshal.Copy(bytesOut, 0, output, bytesOut.Length);

            return (uint)RpcError.RPC_S_OK;
              }
              catch (Exception ex)
              {
            RpcApi.Free(output);
            output = IntPtr.Zero;
            szOutput = 0;

            Log.Error(ex);
            return (uint)RpcError.RPC_E_FAIL;
              }
        }
示例#5
0
 public RpcImpersonationContext(RpcClientInfo client)
 {
     _client = client;
 }