public AddArguments ( System arguments, System requiredCustomModifiers, System optionalCustomModifiers ) : void | ||
arguments | System | |
requiredCustomModifiers | System | |
optionalCustomModifiers | System | |
Результат | void |
internal static SignatureHelper GetMethodSigHelper( Module?scope, CallingConventions callingConvention, int cGenericParam, Type?returnType, Type[]?requiredReturnTypeCustomModifiers, Type[]?optionalReturnTypeCustomModifiers, Type[]?parameterTypes, Type[][]?requiredParameterTypeCustomModifiers, Type[][]?optionalParameterTypeCustomModifiers) { SignatureHelper sigHelp; MdSigCallingConvention intCall; returnType ??= typeof(void); intCall = MdSigCallingConvention.Default; if ((callingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs) { intCall = MdSigCallingConvention.Vararg; } if (cGenericParam > 0) { intCall |= MdSigCallingConvention.Generic; } if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis) { intCall |= MdSigCallingConvention.HasThis; } sigHelp = new SignatureHelper(scope, intCall, cGenericParam, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); return(sigHelp); }
public static SignatureHelper GetPropertySigHelper(Module mod, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { if (returnType == null) { returnType = typeof(void); } System.Reflection.MdSigCallingConvention convention = System.Reflection.MdSigCallingConvention.Default | System.Reflection.MdSigCallingConvention.Property; if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis) { convention = (System.Reflection.MdSigCallingConvention)((byte)(convention | (System.Reflection.MdSigCallingConvention.Default | System.Reflection.MdSigCallingConvention.HasThis))); } SignatureHelper helper = new SignatureHelper(mod, convention, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); helper.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); return(helper); }
public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { SignatureHelper sigHelp; if (returnType == null) { returnType = typeof(void); } sigHelp = new SignatureHelper(mod, IMAGE_CEE_CS_CALLCONV_PROPERTY, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); return(sigHelp); }
public static SignatureHelper GetPropertySigHelper(Module?mod, CallingConventions callingConvention, Type?returnType, Type[]?requiredReturnTypeCustomModifiers, Type[]?optionalReturnTypeCustomModifiers, Type[]?parameterTypes, Type[][]?requiredParameterTypeCustomModifiers, Type[][]?optionalParameterTypeCustomModifiers) { SignatureHelper sigHelp; returnType ??= typeof(void); MdSigCallingConvention intCall = MdSigCallingConvention.Property; if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis) { intCall |= MdSigCallingConvention.HasThis; } sigHelp = new SignatureHelper(mod, intCall, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); return(sigHelp); }
internal static SignatureHelper GetMethodSigHelper( Module scope, CallingConventions callingConvention, int cGenericParam, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { SignatureHelper sigHelp; int intCall; if (returnType == null) { returnType = typeof(void); } intCall = IMAGE_CEE_CS_CALLCONV_DEFAULT; if ((callingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs) { intCall = IMAGE_CEE_CS_CALLCONV_VARARG; } if (cGenericParam > 0) { intCall |= IMAGE_CEE_CS_CALLCONV_GENERIC; } if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis) { intCall |= IMAGE_CEE_CS_CALLCONV_HASTHIS; } sigHelp = new SignatureHelper(scope, intCall, cGenericParam, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); return(sigHelp); }
internal static SignatureHelper GetMethodSigHelper(Module scope, CallingConventions callingConvention, int cGenericParam, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { if (returnType == null) { returnType = typeof(void); } System.Reflection.MdSigCallingConvention convention = System.Reflection.MdSigCallingConvention.Default; if ((callingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs) { convention = System.Reflection.MdSigCallingConvention.C | System.Reflection.MdSigCallingConvention.FastCall; } if (cGenericParam > 0) { convention = (System.Reflection.MdSigCallingConvention)((byte)(convention | (System.Reflection.MdSigCallingConvention.Default | System.Reflection.MdSigCallingConvention.Generic))); } if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis) { convention = (System.Reflection.MdSigCallingConvention)((byte)(convention | (System.Reflection.MdSigCallingConvention.Default | System.Reflection.MdSigCallingConvention.HasThis))); } SignatureHelper helper = new SignatureHelper(scope, convention, cGenericParam, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); helper.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); return(helper); }
private static IDispatchInvokeDelegate Create_IDispatchInvoke(bool returnResult) { const int dispatchPointerIndex = 0; const int memberDispIdIndex = 1; const int flagsIndex = 2; const int dispParamsIndex = 3; const int resultIndex = 4; const int exceptInfoIndex = 5; const int argErrIndex = 6; Debug.Assert(argErrIndex + 1 == typeof(IDispatchInvokeDelegate).GetMethod("Invoke").GetParameters().Length); Type[] paramTypes = new Type[argErrIndex + 1]; paramTypes[dispatchPointerIndex] = typeof(IntPtr); paramTypes[memberDispIdIndex] = typeof(int); paramTypes[flagsIndex] = typeof(ComTypes.INVOKEKIND); paramTypes[dispParamsIndex] = typeof(ComTypes.DISPPARAMS).MakeByRefType(); paramTypes[resultIndex] = typeof(Variant).MakeByRefType(); paramTypes[exceptInfoIndex] = typeof(ExcepInfo).MakeByRefType(); paramTypes[argErrIndex] = typeof(uint).MakeByRefType(); // Define the dynamic method in our assembly so we skip verification DynamicMethod dm = new DynamicMethod("IDispatchInvoke", typeof(int), paramTypes, DynamicModule); ILGenerator method = dm.GetILGenerator(); // return functionPtr(...) EmitLoadArg(method, dispatchPointerIndex); EmitLoadArg(method, memberDispIdIndex); // burn the address of our empty IID in directly. This is never freed, relocated, etc... // Note passing this as a Guid directly results in a ~30% perf hit for IDispatch invokes so // we also pass it directly as an IntPtr instead. if (IntPtr.Size == 4) { method.Emit(OpCodes.Ldc_I4, UnsafeMethods.NullInterfaceId.ToInt32()); // riid } else { method.Emit(OpCodes.Ldc_I8, UnsafeMethods.NullInterfaceId.ToInt64()); // riid } method.Emit(OpCodes.Conv_I); method.Emit(OpCodes.Ldc_I4_0); // lcid EmitLoadArg(method, flagsIndex); EmitLoadArg(method, dispParamsIndex); if (returnResult) { EmitLoadArg(method, resultIndex); } else { method.Emit(OpCodes.Ldsfld, typeof(IntPtr).GetField("Zero")); } EmitLoadArg(method, exceptInfoIndex); EmitLoadArg(method, argErrIndex); // functionPtr = *(IntPtr*)(*(dispatchPointer) + VTABLE_OFFSET) int idispatchInvokeOffset = ((int)IDispatchMethodIndices.IDispatch_Invoke) * Marshal.SizeOf(typeof(IntPtr)); EmitLoadArg(method, dispatchPointerIndex); method.Emit(OpCodes.Ldind_I); method.Emit(OpCodes.Ldc_I4, idispatchInvokeOffset); method.Emit(OpCodes.Add); method.Emit(OpCodes.Ldind_I); System.Reflection.Emit.SignatureHelper signature = System.Reflection.Emit.SignatureHelper.GetMethodSigHelper(CallingConvention.Winapi, typeof(int)); Type[] invokeParamTypes = new Type[] { typeof(IntPtr), // dispatchPointer typeof(int), // memberDispId typeof(IntPtr), // riid typeof(int), // lcid typeof(ushort), // flags typeof(IntPtr), // dispParams typeof(IntPtr), // result typeof(IntPtr), // excepInfo typeof(IntPtr), // argErr }; signature.AddArguments(invokeParamTypes, null, null); method.Emit(OpCodes.Calli, signature); method.Emit(OpCodes.Ret); return((IDispatchInvokeDelegate)dm.CreateDelegate(typeof(IDispatchInvokeDelegate))); }
internal static SignatureHelper GetMethodSigHelper( Module scope, CallingConventions callingConvention, int cGenericParam, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { SignatureHelper sigHelp; MdSigCallingConvention intCall; if (returnType == null) { returnType = typeof(void); } intCall = MdSigCallingConvention.Default; if ((callingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs) intCall = MdSigCallingConvention.Vararg; if (cGenericParam > 0) { intCall |= MdSigCallingConvention.Generic; } if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis) intCall |= MdSigCallingConvention.HasThis; sigHelp = new SignatureHelper(scope, intCall, cGenericParam, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); return sigHelp; }
public static SignatureHelper GetPropertySigHelper(Module mod, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { SignatureHelper sigHelp; if (returnType == null) { returnType = typeof(void); } MdSigCallingConvention intCall = MdSigCallingConvention.Property; if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis) intCall |= MdSigCallingConvention.HasThis; sigHelp = new SignatureHelper(mod, intCall, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); return sigHelp; }
public static SignatureHelper GetPropertySigHelper(Module mod, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { if (returnType == null) { returnType = typeof(void); } System.Reflection.MdSigCallingConvention convention = System.Reflection.MdSigCallingConvention.Default | System.Reflection.MdSigCallingConvention.Property; if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis) { convention = (System.Reflection.MdSigCallingConvention) ((byte) (convention | (System.Reflection.MdSigCallingConvention.Default | System.Reflection.MdSigCallingConvention.HasThis))); } SignatureHelper helper = new SignatureHelper(mod, convention, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); helper.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); return helper; }
internal static SignatureHelper GetMethodSigHelper(Module scope, CallingConventions callingConvention, int cGenericParam, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { if (returnType == null) { returnType = typeof(void); } System.Reflection.MdSigCallingConvention convention = System.Reflection.MdSigCallingConvention.Default; if ((callingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs) { convention = System.Reflection.MdSigCallingConvention.C | System.Reflection.MdSigCallingConvention.FastCall; } if (cGenericParam > 0) { convention = (System.Reflection.MdSigCallingConvention) ((byte) (convention | (System.Reflection.MdSigCallingConvention.Default | System.Reflection.MdSigCallingConvention.Generic))); } if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis) { convention = (System.Reflection.MdSigCallingConvention) ((byte) (convention | (System.Reflection.MdSigCallingConvention.Default | System.Reflection.MdSigCallingConvention.HasThis))); } SignatureHelper helper = new SignatureHelper(scope, convention, cGenericParam, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); helper.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); return helper; }
public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { SignatureHelper sigHelp; if (returnType == null) { returnType = typeof(void); } sigHelp = new SignatureHelper(mod, IMAGE_CEE_CS_CALLCONV_PROPERTY, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); return sigHelp; }
internal static SignatureHelper GetMethodSigHelper( Module scope, CallingConventions callingConvention, int cGenericParam, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { SignatureHelper sigHelp; int intCall; if (returnType == null) { returnType = typeof(void); } intCall = IMAGE_CEE_CS_CALLCONV_DEFAULT; if ((callingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs) intCall = IMAGE_CEE_CS_CALLCONV_VARARG; if (cGenericParam > 0) { intCall |= IMAGE_CEE_CS_CALLCONV_GENERIC; } if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis) intCall |= IMAGE_CEE_CS_CALLCONV_HASTHIS; sigHelp = new SignatureHelper(scope, intCall, cGenericParam, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); return sigHelp; }