示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ModuleInfo"/> class.
        /// </summary>
        /// <param name="module">The Win32 module entry data.</param>
        public ModuleInfo(MODULEENTRY32 module)
        {
            ProcessId = module.th32ProcessID;
            BaseAddress = module.modBaseAddr;
            BaseSize = module.modBaseSize;
            Handle = module.hModule;
            Name = module.szModule;
            Path = module.szExePath;

            ModuleId = module.th32ModuleID;
            StructureSize = module.dwSize;
            GlblcntUsage = module.GlblcntUsage;
            ProccntUsage = module.ProccntUsage;
        }
示例#2
0
        /// <summary>
        /// Similar to System.Diagnostics.WinProcessManager.GetModuleInfos,
        /// except that we include 32 bit modules when we run in x64 mode.
        /// See http://blogs.msdn.com/b/jasonz/archive/2007/05/11/code-sample-is-your-process-using-the-silverlight-clr.aspx
        /// </summary>
        private IEnumerable<MODULEENTRY32> GetModules(int pid)
        {
            var me32 = new MODULEENTRY32();
            var hModuleSnap = NativeMethods.CreateToolhelp32Snapshot(
                SnapshotFlags.Module | SnapshotFlags.Module32,
                pid);

            if (hModuleSnap.IsInvalid) yield break;

            using (hModuleSnap)
            {
                me32.dwSize = (uint)Marshal.SizeOf(me32);
                if (NativeMethods.Module32First(hModuleSnap, ref me32))
                {
                    do
                    {
                        yield return me32;
                    } while (NativeMethods.Module32Next(hModuleSnap, ref me32));
                }
            }
        }
示例#3
0
 public static extern bool Module32Next(ToolHelpHandle hSnapshot, ref MODULEENTRY32 lpme);
示例#4
0
 public static extern bool Module32Next(ToolHelpHandle hSnapshot, ref MODULEENTRY32 lpme);