public void SaveGitGenerationSettings(IModuleData Data) { if (Data != null && Data.ModuleSettings != null) { SaveGitGenerationSettings(Data, Data.ModuleSettings.GitGenSettingsFile); } }
public void LoadUserKeywords(IModuleData Data) { if (Data != null && Data.ModuleSettings != null) { if (File.Exists(Data.ModuleSettings.UserKeywordsFile)) { LoadUserKeywords(Data, Data.ModuleSettings.UserKeywordsFile); } else { if (File.Exists(DefaultPaths.ModuleKeywordsFile(Data))) { LoadUserKeywords(Data, DefaultPaths.ModuleKeywordsFile(Data)); } else { if (Data.UserKeywords == null) { Data.UserKeywords = new UserKeywordData(); Data.UserKeywords.ResetToDefault(); FileCommands.Save.SaveUserKeywords(Data); } } } } }
public void RegisterForRelease(IModuleData module) { if (module != null) { COMHelper.Release(module.LegacyMetaDataImport); } }
public SimpleRobotController([NotNull] IModuleData moduleData) { node = FrameNode.Instantiate("SimpleRobotNode"); ModuleData = moduleData ?? throw new ArgumentNullException(nameof(moduleData)); Config = new RobotConfiguration(); }
public override void SetToDefault(IModuleData Data) { base.SetToDefault(Data); FindDOS2DataDirectory(); DirectoryLayoutFile = DOS2DefaultPaths.DirectoryLayout(Data); }
public static InitializationMode GetInitializationMode(this IModuleData moduleData) { if (moduleData.IsLoadedOnStartup) { return(InitializationMode.OnDemand); } return(InitializationMode.WhenAvailable); }
public bool SetModule(IModuleData moduleData) { var projectControllerEntry = ProjectControllers.FirstOrDefault(p => p.Value.ModuleData == moduleData); if (projectControllerEntry.Value != null) { return(SetModule(projectControllerEntry.Value)); } return(false); }
/// <summary> /// Adds a module from module data /// </summary> /// <param name="moduleData"></param> protected void AddModule(IModuleData moduleData) { AddModule(moduleData.ModuleName, moduleData.ModuleType, CreateFileUri(moduleData.AssemblyPath), moduleData.IsLoadedOnStartup ? InitializationMode.WhenAvailable : InitializationMode.OnDemand, moduleData.DependsOn.ToArray()); }
public override Address GetAddress(ClrAppDomain appDomain, ClrThread thread) { if (_type == null) return 0; DesktopRuntimeBase runtime = _type.DesktopHeap.DesktopRuntime; IModuleData moduleData = runtime.GetModuleData(_field.Module); return runtime.GetThreadStaticPointer(thread.Address, (ClrElementType)_field.CorElementType, (uint)Offset, (uint)moduleData.ModuleId, _type.Shared); }
public virtual void SetToDefault(IModuleData Data) { BackupRootDirectory = DefaultPaths.ModuleBackupsFolder(Data); GitRootDirectory = DefaultPaths.ModuleProjectsFolder(Data); AddedProjectsFile = DefaultPaths.ModuleAddedProjectsFile(Data); TemplateSettingsFile = DefaultPaths.ModuleTemplateSettingsFile(Data); UserKeywordsFile = DefaultPaths.ModuleKeywordsFile(Data); GitGenSettingsFile = DefaultPaths.ModuleGitGenSettingsFile(Data); //BackupMode = BackupMode.Zip; }
public void SaveModuleSettings(IModuleData Data) { Log.Here().Activity("Saving module settings to {0}", Path.GetFullPath(DefaultPaths.ModuleSettingsFile(Data))); if (Data.ModuleSettings != null) { SaveTemplates(Data); string json = JsonConvert.SerializeObject(Data.ModuleSettings, Newtonsoft.Json.Formatting.Indented); FileCommands.WriteToFile(DefaultPaths.ModuleSettingsFile(Data), json); } }
internal DesktopModule GetModule(Address module) { if (module == 0) { return(null); } DesktopModule res; if (_modules.TryGetValue(module, out res)) { return(res); } IModuleData moduleData = GetModuleData(module); if (moduleData == null) { return(null); } string peFile = GetPEFileName(moduleData.PEFile); string assemblyName = GetAssemblyName(moduleData.Assembly); if (_moduleSizes == null) { _moduleSizes = new Dictionary <Address, uint>(); foreach (var native in _dataReader.EnumerateModules()) { _moduleSizes[native.ImageBase] = native.FileSize; } } if (_moduleFiles == null) { _moduleFiles = new Dictionary <string, DesktopModule>(); } uint size = 0; _moduleSizes.TryGetValue(moduleData.ImageBase, out size); if (peFile == null) { res = new DesktopModule(this, moduleData, peFile, assemblyName, size); } else if (!_moduleFiles.TryGetValue(peFile, out res)) { res = new DesktopModule(this, moduleData, peFile, assemblyName, size); _moduleFiles[peFile] = res; } _modules[module] = res; return(res); }
public override Address GetAddress(ClrAppDomain appDomain, ClrThread thread) { if (m_type == null) { return(0); } DesktopRuntimeBase runtime = m_type.m_heap.m_runtime; IModuleData moduleData = runtime.GetModuleData(m_field.Module); return(runtime.GetThreadStaticPointer(thread.Address, (ClrElementType)m_field.CorElementType, (uint)Offset, (uint)moduleData.ModuleId, m_type.Shared)); }
public void LoadAll(IModuleData Data) { LoadModuleSettings(Data); LoadTemplates(Data); LoadUserKeywords(Data); LoadGitGenerationSettings(Data); if (SaveAppSettings) { FileCommands.Save.SaveModuleSettings(Data); SaveAppSettings = false; } }
public DesktopModule(DesktopRuntimeBase runtime, IModuleData data, string name, string assemblyName, ulong size) : base(runtime) { Revision = runtime.Revision; _imageBase = data.ImageBase; _assemblyName = assemblyName; _isPE = data.IsPEFile; _reflection = data.IsReflection || string.IsNullOrEmpty(name) || !name.Contains("\\"); _name = name; ModuleId = data.ModuleId; _size = size; _metadata = data.LegacyMetaDataImport as ICorDebug.IMetadataImport; }
public void LoadModuleSettings(IModuleData Data) { if (File.Exists(DefaultPaths.ModuleSettingsFile(Data))) { Log.Here().Activity("Loading settings from {0}", DefaultPaths.ModuleSettingsFile(Data)); Data.LoadSettings(); } else { Log.Here().Warning("settings file at {0} not found. Creating new file.", DefaultPaths.ModuleSettingsFile(Data)); Data.InitializeSettings(); SaveAppSettings = true; } }
public void LoadTemplates(IModuleData Data) { string templateFilePath = DefaultPaths.ModuleTemplateSettingsFile(Data); if (File.Exists(Data.ModuleSettings.TemplateSettingsFile)) { templateFilePath = Data.ModuleSettings.TemplateSettingsFile; } else if (!File.Exists(templateFilePath)) { FileCommands.WriteToFile(templateFilePath, Properties.Resources.Templates); } XDocument templateXml = null; try { templateXml = XDocument.Load(templateFilePath); foreach (var template in templateXml.Descendants("Template")) { TemplateEditorData templateData = TemplateEditorData.LoadFromXml(Data, template); Data.Templates.Add(templateData); } } catch (Exception ex) { Log.Here().Error(Message: $"Error loading template file {templateFilePath}: {ex.ToString()}"); } if (Data.ModuleSettings.TemplateFiles != null) { foreach (var templateFile in Data.ModuleSettings.TemplateFiles) { var data = Data.Templates.FirstOrDefault(t => t.ID == templateFile.ID); if (data != null) { data.FilePath = templateFile.FilePath; } } } for (int i = 0; i < Data.Templates.Count; i++) { var template = Data.Templates[i]; template.Init(Data); } }
private static string GetPropertyValueFromXml(IModuleData moduleData, XElement xmlData, string propertyName, string defaultValue = "") { XElement element = XmlDataHelper.GetDescendantByAttributeValue(xmlData, "Property", "Name", propertyName); string value = ""; if (element != null) { string type = element.Attribute("Type")?.Value; if (type == null) { type = "String"; } string contents = element.Value; if (!String.IsNullOrWhiteSpace(contents)) { if (type == "Resource") { var resourceVal = moduleData.LoadStringResource(contents); if (resourceVal != null) { return(resourceVal); } } else if (type == "File") { if (File.Exists(contents)) { try { var fileContents = File.ReadAllText(contents); return(fileContents); } catch (Exception ex) { Log.Here().Error("Error loading file(\"{0}\") specified in templates.xml: {1}", contents, ex.ToString()); } } } else { return(contents); } } } return(value); }
public DepthCloudController([NotNull] IModuleData moduleData) { ModuleData = moduleData ?? throw new ArgumentNullException(nameof(moduleData)); depthImageTexture = new ImageTexture(); colorImageTexture = new ImageTexture(); node = FrameNode.Instantiate("DepthCloud"); node.Transform.localRotation = new Quaternion(0, 0.7071f, 0.7071f, 0); projector = ResourcePool.RentDisplay <DepthCloudResource>(node.Transform); projector.DepthImage = depthImageTexture; projector.ColorImage = colorImageTexture; Config = new DepthCloudConfiguration(); depthImageTexture.Colormap = ColormapId.gray; colorImageTexture.Colormap = ColormapId.gray; }
public DesktopModule(DesktopRuntimeBase runtime, ulong address, IModuleData data, string name, string assemblyName) : base(runtime) { _address = address; Revision = runtime.Revision; ImageBase = data.ImageBase; AssemblyName = assemblyName; _isPE = data.IsPEFile; IsDynamic = data.IsReflection || string.IsNullOrEmpty(name); _name = name; ModuleId = data.ModuleId; ModuleIndex = data.ModuleIndex; MetadataAddress = data.MetdataStart; MetadataLength = data.MetadataLength; AssemblyId = data.Assembly; _size = new Lazy <ulong>(() => runtime.GetModuleSize(address)); }
public MarkdownConverterViewData LoadModuleMarkdownConverterSettings(IModuleData Data) { var filePath = DefaultPaths.ModuleMarkdownConverterSettingsFile(Data); if (File.Exists(filePath)) { Log.Here().Activity("Loading markdown converter settings from {0}", DefaultPaths.ModuleMarkdownConverterSettingsFile(Data)); try { return(JsonConvert.DeserializeObject <MarkdownConverterViewData>(File.ReadAllText(filePath))); } catch (Exception ex) { Log.Here().Error($"Error loading markdown converter settings: {ex.ToString()}"); } } return(null); }
public DesktopModule(DesktopRuntimeBase runtime, ulong address, IModuleData data, string name, string assemblyName, ulong size) : base(runtime) { _address = address; Revision = runtime.Revision; _imageBase = data.ImageBase; _assemblyName = assemblyName; _isPE = data.IsPEFile; _reflection = data.IsReflection || string.IsNullOrEmpty(name) || !name.Contains("\\"); _name = name; ModuleId = data.ModuleId; ModuleIndex = data.ModuleIndex; _metadataStart = data.MetdataStart; _metadataLength = data.MetadataLength; _assemblyAddress = data.Assembly; _size = size; if (!runtime.DataReader.IsMinidump) { // This is very expensive in the minidump case, as we may be heading out to the symbol server or // reading multiple files from disk. Only optimistically fetch this data if we have full memory. _metadata = data.LegacyMetaDataImport as ICorDebug.IMetadataImport; } else { // If we are a minidump and metadata isn't mapped in, attempt to fetch this module from the symbol server // on a background thread. #if !V2_SUPPORT if (_isPE && _metadataStart != 0 && _metadataLength > 0) { int read; byte[] tmp = new byte[1]; if (!_runtime.DataReader.ReadMemory(_metadataStart, tmp, 1, out read) || read == 0) { int filesize, imagesize; if (PEFile.TryGetIndexProperties(new ReadVirtualStream(_runtime.DataReader, (long)data.ImageBase, (long)size), true, out imagesize, out filesize)) { _runtime.DataTarget.SymbolLocator.PrefetchBinary(Path.GetFileName(assemblyName), imagesize, filesize); } } } #endif } }
public void SaveGitGenerationSettings(IModuleData Data, string filePath) { if (Data.GitGenerationSettings != null) { if (!String.IsNullOrEmpty(filePath)) { Log.Here().Important("Serializing and saving git generation settings data."); try { string json = JsonConvert.SerializeObject(Data.GitGenerationSettings, Newtonsoft.Json.Formatting.Indented); FileCommands.WriteToFile(filePath, json); } catch (Exception ex) { Log.Here().Error("Error serializing {0}: {1}", filePath, ex.ToString()); } } } }
public ClrmdModule(ClrAppDomain parent, IModuleData data) { if (data is null) { throw new ArgumentNullException(nameof(data)); } AppDomain = parent; Name = data.Name; AssemblyName = data.AssemblyName; AssemblyAddress = data.AssemblyAddress; Address = data.Address; IsPEFile = data.IsPEFile; ImageBase = data.ILImageBase; Layout = data.IsFlatLayout ? ModuleLayout.Flat : ModuleLayout.Unknown; Size = data.Size; MetadataAddress = data.MetadataStart; MetadataLength = data.MetadataLength; IsDynamic = data.IsReflection || string.IsNullOrWhiteSpace(Name); }
public DesktopModule(DesktopRuntimeBase runtime, ulong address, IModuleData data, string name, string assemblyName, ulong size) : base(runtime) { Revision = runtime.Revision; _imageBase = data.ImageBase; _assemblyName = assemblyName; _isPE = data.IsPEFile; _reflection = data.IsReflection || string.IsNullOrEmpty(name) || !name.Contains("\\"); _name = name; ModuleId = data.ModuleId; ModuleIndex = data.ModuleIndex; _metadataStart = data.MetdataStart; _metadataLength = data.MetadataLength; _assemblyAddress = data.Assembly; _size = size; if (!runtime.DataReader.IsMinidump) { // This is very expensive in the minidump case, as we may be heading out to the symbol server or // reading multiple files from disk. Only optimistically fetch this data if we have full memory. _metadata = data.LegacyMetaDataImport as ICorDebug.IMetadataImport; } else { // If we are a minidump and metadata isn't mapped in, attempt to fetch this module from the symbol server // on a background thread. #if !V2_SUPPORT if (_isPE && _metadataStart != 0 && _metadataLength > 0) { int read; byte[] tmp = new byte[1]; if (!_runtime.DataReader.ReadMemory(_metadataStart, tmp, 1, out read) || read == 0) { int filesize, imagesize; if (PEFile.TryGetIndexProperties(new ReadVirtualStream(_runtime.DataReader, (long)data.ImageBase, (long)size), true, out imagesize, out filesize)) _runtime.DataTarget.SymbolLocator.PrefetchBinary(Path.GetFileName(assemblyName), imagesize, filesize); } } #endif } }
public static TemplateEditorData LoadFromXml(IModuleData moduleData, XElement xmlData) { string ID = XmlDataHelper.GetAttributeAsString(xmlData, "ID", ""); if (!String.IsNullOrWhiteSpace(ID)) { TemplateEditorData data = new TemplateEditorData() { ID = ID, Name = GetPropertyValueFromXml(moduleData, xmlData, "TabName"), LabelText = GetPropertyValueFromXml(moduleData, xmlData, "LabelText"), DefaultFileName = GetPropertyValueFromXml(moduleData, xmlData, "DefaultTemplateFilename"), ExportPath = GetPropertyValueFromXml(moduleData, xmlData, "ExportPath"), DefaultEditorText = GetPropertyValueFromXml(moduleData, xmlData, "DefaultEditorText"), ToolTipText = ReplaceNewlineSymbols(GetPropertyValueFromXml(moduleData, xmlData, "ToolTip")) }; return(data); } return(null); }
/* * public void SaveGitIgnore(string content) * { * if (Data.AppSettings != null) * { * Log.Here().Activity("Saving .gitignore.default to {0}", Data.AppSettings.GitIgnoreFile); * * if (FileCommands.IsValidPath(Data.AppSettings.GitIgnoreFile)) * { * FileCommands.WriteToFile(Data.AppSettings.GitIgnoreFile, content); * } * else * { * Log.Here().Error("Invalid path for default .gitignore file: {0}. Using default path: {1}", Data.AppSettings.GitIgnoreFile, DefaultPaths.GitIgnore); * FileCommands.WriteToFile(DefaultPaths.GitIgnore, content); * } * } * } */ public bool SaveUserKeywords(IModuleData Data) { if (Data.UserKeywords != null) { if (Data.ModuleSettings != null && !String.IsNullOrEmpty(Data.ModuleSettings.UserKeywordsFile)) { Log.Here().Important("Serializing and saving user keywords data."); try { string json = JsonConvert.SerializeObject(Data.UserKeywords, Newtonsoft.Json.Formatting.Indented); return(FileCommands.WriteToFile(Data.ModuleSettings.UserKeywordsFile, json)); } catch (Exception ex) { Log.Here().Error("Error serializing Keywords.json: {0}", ex.ToString()); } } } return(false); }
public IEnumerable<MemoryRegion> EnumerateModuleHeaps(IAppDomainData appDomain, ulong addr) { Debug.Assert(appDomain != null); _appDomain = appDomain.Address; _regions.Clear(); if (addr == 0) return _regions; IModuleData module = _runtime.GetModuleData(addr); if (module != null) { _type = ClrMemoryRegionType.ModuleThunkHeap; _runtime.TraverseHeap(module.ThunkHeap, _delegate); _type = ClrMemoryRegionType.ModuleLookupTableHeap; _runtime.TraverseHeap(module.LookupTableHeap, _delegate); } return _regions; }
public void LoadUserKeywords(IModuleData Data, string filePath) { if (Data != null && !String.IsNullOrEmpty(filePath)) { if (File.Exists(filePath)) { Log.Here().Important("Deserializing Keywords list from {0}", filePath); try { Data.UserKeywords = JsonConvert.DeserializeObject <UserKeywordData>(File.ReadAllText(filePath)); } catch (Exception ex) { Log.Here().Error("Error deserializing {0}: {1}", filePath, ex.ToString()); } } } else { MainWindow.FooterLog("Problem loading keywords file at file path \"{0}\"", filePath); } }
private void SaveTemplates(IModuleData Data) { if (Data.ModuleSettings != null && Data.Templates != null) { if (Data.ModuleSettings.TemplateFiles != null) { Data.ModuleSettings.TemplateFiles.Clear(); } else { Data.ModuleSettings.TemplateFiles = new ObservableCollection <TemplateFileData>(); } foreach (var templateData in Data.Templates) { Data.ModuleSettings.TemplateFiles.Add(new TemplateFileData() { ID = templateData.ID, FilePath = templateData.FilePath }); } } }
internal DesktopModule GetModule(ulong module) { if (module == 0) { return(null); } if (_modules.TryGetValue(module, out DesktopModule res)) { return(res); } IModuleData moduleData = GetModuleData(module); if (moduleData == null) { return(null); } string peFile = GetPEFileName(moduleData.PEFile); string assemblyName = GetAssemblyName(moduleData.Assembly); if (peFile == null) { res = new DesktopModule(this, module, moduleData, peFile, assemblyName); } else if (!_moduleFiles.TryGetValue(peFile, out res)) { res = new DesktopModule(this, module, moduleData, peFile, assemblyName); _moduleFiles[peFile] = res; } // We've modified the 'real' module list, so clear the cached version. _moduleList = null; _modules[module] = res; return(res); }
public DesktopModule(DesktopRuntimeBase runtime, ulong address, IModuleData data, string name, string assemblyName, ulong size) { Revision = runtime.Revision; _imageBase = data.ImageBase; _runtime = runtime; _assemblyName = assemblyName; _isPE = data.IsPEFile; _reflection = data.IsReflection || string.IsNullOrEmpty(name) || !name.Contains("\\"); _name = name; ModuleId = data.ModuleId; ModuleIndex = data.ModuleIndex; _metadataStart = data.MetdataStart; _metadataLength = data.MetadataLength; _assemblyAddress = data.Assembly; _address = address; _size = size; // This is very expensive in the minidump case, as we may be heading out to the symbol server or // reading multiple files from disk. Only optimistically fetch this data if we have full memory. if (!runtime.DataReader.IsMinidump) _metadata = data.LegacyMetaDataImport as IMetadata; }