Esempio n. 1
0
 public XDRPCExecutionOptions(
     XDRPCMode mode,
     uint functionAddress,
     XDRPCPostMethodCall postMethodCall)
     : this(mode, string.Empty, string.Empty, 0, functionAddress, postMethodCall)
 {
 }
Esempio n. 2
0
 private XDRPCExecutionOptions(
     XDRPCMode mode,
     string threadName,
     string module,
     string functionName,
     int ordinal,
     uint functionAddress,
     uint processor,
     XDRPCPostMethodCall postMethodCall,
     TimeSpan executionTimeoutPeriod)
 {
     this.Mode = mode;
     if (!string.IsNullOrEmpty(module))
     {
         this.moduleInfo   = (XDRPCArgumentInfo) new XDRPCStringArgumentInfo(module, Encoding.ASCII, ArgumentType.ByRef);
         this.functionInfo = !string.IsNullOrEmpty(functionName) ? (XDRPCArgumentInfo) new XDRPCStringArgumentInfo(functionName, Encoding.ASCII, ArgumentType.ByRef) : (XDRPCArgumentInfo) new XDRPCArgumentInfo <int>(ordinal);
     }
     else
     {
         this.moduleInfo   = (XDRPCArgumentInfo) new XDRPCNullArgumentInfo();
         this.functionInfo = (XDRPCArgumentInfo) new XDRPCArgumentInfo <uint>(functionAddress);
     }
     this.FunctionName           = functionName;
     this.ModuleName             = module;
     this.Ordinal                = ordinal;
     this.FunctionAddress        = functionAddress;
     this.Processor              = processor;
     this.PostMethodCall         = postMethodCall;
     this.ThreadName             = threadName;
     this.ExecutionTimeoutPeriod = executionTimeoutPeriod;
 }
Esempio n. 3
0
 public XDRPCExecutionOptions(
     XDRPCMode mode,
     uint functionAddress,
     TimeSpan executionTimeoutPeriod)
     : this(mode, string.Empty, string.Empty, 0, functionAddress, XDRPCPostMethodCall.None, executionTimeoutPeriod)
 {
 }
Esempio n. 4
0
        public static TDelegate CreateDelegate <TDelegate>(
            this IXboxConsole console,
            XDRPCMode mode,
            string module,
            int ordinal)
        {
            if (!typeof(Delegate).IsAssignableFrom(typeof(TDelegate)))
            {
                throw new XDRPCInvalidArgumentTypeException(typeof(TDelegate), -1);
            }
            MethodInfo method = typeof(TDelegate).GetMethod("Invoke");

            Expression[] array = (Expression[])((IEnumerable <ParameterExpression>)((IEnumerable <ParameterInfo>)method.GetParameters()).Select <ParameterInfo, ParameterExpression>((Func <ParameterInfo, ParameterExpression>)(paramInfo => Expression.Parameter(paramInfo.ParameterType, paramInfo.Name))).ToArray <ParameterExpression>()).Select <ParameterExpression, UnaryExpression>((Func <ParameterExpression, UnaryExpression>)(paramInfo => Expression.Convert((Expression)paramInfo, typeof(object)))).ToArray <UnaryExpression>();
            Type         type  = method.ReturnType;

            if (method.ReturnType == typeof(void))
            {
                type = typeof(uint);
            }
            return(((Expression <TDelegate>)(() => Expression.Call(typeof(XDRPCMarshaler).GetMethod("ExecuteRPC", new Type[5]
            {
                typeof(IXboxConsole),
                typeof(XDRPCMode),
                typeof(string),
                typeof(int),
                typeof(object[])
            }).MakeGenericMethod(type), (Expression)Expression.Constant((object)console), (Expression)Expression.Constant((object)mode), (Expression)Expression.Constant((object)module), (Expression)Expression.Constant((object)ordinal), (Expression)Expression.NewArrayInit(typeof(object), array)))).Compile());
        }
Esempio n. 5
0
 public XDRPCExecutionOptions(
     XDRPCMode mode,
     string module,
     string functionName,
     XDRPCPostMethodCall postMethodCall)
     : this(mode, module, functionName, 0, 0U, postMethodCall)
 {
 }
Esempio n. 6
0
 public XDRPCExecutionOptions(
     XDRPCMode mode,
     string module,
     int ordinal,
     TimeSpan executionTimeoutPeriod)
     : this(mode, module, string.Empty, ordinal, 0U, XDRPCPostMethodCall.None, executionTimeoutPeriod)
 {
 }
Esempio n. 7
0
 public XDRPCExecutionOptions(
     XDRPCMode mode,
     string module,
     int ordinal,
     XDRPCPostMethodCall postMethodCall)
     : this(mode, module, string.Empty, ordinal, 0U, postMethodCall)
 {
 }
