Exemplo n.º 1
0
        public static bool InstallHook()
        {
            dmDelegate = new DispatchMessageDelegate(DispatchMessageHook);
            IntPtr hookPtr = Marshal.GetFunctionPointerForDelegate(dmDelegate);

            try
            {
                return(ImportPatcher.ReplaceIATEntry("user32.dll",
#if S5
                                                     "DispatchMessageA",
#elif S6
                                                     "DispatchMessageW",
#endif
                                                     hookPtr));
            }
            catch (Exception)
            {
                MessageBox.Show("Couldn't patch DispatchMessage!");
                return(false);
            }
        }
Exemplo n.º 2
0
        public static bool InstallHook()
        {
            ErrorHook.errorHandler    = new LuaCFunc(ErrorHook.ErrorCatcher);
            ErrorHook.errorHandlerPtr = Marshal.GetFunctionPointerForDelegate(ErrorHook.errorHandler);

            ErrorHook.pcallHook = new LuaPcallHook(ErrorHook.FakePcall);
            IntPtr pcallHookPtr = Marshal.GetFunctionPointerForDelegate(ErrorHook.pcallHook);

            try
            {
                return(ImportPatcher.ReplaceIATEntry(GlobalState.LuaDll, "lua_pcall", pcallHookPtr));
            }
            catch (Exception e)
            {
                Process p       = Process.GetCurrentProcess();
                string  modules = "";
                foreach (ProcessModule pm in p.Modules)
                {
                    modules += pm.ModuleName + " (@ 0x" + pm.BaseAddress.ToString("X") + ") " + pm.FileName + "\n";
                }
                MessageBox.Show("Patching the Import Table for lua_pcall failed!\nLua Errors won't be caught by the Debugger.\nProblem: " + e.Message + "\n\n" + modules.TrimEnd(), "Press Ctrl+C and send to yoq!");
                return(false);
            }
        }