예제 #1
0
        public static string[] GetModulesInfo(IntPtr[] handles)
        {
            var result = new string[handles.Length];
            var tmp    = GetProcessModules(handles);

            for (int i = 0; i < handles.Length; i++)
            {
                if (tmp[i].Length == 0)
                {
                    result[i] = "";
                    continue;
                }

                Psapi.MODULEINFO info;

                if (Psapi.GetModuleInformation(handles[i], new IntPtr(tmp[i][0]), out info,
                                               (uint)Marshal.SizeOf(new Psapi.MODULEINFO())))
                {
                    result[i] = info.SizeOfImage + " б";
                    while (result[i].Length < 30)
                    {
                        result[i] += " ";
                    }
                }
            }

            return(result);
        }
예제 #2
0
        private static Psapi.MODULEINFO[] GetModuleInfo(IntPtr handle, uint[] modules)
        {
            var infos = new Psapi.MODULEINFO[modules.Length];

            Psapi.MODULEINFO info;

            for (int i = 0; i < modules.Length; i++)
            {
                if (Psapi.GetModuleInformation(handle,
                                               new IntPtr(modules[i]),
                                               out info,
                                               (uint)Marshal.SizeOf(new Psapi.MODULEINFO())))
                {
                    infos[i] = info;
                }
                else
                {
                    infos[i]             = new Psapi.MODULEINFO();
                    infos[i].EntryPoint  = IntPtr.Zero;
                    infos[i].lpBaseOfDll = IntPtr.Zero;
                    infos[i].SizeOfImage = 0;
                }
            }

            return(infos);
        }