private void AddModuleToGrid(ModuleWrapper module, GridEXRow row) { AssignNumberValueToCell <uint>(row.Cells[0], module.GetToken()); AssignNumberValueToCell <ulong>(row.Cells[1], module.GetBaseAddress()); AssignNumberValueToCell <uint>(row.Cells[2], module.GetSize()); row.Cells[3].Value = module.IsDynamic(); row.Cells[4].Value = module.IsInMemory(); string moduleName = module.GetName(); try { row.Cells[5].Value = Path.GetFileName(moduleName); } catch { } row.Cells[6].Value = moduleName; AssemblyWrapper assembly = module.GetAssembly(); row.Cells[7].Value = assembly.GetName(); AppDomainWrapper appDomain = assembly.GetAppDomain(); row.Cells[8].Value = appDomain.GetName(); }
/// <summary> /// 创建游戏模块 /// </summary> /// <typeparam name="T">模块类</typeparam> /// <param name="createParam">创建参数</param> /// <param name="priority">运行时的优先级,优先级越大越早执行。如果没有设置优先级,那么会按照添加顺序执行</param> public static T CreateModule <T>(System.Object createParam, int priority = 0) where T : class, IModule { if (priority < 0) { throw new Exception("The priority can not be negative"); } if (Contains(typeof(T))) { throw new Exception($"Game module {typeof(T)} is already existed"); } // 如果没有设置优先级 if (priority == 0) { int minPriority = GetMinPriority(); priority = --minPriority; } MotionLog.Log($"Create game module : {typeof(T)}"); T module = Activator.CreateInstance <T>(); ModuleWrapper wrapper = new ModuleWrapper(module, priority); wrapper.Module.OnCreate(createParam); _coms.Add(wrapper); _isDirty = true; return(module); }
private void AddFile([NotNull] IProjectFile projectFile, [NotNull] PsiModuleChangeBuilder changeBuilder) { ISolution solution = projectFile.GetSolution(); // creates a new T4PsiModule for the file var lifetimeDefinition = Lifetime.Define(_lifetime, T4FilePsiModule.Prefix + projectFile.Name); var psiModule = new T4FilePsiModule( lifetimeDefinition.Lifetime, projectFile, _changeManager, _shellLocks, _t4Environment, PrimaryTargetFrameworkId ); _modules[projectFile] = new ModuleWrapper(psiModule, lifetimeDefinition); psiModule.AddBaseReferences(); changeBuilder.AddModuleChange(psiModule, PsiModuleChange.ChangeType.Added); changeBuilder.AddFileChange(psiModule.SourceFile, PsiModuleChange.ChangeType.Added); // Invalidate files that had this specific files as an include, // and whose IPsiSourceFile was previously managed by T4OutsideSolutionSourceFileManager. // Those files will be reparsed with the new source file. var fileManager = solution.GetComponent <T4OutsideSolutionSourceFileManager>(); VirtualFileSystemPath location = projectFile.Location; if (fileManager.HasSourceFile(location)) { fileManager.DeleteSourceFile(location); } }
private void AddFile([NotNull] IProjectFile projectFile, [NotNull] PsiModuleChangeBuilder changeBuilder) { ISolution solution = projectFile.GetSolution(); // creates a new T4PsiModule for the file LifetimeDefinition lifetimeDefinition = Lifetimes.Define(_lifetime, "[T4]" + projectFile.Name); var psiModule = new T4PsiModule( lifetimeDefinition.Lifetime, solution.GetComponent <PsiModuleManager>(), solution.GetComponent <DocumentManager>(), _changeManager, solution.GetComponent <IAssemblyFactory>(), _shellLocks, projectFile, solution.GetComponent <T4FileDataCache>(), _t4Environment, solution.GetComponent <OutputAssembliesCache>()); _modules[projectFile] = new ModuleWrapper(psiModule, lifetimeDefinition); changeBuilder.AddModuleChange(psiModule, PsiModuleChange.ChangeType.ADDED); changeBuilder.AddFileChange(psiModule.SourceFile, PsiModuleChange.ChangeType.ADDED); // Invalidate files that had this specific files as an include, // and whose IPsiSourceFile was previously managed by T4OutsideSolutionSourceFileManager. // Those files will be reparsed with the new source file. var fileManager = solution.GetComponent <T4OutsideSolutionSourceFileManager>(); FileSystemPath location = projectFile.Location; if (fileManager.HasSourceFile(location)) { fileManager.DeleteSourceFile(location); InvalidateFilesHavingInclude(location, solution.GetPsiServices()); } }
private void GetThreadName(ThreadWrapper threadWrapper, ValueWrapper threadObject, NuGenFrameRefresher threadActiveFrameRefresher) { List <ModuleWrapper> modules = threadWrapper.FindModulesByName(GetThreadNameMethod.BaseTypeDefinition.ModuleScope.Assembly.FileName); if (modules.Count == 1) { ModuleWrapper module = modules[0]; FunctionWrapper getThreadNameFunction = module.GetFunction(GetThreadNameMethod.Token); List <ValueWrapper> arguments = new List <ValueWrapper>(1); arguments.Add(threadObject); NuGenEvaluationHandler methodCaller = new NuGenEvaluationHandler(threadActiveFrameRefresher); NuGenBaseEvaluationResult evaluationResult = methodCaller.CallFunction(getThreadNameFunction, arguments); if (evaluationResult.IsSuccessful) { if (evaluationResult.Result != null && (CorElementType)evaluationResult.Result.ElementType == CorElementType.ELEMENT_TYPE_STRING) { ValueWrapper dereferencedResult = evaluationResult.Result.DereferenceValue(); if (dereferencedResult != null) { EvaluatedThreadName = NuGenHelperFunctions.ShowEscapeCharacters(dereferencedResult.GetStringValue(), true); } } } } }
public void AddModule(ModuleWrapper module) { modulesGrid.BeginGridUpdate(); GridEXRow moduleRow = modulesGrid.AddItem(); AddModuleToGrid(module, moduleRow); modulesGrid.EndGridUpdate(); }
public void AddModuleToPanel(ModuleWrapper module) { if (invokee.InvokeRequired) { invokee.Invoke(AddModuleToPanelMethod, new object[] { module }); } else { AddModuleToPanelMethod(module); } }
/// <summary> /// 该方法需要外部主动调用执行 /// </summary> public void Update() { // 如果有新模块需要加入 if (_temps.Count > 0) { for (int i = 0; i < _temps.Count; i++) { ModuleWrapper wrapper = _temps[i]; // 如果没有设置优先级 if (wrapper.Priority == 0) { int minPriority = GetMinPriority(); wrapper.SetPriority(--minPriority); } _coms.Add(wrapper); } // 清空临时列表 _temps.Clear(); // 最后重新排序 _coms.Sort((left, right) => { if (left.Priority > right.Priority) { return(-1); } else if (left.Priority == right.Priority) { return(0); } else { return(1); } }); } // 更新所有模块 for (int i = 0; i < _coms.Count; i++) { ModuleWrapper wrapper = _coms[i]; if (wrapper.IsStart == false) { LogSystem.Log(ELogType.Log, $"{wrapper.Module.GetType()} is start."); wrapper.IsStart = true; wrapper.Module.Start(); } wrapper.Module.Update(); } }
private void AddSelectedModuleToProject(GridEXRow selectedRow, string moduleName) { ModuleWrapper inMemoryModule = NuGenHelperFunctions.TaggedObjects[moduleName] as ModuleWrapper; if (inMemoryModule != null) { NuGenAssemblyLoader.Instance.LoadInMemoryModule(inMemoryModule); } else { NuGenAssemblyLoader.Instance.Start(new string[] { moduleName }); } }
/// <summary> /// 注册模块 /// </summary> /// <param name="module">要注册的模块</param> /// <param name="priority">运行时的优先级,优先级越大越早执行。如果没有设置优先级,那么会按照添加顺序执行</param> public void RegisterModule(IModule module, int priority = 0) { if (module == null) { throw new ArgumentNullException(); } ModuleWrapper wrapper = new ModuleWrapper(module, priority); _temps.Add(wrapper); // 执行Awake module.Awake(); }
public void EnumerateTypeDefinitions(NuGenIMetaDataImport2 import, ModuleWrapper debuggedModule) { DebuggedModule = debuggedModule; IntPtr enumHandle = IntPtr.Zero; uint[] typeDefs = new uint[NuGenProject.DefaultArrayCount]; uint count = 0; import.EnumTypeDefs(ref enumHandle, typeDefs, Convert.ToUInt32(typeDefs.Length), out count); while (count > 0) { for (uint typeDefsIndex = 0; typeDefsIndex < count; typeDefsIndex++) { uint token = typeDefs[typeDefsIndex]; uint typeNameLength; uint typeDefFlags; uint baseTypeToken; import.GetTypeDefProps(token, NuGenProject.DefaultCharArray, Convert.ToUInt32(NuGenProject.DefaultCharArray.Length), out typeNameLength, out typeDefFlags, out baseTypeToken); if (typeNameLength > NuGenProject.DefaultCharArray.Length) { NuGenProject.DefaultCharArray = new char[typeNameLength]; import.GetTypeDefProps(token, NuGenProject.DefaultCharArray, Convert.ToUInt32(NuGenProject.DefaultCharArray.Length), out typeNameLength, out typeDefFlags, out baseTypeToken); } NuGenTypeDefinition typeDefinition = new NuGenTypeDefinition(import, this, NuGenHelperFunctions.GetString(NuGenProject.DefaultCharArray, 0, typeNameLength), token, (CorTypeAttr)typeDefFlags, baseTypeToken); TypeDefinitions[token] = typeDefinition; Assembly.AllTokens[token] = typeDefinition; } import.EnumTypeDefs(ref enumHandle, typeDefs, Convert.ToUInt32(typeDefs.Length), out count); } import.CloseEnum(enumHandle); foreach (NuGenTypeDefinition typeDefinition in TypeDefinitions.Values) { if (typeDefinition.IsNestedType) { typeDefinition.FindEnclosingType(import); } } DebuggedModule = null; }
public void AddModules(ModuleWrapper[] modules) { modulesGrid.BeginGridUpdate(); int rowsCount = modulesGrid.RowCount; for (int index = 0; index < modules.Length; index++) { ModuleWrapper module = modules[index]; GridEXRow row = modulesGrid.AddItem(); AddModuleToGrid(module, row); } modulesGrid.EndGridUpdate(); }
private void FindGetThreadNameMethod(uint threadTypeToken, ModuleWrapper module) { NuGenTypeDefinition threadType = NuGenHelperFunctions.FindObjectByToken(threadTypeToken, module) as NuGenTypeDefinition; if (threadType != null) { NuGenProperty nameProperty = threadType.FindPropertyByName("Name"); if (nameProperty != null) { GetThreadNameMethod = NuGenHelperFunctions.FindObjectByToken(nameProperty.GetterMethodToken, module) as NuGenMethodDefinition; } } HasSearchedForNameMethod = true; }
private void AddModule() { var type = this._dialogService.ShowSelectTypeDialog(typeof(BaseModule), "Select a Module"); if (type != null) { var baseModule = Activator.CreateInstance(type) as BaseModule; var moduleWrapper = new ModuleWrapper(baseModule); var undoCommand = new UndoCommand( () => this.Modules.Add(moduleWrapper), () => this.Modules.Remove(moduleWrapper)); this._undoService.Do(undoCommand); } }
private void ShowModules() { modulesGrid.BeginGridUpdate(); modulesGrid.ClearItems(); List <ModuleWrapper> modules = NuGenDebugEventHandler.Instance.EventObjects.Process.GetModules(); for (int index = 0; index < modules.Count; index++) { ModuleWrapper module = modules[index]; GridEXRow row = modulesGrid.AddItem(); AddModuleToGrid(module, row); } modulesGrid.EndGridUpdate(); }
public void LoadInMemoryModule(ModuleWrapper inMemoryModule) { List<NuGenAssembly> loadedAssemblies = new List<NuGenAssembly>(1); try { string moduleName = inMemoryModule.GetName(); try { moduleName = Path.GetFileNameWithoutExtension(moduleName); } catch { } NuGenAssembly inMemoryAssembly = new NuGenAssembly(true); inMemoryAssembly.FileName = moduleName; inMemoryAssembly.Name = moduleName; NuGenMetaDataDispenserEx dispenser = new NuGenMetaDataDispenserEx(); inMemoryAssembly.LoadAssemblyFromMetadataInterfaces(dispenser, (NuGenIMetaDataAssemblyImport)inMemoryModule.GetMetaDataAssemblyImport(), (NuGenIMetaDataImport2)inMemoryModule.GetMetaDataImport2(), inMemoryModule); loadedAssemblies.Add(inMemoryAssembly); } catch (Exception exception) { NuGenUIHandler.Instance.DisplayUserWarning("An error occurred while loading the assembly."); NuGenUIHandler.Instance.ShowException(exception); } NuGenUIHandler.Instance.ResetProgressBar(); if (loadedAssemblies.Count > 0) { NuGenUIHandler.Instance.AssembliesLoaded(loadedAssemblies, false); if (AssembliesLoaded != null) { AssembliesLoaded(loadedAssemblies, false); } } }
public void LoadInMemoryModule(ModuleWrapper inMemoryModule) { List <NuGenAssembly> loadedAssemblies = new List <NuGenAssembly>(1); try { string moduleName = inMemoryModule.GetName(); try { moduleName = Path.GetFileNameWithoutExtension(moduleName); } catch { } NuGenAssembly inMemoryAssembly = new NuGenAssembly(true); inMemoryAssembly.FileName = moduleName; inMemoryAssembly.Name = moduleName; NuGenMetaDataDispenserEx dispenser = new NuGenMetaDataDispenserEx(); inMemoryAssembly.LoadAssemblyFromMetadataInterfaces(dispenser, (NuGenIMetaDataAssemblyImport)inMemoryModule.GetMetaDataAssemblyImport(), (NuGenIMetaDataImport2)inMemoryModule.GetMetaDataImport2(), inMemoryModule); loadedAssemblies.Add(inMemoryAssembly); } catch (Exception exception) { NuGenUIHandler.Instance.DisplayUserWarning("An error occurred while loading the assembly."); NuGenUIHandler.Instance.ShowException(exception); } NuGenUIHandler.Instance.ResetProgressBar(); if (loadedAssemblies.Count > 0) { NuGenUIHandler.Instance.AssembliesLoaded(loadedAssemblies, false); if (AssembliesLoaded != null) { AssembliesLoaded(loadedAssemblies, false); } } }
public void Init() { try { this.IsBusy = true; if (this.FontList.Count == 0) { for (int i = 0; i < Math.Min(Plugin.Iconize.Iconize.Modules.Count, 4); i++) { var module = Plugin.Iconize.Iconize.Modules[i]; var bc = new ModuleWrapper(module); this.FontList.Add(new FontViewModel(bc)); } } } finally { this.IsBusy = false; } }
private void BtnParse_Click(object sender, EventArgs e) { if (txtCVS.Text == String.Empty) { MessageBox.Show("CVS Path Cannot be Empty!"); } else { try { OModel = new ModuleWrapper(txtCVS.Text, config).Parse(); txtJava.Text = OModel; xmlAdapter = new XMLAdapterGenerator(config).Generate(); SyncProvider = new SyncProviderGenerator(config).Generate(); SyncService = new SyncServiceGenerator(config).Generate(); xmlManifest = new ManifestSyncData(config).Generate(); btnSave.Enabled = true; } catch (Exception) { btnParse.Enabled = false; } } }
public FontViewModel(ModuleWrapper mw) { this.FilteredList = new ObservableCollection <IconViewModel>(); this.FontName = mw.FontFamily; if (mw.FontFamily.Contains("Regular")) { this.FontFamily = Device.RuntimePlatform == Device.iOS ? "FontAwesome5Free-Regular" : "FontAwesome5Solid.otf#Regular"; } if (mw.FontFamily.Contains("Solid")) { this.FontFamily = Device.RuntimePlatform == Device.iOS ? "FontAwesome5Free-Solid" : "FontAwesome5Solid.otf#Regular"; } if (mw.FontFamily.Contains("Brands")) { this.FontFamily = Device.RuntimePlatform == Device.iOS ? "FontAwesome5Brands-Regular" : "FontAwesome5Brands.otf#Regular"; } CharList = new List <IconViewModel>(); foreach (var item in mw.Characters) { CharList.Add(new IconViewModel(item)); } }
private void GoDFS(string myNode, ModuleWrapper myNodeInfo) { // get list of nodes to go List <string> nodesToGo; if (!_nextNodeList.TryGetValue(myNode, out nodesToGo)) { if (_sortingMode == SortingMode.Exceptions) { throw new ArgumentException( string.Format( "No such dependency in dictionary. The {0} could not be found.", myNode), "myNode"); } else if (_sortingMode == SortingMode.Silent) { _canBeSorted = false; return; // nodes to go wil be empty -> no place to go } } // stop condition (already visted) if (myNodeInfo.Color == NodeColor.Black) { return; } // stop c if (myNodeInfo.Color == NodeColor.Gray) { if (_sortingMode == SortingMode.Exceptions) { throw new ArgumentException( string.Format("DependencyGraph has cycles. Duplicated node is {0}.", myNode), "myNode"); } else if (_sortingMode == SortingMode.Silent) { _canBeSorted = false; return; } } // mark node as gray (meaning we are traversing this node) myNodeInfo.Color = NodeColor.Gray; foreach (string nodeName in nodesToGo) { // check if the node exists ModuleWrapper nodeToGo; if (!_myNodesDict.TryGetValue(nodeName, out nodeToGo)) { if (_sortingMode == SortingMode.Exceptions) { throw new ArgumentException( string.Format( "No such dependency in dictionary. The {0} could not be found.", myNode), "myNode"); } else if (_sortingMode == SortingMode.Silent) { _canBeSorted = false; // add the starting node to the list of non valid nodes (it has some empty reference) if (!_nonValidModules.Contains(myNodeInfo.Module)) { _nonValidModules.Add(myNodeInfo.Module); } // go to another node continue; } } // get version string name = nodeName; IEnumerable <Version> myNodeDependencyVersions = myNodeInfo.Module.Manifest.ModuleDependencies.Where( x => x.ModuleName.Equals(name)).Select(x => x.MinimalVersion); Version myNodeDependencyVersion = myNodeDependencyVersions.SingleOrDefault(); Version dependencyVersion = nodeToGo.Module.Manifest.ModuleVersion; // compare values of the versions, using system feature if (myNodeDependencyVersion.GetSystemVersion() > dependencyVersion.GetSystemVersion()) { if (_sortingMode == SortingMode.Exceptions) { throw new ArgumentException( string.Format( "Dependency version ({0}) is higher than module's version {1}", myNodeDependencyVersion, dependencyVersion)); } else if (_sortingMode == SortingMode.Silent) { _canBeSorted = false; // wrong version means that our node has wrong reference if (!_nonValidModules.Contains(myNodeInfo.Module)) { _nonValidModules.Add(myNodeInfo.Module); } // let go this way } } // if everything ok, go DFS GoDFS(nodeName, nodeToGo); } _stack.Push(myNodeInfo.Module); myNodeInfo.Color = NodeColor.Black; }
public void AddModuleToPanel(ModuleWrapper module) { modulesPanel.AddModule(module); }
public void LoadAssemblyFromMetadataInterfaces(ModuleWrapper debuggedModule) { string assemblyPath = (IsInMemory ? Name : FullPath); NuGenUIHandler.Instance.ResetProgressBar(); if (IsInMemory) { NuGenUIHandler.Instance.SetProgressBarMaximum(15); DebuggedProcess = debuggedModule.GetProcess(); } else { NuGenUIHandler.Instance.SetProgressBarMaximum(16); NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Reading header...", true); ReadHeader(); NuGenUIHandler.Instance.StepProgressBar(1); } NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Opening assembly references...", true); OpenAssemblyRefs(); NuGenUIHandler.Instance.StepProgressBar(1); NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading user strings...", true); GetUserStrings(); NuGenUIHandler.Instance.StepProgressBar(1); NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading manifest resources...", true); GetManifestResources(); NuGenUIHandler.Instance.StepProgressBar(1); NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading files...", true); GetFiles(); NuGenUIHandler.Instance.StepProgressBar(1); NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading module references...", true); GetModuleReferences(); NuGenUIHandler.Instance.StepProgressBar(1); NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading type references...", true); GetTypeReferences(); NuGenUIHandler.Instance.StepProgressBar(1); NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading global type's references...", true); NuGenHelperFunctions.GetMemberReferences(this, 0); NuGenUIHandler.Instance.StepProgressBar(1); NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading type specifications...", true); GetTypeSpecs(); NuGenUIHandler.Instance.StepProgressBar(1); NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading standalone signatures...", true); GetSignatures(); NuGenUIHandler.Instance.StepProgressBar(1); NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading module scope...", true); ModuleScope = new NuGenModuleScope(Import, this); ModuleScope.EnumerateTypeDefinitions(Import, debuggedModule); NuGenUIHandler.Instance.StepProgressBar(1); NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading global type...", true); GlobalType = new NuGenTypeDefinition(Import, ModuleScope, 0); NuGenUIHandler.Instance.StepProgressBar(1); AllTokens[0] = GlobalType; NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Associating properties with methods...", true); AssociatePropertiesWithMethods(); NuGenUIHandler.Instance.StepProgressBar(1); NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Reading assembly properties...", true); DisplayInTree = false; try { ReadProperties(); DisplayInTree = true; } catch (COMException comException) { unchecked { if (comException.ErrorCode != (int)0x80131130) { throw; } } } NuGenUIHandler.Instance.StepProgressBar(1); NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Loading resolving resolution scopes...", true); ResolveResolutionScopes(); NuGenUIHandler.Instance.StepProgressBar(1); NuGenUIHandler.Instance.SetProgressText(assemblyPath, "Searching for entry method...", true); SearchEntryPoint(); NuGenUIHandler.Instance.StepProgressBar(1); }
private void ShowThreads() { threadsGrid.BeginGridUpdate(); threadsGrid.ClearItems(); List <ThreadWrapper> threads = NuGenDebugEventHandler.Instance.EventObjects.Controller.EnumerateThreads(); foreach (ThreadWrapper thread in threads) { EvaluatedThreadName = "<no name>"; ValueWrapper threadObject = null; ValueWrapper dereferencedObject = null; if (!HasSearchedForNameMethod) { threadObject = thread.GetObject(); if (threadObject != null && !threadObject.IsNull()) { dereferencedObject = threadObject.DereferenceValue(); if (dereferencedObject != null) { ClassWrapper threadClass = dereferencedObject.GetClassInformation(); uint threadTypeToken = threadClass.GetToken(); ModuleWrapper module = threadClass.GetModule(); FindGetThreadNameMethod(threadTypeToken, module); } } } if (HasSearchedForNameMethod) { if (GetThreadNameMethod == null) { EvaluatedThreadName = "<definition of the Thread class is not loaded>"; } else { if (threadObject == null) { threadObject = thread.GetObject(); if (threadObject != null && !threadObject.IsNull()) { dereferencedObject = threadObject.DereferenceValue(); } } if (dereferencedObject != null) { FrameWrapper threadActiveFrame = thread.GetActiveFrame(); if (threadActiveFrame != null) { NuGenFrameRefresher threadActiveFrameRefresher = new NuGenFrameRefresher(thread, threadActiveFrame.ChainIndex, threadActiveFrame.FrameIndex, threadActiveFrame.IsActiveFrame); GetThreadName(thread, threadObject, threadActiveFrameRefresher); } } } } GridEXRow row = threadsGrid.AddItem(); uint threadID = thread.GetID(); GridEXCell idCell = row.Cells[0]; NuGenHelperFunctions.TaggedObjects.Add((int)idCell.Value, threadID); idCell.Value = NuGenHelperFunctions.FormatNumber(threadID); row.Cells[1].Value = EvaluatedThreadName; AppDomainWrapper appDomain = thread.GetAppDomain(); if (appDomain != null) { row.Cells[2].Value = appDomain.GetName(); } NuGenHelperFunctions.TaggedObjects.Add((String)row.Cells[1].Value + (String)row.Cells[2].Value, thread); } threadsGrid.EndGridUpdate(); }
private static void ModifyFile([NotNull] PsiModuleChangeBuilder changeBuilder, ModuleWrapper moduleWrapper) { changeBuilder.AddFileChange(moduleWrapper.Module.SourceFile, PsiModuleChange.ChangeType.MODIFIED); }
private void RemoveFile([NotNull] IProjectFile projectFile, [NotNull] PsiModuleChangeBuilder changeBuilder, ModuleWrapper moduleWrapper) { _modules.Remove(projectFile); changeBuilder.AddFileChange(moduleWrapper.Module.SourceFile, PsiModuleChange.ChangeType.Removed); changeBuilder.AddModuleChange(moduleWrapper.Module, PsiModuleChange.ChangeType.Removed); moduleWrapper.LifetimeDefinition.Terminate(); }
private void AddFile([NotNull] IProjectFile projectFile, [NotNull] PsiModuleChangeBuilder changeBuilder) { ISolution solution = projectFile.GetSolution(); // creates a new T4PsiModule for the file LifetimeDefinition lifetimeDefinition = Lifetimes.Define(_lifetime, "[T4]" + projectFile.Name); var psiModule = new T4PsiModule( lifetimeDefinition.Lifetime, solution.GetComponent<IPsiModules>(), solution.GetComponent<DocumentManager>(), _changeManager, solution.GetComponent<IAssemblyFactory>(), _shellLocks, projectFile, solution.GetComponent<T4FileDataCache>(), _t4Environment, solution.GetComponent<OutputAssemblies>()); _modules[projectFile] = new ModuleWrapper(psiModule, lifetimeDefinition); changeBuilder.AddModuleChange(psiModule, PsiModuleChange.ChangeType.Added); changeBuilder.AddFileChange(psiModule.SourceFile, PsiModuleChange.ChangeType.Added); // Invalidate files that had this specific files as an include, // and whose IPsiSourceFile was previously managed by T4OutsideSolutionSourceFileManager. // Those files will be reparsed with the new source file. var fileManager = solution.GetComponent<T4OutsideSolutionSourceFileManager>(); FileSystemPath location = projectFile.Location; if (fileManager.HasSourceFile(location)) { fileManager.DeleteSourceFile(location); InvalidateFilesHavingInclude(location, solution.GetPsiServices()); } }
private void contextMenu_Opening(object sender, CancelEventArgs e) { setIPToolStripMenuItem.Visible = false; if (NuGenDebugEventHandler.Instance.EventObjects.Frame != null && NuGenDebugEventHandler.Instance.EventObjects.Frame.IsActiveFrame && CurrentLine != null) { NuGenMethodDefinition displayedMethod = CodeObject as NuGenMethodDefinition; if (displayedMethod != null) { FunctionWrapper currentFunction = NuGenDebugEventHandler.Instance.EventObjects.Frame.GetFunction(); uint currentFunctionToken = currentFunction.GetToken(); if (displayedMethod.Token == currentFunctionToken) { ModuleWrapper currentModule = currentFunction.GetModule(); bool isInMemoryCurrentModule = currentModule.IsInMemory(); string currentModuleName = string.Empty; if (isInMemoryCurrentModule) { currentModuleName = currentModule.GetNameFromMetaData(); } else { currentModuleName = currentModule.GetName(); try { currentModuleName = Path.GetFileNameWithoutExtension(currentModuleName); } catch { } } currentModuleName = currentModuleName.ToLower(); if ((isInMemoryCurrentModule && displayedMethod.BaseTypeDefinition.ModuleScope.Name.ToLower() == currentModuleName) || (!isInMemoryCurrentModule && Path.GetFileNameWithoutExtension(displayedMethod.BaseTypeDefinition.ModuleScope.Assembly.FullPath).ToLower() == currentModuleName)) { NuGenBaseILCode currentILCode = ilEditor.GetILCodeAtMouseCursor(); setIPToolStripMenuItem.Visible = true; if (currentILCode != null) { int hResult = NuGenDebugEventHandler.Instance.EventObjects.Frame.CanSetIP(Convert.ToUInt32(currentILCode.Offset)); if (hResult == 0) { setIPToolStripMenuItem.Enabled = true; setIPToolStripMenuItem.Tag = currentILCode; } else { COMException comException = Marshal.GetExceptionForHR(hResult) as COMException; if (comException != null) { NuGenUIHandler.Instance.DisplayUserWarning(Marshal.GetExceptionForHR(hResult).Message); } setIPToolStripMenuItem.Enabled = false; } } else { setIPToolStripMenuItem.Enabled = false; } } } } } }
public void LoadAssemblyFromMetadataInterfaces(NuGenIMetaDataDispenserEx dispenser, NuGenIMetaDataAssemblyImport assemblyImport, NuGenIMetaDataImport2 import, ModuleWrapper debuggedModule) { Dispenser = dispenser; AssemblyImport = assemblyImport; Import = import; uint bufferCount; Import.GetVersionString(NuGenProject.DefaultCharArray, Convert.ToUInt32(NuGenProject.DefaultCharArray.Length), out bufferCount); if (bufferCount > NuGenProject.DefaultCharArray.Length) { NuGenProject.DefaultCharArray = new char[bufferCount]; Import.GetVersionString(NuGenProject.DefaultCharArray, bufferCount, out bufferCount); } FrameworkVersion = NuGenHelperFunctions.GetString(NuGenProject.DefaultCharArray, 0, bufferCount); ProcessWrapper debuggedProcess = debuggedModule.GetProcess(); Process process = Process.GetProcessById(Convert.ToInt32(debuggedProcess.GetID())); FullPath = process.MainModule.FileName; FileName = Name; LoadAssemblyFromMetadataInterfaces(debuggedModule); }
private static void ModifyFile([NotNull] PsiModuleChangeBuilder changeBuilder, ModuleWrapper moduleWrapper) { changeBuilder.AddFileChange(moduleWrapper.Module.SourceFile, PsiModuleChange.ChangeType.Modified); }
public void AddModulesToPanel(ModuleWrapper[] modules) { modulesPanel.AddModules(modules); }
private void RemoveFile([NotNull] IProjectFile projectFile, [NotNull] PsiModuleChangeBuilder changeBuilder, ModuleWrapper moduleWrapper) { _modules.Remove(projectFile); changeBuilder.AddFileChange(moduleWrapper.Module.SourceFile, PsiModuleChange.ChangeType.Removed); changeBuilder.AddModuleChange(moduleWrapper.Module, PsiModuleChange.ChangeType.Removed); InvalidateFilesHavingInclude(projectFile.Location, moduleWrapper.Module.GetPsiServices()); moduleWrapper.LifetimeDefinition.Terminate(); }
public void AddModulesToPanel(ModuleWrapper[] modules) { AddModulesToPanel(modules); }
private void RemoveFile([NotNull] IProjectFile projectFile, [NotNull] PsiModuleChangeBuilder changeBuilder, ModuleWrapper moduleWrapper) { _modules.Remove(projectFile); changeBuilder.AddFileChange(moduleWrapper.Module.SourceFile, PsiModuleChange.ChangeType.REMOVED); changeBuilder.AddModuleChange(moduleWrapper.Module, PsiModuleChange.ChangeType.REMOVED); InvalidateFilesHavingInclude(projectFile.Location, moduleWrapper.Module.GetPsiServices()); moduleWrapper.LifetimeDefinition.Terminate(); }
public void DisplayCallStack(List <FrameWrapper> callStack) { if (callStack != null) { callStackView.BeginUpdate(); callStackView.Items.Clear(); for (int index = 0; index < callStack.Count; index++) { FrameWrapper frame = callStack[index]; ListViewItem item = new ListViewItem(); bool isCodeAvailable = false; FunctionWrapper function = null; try { function = frame.GetFunction(); isCodeAvailable = true; } catch (COMException comException) { //0x80131309 == CORDBG_E_CODE_NOT_AVAILABLE if ((uint)comException.ErrorCode == 0x80131309) { isCodeAvailable = false; } else { throw; } } if (isCodeAvailable) { ModuleWrapper module = function.GetModule(); uint functionToken = function.GetToken(); NuGenTokenBase tokenObject = NuGenHelperFunctions.FindObjectByToken(functionToken, module); NuGenMethodDefinition methodDefinition = tokenObject as NuGenMethodDefinition; if (methodDefinition != null) { bool activeFrame = (index == 0); NuGenFrameInformation frameInformation = new NuGenFrameInformation(NuGenDebugEventHandler.Instance.EventObjects.Thread, methodDefinition, activeFrame, frame); item.Tag = frameInformation; item.Text = string.Format("{0}::{1}", methodDefinition.BaseTypeDefinition.FullName, methodDefinition.DisplayName); if (!frameInformation.IsExactLocation) { item.Text += " - not exact offset"; } } else { string moduleName = module.GetName(); if (module.IsInMemory()) { item.Tag = new NuGenMissingModule(module); } else { item.Tag = new NuGenMissingModule(moduleName); } item.Text = "Unknown method (perhaps a reference is not loaded). Module name: " + moduleName; } } if (!frame.IsILFrame()) { if (isCodeAvailable) { item.Text = "Native frame, IP offset is not available (" + item.Text + ")"; } else { item.Text = "Native frame, IP offset is not available (code is unavailable)."; } } item.ToolTipText = item.Text; callStackView.Items.Add(item); } callStackView.EndUpdate(); } }
public void AddModuleToPanel(ModuleWrapper module) { if(invokee.InvokeRequired) invokee.Invoke(AddModuleToPanelMethod, new object[]{module}); else AddModuleToPanelMethod(module); }