public void LoadInMemoryModule(ModuleWrapper inMemoryModule)
		{
			List<NuGenAssembly> loadedAssemblies = new List<NuGenAssembly>(1);

			try
			{
				string moduleName = inMemoryModule.GetName();

				try
				{
					moduleName = Path.GetFileNameWithoutExtension(moduleName);
				}
				catch
				{
				}

				NuGenAssembly inMemoryAssembly = new NuGenAssembly(true);
				inMemoryAssembly.FileName = moduleName;
				inMemoryAssembly.Name = moduleName;
				NuGenMetaDataDispenserEx dispenser = new NuGenMetaDataDispenserEx();

				inMemoryAssembly.LoadAssemblyFromMetadataInterfaces(dispenser, (NuGenIMetaDataAssemblyImport)inMemoryModule.GetMetaDataAssemblyImport(), (NuGenIMetaDataImport2)inMemoryModule.GetMetaDataImport2(), inMemoryModule);
				loadedAssemblies.Add(inMemoryAssembly);
			}
			catch (Exception exception)
			{
				NuGenUIHandler.Instance.DisplayUserWarning("An error occurred while loading the assembly.");
				NuGenUIHandler.Instance.ShowException(exception);
			}

			NuGenUIHandler.Instance.ResetProgressBar();

			if (loadedAssemblies.Count > 0)
			{
				NuGenUIHandler.Instance.AssembliesLoaded(loadedAssemblies, false);

				if (AssembliesLoaded != null)
				{
					AssembliesLoaded(loadedAssemblies, false);
				}
			}
		}
        public void LoadInMemoryModule(ModuleWrapper inMemoryModule)
        {
            List <NuGenAssembly> loadedAssemblies = new List <NuGenAssembly>(1);

            try
            {
                string moduleName = inMemoryModule.GetName();

                try
                {
                    moduleName = Path.GetFileNameWithoutExtension(moduleName);
                }
                catch
                {
                }

                NuGenAssembly inMemoryAssembly = new NuGenAssembly(true);
                inMemoryAssembly.FileName = moduleName;
                inMemoryAssembly.Name     = moduleName;
                NuGenMetaDataDispenserEx dispenser = new NuGenMetaDataDispenserEx();

                inMemoryAssembly.LoadAssemblyFromMetadataInterfaces(dispenser, (NuGenIMetaDataAssemblyImport)inMemoryModule.GetMetaDataAssemblyImport(), (NuGenIMetaDataImport2)inMemoryModule.GetMetaDataImport2(), inMemoryModule);
                loadedAssemblies.Add(inMemoryAssembly);
            }
            catch (Exception exception)
            {
                NuGenUIHandler.Instance.DisplayUserWarning("An error occurred while loading the assembly.");
                NuGenUIHandler.Instance.ShowException(exception);
            }

            NuGenUIHandler.Instance.ResetProgressBar();

            if (loadedAssemblies.Count > 0)
            {
                NuGenUIHandler.Instance.AssembliesLoaded(loadedAssemblies, false);

                if (AssembliesLoaded != null)
                {
                    AssembliesLoaded(loadedAssemblies, false);
                }
            }
        }
示例#3
0
		public void OpenMetadataInterfaces()
		{
			if (!IsInMemory)
			{
				Dispenser = new NuGenMetaDataDispenserEx();
				object rawScope = null;
				Guid assemblyImportGuid = NuGenGuids.IID_IMetaDataAssemblyImport;
				Dispenser.OpenScopeOnMemory(FileContentUnmanaged, FileContentLength, (uint)CorOpenFlags.ofRead, ref assemblyImportGuid, out rawScope);
				AssemblyImport = (NuGenIMetaDataAssemblyImport)rawScope;

				object rawScope2 = null;
				Guid metaDataImportGuid = NuGenGuids.IID_IMetaDataImport2;
				Dispenser.OpenScopeOnMemory(FileContentUnmanaged, FileContentLength, (uint)CorOpenFlags.ofRead, ref metaDataImportGuid, out rawScope2);
				Import = (NuGenIMetaDataImport2)rawScope2;
			}
		}