Skip to content

Commit

Permalink
8.5.5 update
Browse files Browse the repository at this point in the history
  • Loading branch information
argonlefou committed Apr 7, 2019
1 parent 92c1ee8 commit 81bfcac
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 21 deletions.
55 changes: 53 additions & 2 deletions DemulShooter/Game.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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<string, string> _KnownMd5Prints;

public bool ProcessHooked
{ get { return _ProcessHooked; } }
Expand Down Expand Up @@ -62,7 +65,9 @@ public int screenCursorPosY
protected string _RomName = string.Empty;

public Game()
{ }
{
_KnownMd5Prints = new Dictionary<string, string>();
}

~Game()
{
Expand All @@ -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<string, string> 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()
Expand Down
4 changes: 4 additions & 0 deletions DemulShooter/Game_Demul.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public Game_Demul(string Rom, string SystemName, String DemulVersion, bool Verbo
_WidescreenHack = WidescreenHack;
_Target_Process_Name = "demul";
_ListWidescreenHacks = new List<WidescreenData>();
_KnownMd5Prints.Add("Demul 0.7a_180428", "ce0a6fd5552903311a8935b6f60e26ad");
_KnownMd5Prints.Add("Demul 0.582", "ab4e7654e7b3a4743e9753221cc48fcd");
_KnownMd5Prints.Add("Demul 0.57", "3071ba77ff46d2137f46bfcd8dda5b4f");

ReadGameData();

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions DemulShooter/Game_Hod2pc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion DemulShooter/Game_Hod3pc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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");
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions DemulShooter/Game_LindberghHotd4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 10 additions & 12 deletions DemulShooter/Game_LindberghLgj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions DemulShooter/Game_Model2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions DemulShooter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand Down Expand Up @@ -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("");
Expand Down
2 changes: 1 addition & 1 deletion DemulShooter/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

0 comments on commit 81bfcac

Please sign in to comment.