/// <summary> /// Get all the loaded modules in the current process. /// </summary> /// <returns></returns> public static IDictionary GetModules() { SortedDictionary <object, object> modules = new SortedDictionary <object, object>(); foreach (ProcessModule module in Process.GetCurrentProcess().Modules) { LoadedModule moduleInfo = new LoadedModule(); try { moduleInfo.Name = module.ModuleName; moduleInfo.FullPath = module.FileName; FileInfo file = new System.IO.FileInfo(module.FileName); moduleInfo.Directory = file.DirectoryName; moduleInfo.TimeStamp = file.LastWriteTime.ToString(); moduleInfo.Version = module.FileVersionInfo.FileMajorPart + "." + module.FileVersionInfo.FileMinorPart + "." + module.FileVersionInfo.FilePrivatePart + "." + module.FileVersionInfo.FileBuildPart; } catch { } modules[moduleInfo.Name + "_" + moduleInfo.Version] = moduleInfo; } return(modules); }
/// <summary> /// Get information about the currently executing process. /// </summary> /// <returns></returns> public static IDictionary GetAppDomainInfo() { AppDomain domain = AppDomain.CurrentDomain; Assembly[] loadedAssemblies = domain.GetAssemblies(); IDictionary assemblyInfo = new SortedDictionary <object, object>(); foreach (Assembly assembly in loadedAssemblies) { LoadedModule mod = new LoadedModule(); try { mod.Name = assembly.CodeBase.Substring(assembly.CodeBase.LastIndexOf("/") + 1); mod.FullPath = assembly.Location; mod.Version = assembly.ImageRuntimeVersion; FileInfo file = new FileInfo(assembly.Location); mod.TimeStamp = file.LastWriteTime.ToString(); mod.Directory = file.Directory.FullName; } catch { } assemblyInfo[mod.Name + "_" + mod.Version] = mod; } return(assemblyInfo); }