예제 #1
0
 public static uint* GetParameterDefinitionAddress(MetadataMethodStruct* data, uint slot)
 {
     return (uint*)*((uint*)data + MetadataMethodStruct.ParametersOffset + slot);
 }
예제 #2
0
 public static string GetMethodDefinitionName(MetadataMethodStruct* methodDef)
 {
     return InitializeMetadataString(methodDef->Name);
 }
예제 #3
0
        public static MetadataPRDefinitionStruct* GetProtectedRegionEntryByAddress(uint address, MetadataTypeStruct* exceptionType, MetadataMethodStruct* methodDef)
        {
            var protectedRegionTable = methodDef->ProtectedRegionTable;

            if (protectedRegionTable == null)
                return null;

            uint method = (uint)methodDef->Method;

            if (method == 0)
                return null;

            uint offset = address - method;
            int entries = protectedRegionTable->NumberOfRegions;

            int entry = 0;
            MetadataPRDefinitionStruct* protectedRegionDef = null;
            uint currentStart = uint.MinValue;
            uint currentEnd = uint.MaxValue;

            while (entry < entries)
            {
                var prDef = MetadataPRTableStruct.GetProtectedRegionDefinitionAddress(protectedRegionTable, (uint)entry);

                uint start = prDef->StartOffset;
                uint end = prDef->EndOffset;

                if ((offset >= start) && (offset < end) && (start >= currentStart) && (end < currentEnd))
                {
                    var handlerType = prDef->HandlerType;
                    var exType = prDef->ExceptionType;

                    // If the handler is a finally clause, accept without testing
                    // If the handler is a exception clause, accept if the exception type is in the is within the inheritance chain of the exception object
                    if ((handlerType == ExceptionHandlerType.Finally) ||
                        (handlerType == ExceptionHandlerType.Exception && IsTypeInInheritanceChain(exType, exceptionType)))
                    {
                        protectedRegionDef = prDef;
                        currentStart = start;
                        currentEnd = end;
                    }
                }

                entry++;
            }

            return protectedRegionDef;
        }