C# EasyHook calling the original function crashes the program menu

User Tag List

Results 1 to 1 of 1
  1. #1
    chronicxo's Avatar Member
    Reputation
    1
    Join Date
    Dec 2016
    Posts
    1
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    C# EasyHook calling the original function crashes the program

    Can anyone help me identify why this function always crashes the game?

    I have been following tutorials on easyhook and the game seems to crash when i call the original function. The program enters hkJump(x,y) and I can read the parameters correctly just fine. However, if I dont call the original function then the game doesnt call it either since I have hooked it to my function. When I try to call the original function after performing my function in hkJump(x,y), the game crashes?

    Is there any flaw in what I have written.

    Please help

    Code:
    public class Main : IEntryPoint
        {
            static IntPtr JumpAddress = new IntPtr(0x51478B);
    
            static COInterface Interface;
            static LocalHook JumpHook;
            static String ChannelName;
    
            public Main(RemoteHooking.IContext InContext, String InChannelName)
            {
                Interface = RemoteHooking.IpcConnectClient<COInterface>(InChannelName);
                Interface.Log("DLL Injected into target process.");
                
            }
    
            public unsafe void Run(RemoteHooking.IContext InContext, String InChannelName)
            {
    
               try
                {
                    Interface.Log("Running hook");
                    JumpHook = LocalHook.Create(JumpAddress, new dJumpFunction(hkJump), this);
                    JumpHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
                    Interface.Log("Jump function hooked");
                } catch ( Exception e )
                {
                    Interface.ReportException(e);
                }
                try
                {
                    RemoteHooking.WakeUpProcess();
                } catch(Exception e) {
                    Interface.ReportException(e);
                }
                while (true)
                {
                    Thread.Sleep(1000);
                }
            }
    
            [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)]
            public unsafe delegate int dJumpFunction([MarshalAs(UnmanagedType.I4)] int x, [MarshalAs(UnmanagedType.I4)] int y);
    
            public static unsafe dJumpFunction oDispatchMessage = (dJumpFunction)Marshal.GetDelegateForFunctionPointer(JumpAddress, typeof(dJumpFunction));
           
            static int hkJump([MarshalAs(UnmanagedType.I4)] int x, [MarshalAs(UnmanagedType.I4)] int y )
            {
                try
                {
                    Interface.Log("X=" + x + ", Y=" + y);
                    return oDispatchMessage(x, y);
                } catch(Exception e)
                {
                    Interface.ReportException(e);
                    return oDispatchMessage(x, y);
                }
            }
        }

    C# EasyHook calling the original function crashes the program

Similar Threads

  1. [CODE] Calling the Python disassembler from C
    By GliderPro in forum Programming
    Replies: 1
    Last Post: 05-14-2009, 06:58 PM
  2. [Request]-Need some one to call the EU support.
    By dhzi in forum WoW Scams Help
    Replies: 2
    Last Post: 07-15-2008, 02:05 PM
  3. WoW scam, (Calling the account seller)
    By felan in forum WoW Scam Prevention
    Replies: 6
    Last Post: 06-11-2008, 01:55 PM
  4. Call the future
    By Elephant in forum Community Chat
    Replies: 5
    Last Post: 10-11-2007, 09:33 PM
All times are GMT -5. The time now is 04:15 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search