57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using System;
|
||
using System.Diagnostics;
|
||
using System.IO;
|
||
using System.Security.Cryptography;
|
||
using System.Windows.Forms;
|
||
|
||
namespace AssemblerCasinoLauncher
|
||
{
|
||
static class Program
|
||
{
|
||
const string ExpectedPokerSha256 = "76C4886161218322A5286B48F5542EBF8FBBB78A172EDCA40267148AC0D5EF99";
|
||
|
||
[STAThread]
|
||
static void Main()
|
||
{
|
||
var root = AppDomain.CurrentDomain.BaseDirectory;
|
||
var game = Path.Combine(root, "bin", "poker.exe");
|
||
if (!File.Exists(game))
|
||
{
|
||
MessageBox.Show("bin\\poker.exe не найден рядом с лаунчером.", "Assembler Casino", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
return;
|
||
}
|
||
|
||
if (!VerifyGame(game))
|
||
{
|
||
MessageBox.Show("bin\\poker.exe был изменен или поврежден. Запуск остановлен.", "Assembler Casino", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
return;
|
||
}
|
||
|
||
Process.Start(new ProcessStartInfo
|
||
{
|
||
FileName = game,
|
||
WorkingDirectory = root,
|
||
UseShellExecute = false
|
||
});
|
||
}
|
||
|
||
static bool VerifyGame(string gamePath)
|
||
{
|
||
try
|
||
{
|
||
using (var sha = SHA256.Create())
|
||
using (var stream = File.OpenRead(gamePath))
|
||
{
|
||
var actual = BitConverter.ToString(sha.ComputeHash(stream)).Replace("-", "");
|
||
return actual.Equals(ExpectedPokerSha256, StringComparison.OrdinalIgnoreCase);
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|