Ejemplo n.º 1
0
 static void DisableMemoryMappedIO(HashSet <string> filenames, IPEImage peImage)
 {
     if (peImage != null && filenames.Contains(peImage.Filename))
     {
         MemoryMappedIOHelper.DisableMemoryMappedIO(peImage);
     }
 }
Ejemplo n.º 2
0
 void DisableMemoryMappedIO()
 {
     foreach (var m in fileManager.GetFiles())
     {
         foreach (var f in m.GetAllChildrenAndSelf())
         {
             MemoryMappedIOHelper.DisableMemoryMappedIO(f);
         }
     }
 }
 void DisableMemoryMappedIO()
 {
     foreach (var m in documentService.GetDocuments())
     {
         foreach (var f in m.GetAllChildrenAndSelf())
         {
             MemoryMappedIOHelper.DisableMemoryMappedIO(f);
         }
     }
 }
Ejemplo n.º 4
0
 void DisableMemoryMappedIO(IDnSpyFileNode[] nodes)
 {
     // The nodes will be GC'd eventually, but it's not safe to call Dispose(), so disable
     // mmap'd I/O so the files can at least be modified (eg. deleted) by the user.
     foreach (var node in nodes)
     {
         foreach (var f in node.DnSpyFile.GetAllChildrenAndSelf())
         {
             MemoryMappedIOHelper.DisableMemoryMappedIO(f);
         }
     }
 }
Ejemplo n.º 5
0
        internal static void Execute(Lazy <IUndoCommandService> undoCommandService, Lazy <IDocumentSaver> documentSaver, IAppService appService, DocumentTreeNodeData[] nodes)
        {
            if (!CanExecute(nodes))
            {
                return;
            }

            var asmNodes = nodes.Cast <DsDocumentNode>().ToArray();
            var files    = asmNodes.SelectMany(a => a.Document.GetAllChildrenAndSelf());

            if (!documentSaver.Value.AskUserToSaveIfModified(files))
            {
                return;
            }

            var keepNodes         = new List <DsDocumentNode>();
            var freeNodes         = new List <DsDocumentNode>();
            var onlyInRedoHistory = new List <DsDocumentNode>();

            foreach (var info in GetUndoRedoInfo(undoCommandService.Value, asmNodes))
            {
                if (!info.IsInUndo && !info.IsInRedo)
                {
                    // This asm is safe to remove
                    freeNodes.Add(info.Node);
                }
                else if (!info.IsInUndo && info.IsInRedo)
                {
                    // If we add a RemoveAssemblyCommand, the redo history will be cleared, so this
                    // assembly will be cleared from the history and don't need to be kept.
                    onlyInRedoHistory.Add(info.Node);
                }
                else
                {
                    // The asm is in the undo history, and maybe in the redo history. We must keep it.
                    keepNodes.Add(info.Node);
                }
            }

            if (keepNodes.Count > 0 || onlyInRedoHistory.Count > 0)
            {
                // We can't free the asm since older commands might reference it so we must record
                // it in the history. The user can click Clear History to free everything.
                foreach (var node in keepNodes)
                {
                    foreach (var f in node.Document.GetAllChildrenAndSelf())
                    {
                        MemoryMappedIOHelper.DisableMemoryMappedIO(f);
                    }
                }
                if (keepNodes.Count != 0)
                {
                    undoCommandService.Value.Add(new RemoveAssemblyCommand(appService.DocumentTreeView, keepNodes.ToArray()));
                }
                else
                {
                    undoCommandService.Value.ClearRedo();
                }
                // Redo history was cleared
                FreeAssemblies(onlyInRedoHistory);
            }

            FreeAssemblies(freeNodes);
            if (freeNodes.Count > 0 || onlyInRedoHistory.Count > 0)
            {
                undoCommandService.Value.CallGc();
            }
        }
Ejemplo n.º 6
0
 // Should be called if we don't save it in the documents list. It will eventually be GC'd but it's
 // better to disable mmap'd I/O as soon as possible. The document must've been created by us.
 static IDsDocument DisableMMapdIO(IDsDocument document)
 {
     MemoryMappedIOHelper.DisableMemoryMappedIO(document);
     return(document);
 }
Ejemplo n.º 7
0
 // Should be called if we don't save it in the files list. It will eventually be GC'd but it's
 // better to disable mmap'd I/O as soon as possible. The file must've been created by us.
 static IDnSpyFile DisableMMapdIO(IDnSpyFile file)
 {
     MemoryMappedIOHelper.DisableMemoryMappedIO(file);
     return(file);
 }