Exemple #1
0
        void Save(ModuleVM[] files)
        {
            var list = new Tuple <DnModule, string> [files.Length];

            if (files.Length == 1)
            {
                var vm       = files[0];
                var filename = new PickSaveFilename().GetFilename(GetModuleFilename(vm.Module), GetDefaultExtension(GetModuleFilename(vm.Module), vm.IsExe, vm.Module.CorModule.IsManifestModule), PickFilenameConstants.DotNetAssemblyOrModuleFilter);
                if (string.IsNullOrEmpty(filename))
                {
                    return;
                }
                list[0] = Tuple.Create(vm.Module, filename);
            }
            else
            {
                var dir = new PickDirectory().GetDirectory(null);
                if (!Directory.Exists(dir))
                {
                    return;
                }
                for (int i = 0; i < files.Length; i++)
                {
                    var file     = files[i];
                    var filename = DebugOutputUtils.GetFilename(file.Module.Name);
                    var lf       = filename.ToUpperInvariant();
                    if (lf.EndsWith(".EXE") || lf.EndsWith(".DLL") || lf.EndsWith(".NETMODULE"))
                    {
                    }
                    else if (file.Module.CorModule.IsManifestModule)
                    {
                        filename += file.IsExe ? ".exe" : ".dll";
                    }
                    else
                    {
                        filename += ".netmodule";
                    }
                    list[i] = Tuple.Create(file.Module, Path.Combine(dir, filename));
                }
            }

            var data = new ProgressVM(Dispatcher.CurrentDispatcher, new PEFilesSaver(list));
            var win  = new ProgressDlg();

            win.DataContext = data;
            win.Owner       = appWindow.MainWindow;
            win.Title       = list.Length == 1 ? dnSpy_Debugger_Resources.ModuleSaveModuleTitle :
                              dnSpy_Debugger_Resources.ModuleSaveModulesTitle;
            var res = win.ShowDialog();

            if (res != true)
            {
                return;
            }
            if (!data.WasError)
            {
                return;
            }
            messageBoxManager.Show(string.Format(dnSpy_Debugger_Resources.ErrorOccurredX, data.ErrorMessage));
        }
Exemple #2
0
 static string GetModuleFilename(DnModule module)
 {
     if (module.IsDynamic)
     {
         return(null);
     }
     if (!module.IsInMemory)
     {
         return(DebugOutputUtils.GetFilename(module.Name));
     }
     if (module.CorModule.IsManifestModule)
     {
         return(DebugOutputUtils.GetFilename(new AssemblyNameInfo(module.Assembly.FullName).Name));
     }
     return(DebugOutputUtils.GetFilename(module.DnlibName));
 }
Exemple #3
0
        static void Save(ModuleVM[] files)
        {
            if (files.Length == 0)
            {
                return;
            }
            var buffer = new byte[0x10000];

            if (files.Length == 1)
            {
                var vm       = files[0];
                var filename = new PickSaveFilename().GetFilename(vm.Module.Name, GetDefaultExtension(vm.Module.Name, vm.IsExe), PickFilenameConstants.DotNetAssemblyOrModuleFilter);
                if (string.IsNullOrEmpty(filename))
                {
                    return;
                }
                Save(vm.Module, filename, buffer);
            }
            else
            {
                var dir = new PickDirectory().GetDirectory(null);
                if (string.IsNullOrEmpty(dir))
                {
                    return;
                }
                foreach (var file in files)
                {
                    var filename = DebugOutputUtils.GetFilename(file.Module.Name);
                    if (filename.IndexOf('.') < 0)
                    {
                        filename += file.IsExe ? ".exe" : ".dll";
                    }
                    bool saved = Save(file.Module, Path.Combine(dir, filename), buffer);
                    if (!saved)
                    {
                        return;
                    }
                }
            }
        }
Exemple #4
0
 public void WriteFilename(ProcessVM vm)
 {
     WriteFilename(vm, DebugOutputUtils.GetFilename(vm.FullPath));
 }
Exemple #5
0
 public void WriteName(ModuleVM vm)
 {
     WriteFilename(vm, DebugOutputUtils.GetFilename(vm.Module.Name));
 }