I've been trying to get an EndScene hook working using aHook in 4.2. Heres my code:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using aHook;
namespace CJR_plua_hack
{
class plua
{
static void Main(string[] args)
{
Hook es = new Hook(aProcess.GetProcessIdByName("Wow"));
IntPtr wowb = es.BlackMagic.MainModule.BaseAddress;
System.Diagnostics.Process.EnterDebugMode();
UInt32 pDevicePTR = es.BlackMagic.ReadUInt(0xA7E20C);
Console.WriteLine(pDevicePTR.ToString());
pDevicePTR = es.BlackMagic.ReadUInt(pDevicePTR + 0x27E8);
UInt32 esa = es.BlackMagic.ReadUInt(pDevicePTR);
esa = es.BlackMagic.ReadUInt(esa + 0xA8);
//Hook Installed
Console.WriteLine(es.Hook_Install(esa).ToString());
String command = "DoEmote(\"dance\")";
uint dspace = es.BlackMagic.AllocateMemory(Encoding.UTF8.GetBytes(command).Length + 1);
es.BlackMagic.WriteBytes(dspace, Encoding.UTF8.GetBytes(command));
uint dostring = (uint)wowb + 0x425A30;
es.Hook_AsmAddLine("mov eax, " + dspace);
es.Hook_AsmAddLine("push 0");
es.Hook_AsmAddLine("push eax");
es.Hook_AsmAddLine("push eax");
es.Hook_AsmAddLine("mov eax, " + dostring);
es.Hook_AsmAddLine("call eax");
es.Hook_AsmAddLine("add esp,0xC");
es.Hook_AsmAddLine("retn");
es.Hook_AsmInject();
es.BlackMagic.FreeMemory(dspace);
es.Hook_Remove();
}
}
}
Yes its a copy paste from the aHook thread. Unfortunately, I get an exception, Read UInt failed at the following line:
Code:
pDevicePTR = es.BlackMagic.ReadUInt(pDevicePTR + 0x27E8);
Unless I'm mistaken and just cant read, that is the proper offset for D3D9 OffsetA. What am I doing wrong?