本文整理汇总了C#中System.Reflection.RuntimeModule.GetNativeHandle方法的典型用法代码示例。如果您正苦于以下问题:C# RuntimeModule.GetNativeHandle方法的具体用法?C# RuntimeModule.GetNativeHandle怎么用?C# RuntimeModule.GetNativeHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.RuntimeModule
的用法示例。
在下文中一共展示了RuntimeModule.GetNativeHandle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPropertyOrFieldData
[System.Security.SecurityCritical] // auto-generated
private unsafe static void GetPropertyOrFieldData(
RuntimeModule module, ref IntPtr blobStart, IntPtr blobEnd, out string name, out bool isProperty, out RuntimeType type, out object value)
{
byte* pBlobStart = (byte*)blobStart;
_GetPropertyOrFieldData(
module.GetNativeHandle(), &pBlobStart, (byte*)blobEnd, out name, out isProperty, out type, out value);
blobStart = (IntPtr)pBlobStart;
}
示例2: GetSecurityAttributes
[System.Security.SecurityCritical] // auto-generated
unsafe internal static void GetSecurityAttributes(RuntimeModule module, int token, bool assembly, out object[] securityAttributes)
{
_GetSecurityAttributes(module.GetNativeHandle(), token, assembly, out securityAttributes);
}
示例3: GetMetadataImport
[System.Security.SecurityCritical] // auto-generated
internal static MetadataImport GetMetadataImport(RuntimeModule module)
{
return new MetadataImport(_GetMetadataImport(module.GetNativeHandle()), module);
}
示例4: FilterCustomAttributeRecord
private static unsafe bool FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, ref Assembly lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, bool mustBeInheritable, object[] attributes, IList derivedAttributes, out RuntimeType attributeType, out IRuntimeMethodInfo ctor, out bool ctorHasParameters, out bool isVarArg)
{
ctor = null;
attributeType = null;
ctorHasParameters = false;
isVarArg = false;
IntPtr ptr1 = (IntPtr) (((void*) caRecord.blob.Signature) + caRecord.blob.Length);
attributeType = decoratedModule.ResolveType(scope.GetParentToken((int) caRecord.tkCtor), null, null) as RuntimeType;
if (!attributeFilterType.IsAssignableFrom(attributeType))
{
return false;
}
if (!AttributeUsageCheck(attributeType, mustBeInheritable, attributes, derivedAttributes))
{
return false;
}
RuntimeAssembly targetAssembly = (RuntimeAssembly) attributeType.Assembly;
RuntimeAssembly assembly = (RuntimeAssembly) decoratedModule.Assembly;
if ((targetAssembly != lastAptcaOkAssembly) && !RuntimeAssembly.AptcaCheck(targetAssembly, assembly))
{
return false;
}
lastAptcaOkAssembly = assembly;
ConstArray methodSignature = scope.GetMethodSignature(caRecord.tkCtor);
isVarArg = (methodSignature[0] & 5) != 0;
ctorHasParameters = methodSignature[1] != 0;
if (ctorHasParameters)
{
ctor = ModuleHandle.ResolveMethodHandleInternal(decoratedModule.GetNativeHandle(), (int) caRecord.tkCtor);
}
else
{
ctor = attributeType.GetTypeHandleInternal().GetDefaultConstructor();
if ((ctor == null) && !attributeType.IsValueType)
{
throw new MissingMethodException(".ctor");
}
}
if (ctor == null)
{
if (!attributeType.IsVisible && !attributeType.TypeHandle.IsVisibleFromModule(decoratedModule))
{
return false;
}
return true;
}
if (RuntimeMethodHandle.IsVisibleFromModule(ctor, decoratedModule))
{
return true;
}
MetadataToken token = new MetadataToken();
if (decoratedToken.IsParamDef)
{
token = new MetadataToken(scope.GetParentToken((int) decoratedToken));
token = new MetadataToken(scope.GetParentToken((int) token));
}
else if ((decoratedToken.IsMethodDef || decoratedToken.IsProperty) || (decoratedToken.IsEvent || decoratedToken.IsFieldDef))
{
token = new MetadataToken(scope.GetParentToken((int) decoratedToken));
}
else if (decoratedToken.IsTypeDef)
{
token = decoratedToken;
}
return (token.IsTypeDef && RuntimeMethodHandle.IsVisibleFromType(ctor, decoratedModule.ModuleHandle.ResolveTypeHandle((int) token)));
}
示例5: ContainsPropertyMatchingHash
[System.Security.SecurityCritical] // auto-generated
internal static bool ContainsPropertyMatchingHash(RuntimeModule module, int propertyToken, uint hash)
{
return _ContainsPropertyMatchingHash(module.GetNativeHandle(), propertyToken, hash);
}
示例6: GetModuleType
[System.Security.SecuritySafeCritical] // auto-generated
internal static RuntimeType GetModuleType(RuntimeModule module)
{
RuntimeType type = null;
GetModuleType(module.GetNativeHandle(), JitHelpers.GetObjectHandleOnStack(ref type));
return type;
}
示例7: GetModuleType
internal static RuntimeType GetModuleType(RuntimeModule module)
{
RuntimeType result = null;
ModuleHandle.GetModuleType(module.GetNativeHandle(), JitHelpers.GetObjectHandleOnStack<RuntimeType>(ref result));
return result;
}
示例8: ResolveMethodHandleInternalCore
[System.Security.SecurityCritical] // auto-generated
internal static RuntimeMethodHandleInternal ResolveMethodHandleInternalCore(RuntimeModule module, int methodToken, IntPtr[] typeInstantiationContext, int typeInstCount, IntPtr[] methodInstantiationContext, int methodInstCount)
{
ValidateModulePointer(module);
if (!ModuleHandle.GetMetadataImport(module.GetNativeHandle()).IsValidToken(methodToken))
throw new ArgumentOutOfRangeException("metadataToken",
Environment.GetResourceString("Argument_InvalidToken", methodToken, new ModuleHandle(module)));
fixed (IntPtr* typeInstArgs = typeInstantiationContext, methodInstArgs = methodInstantiationContext)
{
return ResolveMethod(module.GetNativeHandle(), methodToken, typeInstArgs, typeInstCount, methodInstArgs, methodInstCount);
}
}
示例9: ResolveFieldHandleInternal
internal unsafe static IRuntimeFieldInfo ResolveFieldHandleInternal(RuntimeModule module, int fieldToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
{
ModuleHandle.ValidateModulePointer(module);
if (!ModuleHandle.GetMetadataImport(module.GetNativeHandle()).IsValidToken(fieldToken))
{
throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", new object[]
{
fieldToken,
new ModuleHandle(module)
}));
}
int typeInstCount;
IntPtr[] array = RuntimeTypeHandle.CopyRuntimeTypeHandles(typeInstantiationContext, out typeInstCount);
int methodInstCount;
IntPtr[] array2 = RuntimeTypeHandle.CopyRuntimeTypeHandles(methodInstantiationContext, out methodInstCount);
fixed (IntPtr* ptr = array)
{
fixed (IntPtr* ptr2 = array2)
{
IRuntimeFieldInfo result = null;
ModuleHandle.ResolveField(module.GetNativeHandle(), fieldToken, ptr, typeInstCount, ptr2, methodInstCount, JitHelpers.GetObjectHandleOnStack<IRuntimeFieldInfo>(ref result));
GC.KeepAlive(typeInstantiationContext);
GC.KeepAlive(methodInstantiationContext);
return result;
}
}
}
示例10: GetAssembly
internal static RuntimeAssembly GetAssembly(RuntimeModule module)
{
RuntimeAssembly result = null;
ModuleHandle.GetAssembly(module.GetNativeHandle(), JitHelpers.GetObjectHandleOnStack<RuntimeAssembly>(ref result));
return result;
}
示例11: ResolveMethodHandleInternalCore
internal unsafe static RuntimeMethodHandleInternal ResolveMethodHandleInternalCore(RuntimeModule module, int methodToken, IntPtr[] typeInstantiationContext, int typeInstCount, IntPtr[] methodInstantiationContext, int methodInstCount)
{
ModuleHandle.ValidateModulePointer(module);
if (!ModuleHandle.GetMetadataImport(module.GetNativeHandle()).IsValidToken(methodToken))
{
throw new ArgumentOutOfRangeException("metadataToken", Environment.GetResourceString("Argument_InvalidToken", new object[]
{
methodToken,
new ModuleHandle(module)
}));
}
fixed (IntPtr* ptr = typeInstantiationContext)
{
fixed (IntPtr* ptr2 = methodInstantiationContext)
{
return ModuleHandle.ResolveMethod(module.GetNativeHandle(), methodToken, ptr, typeInstCount, ptr2, methodInstCount);
}
}
}
示例12: IsVisibleFromModule
internal bool IsVisibleFromModule(RuntimeModule module)
{
return IsVisibleFromModule(GetNativeHandle(), module.GetNativeHandle());
}
示例13: GetCustomAttributes
//.........这里部分代码省略.........
if (FilterCustomAttributeRecord(caRecord, metadataImport, ref lastAptcaOkAssembly, decoratedModule, decoratedMetadataToken, attributeFilterType, mustBeInheritable, attributes, derivedAttributes, out attributeType, out ctor, out flag2, out flag3))
{
if (ctor != null)
{
RuntimeMethodHandle.CheckLinktimeDemands(ctor, decoratedModule, isDecoratedTargetSecurityTransparent);
}
RuntimeConstructorInfo.CheckCanCreateInstance(attributeType, flag3);
if (flag2)
{
obj2 = CreateCaObject(decoratedModule, ctor, ref signature, blobEnd, out namedArgs);
}
else
{
obj2 = RuntimeTypeHandle.CreateCaInstance(attributeType, ctor);
if (num4 == 0)
{
namedArgs = 0;
}
else
{
if (Marshal.ReadInt16(signature) != 1)
{
throw new CustomAttributeFormatException();
}
signature = (IntPtr) (((void*) signature) + 2);
namedArgs = Marshal.ReadInt16(signature);
signature = (IntPtr) (((void*) signature) + 2);
}
}
for (int j = 0; j < namedArgs; j++)
{
string str;
bool flag4;
RuntimeType type;
object obj3;
IntPtr ptr1 = caRecord.blob.Signature;
GetPropertyOrFieldData(decoratedModule, ref signature, blobEnd, out str, out flag4, out type, out obj3);
try
{
if (flag4)
{
if ((type == null) && (obj3 != null))
{
type = (RuntimeType) obj3.GetType();
if (type == Type_RuntimeType)
{
type = Type_Type;
}
}
RuntimePropertyInfo property = null;
if (type == null)
{
property = attributeType.GetProperty(str) as RuntimePropertyInfo;
}
else
{
property = attributeType.GetProperty(str, type, Type.EmptyTypes) as RuntimePropertyInfo;
}
if (property == null)
{
throw new CustomAttributeFormatException(string.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString(flag4 ? "RFLCT.InvalidPropFail" : "RFLCT.InvalidFieldFail"), new object[] { str }));
}
RuntimeMethodInfo setMethod = property.GetSetMethod(true) as RuntimeMethodInfo;
if (setMethod.IsPublic)
{
RuntimeMethodHandle.CheckLinktimeDemands(setMethod, decoratedModule, isDecoratedTargetSecurityTransparent);
setMethod.Invoke(obj2, BindingFlags.Default, null, new object[] { obj3 }, null, true);
}
}
else
{
RtFieldInfo field = attributeType.GetField(str) as RtFieldInfo;
if (isDecoratedTargetSecurityTransparent)
{
RuntimeFieldHandle.CheckAttributeAccess(field.FieldHandle, decoratedModule.GetNativeHandle());
}
field.InternalSetValue(obj2, obj3, BindingFlags.Default, Type.DefaultBinder, null, false);
}
}
catch (Exception exception)
{
throw new CustomAttributeFormatException(string.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString(flag4 ? "RFLCT.InvalidPropFail" : "RFLCT.InvalidFieldFail"), new object[] { str }), exception);
}
}
if (!signature.Equals(blobEnd))
{
throw new CustomAttributeFormatException();
}
attributes[length++] = obj2;
}
}
frame.Pop();
if ((length == customAttributeRecords.Length) && (pcaCount == 0))
{
return attributes;
}
object[] destinationArray = CreateAttributeArrayHelper(elementType, length + pcaCount);
Array.Copy(attributes, 0, destinationArray, 0, length);
return destinationArray;
}
示例14: GetCustomAttribute
[System.Security.SecurityCritical] // auto-generated
internal static Attribute GetCustomAttribute(int token, RuntimeModule scope)
{
UnmanagedType unmanagedType, arraySubType;
VarEnum safeArraySubType;
int sizeParamIndex = 0, sizeConst = 0;
string marshalTypeName = null, marshalCookie = null, safeArrayUserDefinedTypeName = null;
int iidParamIndex = 0;
ConstArray nativeType = ModuleHandle.GetMetadataImport(scope.GetNativeHandle()).GetFieldMarshal(token);
if (nativeType.Length == 0)
return null;
MetadataImport.GetMarshalAs(nativeType,
out unmanagedType, out safeArraySubType, out safeArrayUserDefinedTypeName, out arraySubType, out sizeParamIndex,
out sizeConst, out marshalTypeName, out marshalCookie, out iidParamIndex);
RuntimeType safeArrayUserDefinedType = safeArrayUserDefinedTypeName == null || safeArrayUserDefinedTypeName.Length == 0 ? null :
RuntimeTypeHandle.GetTypeByNameUsingCARules(safeArrayUserDefinedTypeName, scope);
RuntimeType marshalTypeRef = null;
try
{
marshalTypeRef = marshalTypeName == null ? null : RuntimeTypeHandle.GetTypeByNameUsingCARules(marshalTypeName, scope);
}
catch (System.TypeLoadException)
{
// The user may have supplied a bad type name string causing this TypeLoadException
// Regardless, we return the bad type name
Contract.Assert(marshalTypeName != null);
}
return new MarshalAsAttribute(
unmanagedType, safeArraySubType, safeArrayUserDefinedType, arraySubType,
(short)sizeParamIndex, sizeConst, marshalTypeName, marshalTypeRef, marshalCookie, iidParamIndex);
}
示例15: GetPEKind
internal static void GetPEKind(RuntimeModule module, out PortableExecutableKinds peKind, out ImageFileMachine machine)
{
int num;
int num2;
ModuleHandle.GetPEKind(module.GetNativeHandle(), out num, out num2);
peKind = (PortableExecutableKinds)num;
machine = (ImageFileMachine)num2;
}