Hello,
Here is a little dll based on BlackMagic for hooking the EndScene using static address.
It allow to run asm code through the EndScene, have fun with it.
I'll post the source once the last "problem" is fixed, under Win 7 / Vista WoW need to be run as admin, i assume cause of some win API used, i need to do something for grant WoW privilege.
Of course it's easier using injected dll with MS Detours, but anyway i'll post it i'm sure it can be usefull for someone.
Here is sample code to use Lua_DoString :
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using aHook;
namespace TestaHook
{
class Program
{
static void Main(string[] args)
{
Hook EndScene = new Hook(aProcess.GetProcessIdByName("Wow"));
UInt32 pDevicePtr = EndScene.BlackMagic.ReadUInt(0x00C76668);
pDevicePtr = EndScene.BlackMagic.ReadUInt(pDevicePtr + 0x397C);
UInt32 EndSceneAddr = EndScene.BlackMagic.ReadUInt(pDevicePtr);
EndSceneAddr = EndScene.BlackMagic.ReadUInt(EndSceneAddr + 0xA8);
Console.WriteLine(EndScene.Hook_Install(EndSceneAddr).ToString());
// Command to send using LUA
String Command = "print(\"EndScene hooked!\");";
// Allocate memory for command
uint DoString_space = EndScene.BlackMagic.AllocateMemory(Encoding.UTF8.GetBytes(Command).Length + 1);
// Write command in the allocated memory
EndScene.BlackMagic.WriteBytes(DoString_space, Encoding.UTF8.GetBytes(Command));
// Write the asm stuff for Lua_DoString
EndScene.Hook_AsmAddLine("mov eax, " + DoString_space);
EndScene.Hook_AsmAddLine("push 0");
EndScene.Hook_AsmAddLine("push eax");
EndScene.Hook_AsmAddLine("push eax");
EndScene.Hook_AsmAddLine("mov eax, 0x007F1F40"); // Lua_DoString
EndScene.Hook_AsmAddLine("call eax");
EndScene.Hook_AsmAddLine("add esp, 0xC");
EndScene.Hook_AsmAddLine("retn");
// Inject the shit
EndScene.Hook_AsmInject();
// Free memory allocated for command
EndScene.BlackMagic.FreeMemory(DoString_space);
// Uninstall the hook
EndScene.Hook_Remove();
Console.ReadLine();
}
}
}
It's based on ASM detour by Shynd, so credit to Shynd