internal CILModuleImpl(CILReflectionContextImpl ctx, Int32 anID, System.Reflection.Module mod) : base(ctx, anID, CILElementKind.Module, () => new CustomAttributeDataEventArgs(ctx, mod)) { ArgumentValidator.ValidateNotNull("Module", mod); var mName = mod.Name; //var match = EXTENSION_REGEX.Match( mName ); InitFields( ref this.name, ref this.assembly, ref this.types, ref this.moduleInitializer, ref this.associatedMSCorLib, ref this.typeNameCache, ref this.manifestResources, mod.Name, // match.Success ? mName.Substring( 0, match.Index ) : mName, () => ctx.Cache.GetOrAdd(mod.Assembly), () => ctx.CollectionsFactory.NewListProxy <CILType>( ctx.LaunchModuleTypesLoadEvent(new ModuleTypesEventArgs(mod)) .Select(type => (CILType)ctx.Cache.GetOrAdd(type)) .ToList() ), this.BuildModuleInitializerType, this.LoadNativeMSCorLibModule, null, this ); }
public void SetHook(bool enable) { if (enable && m_hHook == 0) { m_HookCallback = new ColorPicker_NativeMethods.HookProc(HookCallbackProc); System.Reflection.Module module = System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]; m_hHook = ColorPicker_NativeMethods.SetWindowsHookEx(WinUtil.WH_KEYBOARD_LL, m_HookCallback, System.Runtime.InteropServices.Marshal.GetHINSTANCE (module), 0); if (m_hHook == 0) { System.Windows.Forms.MessageBox.Show( "SetHook Failed. Please make sure the 'Visual Studio Host Process' on the debug setting page is disabled"); return; } return; } if (enable == false && m_hHook != 0) { ColorPicker_NativeMethods.UnhookWindowsHookEx(m_hHook); m_hHook = 0; } }
/// <summary> /// Loads an Icon Error Checked. /// </summary> internal static System.Drawing.Icon _LoadIconErrorChecked(string resource, int Width, int Height) { int error = 0; System.Drawing.Icon retIcon = null; System.IntPtr hIcon = System.IntPtr.Zero; System.Reflection.Module hMod = null; try { hMod = System.Reflection.Assembly.GetEntryAssembly().GetModules()[0]; } catch (System.Exception) { } if (hMod != null) { System.IntPtr hProc = System.Runtime.InteropServices.Marshal.GetHINSTANCE(hMod); hIcon = LoadImage(hProc, resource, (uint)Enums.LoadImageTypes.IMAGE_ICON, Width, Height, (uint)Enums.LoadImagefuLoad.LR_SHARED); error = System.Runtime.InteropServices.Marshal.GetLastWin32Error(); if (error == 0 && hIcon != System.IntPtr.Zero) { System.Drawing.Icon iconold = System.Drawing.Icon.FromHandle(hIcon); retIcon = new System.Drawing.Icon(iconold, Width, Height); } } else { // Forms Designer hack. // Load from a *.resx if it exists, otherwise make one. if (!System.IO.File.Exists(ResourcesDir.resourcespath)) { System.Resources.ResXResourceWriter resx = new System.Resources.ResXResourceWriter(ResourcesDir.resourcespath); System.IO.MemoryStream iconstream = new System.IO.MemoryStream(System.IO.File.ReadAllBytes(ResourcesDir.iconpath)); System.Drawing.Icon icon2Dump = new System.Drawing.Icon(iconstream); resx.AddResource(GetFileBaseName(ResourcesDir.iconpath).Trim(".ico".ToCharArray()), icon2Dump); icon2Dump.Dispose(); // write resource file. resx.Dispose(); } // now read it. System.Resources.ResXResourceSet resxSet = new System.Resources.ResXResourceSet(ResourcesDir.resourcespath); // hopefully this works. System.Drawing.Icon iconold = (System.Drawing.Icon)resxSet.GetObject(GetFileBaseName(ResourcesDir.iconpath).Trim(".ico".ToCharArray())); retIcon = new System.Drawing.Icon(iconold, Width, Height); hIcon = retIcon.Handle; resxSet.Dispose(); } if (hIcon == System.IntPtr.Zero) { MessageManager.ShowError("LoadImage returned Error Code: " + error + ".", "Error!"); } return(retIcon); }
//------------------------------------------------------------------------------ public static Module Create(System.Reflection.Module aNative) { var mod = new Module(); mod.Name = aNative.Name; foreach (var type in aNative.GetTypes()) { mod.Types.Add(Type.Create(type)); } return(mod); }
IntPtr GetManifestResourceInternal(string name, out int size, out System.Reflection.Module module) { /* Return the address (and fill out size and module fields) of a resource embedded in the assembly. * * For now, we don't support this and will return null * * Log what was requested though */ Formatter.WriteLine("System.Reflection.Assembly.GetManifestResourceInternal: Request for resource: " + name + " - currently unsupported. Returning null.", Program.arch.DebugOutput); size = 0; module = null; return(IntPtr.Zero); }
internal ModuleImpl(System.Reflection.Module module) { Debug.Assert(module != null); this.Module = module; }