internal static byte[] DoDispatch(byte[] reqStmBuff, SmuggledMethodCallMessage smuggledMcm, out SmuggledMethodReturnMessage smuggledMrm)
 {
     IMessage msg = null;
     if (smuggledMcm != null)
     {
         ArrayList deserializedArgs = smuggledMcm.FixupForNewAppDomain();
         msg = new MethodCall(smuggledMcm, deserializedArgs);
     }
     else
     {
         MemoryStream stm = new MemoryStream(reqStmBuff);
         msg = CrossAppDomainSerializer.DeserializeMessage(stm);
     }
     LogicalCallContext logicalCallContext = CallContext.GetLogicalCallContext();
     logicalCallContext.SetData("__xADCall", true);
     IMessage message2 = ChannelServices.SyncDispatchMessage(msg);
     logicalCallContext.FreeNamedDataSlot("__xADCall");
     smuggledMrm = SmuggledMethodReturnMessage.SmuggleIfPossible(message2);
     if (smuggledMrm != null)
     {
         return null;
     }
     if (message2 == null)
     {
         return null;
     }
     LogicalCallContext context2 = (LogicalCallContext) message2.Properties[Message.CallContextKey];
     if ((context2 != null) && (context2.Principal != null))
     {
         context2.Principal = null;
     }
     return CrossAppDomainSerializer.SerializeMessage(message2).GetBuffer();
 }
 internal MethodCall(SmuggledMethodCallMessage smuggledMsg, ArrayList deserializedArgs)
 {
     this.uri             = smuggledMsg.Uri;
     this.typeName        = smuggledMsg.TypeName;
     this.methodName      = smuggledMsg.MethodName;
     this.methodSignature = (Type[])smuggledMsg.GetMethodSignature(deserializedArgs);
     this.args            = smuggledMsg.GetArgs(deserializedArgs);
     this.instArgs        = smuggledMsg.GetInstantiation(deserializedArgs);
     this.callContext     = smuggledMsg.GetCallContext(deserializedArgs);
     this.ResolveMethod();
     if (smuggledMsg.MessagePropertyCount > 0)
     {
         smuggledMsg.PopulateMessageProperties(this.Properties, deserializedArgs);
     }
 }
        [System.Security.SecurityCritical]  // auto-generated
        internal byte[] DoTransitionDispatch(
            byte[] reqStmBuff,  
            SmuggledMethodCallMessage smuggledMcm,
            out SmuggledMethodReturnMessage smuggledMrm)
        {    
            byte[] retBuff = null;

            Object[] args = new Object[] { reqStmBuff, smuggledMcm, null };
            
            retBuff = (byte[]) Thread.CurrentThread.InternalCrossContextCallback(null, 
                                                              _xadData.ContextID, 
                                                              _xadData.DomainID, 
                                                              s_xctxDel, 
                                                              args);

#if !FEATURE_CORECLR
            Message.DebugOut("#### : changed back to Client Domain " + (Thread.CurrentContext.InternalContextID).ToString("X"));
#endif

            smuggledMrm = (SmuggledMethodReturnMessage) args[2];

            // System.Diagnostics.Debugger.Break();
            return retBuff;
        } // DoTransitionDispatch
        [System.Security.SecurityCritical]  // auto-generated
        internal static byte[] DoDispatch(byte[] reqStmBuff, 
                                          SmuggledMethodCallMessage smuggledMcm,
                                          out SmuggledMethodReturnMessage smuggledMrm)
        {
            //*********************** DE-SERIALIZE REQ-MSG ********************

            IMessage desReqMsg = null;
            
            if (smuggledMcm != null)
            {
                ArrayList deserializedArgs = smuggledMcm.FixupForNewAppDomain();
                desReqMsg = new MethodCall(smuggledMcm, deserializedArgs);
            }
            else
            {
                MemoryStream reqStm = new MemoryStream(reqStmBuff);
                desReqMsg = CrossAppDomainSerializer.DeserializeMessage(reqStm);
            }

            LogicalCallContext lcc = Thread.CurrentThread.GetMutableExecutionContext().LogicalCallContext;
            lcc.SetData(LCC_DATA_KEY, true);
            // now we can delegate to the DispatchMessage to do the rest

            IMessage retMsg = ChannelServices.SyncDispatchMessage(desReqMsg);
            lcc.FreeNamedDataSlot(LCC_DATA_KEY);
            
            smuggledMrm = SmuggledMethodReturnMessage.SmuggleIfPossible(retMsg);
            if (smuggledMrm != null)
            {                
                return null;
            }
            else
            {                
                if (retMsg != null)
                {
                    // Null out the principal since we won't use it on the other side.
                    // This is handled inside of SmuggleIfPossible for method call
                    // messages.
                    LogicalCallContext callCtx = (LogicalCallContext)
                        retMsg.Properties[Message.CallContextKey];
                    if (callCtx != null)
                    {
                        if (callCtx.Principal != null)
                            callCtx.Principal = null;
                    }
                    
                    return CrossAppDomainSerializer.SerializeMessage(retMsg).GetBuffer();
                }
            
                //*********************** SERIALIZE RET-MSG ********************
                return null;
            }
        } // DoDispatch
 internal MethodCall(SmuggledMethodCallMessage smuggledMsg, ArrayList deserializedArgs)
 {
     this.uri = smuggledMsg.Uri;
     this.typeName = smuggledMsg.TypeName;
     this.methodName = smuggledMsg.MethodName;
     this.methodSignature = (Type[]) smuggledMsg.GetMethodSignature(deserializedArgs);
     this.args = smuggledMsg.GetArgs(deserializedArgs);
     this.instArgs = smuggledMsg.GetInstantiation(deserializedArgs);
     this.callContext = smuggledMsg.GetCallContext(deserializedArgs);
     this.ResolveMethod();
     if (smuggledMsg.MessagePropertyCount > 0)
     {
         smuggledMsg.PopulateMessageProperties(this.Properties, deserializedArgs);
     }
 }
