Search code examples
c#deviare

Deviare v2 C# Hook API Call and read param


I'm trying to figure out how I can read a param. I got the hook working, only thing is that whenever I do this, it crashes:

private void onFuncCall(NktHook hook, NktProcess process, NktHookCallInfo hookCallInfo)
    var paramsEnum = hookCallInfo.Params();
    if (hook.FunctionName.Equals("getPlayerPtr"))
    {
        INktParam p;
        p = paramsEnum.First();
        Debug.WriteLine(p.Value);//This line cause a crash
        return;
    }
}

getPlayerPtr definition:

UINT64 *getPlayerPtr(int Id);

Solution

  • This code should print all parameters values:

     private void OnFunctionCalled(NktHook hook, NktProcess process, NktHookCallInfo hookCallInfo)
        {
            Output(hook.FunctionName + "( ");
            bool first = true;
            foreach (INktParam param in hookCallInfo.Params())
            {
                if (first)
                    first = false;
                else
                {
                    Output(", ");
                }
                Output(param.Name + " = " + param.Value.ToString());
            }
            Output(" )" + Environment.NewLine);
        }
    

    It it doesn't work means that the hooked function isn't in Deviare Database. If that's the situation you should create a custom database: http://forum.nektra.com/forum/viewtopic.php?f=9&t=7130