public required MemoryFunctionVoid<IntPtr, IntPtr, int, bool, float, IntPtr> ProcessUsercmds;
// access the signatures in Load function
ProcessUsercmds = new(GameData.GetSignature("ProcessUsercmds"));
ProcessUsercmds.Hook(_OnProcessUsercmds, HookMode.Pre);
public HookResult _OnProcessUsercmds(DynamicHook h)
{
Logger.LogInformation("OnProcessUsercmds");
Logger.LogInformation("Param0: {value}", h.GetParam<IntPtr>(0));
nint ptr = h.GetParam<IntPtr>(0);
if (ptr == IntPtr.Zero)
return HookResult.Continue;
Logger.LogInformation("Ptr: {value}", ptr);
unsafe
{
// error happens here i tried CCSPlayerController player = new(ptr) but same error
// Whatever I try to do here to recast the type i just get that same error and ONLY in windows
CCSPlayerController player = ReinterpretCast<IntPtr, CCSPlayerController>(ptr);
Logger.LogInformation("Player: {value}", player);
Logger.LogInformation("Player SteamID: {value}", player.SteamID);
}
//Logger.LogInformation("Param0[CCSPlayerController*]: {value}", h.GetParam<CCSPlayerController>(0));
Logger.LogInformation("Param1[CUserCmd*]: {value}", h.GetParam<IntPtr>(1));
Logger.LogInformation("Param2[cmdCount]: {value}", h.GetParam<int>(2));
Logger.LogInformation("Param3[paused]: {value}", h.GetParam<bool>(3));
Logger.LogInformation("Param4[margin]: {value}", h.GetParam<float>(4));
return HookResult.Continue;
}