コード例 #1
0
        /// <summary>
        /// Each managed module linked into the final binary may have its own global tables for strings,
        /// statics, etc that need initializing. InitializeGlobalTables walks through the modules
        /// and offers each a chance to initialize its global tables.
        /// </summary>
        private static unsafe void InitializeGlobalTablesForModule(IntPtr moduleManager)
        {
            // Configure the module indirection cell with the newly created ModuleManager. This allows EETypes to find
            // their interface dispatch map tables.
            int     length;
            IntPtr *section = (IntPtr *)RuntimeImports.GetModuleSection(moduleManager, (int)ReadyToRunSectionType.ModuleManagerIndirection, out length);

            *section = moduleManager;

            // Initialize statics if any are present
            IntPtr staticsSection = RuntimeImports.GetModuleSection(moduleManager, (int)ReadyToRunSectionType.GCStaticRegion, out length);

            if (staticsSection != IntPtr.Zero)
            {
                Debug.Assert(length % IntPtr.Size == 0);
                InitializeStatics(staticsSection, length);
            }

            // Initialize frozen object segment with GC present
            IntPtr frozenObjectSection = RuntimeImports.GetModuleSection(moduleManager, (int)ReadyToRunSectionType.FrozenObjectRegion, out length);

            if (frozenObjectSection != IntPtr.Zero)
            {
                Debug.Assert(length % IntPtr.Size == 0);
                InitializeFrozenObjectSegment(frozenObjectSection, length);
            }
        }