public bool InvokeAfterCall(UnmanagedContext ctx, UnmanagedStack stck) { if (afterCall != null) { return(afterCall(ctx, stck)); } return(true); }
//Internal Event Handler //-> onTick is just a name, it's not really a timer and ticks are not necessarily well spaced //-> This is basically a function called from a hook of the client's "general-purpose" function //-> this is a function called by the client whenever it has no windows messages to handle. //-> from this function it does everything else it needs to do: send packets that are in the packet queue //-> receive/handle packets, perform pathfinding/following/.... etc. //-> In this hook we can do our own things at that time... completely synchronized with the client. //-> So onTick = synchronized stuff. //-> The invokation for the ISynchronizeInvoke of the client also goes here. private bool Client_onTick(UnmanagedContext ctx, UnmanagedStack stck) { if (m_HookProc == null) { //install message hook if not installed yet (must be done here as we need the correct threadid, and this tick event gets handled on the client's main thread) m_ClientThread = Thread.CurrentThread.ManagedThreadId; m_HookProc = new Imports.HookProc(MessageHook); Imports.SetWindowsHookEx(Imports.HookType.WH_GETMESSAGE, System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(m_HookProc), IntPtr.Zero, Imports.GetCurrentThreadId()); } if (!m_ShuttingDown) { while (DelegateQueue.Count > 0) { DelegateQueue.Dequeue().DoInvoke(); } } return(true); }