/*
* Wolfenstein.cs
* Copyright (C)2009 David Rudie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* $Author: dopefish $
* $Id: Wolfenstein.cs 9 2010-04-06 23:45:33Z dopefish $
* $Rev: 9 $
*/
using System;
using System.Drawing;
using Library.Plugin.Attributes;
using Library.Plugin.Interfaces;
using Library.WSF;
namespace Game.Wolfenstein
{
[FixerPluginAttribute(“Wolfenstein_11112”)]
class Wolfenstein_11112 : IFixer {
#region Global variables
private static String m_GameName = “Wolfenstein”;
private static String m_GameVersion = “v1.11/v1.2”;
private static Boolean m_DefaultVersion = true;
private static Boolean m_TimerNeeded = false;
private static Int32 m_MaxAspectRatio = -1;
private static String m_ExeName = “Wolf2”;
private static String m_ModuleName = “gamex86.dll”;
private static UInt32 m_OffsetToPoke = 0x6E036;
private static UInt32 m_OffsetOfWidth = 0x6E03C;
private static UInt32 m_OffsetOfHeight = 0x6E044;
private static UInt32 m_OffsetOfNewValue1 = 0x4C5EA0;
private static UInt32 m_OffsetOfNewValue2 = 0x4C5EA4;
private static UInt32 m_OffsetOfOldValue1 = 0x4A2A0EE4;
private static UInt32 m_OffsetOfOldValue2 = 0x4A29FF1C;
private static Byte[] m_PokeEnable = { 0x90, 0x90 };
private static Byte[] m_PokeDisable = { 0x76, 0x12 };
private Byte[] m_Aspect1;
private Byte[] m_Aspect2;
private Boolean m_Enabled = false;
private String m_Value = “”;
#endregion
#region Implementation
public Boolean DefaultVersion() {
return m_DefaultVersion;
}
public Bitmap GetIcon()
{
return new Bitmap(Properties.Resources.Icon);
}
public String GetName()
{
return m_GameName + ” ” + m_GameVersion;
}
public void CheckUpdate()
{ WSFFunctions.UpdateCheck(m_GameName); }
public Boolean Enabled()
{
return m_Enabled;
}
public String GetValue()
{
return m_Value;
}
public Boolean GameRunning()
{ Int32 ProcessID = WSFFunctions.GetProcessID(m_ExeName);
if (ProcessID > 0)
return true;
else
return false; }
public Boolean TimerNeeded()
{
return m_TimerNeeded;
}
public Int32 MaxAspectRatio()
{
return m_MaxAspectRatio;
}
public Int32 Enable(Int32 AspectRatio)
{ Int32 ProcessID = WSFFunctions.GetProcessID(m_ExeName);
if (ProcessID > 0)
{ Int32 ModuleAddress = WSFFunctions.GetModuleAddress(m_ExeName, m_ModuleName);
if (ModuleAddress > 0)
{
m_Enabled = true;
m_Value = String.Format(“{0:X}”, ModuleAddress); Single[] AspectRatios = WSFFunctions.GetAspectRatioArray(AspectRatio);
m_Aspect1 = BitConverter.GetBytes(AspectRatios[0]);
m_Aspect2 = BitConverter.GetBytes(AspectRatios[1]);
IntPtr ProcessHandle = WSFFunctions.OpenProcess(0x8 | 0x10 | 0x20, false, ProcessID);
Int32 OffsetToPoke = (Int32)m_OffsetToPoke + ModuleAddress; Int32 OffsetOfWidth = (Int32)m_OffsetOfNewValue1 + ModuleAddress; Int32 OffsetOfHeight = (Int32)m_OffsetOfNewValue2 + ModuleAddress; Int32 OffsetToPoke2 = (Int32)m_OffsetOfWidth + ModuleAddress; Int32 OffsetToPoke3 = (Int32)m_OffsetOfHeight + ModuleAddress; Byte[] bOffsetOfWidth = BitConverter.GetBytes(OffsetOfWidth); Byte[] bOffsetOfHeight = BitConverter.GetBytes(OffsetOfHeight); IntPtr BytesWritten = IntPtr.Zero;
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetOfWidth, m_Aspect1, (UInt32)m_Aspect1.Length, ref BytesWritten);
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetOfHeight, m_Aspect2, (UInt32)m_Aspect2.Length, ref BytesWritten);
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetToPoke, m_PokeEnable, (UInt32)m_PokeEnable.Length, ref BytesWritten);
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetToPoke2, bOffsetOfWidth, (UInt32)bOffsetOfWidth.Length, ref BytesWritten);
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetToPoke3, bOffsetOfHeight, (UInt32)bOffsetOfHeight.Length, ref BytesWritten); WSFFunctions.CloseMemory(ProcessHandle); } }
return 0;
}
public Int32 Disable()
{ Int32 ProcessID = WSFFunctions.GetProcessID(m_ExeName);
if (ProcessID > 0)
{ Int32 ModuleAddress = WSFFunctions.GetModuleAddress(m_ExeName, m_ModuleName);
if (ModuleAddress > 0)
{
m_Enabled = false;
m_Value = “”;
IntPtr ProcessHandle = WSFFunctions.OpenProcess(0x8 | 0x10 | 0x20, false, ProcessID);
Int32 OffsetToPoke = (Int32)m_OffsetToPoke + ModuleAddress; Int32 OffsetOfWidth = (Int32)m_OffsetOfWidth + ModuleAddress; Int32 OffsetOfHeight = (Int32)m_OffsetOfHeight + ModuleAddress; Byte[] bOffsetOfOldValue1 = BitConverter.GetBytes(m_OffsetOfOldValue1); Byte[] bOffsetOfOldValue2 = BitConverter.GetBytes(m_OffsetOfOldValue2); IntPtr BytesWritten = IntPtr.Zero;
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetOfWidth, bOffsetOfOldValue1, (UInt32)bOffsetOfOldValue1.Length, ref BytesWritten);
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetOfHeight, bOffsetOfOldValue2, (UInt32)bOffsetOfOldValue2.Length, ref BytesWritten);
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetToPoke, m_PokeDisable, (UInt32)m_PokeDisable.Length, ref BytesWritten); WSFFunctions.CloseMemory(ProcessHandle); } }
return 0;
}
#endregion
}
[FixerPluginAttribute(“Wolfenstein_10”)]
class Wolfenstein_10 : IFixer {
#region Global variables
private static String m_GameName = “Wolfenstein”;
private static String m_GameVersion = “v1.0”;
private static Boolean m_DefaultVersion = false;
private static Boolean m_TimerNeeded = false;
private static Int32 m_MaxAspectRatio = -1;
private static String m_ExeName = “Wolf2”;
private static String m_ModuleName = “gamex86.dll”;
private static UInt32 m_OffsetToPoke = 0x6E1B6;
private static UInt32 m_OffsetOfWidth = 0x6E1BC;
private static UInt32 m_OffsetOfHeight = 0x6E1C4;
private static UInt32 m_OffsetOfNewValue1 = 0x4C5F00;
private static UInt32 m_OffsetOfNewValue2 = 0x4C5F04;
private static UInt32 m_OffsetOfOldValue1 = 0x485A0EE4;
private static UInt32 m_OffsetOfOldValue2 = 0x4859FF1C;
private static Byte[] m_PokeEnable = { 0x90, 0x90 };
private static Byte[] m_PokeDisable = { 0x76, 0x12 };
private Byte[] m_Aspect1;
private Byte[] m_Aspect2;
private Boolean m_Enabled = false;
private String m_Value = “”;
#endregion
#region Implementation
public Boolean DefaultVersion() {
return m_DefaultVersion;
}
public Bitmap GetIcon()
{
return new Bitmap(Properties.Resources.Icon);
}
public void CheckUpdate()
{ WSFFunctions.UpdateCheck(m_GameName); }
public String GetName()
{
return m_GameName + ” ” + m_GameVersion;
}
public Boolean Enabled()
{
return m_Enabled;
}
public String GetValue()
{
return m_Value;
}
public Boolean GameRunning()
{ Int32 ProcessID = WSFFunctions.GetProcessID(m_ExeName);
if (ProcessID > 0)
return true;
else
return false; }
public Boolean TimerNeeded()
{
return m_TimerNeeded;
}
public Int32 MaxAspectRatio()
{
return m_MaxAspectRatio;
}
public Int32 Enable(Int32 AspectRatio)
{ Int32 ProcessID = WSFFunctions.GetProcessID(m_ExeName);
if (ProcessID > 0)
{ Int32 ModuleAddress = WSFFunctions.GetModuleAddress(m_ExeName, m_ModuleName);
if (ModuleAddress > 0)
{
m_Enabled = true;
m_Value = String.Format(“{0:X}”, ModuleAddress); Single[] AspectRatios = WSFFunctions.GetAspectRatioArray(AspectRatio);
m_Aspect1 = BitConverter.GetBytes(AspectRatios[0]);
m_Aspect2 = BitConverter.GetBytes(AspectRatios[1]);
IntPtr ProcessHandle = WSFFunctions.OpenProcess(0x8 | 0x10 | 0x20, false, ProcessID);
Int32 OffsetToPoke = (Int32)m_OffsetToPoke + ModuleAddress; Int32 OffsetOfWidth = (Int32)m_OffsetOfNewValue1 + ModuleAddress; Int32 OffsetOfHeight = (Int32)m_OffsetOfNewValue2 + ModuleAddress; Int32 OffsetToPoke2 = (Int32)m_OffsetOfWidth + ModuleAddress; Int32 OffsetToPoke3 = (Int32)m_OffsetOfHeight + ModuleAddress; Byte[] bOffsetOfWidth = BitConverter.GetBytes(OffsetOfWidth); Byte[] bOffsetOfHeight = BitConverter.GetBytes(OffsetOfHeight); IntPtr BytesWritten = IntPtr.Zero;
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetOfWidth, m_Aspect1, (UInt32)m_Aspect1.Length, ref BytesWritten);
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetOfHeight, m_Aspect2, (UInt32)m_Aspect2.Length, ref BytesWritten);
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetToPoke, m_PokeEnable, (UInt32)m_PokeEnable.Length, ref BytesWritten);
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetToPoke2, bOffsetOfWidth, (UInt32)bOffsetOfWidth.Length, ref BytesWritten);
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetToPoke3, bOffsetOfHeight, (UInt32)bOffsetOfHeight.Length, ref BytesWritten); WSFFunctions.CloseMemory(ProcessHandle); } }
return 0;
}
public Int32 Disable()
{ Int32 ProcessID = WSFFunctions.GetProcessID(m_ExeName);
if (ProcessID > 0)
{ Int32 ModuleAddress = WSFFunctions.GetModuleAddress(m_ExeName, m_ModuleName);
if (ModuleAddress > 0)
{
m_Enabled = false;
m_Value = “”;
IntPtr ProcessHandle = WSFFunctions.OpenProcess(0x8 | 0x10 | 0x20, false, ProcessID);
Int32 OffsetToPoke = (Int32)m_OffsetToPoke + ModuleAddress; Int32 OffsetOfWidth = (Int32)m_OffsetOfWidth + ModuleAddress; Int32 OffsetOfHeight = (Int32)m_OffsetOfHeight + ModuleAddress; Byte[] bOffsetOfOldValue1 = BitConverter.GetBytes(m_OffsetOfOldValue1); Byte[] bOffsetOfOldValue2 = BitConverter.GetBytes(m_OffsetOfOldValue2); IntPtr BytesWritten = IntPtr.Zero;
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetOfWidth, bOffsetOfOldValue1, (UInt32)bOffsetOfOldValue1.Length, ref BytesWritten);
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetOfHeight, bOffsetOfOldValue2, (UInt32)bOffsetOfOldValue2.Length, ref BytesWritten);
WSFFunctions.WriteMemory(ProcessHandle, (IntPtr)OffsetToPoke, m_PokeDisable, (UInt32)m_PokeDisable.Length, ref BytesWritten); WSFFunctions.CloseMemory(ProcessHandle); } }
return 0;
}
#endregion
} }