public void DetourWndProc() { WndProcPatchInstance = WndProcPatch; IntPtr hwnd = Process.GetCurrentProcess().MainWindowHandle; IntPtr originalWndProcAddress = (IntPtr)SystemWin32.GetWindowLong(hwnd, SystemWin32.GWL_WNDPROC); originalWndProc = Marshal.GetDelegateForFunctionPointer <SystemWin32.WndProc>(originalWndProcAddress); SystemWin32.SetWindowLong(hwnd, SystemWin32.GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(WndProcPatchInstance)); }
public void Dispose() { DestroyLuaEventFrameHandler(); if (originalWndProc != null) { /* restore original wnd proc if hooked */ SystemWin32.SetWindowLong( Process.GetCurrentProcess().MainWindowHandle, SystemWin32.GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(originalWndProc)); } }