Esempio n. 8
0
 public XDRPCExecutionOptions(
     XDRPCMode mode,
     string module,
     string functionName,
     TimeSpan executionTimeoutPeriod)
     : this(mode, module, functionName, 0, 0U, XDRPCPostMethodCall.None, executionTimeoutPeriod)
 {
 }
Esempio n. 9
0
 public XDRPCExecutionOptions(
     XDRPCMode mode,
     string module,
     string functionName,
     uint processor)
     : this(mode, module, functionName, 0, 0U, processor, XDRPCPostMethodCall.None)
 {
 }
Esempio n. 10
0
 private XDRPCExecutionOptions(
     XDRPCMode mode,
     string module,
     string functionName,
     int ordinal,
     uint functionAddress)
     : this(mode, module, functionName, ordinal, functionAddress, 5U, XDRPCPostMethodCall.None, XDRPCExecutionOptions.DefaultTimeoutPeriod)
 {
 }
Esempio n. 11
0
 public XDRPCExecutionOptions(
     XDRPCMode mode,
     uint functionAddress,
     uint processor,
     XDRPCPostMethodCall postMethodCall,
     TimeSpan executionTimeoutPeriod)
     : this(mode, string.Empty, string.Empty, 0, functionAddress, processor, postMethodCall, executionTimeoutPeriod)
 {
 }
Esempio n. 12
0
 private XDRPCExecutionOptions(
     XDRPCMode mode,
     string module,
     string functionName,
     int ordinal,
     uint functionAddress,
     XDRPCPostMethodCall postMethodCall)
     : this(mode, module, functionName, ordinal, functionAddress, 5U, postMethodCall)
 {
 }
Esempio n. 13
0
 public XDRPCExecutionOptions(
     XDRPCMode mode,
     string module,
     int ordinal,
     uint processor,
     XDRPCPostMethodCall postMethodCall,
     TimeSpan executionTimeoutPeriod)
     : this(mode, module, string.Empty, ordinal, 0U, processor, postMethodCall, executionTimeoutPeriod)
 {
 }
Esempio n. 14
0
 public XDRPCExecutionOptions(
     XDRPCMode mode,
     string module,
     string functionName,
     uint processor,
     XDRPCPostMethodCall postMethodCall,
     TimeSpan executionTimeoutPeriod)
     : this(mode, module, functionName, 0, 0U, processor, postMethodCall, executionTimeoutPeriod)
 {
 }
Esempio n. 15
0
 private XDRPCExecutionOptions(
     XDRPCMode mode,
     string module,
     string functionName,
     int ordinal,
     uint functionAddress,
     uint processor,
     XDRPCPostMethodCall postMethodCall)
     : this(mode, string.Empty, module, functionName, ordinal, functionAddress, 5U, postMethodCall, XDRPCExecutionOptions.DefaultTimeoutPeriod)
 {
 }
Esempio n. 16
0
 private XDRPCExecutionOptions(
     XDRPCMode mode,
     string module,
     string functionName,
     int ordinal,
     uint functionAddress,
     uint processor,
     TimeSpan executionTimeoutPeriod)
     : this(mode, string.Empty, module, functionName, ordinal, functionAddress, 5U, XDRPCPostMethodCall.None, executionTimeoutPeriod)
 {
 }
Esempio n. 17
0
 private XDRPCExecutionOptions(
     XDRPCMode mode,
     string module,
     string functionName,
     int ordinal,
     uint functionAddress,
     XDRPCPostMethodCall postMethodCall,
     TimeSpan executionTimeoutPeriod)
     : this(mode, module, functionName, ordinal, functionAddress, 5U, postMethodCall, executionTimeoutPeriod)
 {
 }
Esempio n. 18
0
        public static T ExecuteRPC <T>(
            this IXboxConsole console,
            XDRPCMode mode,
            uint functionAddress,
            params object[] args)
            where T : struct
        {
            XDRPCExecutionOptions options = new XDRPCExecutionOptions(mode, functionAddress);

            XDRPCArgumentInfo[] argumentInfoArray = XDRPCMarshaler.GenerateArgumentInfoArray(args);
            return(XDRPCMarshaler.ExecuteRPC <T>(console, options, argumentInfoArray));
        }
Esempio n. 19
0
        public static T ExecuteRPC <T>(
            this IXboxConsole console,
            XDRPCMode mode,
            string module,
            int ordinal,
            params object[] args)
            where T : struct
        {
            XDRPCExecutionOptions options = new XDRPCExecutionOptions(mode, module, ordinal);

            XDRPCArgumentInfo[] argumentInfoArray = XDRPCMarshaler.GenerateArgumentInfoArray(args);
            return(XDRPCMarshaler.ExecuteRPC <T>(console, options, argumentInfoArray));
        }
