| ofs | hex dump | ascii |
|---|
| 0000 | 21 3c 61 72 63 68 3e 0a 2f 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 31 34 38 35 30 32 33 33 | !<arch>./...............14850233 |
| 0020 | 36 32 20 20 20 20 20 20 20 20 20 20 20 20 20 20 30 20 20 20 20 20 20 20 31 33 32 37 38 20 20 20 | 62..............0.......13278... |
| 0040 | 20 20 60 0a 00 00 02 14 00 00 7d b8 00 00 7d b8 00 00 7d b8 00 00 7d b8 00 00 7d b8 00 00 7d b8 | ..`.......}...}...}...}...}...}. |
| 0060 | 00 00 7d b8 00 00 7d b8 00 00 7d b8 00 00 7d b8 00 00 7d b8 00 00 7d b8 00 00 7d b8 00 00 7d b8 | ..}...}...}...}...}...}...}...}. |
| 0080 | 00 00 90 02 00 00 94 be 00 00 98 64 00 00 98 64 00 00 98 64 00 00 a1 24 00 00 a1 24 00 00 a1 24 | ...........d...d...d...$...$...$ |
| 00a0 | 00 00 a6 56 00 00 a9 5e 00 00 ac c0 00 00 ac c0 00 00 ac c0 00 00 ac c0 00 00 b4 f0 00 00 b7 ee | ...V...^........................ |
| 00c0 | 00 00 b7 ee 00 00 b7 ee 00 00 b7 ee 00 00 b7 ee 00 00 b7 ee 00 00 b7 ee 00 00 b7 ee 00 00 b7 ee | ................................ |
| 00e0 | 00 00 b7 ee 00 00 b7 ee 00 00 b7 ee 00 00 b7 ee 00 00 b7 ee 00 00 b7 ee 00 00 b7 ee 00 00 b7 ee | ................................ |
| 0100 | 00 00 b7 ee 00 00 b7 ee 00 00 ca 20 00 00 ca 20 00 00 d5 c6 00 00 d5 c6 00 00 d5 c6 00 00 d5 c6 | ................................ |
| 0120 | 00 00 d5 c6 00 00 d5 c6 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 | ................................ |
| 0140 | 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 | ................................ |
| 0160 | 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 | ................................ |
| 0180 | 00 00 f6 a8 00 00 f6 a8 00 00 f6 a8 00 01 1d f8 00 01 1d f8 00 01 22 d4 00 01 27 1e 00 01 2a c0 | ......................"...'...*. |
| 01a0 | 00 01 2a c0 00 01 36 46 00 01 36 46 00 01 36 46 00 01 42 86 00 01 42 86 00 01 42 86 00 01 4e 52 | ..*...6F..6F..6F..B...B...B...NR |
| 01c0 | 00 01 4e 52 00 01 55 56 00 01 58 98 00 01 58 98 00 01 58 98 00 01 6b 26 00 01 6b 26 00 01 70 b8 | ..NR..UV..X...X...X...k&..k&..p. |
| 01e0 | 00 01 73 a2 00 01 73 a2 00 01 73 a2 00 01 73 a2 00 01 73 a2 00 01 81 b6 00 01 84 e2 00 01 84 e2 | ..s...s...s...s...s............. |
| 0200 | 00 01 84 e2 00 01 8a 88 00 01 8f 7a 00 01 93 a2 00 01 93 a2 00 01 93 a2 00 01 9b 06 00 01 a2 8a | ...........z.................... |
| 0220 | 00 01 a2 8a 00 01 a2 8a 00 01 a2 8a 00 01 a2 8a 00 01 a2 8a 00 01 a2 8a 00 01 a2 8a 00 01 a2 8a | ................................ |
| 0240 | 00 01 a2 8a 00 01 a2 8a 00 01 a2 8a 00 01 a2 8a 00 01 b5 f6 00 01 b5 f6 00 01 b5 f6 00 01 b5 f6 | ................................ |
| 0260 | 00 01 b5 f6 00 01 b5 f6 00 01 b5 f6 00 01 b5 f6 00 01 b5 f6 00 01 b5 f6 00 01 b5 f6 00 01 b5 f6 | ................................ |
| 0280 | 00 01 b5 f6 00 01 ea f2 00 01 ea f2 00 01 ea f2 00 01 ea f2 00 01 ea f2 00 01 ea f2 00 01 ea f2 | ................................ |
| 02a0 | 00 01 ea f2 00 01 ea f2 00 02 00 0e 00 02 00 0e 00 02 00 0e 00 02 00 0e 00 02 04 ee 00 02 04 ee | ................................ |
| 02c0 | 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee | ................................ |
| 02e0 | 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee | ................................ |
| 0300 | 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee | ................................ |
| 0320 | 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 04 ee 00 02 71 48 00 02 71 48 00 02 71 48 00 02 71 48 | ..................qH..qH..qH..qH |
| 0340 | 00 02 71 48 00 02 71 48 00 02 71 48 00 02 71 48 00 02 71 48 00 02 71 48 00 02 71 48 00 02 71 48 | ..qH..qH..qH..qH..qH..qH..qH..qH |
| 0360 | 00 02 71 48 00 02 71 4using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Threading;
namespace Tango.MachineStudio.Updater
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private String _sourceFolder = AppDomain.CurrentDomain.BaseDirectory;
private String _msProcessName = "Tango.MachineStudio.UI";
private String _appPath = String.Join(" ", App.StartupArgs);
public MainWindow()
{
if (!Directory.Exists(_appPath))
{
ShowError("This update utility can only be executed by Machine Studio.");
Environment.Exit(0);
}
InitializeComponent();
ContentRendered += MainWindow_ContentRendered;
}
private void MainWindow_ContentRendered(object sender, EventArgs e)
{
Update();
}
private void Update()
{
EnsureMachineStudioIsDown();
//RemoveOldDLLFiles();
ReplaceFiles();
StartMachineStudio();
Environment.Exit(0);
}
private void StartMachineStudio()
{
txtStatus.Text = "Update completed. Starting Machine Studio...";
DoEvents();
Thread.Sleep(1000);
Process p = new Process();
p.StartInfo.FileName = _appPath + "\\" + _msProcessName + ".exe";
p.StartInfo.LoadUserProfile = true;
p.StartInfo.UseShellExecute = true;
p.Start();
}
//private void RemoveOldDLLFiles()
//{
// foreach (string dll in Directory.GetFiles(_appPath, "*.dll"))
// {
// try
// {
// File.Delete(dll);
// }
// catch
// {
// ShowError($"The file '{Path.GetFileName(dll)}' could not be removed. Please close all instances of Machine Studio and press OK.");
// RemoveOldDLLFiles();
// return;
// }
// }
//}
private void ReplaceFiles()
{
int maxProgress = Directory.GetFiles(_sourceFolder, "*.*", SearchOption.AllDirectories).Length;
int progress = 0;
foreach (string dirPath in Directory.GetDirectories(_sourceFolder, "*", SearchOption.AllDirectories))
{
try
{
Directory.CreateDirectory(dirPath.Replace(_sourceFolder, _appPath));
}
catch (Exception ex)
{
ShowError("Could not create directory " + Path.GetFileName(dirPath) + Environment.NewLine + ex.Message);
}
}
foreach (string newPath in Directory.GetFiles(_sourceFolder, "*.*", SearchOption.AllDirectories))
{
try
{
txtStatus.Text = "Copying file " + Path.GetFileName(newPath);
DoEvents();
File.Copy(newPath, newPath.Replace(_sourceFolder, _appPath), true);
prog.Maximum = maxProgress;
prog.Value = progress++;
DoEvents();
Thread.Sleep(10);
}
catch (Exception ex)
{
if (!newPath.ToLower().Contains("updater.exe"))
{
ShowError("Could not create file " + Path.GetFileName(newPath) + Environment.NewLine + ex.Message);
}
}
}
}
private void EnsureMachineStudioIsDown()
{
Process appProcess = null;
int tries = 0;
do
{
appProcess = Process.GetProcessesByName(_msProcessName).FirstOrDefault();
Process p = new Process();
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.FileName = "wmic";
p.StartInfo.Arguments = String.Format("process where name='{0}' delete", _msProcessName);
if (appProcess != null)
{
tries++;
try
{
appProcess.Kill();
}
catch { }
try
{
p.Start();
}
catch { }
Thread.Sleep(1000);
}
if (tries > 10)
{
ShowError("The main Machine Studio process seems to in a frozen state. Please restart your computer and try again.");
Environment.Exit(0);
}
} while (appProcess != null);
}
private void DoEvents()
{
Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { }));
}
private void ShowError(String error)
{
MessageBox.Show(error, "Machine Studio Update", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
|