I cleaned up my code as Shynd suggested and was playing around with my bot but I still have issues with the following function. WoW is crashing with access violation. Ideas anyone?
Code:
public static String GetLocalizedText(string variable)
{
uint codecave = wow.AllocateMemory();
bm.WriteASCIIString(codecave + 0x100, variable);
bm.Asm.Clear();
AsmUpdateCurrentManager();
bm.Asm.AddLine("mov ecx, {0}", Globals.Player.LocalPlayerGUID);
bm.Asm.AddLine("push {0}", -1);
bm.Asm.AddLine("push {0}", codecave + 0x100);
bm.Asm.AddLine("call {0}", Globals.Functions.Lua_GetLocalizedText);
bm.Asm.AddLine("retn");
bm.SuspendThread();
uint result = bm.Asm.InjectAndExecute(codecave);
String sResult = "null";
if (result != 0)
{
sResult = bm.ReadASCIIString(result);
}
bm.FreeMemory(codecave);
bm.ResumeThread();
return sResult;
}