Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
Version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JKAnderson committed May 26, 2018
1 parent 5de8c58 commit dfa12cc
Show file tree
Hide file tree
Showing 48 changed files with 6,627 additions and 153 deletions.
98 changes: 98 additions & 0 deletions DSR-Gadget/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,104 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="DSR_Gadget.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="lib" />
</assemblyBinding>
</runtime>
<userSettings>
<DSR_Gadget.Properties.Settings>
<setting name="WindowLocation" serializeAs="String">
<value>200, 200</value>
</setting>
<setting name="UpgradeRequired" serializeAs="String">
<value>True</value>
</setting>
<setting name="HotkeysEnable" serializeAs="String">
<value>True</value>
</setting>
<setting name="HotkeysHandle" serializeAs="String">
<value>True</value>
</setting>
<setting name="HotkeyGravity" serializeAs="String">
<value>27</value>
</setting>
<setting name="HotkeyTest1" serializeAs="String">
<value>219</value>
</setting>
<setting name="HotkeyTest2" serializeAs="String">
<value>221</value>
</setting>
<setting name="FilterOverride" serializeAs="String">
<value>False</value>
</setting>
<setting name="FilterBrightnessSync" serializeAs="String">
<value>True</value>
</setting>
<setting name="FilterBrightnessR" serializeAs="String">
<value>1</value>
</setting>
<setting name="FilterBrightnessG" serializeAs="String">
<value>1</value>
</setting>
<setting name="FilterBrightnessB" serializeAs="String">
<value>1</value>
</setting>
<setting name="FilterContrastR" serializeAs="String">
<value>1</value>
</setting>
<setting name="FilterContrastG" serializeAs="String">
<value>1</value>
</setting>
<setting name="FilterContrastB" serializeAs="String">
<value>1</value>
</setting>
<setting name="FilterSaturation" serializeAs="String">
<value>1</value>
</setting>
<setting name="FilterHue" serializeAs="String">
<value>0</value>
</setting>
<setting name="HotkeyFilter" serializeAs="String">
<value>27</value>
</setting>
<setting name="FilterContrastSync" serializeAs="String">
<value>True</value>
</setting>
<setting name="AnimSpeed" serializeAs="String">
<value>1</value>
</setting>
<setting name="HotkeyCollision" serializeAs="String">
<value>27</value>
</setting>
<setting name="HotkeySpeed" serializeAs="String">
<value>27</value>
</setting>
<setting name="HotkeyStore" serializeAs="String">
<value>27</value>
</setting>
<setting name="HotkeyRestore" serializeAs="String">
<value>27</value>
</setting>
<setting name="HotkeyUp" serializeAs="String">
<value>27</value>
</setting>
<setting name="HotkeyDown" serializeAs="String">
<value>27</value>
</setting>
<setting name="HotkeyMenu" serializeAs="String">
<value>27</value>
</setting>
<setting name="HotkeyDeadMode" serializeAs="String">
<value>27</value>
</setting>
</DSR_Gadget.Properties.Settings>
</userSettings>
</configuration>
81 changes: 81 additions & 0 deletions DSR-Gadget/DSR-Gadget.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="LowLevelHooking, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LowLevelHooking.1.0.1\lib\net20\LowLevelHooking.dll</HintPath>
</Reference>
<Reference Include="Octokit, Version=0.29.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Octokit.0.29.0\lib\net45\Octokit.dll</HintPath>
</Reference>
<Reference Include="Semver, Version=2.0.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Semver.2.0.4\lib\net452\Semver.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -49,15 +58,40 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DSRAssembly.cs" />
<Compile Include="DSRInterface.cs" />
<Compile Include="DSROffsets.cs" />
<Compile Include="DSRProcess.cs" />
<Compile Include="FormMain Tabs\Cheats.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormMain Tabs\Graphics.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormMain Tabs\Hotkeys.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormMain Tabs\Items.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormMain Tabs\Player.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormMain Tabs\Stats.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormMain.Designer.cs">
<DependentUpon>FormMain.cs</DependentUpon>
</Compile>
<Compile Include="GadgetHotkey.cs" />
<Compile Include="List Items\DSRBonfire.cs" />
<Compile Include="List Items\DSRClass.cs" />
<Compile Include="List Items\DSRInfusion.cs" />
<Compile Include="List Items\DSRItem.cs" />
<Compile Include="List Items\DSRItemCategory.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FormMain.resx">
Expand All @@ -71,7 +105,9 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand All @@ -87,6 +123,51 @@
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
<Content Include="Resources\Assembly\BonfireWarp.txt" />
<Content Include="Resources\Assembly\GetItem.txt" />
<Content Include="Resources\Assembly\LevelUp.txt" />
<None Include="Resources\Bonfires.txt" />
<None Include="Resources\Classes.txt" />
<None Include="Resources\Items\UsableItems.txt" />
<None Include="Resources\Items\UpgradeMaterials.txt" />
<None Include="Resources\Items\SpellTools.txt" />
<None Include="Resources\Items\Spells.txt" />
<None Include="Resources\Items\Shields.txt" />
<None Include="Resources\Items\Rings.txt" />
<None Include="Resources\Items\RangedWeapons.txt" />
<None Include="Resources\Items\MysteryWeapons.txt" />
<None Include="Resources\Items\MysteryGoods.txt" />
<None Include="Resources\Items\MysteryArmor.txt" />
<None Include="Resources\Items\MeleeWeapons.txt" />
<None Include="Resources\Items\KeyItems.txt" />
<None Include="Resources\Items\Consumables.txt" />
<None Include="Resources\Items\Armor.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="PostBuildMacros">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="Targets" />
</GetAssemblyIdentity>
<ItemGroup>
<VersionNumber Include="@(Targets->'%(Version)')" />
</ItemGroup>
</Target>
<PropertyGroup>
<PostBuildEventDependsOn>
$(PostBuildEventDependsOn);
PostBuildMacros;
</PostBuildEventDependsOn>
<PostBuildEvent>set output=$(TargetDir)$(ProjectName) @(VersionNumber)
if "$(ConfigurationName)" == "Release" (
md "%25output%25"
del "%25output%25"
md "%25output%25\lib"
copy "$(TargetPath)" "%25output%25\"
copy "$(TargetPath).config" "%25output%25\"
copy "$(TargetDir)$(TargetName).pdb" "%25output%25\"
copy "$(SolutionDir)readme.txt" "%25output%25\"
copy "$(TargetDir)*.dll" "%25output%25\lib\"
copy "$(TargetDir)*.xml" "%25output%25\lib\"
)</PostBuildEvent>
</PropertyGroup>
</Project>
30 changes: 30 additions & 0 deletions DSR-Gadget/DSRAssembly.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace DSR_Gadget
{
// Parses output from https://defuse.ca/online-x86-assembler.htm
// I like to keep the whole thing for quick reference to line numbers and so on
static class DSRAssembly
{
private static Regex asmLineRx = new Regex(@"^[\w\d]+:\s+((?:[\w\d][\w\d] ?)+)");

private static byte[] loadDefuseOutput(string lines)
{
List<byte> bytes = new List<byte>();
foreach (string line in Regex.Split(lines, "[\r\n]+"))
{
Match match = asmLineRx.Match(line);
string hexes = match.Groups[1].Value;
foreach (Match hex in Regex.Matches(hexes, @"\S+"))
bytes.Add(Byte.Parse(hex.Value, System.Globalization.NumberStyles.AllowHexSpecifier));
}
return bytes.ToArray();
}

public static byte[] BonfireWarp = loadDefuseOutput(Properties.Resources.BonfireWarp);
public static byte[] GetItem = loadDefuseOutput(Properties.Resources.GetItem);
public static byte[] LevelUp = loadDefuseOutput(Properties.Resources.LevelUp);
}
}
39 changes: 37 additions & 2 deletions DSR-Gadget/DSRInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ namespace DSR_Gadget
class DSRInterface
{
private const uint PROCESS_ALL_ACCESS = 0x1F0FFF;
private const uint MEM_COMMIT = 0x1000;
private const uint MEM_COMMIT_RESERVE = 0x1000 | 0x2000;
private const uint MEM_RELEASE = 0x8000;
private const uint PAGE_READWRITE = 0x4;
private const uint PAGE_EXECUTE_READWRITE = 0x40;

[DllImport("kernel32.dll")]
private static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, uint dwProcessId);
Expand Down Expand Up @@ -67,6 +68,40 @@ private bool WriteProcessMemory(IntPtr address, byte[] bytes)
return WriteProcessMemory(handle, address, bytes, (uint)bytes.Length, 0);
}

