Skip to content

Commit

Permalink
Removed frida, incorporated lquis fork, updated for 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Labreezy committed May 13, 2018
1 parent 3bccbc0 commit 649164d
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 428 deletions.
337 changes: 0 additions & 337 deletions GGXrdWakeupDPUtil.Library/Fasm.NET.xml

This file was deleted.

9 changes: 2 additions & 7 deletions GGXrdWakeupDPUtil.Library/GGXrdWakeupDPUtil.Library.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Fasm.NET, Version=1.0.4939.27955, Culture=neutral, processorArchitecture=x86">
<HintPath>..\packages\Fasm.NET.1.70.03\lib\Fasm.NET.dll</HintPath>
</Reference>
<Reference Include="Frida">
<HintPath>C:\Users\Iquis\Downloads\Frida.dll</HintPath>
<HintPath>..\packages\Fasm.NET.1.70.03.2\lib\Fasm.NET.dll</HintPath>
</Reference>
<Reference Include="MemorySharp, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MemorySharp.1.2.0\lib\MemorySharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Remoting" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -60,9 +58,6 @@
<Compile Include="ReversalType.cs" />
<Compile Include="SlotInput.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Fasm.NET.xml" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
Expand Down
101 changes: 22 additions & 79 deletions GGXrdWakeupDPUtil.Library/ReversalTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace GGXrdWakeupDPUtil.Library
{
public class ReversalTool : IDisposable
{
private readonly Dispatcher _dispatcher;
private readonly string _ggprocname = ConfigurationManager.AppSettings.Get("GGProcessName");


Expand Down Expand Up @@ -66,23 +65,15 @@ public class ReversalTool : IDisposable
private readonly string FaceUpAnimation = "CmnActBDown2Stand";

private const int RecordingSlotSize = 4808;


private byte[] _originalCodeAOB;
private byte[] _remoteCodeAOB;
private MemorySharp _memorySharp;

private Frida.Script _script;
private Frida.DeviceManager _deviceManager;
private Frida.Device _device;
private Frida.Session _session;

private Binarysharp.MemoryManagement.Memory.RemoteAllocation _newmem;
private IntPtr _newmembase;
private static bool _runReversalThread;
private static readonly object RunReversalThreadLock = new object();

private IntPtr _nonRelativeScriptOffset;
#region Constructors
public ReversalTool(Dispatcher dispatcher)
{
_dispatcher = dispatcher;
}
#endregion


Expand All @@ -97,9 +88,14 @@ public void AttachToProcess()
}

_memorySharp = new MemorySharp(process);


CreateScript(_dispatcher, _memorySharp.Pid);
_nonRelativeScriptOffset = IntPtr.Add(_memorySharp.Modules.MainModule.BaseAddress, (int)_scriptOffset);
_newmem = _memorySharp.Memory.Allocate(128);
_newmembase = _newmem.Information.AllocationBase;
var originalCodeAOB = _memorySharp.Assembly.Assembler.Assemble("mov ebp,[ebp+0x0C]\n" + "test [edx],ebp\n" + String.Format("jmp 0x{0}", (_nonRelativeScriptOffset + 5).ToString("X8")), _newmembase);
_originalCodeAOB = new byte[originalCodeAOB.Length + 20];
originalCodeAOB.CopyTo(_originalCodeAOB, 0);
_remoteCodeAOB = _memorySharp.Assembly.Assembler.Assemble(String.Format("mov ebp,[ebp+0x0C]\n" +"cmp edi,3\n" + "jne 0x{0}\n" + "mov ebp,[edx]\n" + "test [edx],ebp\n" + "jmp 0x{1}", IntPtr.Add(_newmembase, 0xA).ToString("X8"), ( _nonRelativeScriptOffset.ToInt32() + 5).ToString("X8")), _newmembase);
_memorySharp.Write<byte>(_newmembase, _originalCodeAOB, false);
}

public NameWakeupData GetDummy()
Expand Down Expand Up @@ -137,7 +133,13 @@ public void PlayReversal()
#if DEBUG
Console.WriteLine("Play Reversal");
#endif
_script.Post("{\"type\": \"playback\"}");
var fc = FrameCount();
_memorySharp.Write<byte>(_newmembase, _remoteCodeAOB, false);
while(FrameCount() < fc + 1)
{

}
_memorySharp.Write<byte>(_newmembase, _originalCodeAOB, false);
}


