88 lines
2.6 KiB
C#
88 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Security.Cryptography;
|
|
using System.Security.Policy;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using DamienG.Security.Cryptography;
|
|
|
|
namespace EqVerCheck
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
string[] files = { "eqgame.exe", "eqgraphicsdx9.dll", "eqmain.dll", "eqgfx_dx8.dll", "mss32.dll" };
|
|
|
|
logEntry("\r\nBeginning Process...");
|
|
if (!File.Exists("eqgame.exe"))
|
|
{
|
|
logEntry("Could not find a complete EverQuest installation in the current directory.");
|
|
logEntry("Please move EQVerCheck.exe to your EverQuest folder and re-run.");
|
|
return;
|
|
}
|
|
if (File.Exists("eqgraphicsdx9.dll"))
|
|
logEntry("EQGraphicsDX9.dll and eqgame.exe FOUND.");
|
|
else
|
|
{
|
|
if (File.Exists("eqgfx_dx7.dll"))
|
|
{
|
|
logEntry("eqgfx_dx7.dll and eqgame.exe FOUND.");
|
|
files = new string[] { "eqgame.exe", "eqgfx_dx7.dll", "eqmain.dll", "eqgfx_dx8.dll", "mss32.dll" };
|
|
}
|
|
}
|
|
logEntry("Assuming EQ Installation is complete.");
|
|
string sVersionCode = "SHORT VERSION: SEQ";
|
|
string lVersionCode = "LONG VERSION: EQ";
|
|
|
|
logEntry("Generating Version Strings...");
|
|
foreach (var file in files)
|
|
{
|
|
string checksum = GetChecksum(file);
|
|
lVersionCode += checksum;
|
|
sVersionCode += checksum[checksum.Length - 1];
|
|
}
|
|
logEntry(sVersionCode);
|
|
logEntry(lVersionCode);
|
|
}
|
|
|
|
static string GetChecksum(string fileName)
|
|
{
|
|
if (!File.Exists(fileName))
|
|
return "00000000";
|
|
|
|
var crc32 = new Crc32();
|
|
var hash = String.Empty;
|
|
|
|
using (var fs = File.OpenRead(fileName))
|
|
{
|
|
foreach (byte b in crc32.ComputeHash(fs))
|
|
hash += b.ToString("x2").ToLower();
|
|
}
|
|
|
|
return hash;
|
|
}
|
|
|
|
private void logEntry(string entry)
|
|
{
|
|
textBox1.Text += entry + Environment.NewLine;
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
Application.Exit();
|
|
}
|
|
}
|
|
}
|