internal static void Patch() { Log(string.Format("Patch() - Patching CommandHandler: {0:X} ...", (uint)LuaInterface.CommandHandlerPtr)); int bw = LuaInterface.SetFunctionPtr(LuaInterface.CommandHandlerPtr); Log(string.Format("Patch() - Patched CommandHandler. Bytes written: {0}", bw)); }
internal static void RestorePatch() { Log(string.Format("RestorePatch() - Restoring patched CommandHandler ... ")); int bw = LuaInterface.RestoreFunctionPtr(); Log(string.Format("RestorePatch() - Restored patched CommandHandler. Bytes written: {0}", bw)); }
public void RegisterLuaDelegate(Dictionary <string, uint> lua_config) { LuaInterface.RegisterLuaDelegate(lua_config); }
public uint EndScene(D3D9.IDirect3DDevice9 Device) { lock (LuaInterface.dataLock) { //Kernel32.SuspendThread(LuaInterface.WowMainThreadId); if (EndSceneDebug) { LuaInterface.LoggingInterface.LogEndScene(true); } try { switch (LuaInterface.LuaState) { case 255: // NOTE: disabled logging of each EndScene message as it was driving me mad during debug ;) //LuaInterface.LoggingInterface.Log("EndScene()"); break; case 0: // Need registration LuaInterface.LoggingInterface.Log("EndScene() - Lua registering ..."); LuaInterface.Patch(); if (!LuaInterface.InputHandlerRegistered) { LuaInterface.RegisterLuaInputHandler(); LuaInterface.InputHandlerRegistered = true; } LuaInterface.LoggingInterface.Log("EndScene() - Lua registered"); // Always last LuaInterface.LuaState = 255; break; case 1: //check for pending do_string's LuaInterface.LoggingInterface.Log("EndScene() - DoString Starting ..."); //LuaInterface.DoString(LuaInterface.PendingDoString); LuaInterface.DoString(LuaInterface.PendingDoString); LuaInterface.LoggingInterface.Log("EndScene() - LuaDoString Done"); // Always last LuaInterface.LuaState = 255; break; case 2: //check for pending do_string's with registered callback LuaInterface.LoggingInterface.Log( string.Format("EndScene() - DoStringEx Starting ...", LuaInterface.PendingDoString)); //LuaInterface.DoString(LuaInterface.PendingDoString); LuaInterface.DoStringEx(LuaInterface.PendingDoString); LuaInterface.LoggingInterface.Log("EndScene() - DoStringEx done"); // Always last LuaInterface.LuaState = 255; break; case 3: // Unregister handle LuaInterface.LoggingInterface.Log("EndScene() - Lua un-registering ..."); LuaInterface.RestorePatch(); LuaInterface.LoggingInterface.Log("EndScene() - Lua un-registered"); // Always last LuaInterface.LuaState = 255; break; default: // Unknown state throw exception throw new Exception("Unknown EndScene State: " + LuaInterface.LuaState); } if (EndSceneDebug) { LuaInterface.LoggingInterface.Log(string.Format("{0:X} Device", (uint)&Device)); LuaInterface.LoggingInterface.Log(string.Format("{0:X} EndScene()", (uint)OriginalEndScene)); } } catch (Exception e) { LuaInterface.LoggingInterface.Log(string.Format("EndScene() - Exception: {0}", e.ToString())); LuaInterface.LuaState = 255; } // NativeIDirect3DDevice9->VFTable[0][42] = Marshal.GetFunctionPointerForDelegate(MyEndScene); // LuaInterface.LoggingInterface.Log("EndScene " + LuaInterface.LuaState + " done"); if (EndSceneDebug) { LuaInterface.LoggingInterface.LogEndScene(false); } //LuaInterface.LoggingInterface.Log(string.Format("Device:{0} RealEndScene:{1}", Device, RealEndScene)); //Kernel32.ResumeThread(LuaInterface.WowMainThreadId); return(RealEndScene(Device)); } }