Ejemplo n.º 1
0
        internal XDRPCExecutionState(
            IXboxConsole console,
            XDRPCExecutionOptions options,
            XDRPCArgumentInfo[] arguments,
            XDRPCExecutionState.XDRPCCallFlags flags)
        {
            this.Console     = console;
            this.Options     = options;
            this.ReturnValue = 0UL;
            this.PostMethodCallReturnValue = 0UL;
            this.callFlags = flags;
            List <XDRPCArgumentInfo> xdrpcArgumentInfoList = new List <XDRPCArgumentInfo>();

            for (int index = 0; index < arguments.Length; ++index)
            {
                if (arguments[index].IsFloatingPointValue())
                {
                    xdrpcArgumentInfoList.Add(arguments[index]);
                    arguments[index] = (XDRPCArgumentInfo) new XDRPCNullArgumentInfo();
                }
            }
            this.IntegerArguments       = arguments;
            this.FloatingPointArguments = xdrpcArgumentInfoList.ToArray();
            this.totalArgumentCount     = 0;
            for (int index = 0; index < this.IntegerArguments.Length; ++index)
            {
                this.totalArgumentCount += this.IntegerArguments[index].GetArgumentCount();
            }
            this.bufferData        = (XDRPCExecutionState.ArgumentBufferData[])null;
            this.totalBufferSize   = 0;
            this.connectionId      = 0U;
            this.bufferBaseAddress = 0U;
            this.callData          = (byte[])null;
        }
Ejemplo n.º 2
0
        public static T ExecuteRPC <T>(
            this IXboxConsole console,
            XDRPCExecutionOptions options,
            out ulong postMethodCallReturn,
            params XDRPCArgumentInfo[] args)
            where T : struct
        {
            Type t = typeof(T);

            postMethodCallReturn = 0UL;
            if (!XDRPCMarshaler.IsValidReturnType(t))
            {
                if (!t.IsValueType)
                {
                    throw new XDRPCInvalidReturnTypeException(t);
                }
                XDRPCStructArgumentInfo <T> structArgumentInfo     = new XDRPCStructArgumentInfo <T>(default(T), ArgumentType.Out);
                XDRPCArgumentInfo[]         xdrpcArgumentInfoArray = new XDRPCArgumentInfo[args.Length + 1];
                xdrpcArgumentInfoArray[0] = (XDRPCArgumentInfo)structArgumentInfo;
                Array.Copy((Array)args, 0, (Array)xdrpcArgumentInfoArray, 1, args.Length);
                int num = (int)XDRPCMarshaler.ExecuteRPC <uint>(console, options, xdrpcArgumentInfoArray);
                return(structArgumentInfo.Value);
            }
            XDRPCExecutionState.XDRPCCallFlags flags = XDRPCExecutionState.XDRPCCallFlags.IntegerReturn;
            if (t == typeof(float) || t == typeof(double))
            {
                flags = XDRPCExecutionState.XDRPCCallFlags.FloatingPointReturn;
            }
            XDRPCExecutionState xdrpcExecutionState = new XDRPCExecutionState(console, options, args, flags);

            xdrpcExecutionState.NoDevkit = XDRPCMarshaler.NoDevkit;
            xdrpcExecutionState.Invoke();
            if (options.PostMethodCall != XDRPCPostMethodCall.None)
            {
                postMethodCallReturn = xdrpcExecutionState.PostMethodCallReturnValue;
            }
            object obj = XDRPCMarshaler.UnpackReturnType(t, xdrpcExecutionState.ReturnValue);

            if (obj == null)
            {
                return(default(T));
            }
            return((T)obj);
        }