diff --git a/FodyWeavers.xml b/FodyWeavers.xml new file mode 100644 index 0000000..5029e70 --- /dev/null +++ b/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/FodyWeavers.xsd b/FodyWeavers.xsd new file mode 100644 index 0000000..05e92c1 --- /dev/null +++ b/FodyWeavers.xsd @@ -0,0 +1,141 @@ + + + + + + + + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with line breaks. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with line breaks. + + + + + The order of preloaded assemblies, delimited with line breaks. + + + + + + This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file. + + + + + Controls if .pdbs for reference assemblies are also embedded. + + + + + Controls if runtime assemblies are also embedded. + + + + + Controls whether the runtime assemblies are embedded with their full path or only with their assembly name. + + + + + Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. + + + + + As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off. + + + + + Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code. + + + + + Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior. + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with |. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with |. + + + + + The order of preloaded assemblies, delimited with |. + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/Form1.cs b/Form1.cs index b6c9f65..8494bae 100644 --- a/Form1.cs +++ b/Form1.cs @@ -2,9 +2,10 @@ using System.Diagnostics; using System.Threading.Tasks; using System.Windows.Forms; -using System.Net; using System.IO; +using System.Net; using Newtonsoft.Json.Linq; +using System.Security.Cryptography; namespace TadahLauncher { @@ -67,16 +68,56 @@ namespace TadahLauncher if (doInstall) { // Assuming we're in the temp folder or the user knows what they're doing, start replacing files. - label1.Text = "Installing Tadah..."; + label1.Text = "Downloading latest client..."; - // download zip... check sha512... extract zip... (optional) redirect to servers page + WebClient client = new WebClient(); + string tempZipArchivePath = Path.GetTempPath() + "Tadah" + client + ".zip"; + + client.DownloadProgressChanged += (s, e) => + { + progressBar1.Value = e.ProgressPercentage; + }; + + client.DownloadFileCompleted += (s, e) => + { + label1.Text = "Verifying downloaded files..."; + + SHA512 cSha512 = SHA512.Create(); + + byte[] zipArchiveSha512Bytes; + using (FileStream stream = File.OpenRead(tempZipArchivePath)) + { + zipArchiveSha512Bytes = cSha512.ComputeHash(stream); + } + + string sha512result = ""; + foreach (byte b in zipArchiveSha512Bytes) sha512result += b.ToString("x2"); + + if (sha512result != sha512) + { + MessageBox.Show("SHA512 mismatch.\nWebsite reported: " + sha512 + "\nLocal file: " + sha512result, "Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + Close(); + return; + } + }; + + try + { + client.DownloadFileAsync(new Uri(baseUrl + "/client/download/" + client), tempZipArchivePath); + } + catch + { + MessageBox.Show("Could not get latest client files from the website.", "Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + Close(); + return; + } } else { // Clone the installer to the temp folder so we can actually install. string currentExecutablePath = System.Reflection.Assembly.GetExecutingAssembly().Location; - string copiedExecutablePath = Path.GetTempPath() + "TadahLauncher.exe"; + string copiedExecutablePath = Path.GetTempPath() + "TadahLauncher" + client + ".exe"; File.Copy(currentExecutablePath, copiedExecutablePath, true); @@ -99,7 +140,6 @@ namespace TadahLauncher { string[] args = Environment.GetCommandLineArgs(); - if (args.Length < 2) { UpdateClient(false); diff --git a/TadahLauncher.csproj b/TadahLauncher.csproj index c5d85b4..8f49b6f 100644 --- a/TadahLauncher.csproj +++ b/TadahLauncher.csproj @@ -1,5 +1,6 @@  + Debug @@ -24,11 +25,13 @@ false true true - 2 + 4 1.0.0.%2a false true true + + AnyCPU @@ -48,6 +51,7 @@ TRACE prompt 4 + Off 1FB6CEC5DC86561A6C0225048A2B9A105001A42F @@ -65,20 +69,154 @@ TadahLauncher.ico + + ..\packages\Costura.Fody.5.7.0\lib\netstandard1.0\Costura.dll + + + ..\packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll + True + True + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + ..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll + True + True + + + + ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll + True + True + + + ..\packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll + True + True + + + ..\packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll + True + True + + + ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll + True + True + + + ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + True + True + + + + ..\packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll + True + True + + + ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll + True + True + + + ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + True + True + + + ..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll + True + True + + + ..\packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll + True + True + + + ..\packages\System.Net.Http.4.3.0\lib\net46\System.Net.Http.dll + True + True + + + ..\packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll + True + True + + + + ..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll + True + True + + + ..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll + True + True + + + ..\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll + True + True + + + ..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll + True + True + + + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + True + True + + + + ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll + True + True + + + ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + True + + + ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + True + + + ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + True + True + + + ..\packages\System.Text.RegularExpressions.4.3.0\lib\net463\System.Text.RegularExpressions.dll + True + True + - + + ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll + True + True + @@ -132,4 +270,14 @@ + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/packages.config b/packages.config index 5eaa239..d12b455 100644 --- a/packages.config +++ b/packages.config @@ -1,4 +1,52 @@  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file