Hi guys,
I know this has been discussed a lot but after looking old posts and comparing to my code I could find no obvious reason why this is not working:
I tried to keep the code as simple as possible.
When I run for example: LuaDoString("DoEmote(\"Dance\")")
I get nothing. No crashes or dancing.
Have I missed anything or is this supposed to work only via EndScene?
Code:
public void LuaDoString(string command)
{
// Offset:
uint FrameScript__Execute = 0x43C010;
// Allocate memory
var args = Memory.AllocateMemory(Encoding.UTF8.GetBytes(command).Length + 1);
var codecave = Memory.AllocateMemory(0x3332);
// Write value:
Memory.WriteBytes(args, Encoding.UTF8.GetBytes(command));
try
{
// Write the asm stuff for Lua_DoString
Memory.Asm.Clear();
Memory.Asm.AddLine("mov eax, " + args);
Memory.Asm.AddLine("push 0");
Memory.Asm.AddLine("push eax");
Memory.Asm.AddLine("push eax");
Memory.Asm.AddLine("mov eax, " + ((uint)Memory.MainModule.BaseAddress + FrameScript__Execute));
Memory.Asm.AddLine("call eax");
Memory.Asm.AddLine("add esp, 0xC");
Memory.Asm.AddLine("retn");
// Inject
Memory.Asm.InjectAndExecute(codecave);
}
catch (Exception ex)
{
Debug.WriteLine(ex.StackTrace);
}
finally
{
// Free memory allocated
Memory.FreeMemory(codecave);
Memory.FreeMemory(args);
}
}