Exemplo n.º 1
0
        internal override MetaDataImport GetMetadataImport(ulong module)
        {
            IntPtr import;

            if (CLRVersion == DesktopVersion.v2)
            {
                V2ModuleData data = new V2ModuleData();
                if (!RequestStruct(DacRequests.MODULE_DATA, module, ref data))
                {
                    return(null);
                }

                import = data.MetaDataImport;
            }
            else
            {
                V4ModuleData data = new V4ModuleData();
                if (!RequestStruct(DacRequests.MODULE_DATA, module, ref data))
                {
                    return(null);
                }

                import = data.MetaDataImport;
            }

            try
            {
                return(import != IntPtr.Zero ? new MetaDataImport(DacLibrary, import) : null);
            }
            catch (InvalidCastException)
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        internal override IModuleData GetModuleData(ulong addr)
        {
            if (addr == 0)
            {
                return(null);
            }

            IModuleData result;

            if (CLRVersion == DesktopVersion.v2)
            {
                V2ModuleData data = new V2ModuleData();
                if (!RequestStruct(DacRequests.MODULE_DATA, addr, ref data))
                {
                    return(null);
                }

                COMHelper.Release(data.MetaDataImport);
                result = data;
            }
            else
            {
                V4ModuleData data = new V4ModuleData();
                if (!RequestStruct(DacRequests.MODULE_DATA, addr, ref data))
                {
                    return(null);
                }

                COMHelper.Release(data.MetaDataImport);
                result = data;
            }

            return(result);
        }