diff --git a/DemulShooter/Game.cs b/DemulShooter/Game.cs index a88b4c4..e228af5 100644 --- a/DemulShooter/Game.cs +++ b/DemulShooter/Game.cs @@ -1,10 +1,11 @@ using System; +using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Runtime.InteropServices; +using System.Security.Cryptography; using System.Windows.Forms; -using Microsoft.Win32; namespace DemulShooter { @@ -21,6 +22,8 @@ class Game protected IntPtr _TargetProcess_MemoryBaseAddress = IntPtr.Zero; protected bool _VerboseEnable; protected bool _DisableWindow = false; + protected string _TargetProcess_Md5Hash = string.Empty; + protected Dictionary _KnownMd5Prints; public bool ProcessHooked { get { return _ProcessHooked; } } @@ -62,7 +65,9 @@ public int screenCursorPosY protected string _RomName = string.Empty; public Game() - { } + { + _KnownMd5Prints = new Dictionary(); + } ~Game() { @@ -75,6 +80,52 @@ public Game() } } + #region MD5 Verification + + protected void ChecExeMd5() + { + GetMd5HashAsString(); + WriteLog("MD5 hash of " + _TargetProcess.MainModule.FileName + " = " + _TargetProcess_Md5Hash); + + string FoundExe = string.Empty; + foreach (KeyValuePair pair in _KnownMd5Prints) + { + if (pair.Value == _TargetProcess_Md5Hash) + { + FoundExe = pair.Key; + break; + } + } + + if (FoundExe == string.Empty) + { + WriteLog(@"/!\ MD5 Hash unknown, DemulShooter may not work correctly with this target /!\"); + } + else + { + WriteLog("MD5 Hash is corresponding to a known target = " + FoundExe); + } + + } + + private void GetMd5HashAsString() + { + string process_path = _TargetProcess.MainModule.FileName; + if (File.Exists(process_path)) + { + using (var md5 = MD5.Create()) + { + using (var stream = File.OpenRead(process_path)) + { + var hash = md5.ComputeHash(stream); + _TargetProcess_Md5Hash = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant(); + } + } + } + } + + #endregion + #region Screen public virtual void GetScreenResolution() diff --git a/DemulShooter/Game_Demul.cs b/DemulShooter/Game_Demul.cs index 129f765..01066c3 100644 --- a/DemulShooter/Game_Demul.cs +++ b/DemulShooter/Game_Demul.cs @@ -51,6 +51,9 @@ public Game_Demul(string Rom, string SystemName, String DemulVersion, bool Verbo _WidescreenHack = WidescreenHack; _Target_Process_Name = "demul"; _ListWidescreenHacks = new List(); + _KnownMd5Prints.Add("Demul 0.7a_180428", "ce0a6fd5552903311a8935b6f60e26ad"); + _KnownMd5Prints.Add("Demul 0.582", "ab4e7654e7b3a4743e9753221cc48fcd"); + _KnownMd5Prints.Add("Demul 0.57", "3071ba77ff46d2137f46bfcd8dda5b4f"); ReadGameData(); @@ -102,6 +105,7 @@ protected virtual void tProcess_Tick(Object Sender, EventArgs e) WriteLog("Attached to Process " + _Target_Process_Name + ".exe, ProcessHandle = " + _ProcessHandle); WriteLog("Demul.exe = 0x" + _TargetProcess_MemoryBaseAddress.ToString("X8") + ", padDemul.dll = 0x" + _PadDemul_ModuleBaseAddress.ToString("X8")); + ChecExeMd5(); if (_DemulVersion.Equals("057") || _DemulVersion.Equals("058")) SetHack_057(); diff --git a/DemulShooter/Game_Hod2pc.cs b/DemulShooter/Game_Hod2pc.cs index d1459ed..a24a057 100644 --- a/DemulShooter/Game_Hod2pc.cs +++ b/DemulShooter/Game_Hod2pc.cs @@ -40,6 +40,7 @@ public Game_Hod2pc(string RomName, bool NoAutoReload, bool Verbose) _VerboseEnable = Verbose; _ProcessHooked = false; _Target_Process_Name = "hod2"; + _KnownMd5Prints.Add("hod2pc", "1111"); ReadGameData(); @@ -73,6 +74,7 @@ private void tProcess_Tick(Object Sender, EventArgs e) _ProcessHooked = true; WriteLog("Attached to Process " + _Target_Process_Name + ".exe, ProcessHandle = " + _ProcessHandle); WriteLog(_Target_Process_Name + ".exe = 0x" + _TargetProcess_MemoryBaseAddress.ToString("X8")); + ChecExeMd5(); //Adding a "Coin" button ApplyKeyboardHook(); diff --git a/DemulShooter/Game_Hod3pc.cs b/DemulShooter/Game_Hod3pc.cs index b5ff2f5..d233afc 100644 --- a/DemulShooter/Game_Hod3pc.cs +++ b/DemulShooter/Game_Hod3pc.cs @@ -56,6 +56,7 @@ public Game_Hod3pc(string RomName, bool NoAutoReload, bool ArcadeModeDisplay, bo _VerboseEnable = Verbose; _ProcessHooked = false; _Target_Process_Name = "hod3pc"; + _KnownMd5Prints.Add("hod3pc", "1111"); ReadGameData(); ReadKeyConfig(); @@ -90,6 +91,7 @@ private void tProcess_Tick(Object Sender, EventArgs e) _ProcessHooked = true; WriteLog("Attached to Process " + _Target_Process_Name + ".exe, ProcessHandle = " + _ProcessHandle); WriteLog(_Target_Process_Name + ".exe = 0x" + _TargetProcess_MemoryBaseAddress.ToString("X8")); + ChecExeMd5(); SetHack(); ApplyMouseHook(); ApplyKeyboardHook(); @@ -102,7 +104,7 @@ private void tProcess_Tick(Object Sender, EventArgs e) } catch { - WriteLog("Unable to find/open the coin002.aif file for Hotd2"); + WriteLog("Unable to find/open the coin002.aif file for Hotd3"); } } } diff --git a/DemulShooter/Game_LindberghHotd4.cs b/DemulShooter/Game_LindberghHotd4.cs index 2f6d6d0..71e5437 100644 --- a/DemulShooter/Game_LindberghHotd4.cs +++ b/DemulShooter/Game_LindberghHotd4.cs @@ -18,7 +18,7 @@ class Game_LindberghHotd4 : Game private const string P1_WEAPONBTN_INIT_NOP_ADDRESS = "0x081C960D|3"; // Pointer address used to find the INPUT_SET struct containing both players data in game - private const int BASE_PLAYER_DATA_PTR_OFFSET = 0x007F621C; + private const int BASE_PLAYER_DATA_PTR_OFFSET = 0x00235870; // INPUT_SET direct address private int _Base_Player_Data_Address = 0; // INPUT_SET offsets to find data @@ -82,10 +82,13 @@ private void tProcess_Tick(Object Sender, EventArgs e) byte[] Buffer = ReadBytes((int)_TargetProcess_MemoryBaseAddress + BASE_PLAYER_DATA_PTR_OFFSET, 4); int i = BitConverter.ToInt32(Buffer, 0); - Buffer = ReadBytes(i + 0x5C0, 4); + Buffer = ReadBytes(i + 0x590, 4); i = BitConverter.ToInt32(Buffer, 0); - Buffer = ReadBytes(i + 0x00, 4); + Buffer = ReadBytes(i + 0x98, 4); + i = BitConverter.ToInt32(Buffer, 0); + + Buffer = ReadBytes(i + 0x0C, 4); i = BitConverter.ToInt32(Buffer, 0); if (i != 0) diff --git a/DemulShooter/Game_LindberghLgj.cs b/DemulShooter/Game_LindberghLgj.cs index c9d531a..d077f8d 100644 --- a/DemulShooter/Game_LindberghLgj.cs +++ b/DemulShooter/Game_LindberghLgj.cs @@ -20,7 +20,7 @@ class Game_LindberghLgj : Game private byte[] _AxisX_HexCode = new byte[] { 0xF3, 0x0F, 0x11, 0x83, 0x34, 0x01, 0x00, 0x00}; //Base PTR to find P1 & P2 float axis values - private const int PLAYER_AXIS_PTR_OFFSET = 0x00130824; + private const int PLAYER_AXIS_PTR_OFFSET = 0x006AA6C8; private int _Player1_Float_Axis_Address = 0; private int _Player2_Float_Axis_Address = 0; private float _P1_X_Float; @@ -88,20 +88,18 @@ private void tProcess_Tick(Object Sender, EventArgs e) byte[] Buffer = ReadBytes((int)_TargetProcess_MemoryBaseAddress + PLAYER_AXIS_PTR_OFFSET, 4); int i1 = BitConverter.ToInt32(Buffer, 0); - int i2 = i1; - - Buffer = ReadBytes(i1 + 0x51C, 4); + Buffer = ReadBytes(i1 + 0x58C, 4); i1 = BitConverter.ToInt32(Buffer, 0); - Buffer = ReadBytes(i2 + 0xC4, 4); - i2 = BitConverter.ToInt32(Buffer, 0); - - Buffer = ReadBytes(i1 + 0x0, 4); + Buffer = ReadBytes(i1 + 0x4, 4); i1 = BitConverter.ToInt32(Buffer, 0); + + Buffer = ReadBytes((int)_TargetProcess_MemoryBaseAddress + PLAYER_AXIS_PTR_OFFSET, 4); + int i2 = BitConverter.ToInt32(Buffer, 0); + Buffer = ReadBytes(i2 + 0x58C, 4); + i2 = BitConverter.ToInt32(Buffer, 0); Buffer = ReadBytes(i2 + 0x0, 4); - i2 = BitConverter.ToInt32(Buffer, 0); - - - + i2 = BitConverter.ToInt32(Buffer, 0); + if (i1 != 0 && i2 != 0 && GameLoaded) { _Player1_Float_Axis_Address = i1 + 0x134; diff --git a/DemulShooter/Game_Model2.cs b/DemulShooter/Game_Model2.cs index 2c25bc6..ed0dba5 100644 --- a/DemulShooter/Game_Model2.cs +++ b/DemulShooter/Game_Model2.cs @@ -52,6 +52,9 @@ public Game_Model2(string RomName, String EmulatorVersion, bool Verbose) { _Target_Process_Name = "emulator_multicpu"; } + _KnownMd5Prints.Add("Model2Emulator 1.1a", "26bd488f9a391dcac1c5099014aa1c9e"); + _KnownMd5Prints.Add("Model2Emulator 1.1a multicpu", "ac59ce7cfb95d6d639c0f0d1afba1192"); + ReadGameData(); diff --git a/DemulShooter/Program.cs b/DemulShooter/Program.cs index ea782aa..ce627fc 100644 --- a/DemulShooter/Program.cs +++ b/DemulShooter/Program.cs @@ -48,7 +48,7 @@ static void Main(string[] args) Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("DemulShooter v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString()); - Console.WriteLine("Build date : March, 29th 2019"); + Console.WriteLine("Build date : April, 4th 2019"); Console.WriteLine(""); Console.WriteLine("usage : DemulShooter.exe -target=[target] -rom=[rom] [options]"); Console.WriteLine(""); @@ -100,7 +100,7 @@ static void Main(string[] args) Console.WriteLine(" aliens\t\tAliens Extermination Dehasped (2nd dump, x86 and x64, no need for VM)"); Console.WriteLine(" fearland\tFright Fear Land"); Console.WriteLine(""); - Console.WriteLine("Lindbergh roms (TeknoParrot 1.93 only) :"); + Console.WriteLine("Lindbergh roms (TeknoParrot 1.0.0.112 only) :"); Console.WriteLine(" hotd4\t\tHouse of The Dead 4"); Console.WriteLine(" lgj\t\tLet's Go Jungle"); Console.WriteLine(""); diff --git a/DemulShooter/Properties/AssemblyInfo.cs b/DemulShooter/Properties/AssemblyInfo.cs index 8f92d66..60ebf82 100644 --- a/DemulShooter/Properties/AssemblyInfo.cs +++ b/DemulShooter/Properties/AssemblyInfo.cs @@ -31,4 +31,4 @@ // // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut // en utilisant '*', comme indiqué ci-dessous : -[assembly: AssemblyVersion("8.5.4.0")] +[assembly: AssemblyVersion("8.5.5.0")]