コード例 #1
0
ファイル: Runtime.cs プロジェクト: modulexcite/MOSA-Project
        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 inhertiance chain of the exception object
                    if ((handlerType == ExceptionHandlerType.Finally) ||
                        (handlerType == ExceptionHandlerType.Exception && IsTypeInInheritanceChain(exType, exceptionType)))
                    {
                        protectedRegionDef = prDef;
                        currentStart       = start;
                        currentEnd         = end;
                    }
                }

                entry++;
            }

            return(protectedRegionDef);
        }
コード例 #2
0
		public static MetadataPRDefinitionStruct* GetProtecteRegionDefinitionAddress(MetadataPRTableStruct* data, uint slot)
		{
			return (MetadataPRDefinitionStruct*)*((uint*)data + MetadataPRTableStruct.ProtectedRegionDefintionOffset + slot);
		}