MalwareSourceCode/MSIL/Virus/Win32/S/Virus.Win32.Sality.sil-906e49d7772808af1fb67511fd33b01c809079fddb77015425883ca9739cad33/MNUFileMigrator.cs
2022-08-18 06:28:56 -05:00

138 lines
5.6 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Autodesk.AutoCAD.ADMigrator.MNUFileMigrator
// Assembly: ADMigrator, Version=18.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 1EA8663B-E949-4FAD-ABC5-280393847F56
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Virus.Win32.Sality.sil-906e49d7772808af1fb67511fd33b01c809079fddb77015425883ca9739cad33.exe
using Autodesk.AutoCAD.Customization;
using Autodesk.AutoCAD.CustomMigrator;
using System;
using System.Globalization;
using System.IO;
namespace Autodesk.AutoCAD.ADMigrator
{
public class MNUFileMigrator
{
public static ILogXML _logger;
private string _originalSourceMNUPath;
private string _targetCUIPath;
private string _sourceMNUPath;
private bool _loadTarget;
private CustomizationSection _convertedCUI;
public MNUFileMigrator(string source, ILogXML mainFormLogger)
{
string path = Path.GetDirectoryName(source) + "\\" + Path.GetFileNameWithoutExtension(source) + CustomizationSection.EXTENSION_SOURCE;
MNUFileMigrator._logger = mainFormLogger;
if (!File.Exists(path))
path = Path.ChangeExtension(path, CustomizationSection.EXTENSION_TEMPLATE);
if (!File.Exists(path))
return;
this._originalSourceMNUPath = path;
}
public bool LoadTarget => this._loadTarget;
public string OriginalSource => this._originalSourceMNUPath;
public CustomizationSection ConvertedCUI => this._convertedCUI;
public string TargetCUIPath => this._targetCUIPath;
public bool ConvertToCUIx(ProfileMigrator pm, string targetRootKey, bool mainMNS)
{
if (this._originalSourceMNUPath == null || this._originalSourceMNUPath.Length < 1)
return false;
string path = Migrator.GetRoamableRootFolder(targetRootKey) + "Previous Version Custom Files\\";
string str1 = path + Path.GetFileName(this._originalSourceMNUPath);
try
{
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
File.Copy(this._originalSourceMNUPath, str1, true);
if ((File.GetAttributes(str1) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
File.SetAttributes(str1, File.GetAttributes(str1) ^ FileAttributes.ReadOnly);
this._sourceMNUPath = str1;
}
catch (Exception ex)
{
string sLine = string.Format(LocalResources.GetString("ERROR_FILE_ACCESS_DENIED"), (object) str1);
MainForm.Log2File(sLine);
MNUFileMigrator._logger.LogXMLElement((LogOperation) 1, (LogCategory) 0, sLine);
return false;
}
string str2 = pm.SourceEncode(this._originalSourceMNUPath);
string str3 = pm.TargetExpand(str2);
if (mainMNS)
this._targetCUIPath = Path.GetDirectoryName(str3) + (object) Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(str3) + LocalResources.GetString("MIGRATED_FILE_SUFFIX") + CustomizationSection.EXTENSION_OPC;
else
this._targetCUIPath = Path.ChangeExtension(str3, CustomizationSection.EXTENSION_OPC);
if (string.Compare(this._originalSourceMNUPath, str3, true, CultureInfo.InvariantCulture) != 0)
{
try
{
CustomizationSection customizationSection = new CustomizationSection(this._sourceMNUPath, true, false);
if (!Directory.Exists(Path.GetDirectoryName(this._targetCUIPath)))
Directory.CreateDirectory(Path.GetDirectoryName(this._targetCUIPath));
if (File.Exists(this._targetCUIPath))
{
string str4 = string.Format(LocalResources.GetString("LOG_FILE_ALREADY_EXISTS"), (object) this._targetCUIPath);
MNUFileMigrator._logger.LogXMLElement((LogOperation) 1, (LogCategory) 3, str4);
this._convertedCUI = customizationSection;
this._loadTarget = true;
}
else
{
customizationSection.SaveAs(this._targetCUIPath);
this._convertedCUI = new CustomizationSection(this._targetCUIPath, true, false);
this._loadTarget = true;
}
}
catch (FileNotFoundException ex)
{
string sLine = string.Format(LocalResources.GetString("ERROR_CUI_FILE_NOT_FOUND"), (object) this._targetCUIPath);
MainForm.Log2File(sLine);
MNUFileMigrator._logger.LogXMLElement((LogOperation) 1, (LogCategory) 0, sLine);
return false;
}
catch (FileSaveException ex)
{
MainForm.Log2File(((Exception) ex).Message);
MNUFileMigrator._logger.LogXMLElement((LogOperation) 1, (LogCategory) 0, ((Exception) ex).Message);
return false;
}
catch (Exception ex)
{
MainForm.Log2File(ex.Message);
MNUFileMigrator._logger.LogXMLElement((LogOperation) 1, (LogCategory) 0, ex.Message);
return false;
}
}
else
{
try
{
this._convertedCUI = new CustomizationSection(this._originalSourceMNUPath, true, false);
this._targetCUIPath = this._convertedCUI.CUIFileName;
this._loadTarget = true;
}
catch (FileNotFoundException ex)
{
string sLine = string.Format(LocalResources.GetString("ERROR_CUI_FILE_NOT_FOUND"), (object) this._originalSourceMNUPath);
MainForm.Log2File(sLine);
MNUFileMigrator._logger.LogXMLElement((LogOperation) 1, (LogCategory) 0, sLine);
return false;
}
catch (FileSaveException ex)
{
MainForm.Log2File(((Exception) ex).Message);
MNUFileMigrator._logger.LogXMLElement((LogOperation) 1, (LogCategory) 0, ((Exception) ex).Message);
return false;
}
}
return true;
}
}
}