/// <summary> /// Initializes a new instance of the <see cref="Module" /> class. /// </summary> /// <param name="process">The process.</param> /// <param name="address">The module address.</param> internal Module(Process process, ulong address) { Address = address; Process = process; Id = uint.MaxValue; name = SimpleCache.Create(() => { string name = Context.Debugger.GetModuleName(this); Process.UpdateModuleByNameCache(this, name); return(name); }); imageName = SimpleCache.Create(() => Context.Debugger.GetModuleImageName(this)); loadedImageName = SimpleCache.Create(() => Context.Debugger.GetModuleLoadedImage(this)); symbolFileName = SimpleCache.Create(() => Context.Debugger.GetModuleSymbolFile(this)); mappedImageName = SimpleCache.Create(() => Context.Debugger.GetModuleMappedImage(this)); moduleVersion = SimpleCache.Create(() => { ModuleVersion version = new ModuleVersion(); Context.Debugger.GetModuleVersion(this, out version.Major, out version.Minor, out version.Revision, out version.Patch); return(version); }); timestampAndSize = SimpleCache.Create(() => Context.Debugger.GetModuleTimestampAndSize(this)); clrModule = SimpleCache.Create(() => Process.ClrRuntimes.SelectMany(r => r.Modules).Where(m => m.ImageBase == Address).FirstOrDefault()); pointerSize = SimpleCache.Create(() => Process.GetPointerSize()); TypesByName = new DictionaryCache <string, CodeType>(GetTypeByName); TypesById = new DictionaryCache <uint, CodeType>(GetTypeById); ClrTypes = new DictionaryCache <IClrType, CodeType>(GetClrCodeType); GlobalVariables = new DictionaryCache <string, Variable>(GetGlobalVariable); UserTypeCastedGlobalVariables = Context.UserTypeMetadataCaches.CreateDictionaryCache <string, Variable>((name) => Process.CastVariableToUserType(GlobalVariables[name])); }
/// <summary> /// Initializes a new instance of the <see cref="Module" /> class. /// </summary> /// <param name="process">The process.</param> /// <param name="address">The module address.</param> internal Module(Process process, ulong address) { Address = address; Process = process; name = SimpleCache.Create(() => { string name = Context.Debugger.GetModuleName(this); Process.UpdateModuleByNameCache(this, name); return(name); }); imageName = SimpleCache.Create(() => Context.Debugger.GetModuleImageName(this)); loadedImageName = SimpleCache.Create(() => Context.Debugger.GetModuleLoadedImage(this)); symbolFileName = SimpleCache.Create(() => Context.Debugger.GetModuleSymbolFile(this)); mappedImageName = SimpleCache.Create(() => Context.Debugger.GetModuleMappedImage(this)); moduleVersion = SimpleCache.Create(() => { ModuleVersion version = new ModuleVersion(); Context.Debugger.GetModuleVersion(this, out version.Major, out version.Minor, out version.Revision, out version.Patch); return(version); }); timestampAndSize = SimpleCache.Create(() => Context.Debugger.GetModuleTimestampAndSize(this)); clrModule = SimpleCache.Create(() => Process.ClrRuntimes.SelectMany(r => r.ClrRuntime.Modules).Where(m => m.ImageBase == Address).FirstOrDefault()); clrPdbReader = SimpleCache.Create(() => { try { string pdbPath = ClrModule.Runtime.DataTarget.SymbolLocator.FindPdb(ClrModule.Pdb); if (!string.IsNullOrEmpty(pdbPath)) { return(new Microsoft.Diagnostics.Runtime.Utilities.Pdb.PdbReader(pdbPath)); } } catch (Exception) { } return(null); }); TypesByName = new DictionaryCache <string, CodeType>(GetTypeByName); TypesById = new DictionaryCache <uint, CodeType>(GetTypeById); ClrTypes = new DictionaryCache <Microsoft.Diagnostics.Runtime.ClrType, CodeType>(GetClrCodeType); GlobalVariables = new DictionaryCache <string, Variable>(GetGlobalVariable); UserTypeCastedGlobalVariables = new DictionaryCache <string, Variable>((name) => { Variable variable = Process.CastVariableToUserType(GlobalVariables[name]); if (UserTypeCastedGlobalVariables.Count == 0) { GlobalCache.VariablesUserTypeCastedFieldsByName.Add(UserTypeCastedGlobalVariables); } return(variable); }); }
/// <summary> /// Initializes a new instance of the <see cref="Module" /> class. /// </summary> /// <param name="process">The process.</param> /// <param name="address">The module address.</param> internal Module(Process process, ulong address) { Address = address; Process = process; name = SimpleCache.Create(() => { string name = Context.Debugger.GetModuleName(this); Process.UpdateModuleByNameCache(this, name); return name; }); imageName = SimpleCache.Create(() => Context.Debugger.GetModuleImageName(this)); loadedImageName = SimpleCache.Create(() => Context.Debugger.GetModuleLoadedImage(this)); symbolFileName = SimpleCache.Create(() => Context.Debugger.GetModuleSymbolFile(this)); mappedImageName = SimpleCache.Create(() => Context.Debugger.GetModuleMappedImage(this)); moduleVersion = SimpleCache.Create(() => { ModuleVersion version = new ModuleVersion(); Context.Debugger.GetModuleVersion(this, out version.Major, out version.Minor, out version.Revision, out version.Patch); return version; }); timestampAndSize = SimpleCache.Create(() => Context.Debugger.GetModuleTimestampAndSize(this)); clrModule = SimpleCache.Create(() => Process.ClrRuntimes.SelectMany(r => r.ClrRuntime.Modules).Where(m => m.ImageBase == Address).FirstOrDefault()); clrPdbReader = SimpleCache.Create(() => { try { string pdbPath = ClrModule.Runtime.DataTarget.SymbolLocator.FindPdb(ClrModule.Pdb); if (!string.IsNullOrEmpty(pdbPath)) { return new Microsoft.Diagnostics.Runtime.Utilities.Pdb.PdbReader(pdbPath); } } catch (Exception) { } return null; }); TypesByName = new DictionaryCache<string, CodeType>(GetTypeByName); TypesById = new DictionaryCache<uint, CodeType>(GetTypeById); ClrTypes = new DictionaryCache<Microsoft.Diagnostics.Runtime.ClrType, CodeType>(GetClrCodeType); GlobalVariables = new DictionaryCache<string, Variable>(GetGlobalVariable); UserTypeCastedGlobalVariables = new DictionaryCache<string, Variable>((name) => { Variable variable = Process.CastVariableToUserType(GlobalVariables[name]); if (UserTypeCastedGlobalVariables.Count == 0) { GlobalCache.VariablesUserTypeCastedFieldsByName.Add(UserTypeCastedGlobalVariables); } return variable; }); }