private void CreateCallDataBufferLayout() { int num1 = XDRPCExecutionState.ArgumentSize * (8 + this.totalArgumentCount + this.FloatingPointArguments.Length); int num2 = 2; this.bufferData = new XDRPCExecutionState.ArgumentBufferData[this.IntegerArguments.Length + num2]; this.referenceData = new XDRPCExecutionState.ArgumentBufferData[this.IntegerArguments.Length]; int currOffset = num1; for (int index = 0; index < this.IntegerArguments.Length + num2; ++index) { XDRPCExecutionState.ArgumentBufferData argumentBufferData = new XDRPCExecutionState.ArgumentBufferData(); argumentBufferData.BufferOffset = currOffset; argumentBufferData.BufferSize = index >= num2 ? this.IntegerArguments[index - num2].GetRequiredBufferSize() : this.Options.GetRequiredBufferSize(index); currOffset += argumentBufferData.BufferSize; XDRPCExecutionState.AlignBufferOffset(ref currOffset); this.bufferData[index] = argumentBufferData; } for (int index = 0; index < this.IntegerArguments.Length; ++index) { XDRPCExecutionState.ArgumentBufferData argumentBufferData = new XDRPCExecutionState.ArgumentBufferData(); argumentBufferData.BufferOffset = currOffset; argumentBufferData.BufferSize = this.IntegerArguments[index].GetRequiredReferenceSize(); currOffset += argumentBufferData.BufferSize; XDRPCExecutionState.AlignBufferOffset(ref currOffset); this.referenceData[index] = argumentBufferData; } this.totalBufferSize = currOffset; }
private XDRPCArrayArgumentInfo <T> .ArrayElementData GenerateArrayBufferData( XDRPCArgumentInfo info, ref int referenceOffset) { XDRPCArrayArgumentInfo <T> .ArrayElementData arrayElementData = new XDRPCArrayArgumentInfo <T> .ArrayElementData(); arrayElementData.Info = info; arrayElementData.ReferenceOffset = referenceOffset; arrayElementData.ReferenceSize = info.GetRequiredReferenceSize(); referenceOffset += arrayElementData.ReferenceSize; XDRPCExecutionState.AlignBufferOffset(ref referenceOffset); return(arrayElementData); }
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); }