private IntPtr _weaponNamePtr = 0;

    private HookResult OnGiveNamedItem(DynamicHook arg)
    {
        try
        {
            var weaponName = arg.GetParam<string>(1);
            if (IsKnife(weaponName))
            {
                var services = arg.GetParam<CCSPlayer_WeaponServices>(0);
                var player = FindPlayerByWeaponServices(services);
                if (player?.TeamSettings == null)
                    return HookResult.Continue;

                var team = player.Controller.TeamNum - 2;
                if (team < 0)
                    return HookResult.Continue;

                if (!_knifes.TryGetValue(player.TeamSettings[team].Knife ?? -1, out var knife))
                    return HookResult.Continue;

                var strPtr = Marshal.AllocHGlobal(knife.Length + 1);
                var strPtrCopy = strPtr;
                foreach (var b in Encoding.ASCII.GetBytes(knife))
                {
                    Marshal.WriteByte(strPtrCopy++, b);
                }

                Marshal.WriteByte(strPtrCopy, 0);

                arg.SetParam<IntPtr>(1, strPtr);
                _weaponNamePtr = strPtr;
                return HookResult.Changed;
            }
        }
        catch (Exception e)
        {
            Logger.LogError("Error while handling GiveNamedItemPre: {e}", e);
        }

        return HookResult.Continue;
    }

    private HookResult OnGiveNamedItemPost(DynamicHook arg)
    {
        try
        {
            var weapon = arg.GetReturn<CBasePlayerWeapon>();
            if (weapon.Handle == 0)
                return HookResult.Continue;

            if (!IsKnife(weapon.DesignerName))
                weapon.Entity!.DesignerName = arg.GetParam<string>(1);

            var services = arg.GetParam<CCSPlayer_WeaponServices>(0);
            var player = FindPlayerByWeaponServices(services);
            if (player?.TeamSettings == null)
                return HookResult.Continue;

            var team = player.Controller.TeamNum - 2;
            if (team < 0)
                return HookResult.Continue;

            var manager = weapon.AttributeManager;
            var itemDefId = manager.Item.ItemDefinitionIndex;

            if (!player.TeamSettings[team].WeaponSettings.TryGetValue(itemDefId, out var weaponSettings))
                return HookResult.Continue;

            manager.Item.ItemID = 16384;
            manager.Item.ItemIDLow = 16384 & 0xFFFFFFFF;
            manager.Item.ItemIDHigh = manager.Item.ItemIDLow >> 32;

            if (!string.IsNullOrWhiteSpace(weaponSettings.Name))
                manager.Item.CustomName = weaponSettings.Name;

            weapon.FallbackPaintKit = weaponSettings.Paint;
            weaponSettings.Quality += 0.001f;
            weapon.FallbackWear = weaponSettings.Quality;
            weapon.FallbackSeed = weaponSettings.Pattern;

            if (weapon.CBodyComponent is { SceneNode: not null } cBodyComponent)
            {
                var skeleton = cBodyComponent.SceneNode.GetSkeletonInstance();
                skeleton.ModelState.MeshGroupMask = 2;
            }

            var attributesHandle = manager.Item.NetworkedDynamicAttributes.Handle;
            SetAttribute(attributesHandle, "set item texture prefab", weaponSettings.Paint);
            SetAttribute(attributesHandle, "set item texture wear", weaponSettings.Quality);
            SetAttribute(attributesHandle, "set item texture seed", weaponSettings.Quality);

            for (var i = 0; i < weaponSettings.Stickers.Length; i++)
            {
                unsafe
                {
                    var stickerId = weaponSettings.Stickers[i];
                    var stickerIdFloat = *(float*)&stickerId;
                    SetAttribute(attributesHandle, $"sticker slot {i} id", stickerIdFloat);
                    SetAttribute(manager.Item.AttributeList.Handle, $"sticker slot {i} id", stickerIdFloat);
                }
            }
        }
        catch (Exception e)
        {
            Logger.LogError("Error while handling GiveNamedItemPost: {e}", e);
        }
        finally
        {
            if (_weaponNamePtr != 0)
            {
                Marshal.FreeHGlobal(_weaponNamePtr);
                _weaponNamePtr = 0;
            }
        }


        return HookResult.Continue;
    }

    private SkinsPlayer? FindPlayerByWeaponServices(CCSPlayer_WeaponServices? services)
    {
        var pawn = services?.Pawn.Value;
        if (pawn == null)
            return null;

        return _players[pawn.As<CCSPlayerPawn>().OriginalController.Value!.Slot];
    }

    private bool IsKnife(string weapon)
    {
        return weapon.Contains("knife") || weapon.Contains("bayonet");
    }

what can crash there?