Example #6
0
        internal MethodCall(SmuggledMethodCallMessage smuggledMsg, ArrayList deserializedArgs)
        {
            uri = smuggledMsg.Uri;
            typeName = smuggledMsg.TypeName;
            methodName = smuggledMsg.MethodName;
            methodSignature = (Type[])smuggledMsg.GetMethodSignature(deserializedArgs);
            args = smuggledMsg.GetArgs(deserializedArgs);
            callContext = smuggledMsg.GetCallContext(deserializedArgs);
   
            ResolveMethod();

            if (smuggledMsg.MessagePropertyCount > 0)
                smuggledMsg.PopulateMessageProperties(Properties, deserializedArgs);
        }
 internal byte[] DoTransitionDispatch(byte[] reqStmBuff, SmuggledMethodCallMessage smuggledMcm, out SmuggledMethodReturnMessage smuggledMrm)
 {
     byte[] buffer = null;
     object[] objArray2 = new object[3];
     objArray2[0] = reqStmBuff;
     objArray2[1] = smuggledMcm;
     object[] args = objArray2;
     buffer = (byte[]) Thread.CurrentThread.InternalCrossContextCallback(null, this._xadData.ContextID, this._xadData.DomainID, s_xctxDel, args);
     smuggledMrm = (SmuggledMethodReturnMessage) args[2];
     return buffer;
 }
Example #8
0
        } // DoDispatch



        internal byte[] DoTransitionDispatch(
            byte[] reqStmBuff,  
            SmuggledMethodCallMessage smuggledMcm,
            out SmuggledMethodReturnMessage smuggledMrm)
        {    
            // Note: To be safe w.r.t. the app domain leak code, this frame
            // should have no non-agile references in it.

            ContextTransitionFrame frame = new ContextTransitionFrame();

            // change to server domain                  
            Thread.CurrentThread.EnterContextInternal(
                                    null, 
                                    _srvContextID, 
                                    _srvDomainID, 
                                    ref frame);

            byte[] retBuff = null;
            smuggledMrm = null;
            try
            {
                Message.DebugOut("#### : changed to Server Domain :: "+ (Thread.CurrentContext.InternalContextID).ToString("X") );

                retBuff = DoDispatch(reqStmBuff, smuggledMcm, out smuggledMrm);
            }
            catch (Exception e)
            {
                // This will catch exceptions thrown by the infrastructure,
                // Serialization/Deserialization etc
                // Those thrown by the server are already taken care of 
                // and encoded in the retMsg .. so we don't come here for 
                // that case.

                // We are in another appDomain, so we can't simply throw 
                // the exception object across. The following marshals it
                // into a serialized return message. 
                IMessage retMsg = 
                    new ReturnMessage(e, new ErrorMessage());
                //*********************** SERIALIZE RET-MSG ******************
                retBuff = CrossAppDomainSerializer.SerializeMessage(retMsg).GetBuffer(); 
                retMsg = null;
            }
            finally
            {                
                RemotingServices.LogRemotingStage(RemotingServices.SERVER_RET_SEND);
                Thread.CurrentThread.ReturnToContext(ref frame);
                Message.DebugOut("#### : changed back to Client Domain " + (Thread.CurrentContext.InternalContextID).ToString("X"));
            }

            // System.Diagnostics.Debugger.Break();
            return retBuff;
        } // DoTransitionDispatch
Example #9
0
        internal byte[] DoDispatch(byte[] reqStmBuff, 
                                   SmuggledMethodCallMessage smuggledMcm,
                                   out SmuggledMethodReturnMessage smuggledMrm)
        {
            RemotingServices.LogRemotingStage(RemotingServices.SERVER_MSG_DESER);

            //*********************** DE-SERIALIZE REQ-MSG ********************

            IMessage desReqMsg = null;
            
            if (smuggledMcm != null)
            {
                ArrayList deserializedArgs = smuggledMcm.FixupForNewAppDomain();
                desReqMsg = new MethodCall(smuggledMcm, deserializedArgs);
            }
            else
            {
                MemoryStream reqStm = new MemoryStream(reqStmBuff);
                desReqMsg = CrossAppDomainSerializer.DeserializeMessage(reqStm);
            }

            // now we can delegate to the DispatchMessage to do the rest

            RemotingServices.LogRemotingStage(RemotingServices.SERVER_MSG_SINK_CHAIN);

            IMessage retMsg = ChannelServices.SyncDispatchMessage(desReqMsg);

            RemotingServices.LogRemotingStage(RemotingServices.SERVER_RET_SER);

            smuggledMrm = SmuggledMethodReturnMessage.SmuggleIfPossible(retMsg);
            if (smuggledMrm != null)
            {                
                return null;
            }
            else
            {                
                if (retMsg != null)
                {
                    // Null out the principal since we won't use it on the other side.
                    // This is handled inside of SmuggleIfPossible for method call
                    // messages.
                    LogicalCallContext callCtx = (LogicalCallContext)
                        retMsg.Properties[Message.CallContextKey];
                    if (callCtx != null)
                    {
                        if (callCtx.Principal != null)
                            callCtx.Principal = null;
                    }
                }
            
                //*********************** SERIALIZE RET-MSG ********************
                return CrossAppDomainSerializer.SerializeMessage(retMsg).GetBuffer();
            }
        } // DoDispatch