コード例 #1
0
ファイル: InputMultiplexer.cs プロジェクト: KKovs/SpellFire
 private void BroadcastMessage(SystemWin32.WindowMessage wmsg)
 {
     foreach (IntPtr sink in Sinks)
     {
         SystemWin32.PostMessage(sink, wmsg.msg, wmsg.wParam, wmsg.lParam);
     }
 }
コード例 #2
0
ファイル: Primer.cs プロジェクト: zgbjmy2009/SpellFire
        static void Main(string[] args)
        {
            if (args.Length == 1 && args[0] == "-c")
            {
                SystemWin32.AllocConsole();
            }

            RunGui();
        }
コード例 #3
0
 private void MessageDispatcher(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
 {
     if (BroadcastKeys.Contains((Keys)wParam))
     {
         foreach (IntPtr sink in Sinks)
         {
             SystemWin32.PostMessage(sink, msg, wParam, lParam);
         }
     }
 }
コード例 #4
0
ファイル: Command.cs プロジェクト: KKovs/SpellFire
        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));
        }
コード例 #5
0
ファイル: WardenBuster.cs プロジェクト: KKovs/SpellFire
        private void PatchVirtualProtect()
        {
            IntPtr vpAddress = SystemWin32.GetProcAddress(SystemWin32.GetModuleHandle("kernel32.dll"), "VirtualProtect");

            originalVirtualProtect = Marshal.GetDelegateForFunctionPointer <SystemWin32.VirtualProtectDelegate>(vpAddress);

            virtualProtectPatch = LocalHook.Create(
                vpAddress,
                new SystemWin32.VirtualProtectDelegate(VirtualProtectPatchHandler),
                this);

            virtualProtectPatch.ThreadACL.SetExclusiveACL(new Int32[] { });
        }
コード例 #6
0
ファイル: Command.cs プロジェクト: KKovs/SpellFire
        public void Dispose()
        {
            DestroyLuaEventFrameHandler();

            if (originalWndProc != null)
            {
                /* restore original wnd proc if hooked */
                SystemWin32.SetWindowLong(
                    Process.GetCurrentProcess().MainWindowHandle,
                    SystemWin32.GWL_WNDPROC,
                    Marshal.GetFunctionPointerForDelegate(originalWndProc));
            }
        }
コード例 #7
0
ファイル: PageCheckHook.cs プロジェクト: zgbjmy2009/SpellFire
        public PageCheckHook(Memory memory, PageCheck pageCheckHandlerInstance, IntPtr targetAddress)
        {
            this.memory = memory;
            this.pageCheckHandlerInstance = pageCheckHandlerInstance;

            IntPtr hookAddress = Marshal.GetFunctionPointerForDelegate(pageCheckHandlerInstance);

            IntPtr endAddress = targetAddress + Offset.PageCheckReturnOffset;

            uint oldProtect = 0;

            SystemWin32.VirtualProtect(targetAddress, (UIntPtr)jmpShellcode.Length, SystemWin32.MemoryProtection.PAGE_EXECUTE_READWRITE, ref oldProtect);

            codeCaveAddress = Marshal.AllocHGlobal(PageCheckShellCode_Length);
            SystemWin32.VirtualProtect(codeCaveAddress, (UIntPtr)PageCheckShellCode_Length, SystemWin32.MemoryProtection.PAGE_EXECUTE_READWRITE, ref oldProtect);

            int hookJumpOffset = hookAddress.ToInt32() - codeCaveAddress.ToInt32() - PageCheckShellCode_CallHookOffset;
            int endJumpOffset  = endAddress.ToInt32() - codeCaveAddress.ToInt32() - PageCheckShellCode_Length;

            byte[] pageCheckShellcodeAssembly = PageCheckShellCode(hookJumpOffset, endJumpOffset);

            memory.Write(codeCaveAddress, pageCheckShellcodeAssembly);


            int offsetCodeCave = codeCaveAddress.ToInt32() - targetAddress.ToInt32() - jmpShellcode.Length;

            byte[] offsetCodeCaveBytes = BitConverter.GetBytes(offsetCodeCave);
            jmpShellcode[0] = 0xE9;             // JMP
            jmpShellcode[1] = offsetCodeCaveBytes[0];
            jmpShellcode[2] = offsetCodeCaveBytes[1];
            jmpShellcode[3] = offsetCodeCaveBytes[2];
            jmpShellcode[4] = offsetCodeCaveBytes[3];

            originalPageCheckBytes = memory.Read(targetAddress, jmpShellcode.Length);
            memory.Write(targetAddress, jmpShellcode);
        }
コード例 #8
0
ファイル: Command.cs プロジェクト: KKovs/SpellFire
 public void YieldWindowFocusHandler(IntPtr target)
 {
     SystemWin32.SwitchToThisWindow(target, true);
 }