Expand All @@ -153,6 +155,7 @@ public void StartReversalLoop(SlotInput slotInput, Action errorAction = null)
{
var currentDummy = GetDummy();
bool localRunReversalThread = true;
_memorySharp.Assembly.Inject(String.Format("jmp 0x{0}", _newmembase.ToString("X8")), _nonRelativeScriptOffset);
while (localRunReversalThread)
{
try
Expand Down Expand Up @@ -207,6 +210,7 @@ public void StopReversalLoop()
lock (RunReversalThreadLock)
{
_runReversalThread = false;
_memorySharp.Assembly.Inject(new string[] { "mov ebp, [ebp+0x0C]", "test [edx],ebp" }, _nonRelativeScriptOffset);
}
}

Expand Down Expand Up @@ -357,54 +361,6 @@ private string ReadAnimationString(int player)
return string.Empty;
}

private void CreateScript(Dispatcher dispatcher, int pid)
{
if (_script == null)
{
_deviceManager = new Frida.DeviceManager(dispatcher);
_device = _deviceManager.EnumerateDevices().FirstOrDefault(x => x.Type == Frida.DeviceType.Local);



if (_device == null)
{
throw new Exception("Local device not found.This application will now close.");
}

_session = _device.Attach((uint)pid);


var src =
@"var xrdbase = Module.findBaseAddress('GuiltyGearXrd.exe');
var hookaddr = xrdbase.add(" + "0x" + _scriptOffset.ToString("x") + @");
var playingback = false;
var running = true;
Interceptor.attach(hookaddr, function(args){
if(playingback && this.context.edi.equals(ptr('3'))){
playingback = false;
this.context.ebp = ptr(Memory.readU32(this.context.edx).toString());
}
});
var quit = recv('quit', function (value) {
Interceptor.detachAll();
running = false;
});
setTimeout( function () {
while (running){
var op = recv('playback', function (value) {
playingback=true;
});
op.wait();
}
}, 0);";

_script = _session.CreateScript(src);
_script.Load();


}
}

private int FrameCount()
{
return _memorySharp.Read<int>(_frameCountOffset);
Expand All @@ -431,20 +387,7 @@ private int GetWakeupTiming(NameWakeupData currentDummy)
public void Dispose()
{
StopReversalLoop();

_memorySharp?.Dispose();


_script?.Post("{\"type\": \"quit\"}");
_script?.Post("{\"type\": \"playback\"}");
_script?.Unload();
_session?.Detach();


_script?.Dispose();
_deviceManager?.Dispose();
_device?.Dispose();
_session?.Dispose();
}
#endregion

Expand Down
3 changes: 2 additions & 1 deletion GGXrdWakeupDPUtil.Library/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Fasm.NET" version="1.70.03" targetFramework="net452" />
<package id="EasyHook" version="2.7.6684" targetFramework="net452" />
<package id="Fasm.NET" version="1.70.03.2" targetFramework="net452" />
<package id="MemorySharp" version="1.2.0" targetFramework="net452" />
</packages>
2 changes: 1 addition & 1 deletion GGXrdWakeupDPUtil.Test/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private void button1_Click(object sender, EventArgs e)

private void Form1_Load(object sender, EventArgs e)
{
_reversalTool = new ReversalTool(Dispatcher.CurrentDispatcher);
_reversalTool = new ReversalTool();

_reversalTool.AttachToProcess();
}
Expand Down
2 changes: 1 addition & 1 deletion GGXrdWakeupDPUtil.UnitTests/ReversalToolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ReversalToolTests
public void CheckValidInput_Test(string input, bool isValid)
{
//Arrange
ReversalTool reversalTool = new ReversalTool(Dispatcher.CurrentDispatcher);
ReversalTool reversalTool = new ReversalTool();

//Act
var result = reversalTool.CheckValidInput(input);
Expand Down
2 changes: 1 addition & 1 deletion GGXrdWakeupDPUtil/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<add key="P2AnimStringPtrOffset" value="0x244C" />
<add key="FrameCountOffset" value="0x1BD1F90" />

<add key="ScriptOffset" value="0xb825e6" />
<add key="ScriptOffset" value="0xb825e3" />


</appSettings>
Expand Down
2 changes: 1 addition & 1 deletion GGXrdWakeupDPUtil/Window1.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Window1()

private void Window_Loaded(object sender, RoutedEventArgs e)
{
_reversalTool = new ReversalTool(Dispatcher);
_reversalTool = new ReversalTool();

try
{
Expand Down

0 comments on commit 649164d

Please sign in to comment.