private IntPtr VirtualAllocEx(int size, uint protect = PAGE_READWRITE)
{
return VirtualAllocEx(handle, IntPtr.Zero, (uint)size, MEM_COMMIT_RESERVE, protect);
}

private bool VirtualFreeEx(IntPtr address)
{
return VirtualFreeEx(handle, address, 0, MEM_RELEASE);
}

private IntPtr CreateRemoteThread(IntPtr address)
{
return CreateRemoteThread(handle, IntPtr.Zero, 0, address, IntPtr.Zero, 0, IntPtr.Zero);
}

public IntPtr Allocate(int size)
{
return VirtualAllocEx(size);
}

public bool Free(IntPtr address)
{
return VirtualFreeEx(address);
}

public void Execute(byte[] asm)
{
IntPtr address = VirtualAllocEx(asm.Length, PAGE_EXECUTE_READWRITE);
WriteProcessMemory(address, asm);
IntPtr thread = CreateRemoteThread(address);
WaitForSingleObject(thread, 0xFFFFFFFF);
VirtualFreeEx(address);
}

public byte[] ReadBytes(IntPtr address, int size)
{
return ReadProcessMemory(address, (uint)size);
Expand Down Expand Up @@ -141,7 +176,7 @@ public IntPtr ResolveAddress(IntPtr address, params int[] offsets)
{
foreach (int offset in offsets)
address = ReadIntPtr(address) + offset;
return address;
return ReadIntPtr(address);
}

public bool ReadFlag32(IntPtr address, uint mask)
Expand Down
Loading

0 comments on commit dfa12cc

Please sign in to comment.