Esempio n. 20
0
 public static XDRPCReference AllocateRPC(
     this IXboxConsole console,
     XDRPCArgumentInfo lpvBufArg,
     XDRPCMode mode)
 {
     if (lpvBufArg.PassBy == ArgumentType.ByValue)
     {
         throw new XDRPCInvalidOperationException("Allocating XDRPCArgumentInfo with ByValue argument type is not allowed.");
     }
     if (lpvBufArg.GetRequiredReferenceSize() > 0)
     {
         throw new XDRPCInvalidOperationException("Struct type containing references is not supported by the XDRPC allocation system. You will need to use the XDRPC allocation system to create the data for the references on the Xbox and change the struct to have uints filled with the XDRPCReference.Pointer values for that data instead of the references. See the How to Use XDRPC documentation for more info.");
     }
     return(console.AllocateRPC(lpvBufArg.GetRequiredBufferSize(), mode));
 }
Esempio n. 21
0
        public static XDRPCReference AllocateRPC <T>(
            this IXboxConsole console,
            XDRPCMode mode)
            where T : struct
        {
            Type t = typeof(T);

            if (!XDRPCMarshaler.IsValidArgumentType(t))
            {
                throw new XDRPCInvalidTypeException(t, string.Format("Invalid type {0}: Cannot allocate type not supported by XDRPC.", (object)t.Name));
            }
            XDRPCArgumentInfo argumentInfo = XDRPCMarshaler.GenerateArgumentInfo(t, (object)default(T), ArgumentType.ByRef);

            return(console.AllocateRPC(argumentInfo, mode));
        }
Esempio n. 22
0
        public static XDRPCReference AllocateRPC(
            this IXboxConsole console,
            int size,
            XDRPCMode mode)
        {
            if (size == 0)
            {
                throw new XDRPCInvalidOperationException("Allocating size of 0 is not allowed.");
            }
            uint pointer = console.ExecuteRPC <uint>(mode, "xbdm.xex", 1, (object)size);

            if (pointer == 0U)
            {
                throw new XDRPCException("Failed allocation: null pointer was returned.");
            }
            return(new XDRPCReference(console, pointer, size)
            {
                XDRPCManaged = true
            });
        }
Esempio n. 23
0
        public static TDelegate CreateDelegate <TDelegate>(IXboxConsole console, XDRPCMode mode, string module, int ordinal)
        {
            if (!typeof(Delegate).IsAssignableFrom(typeof(TDelegate)))
            {
                throw new XDRPCInvalidArgumentTypeException(typeof(TDelegate), -1);
            }
            MethodInfo method = typeof(TDelegate).GetMethod("Invoke");

            ParameterExpression[] parameters   = (from paramInfo in method.GetParameters() select Expression.Parameter(paramInfo.ParameterType, paramInfo.Name)).ToArray <ParameterExpression>();
            Expression[]          initializers = (from paramInfo in parameters select Expression.Convert(paramInfo, typeof(object))).ToArray <UnaryExpression>();
            Type returnType = method.ReturnType;

            if (method.ReturnType == typeof(void))
            {
                returnType = typeof(uint);
            }
            MethodInfo info2 = typeof(XDRPCMarshaler).GetMethod("ExecuteRPC", new Type[] { typeof(IXboxConsole), typeof(XDRPCMode), typeof(string), typeof(int), typeof(object[]) }).MakeGenericMethod(new Type[] { returnType });

            Expression[] arguments = new Expression[] { Expression.Constant(console), Expression.Constant(mode), Expression.Constant(module), Expression.Constant(ordinal), Expression.NewArrayInit(typeof(object), initializers) };
            return(Expression.Lambda <TDelegate>(Expression.Call(info2, arguments), parameters).Compile());
        }
Esempio n. 24
0
 public XDRPCExecutionOptions(XDRPCMode mode, uint functionAddress, uint processor)
     : this(mode, string.Empty, string.Empty, 0, functionAddress, processor, XDRPCPostMethodCall.None)
 {
 }
Esempio n. 25
0
 public XDRPCExecutionOptions(XDRPCMode mode, string module, int ordinal, uint processor)
     : this(mode, module, string.Empty, ordinal, 0U, processor, XDRPCPostMethodCall.None)
 {
 }
Esempio n. 26
0
 public XDRPCExecutionOptions(XDRPCMode mode, string module, string functionName)
     : this(mode, module, functionName, 0, 0U)
 {
 }
Esempio n. 27
0
 public XDRPCExecutionOptions(XDRPCMode mode, uint functionAddress)
     : this(mode, string.Empty, string.Empty, 0, functionAddress)
 {
 }
Esempio n. 28
0
 public XDRPCExecutionOptions(XDRPCMode mode, string module, int ordinal)
     : this(mode, module, string.Empty, ordinal, 0U)
 {
 }