Hi there. So I used some code posted by someone on here to implement a Lua-DoString function:
Code:
public void DoString(string luacode) {
if (luacode == null)
throw new ArgumentNullException("Game->DoString: LuaCode cannot be null");
if (Wow == null || Wow == null)
throw new ArgumentNullException("Wow and MemorySharp must both be initialized before calling DoString");
RemoteAllocation cave = Wow.Memory.Allocate(luacode.Length + 0x01);
cave.WriteString(luacode, Encoding.ASCII);
string[] asmcode = new[] {
"mov eax, 0",
"mov ecx, 0" + cave.BaseAddress,
"mov edx, "+ cave.BaseAddress,
"call 0x704cd0",
"retn"
};
Wow.Assembly.InjectAndExecute(asmcode);
cave.Dispose();
}
When doing this every 500ms+ it works perfectly, but SOMETIMES it crashes the game (Access Violation - The memory at X could not be read). When changing the interval to 100ms it crashes immediately.
Could anybody explain to me why this happens and if I am doing something wrong?
Thanks!