From 8840a1cfc837c7e46ca10bd91b9d9840d71be1f8 Mon Sep 17 00:00:00 2001 From: Anatoly <25752428+darkerz7@users.noreply.github.com> Date: Sun, 22 Dec 2024 22:26:56 +0500 Subject: [PATCH] Update 1.DZ.6 -Fixed some IO crash. Workaround, need -> https://github.com/roflmuffin/CounterStrikeSharp/pull/569 --- src/CustomIO.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/CustomIO.cs b/src/CustomIO.cs index f52dbae..2d2f359 100644 --- a/src/CustomIO.cs +++ b/src/CustomIO.cs @@ -3,21 +3,33 @@ using CounterStrikeSharp.API.Modules.Memory; using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions; using CounterStrikeSharp.API.Modules.Utils; +using System.Runtime.InteropServices; namespace CS2_CustomIO { public class CustomIO : BasePlugin { - public class CUtlSymbolLarge : NativeObject + /*public class CUtlSymbolLarge : NativeObject { public CUtlSymbolLarge(IntPtr pointer) : base(pointer) { } public string KeyValue => Utilities.ReadStringUtf8(Handle + 0); + }*/ + public class CUtlSymbolLarge : NativeObject + { + public CUtlSymbolLarge(IntPtr pointer) : base(pointer) + { + IntPtr ptr = Marshal.ReadIntPtr(pointer); + //KeyValue = ptr.ToString(); + if (ptr == IntPtr.Zero || ptr < 200000000000) return; + KeyValue = Marshal.PtrToStringUTF8(ptr); + } + public string? KeyValue; } public static MemoryFunctionVoid CEntityIdentity_AcceptInputFunc = new(GameData.GetSignature("CEntityIdentity_AcceptInput")); public override string ModuleName => "Custom IO"; public override string ModuleDescription => "Fixes missing keyvalues from CSS/CS:GO"; public override string ModuleAuthor => "DarkerZ [RUS]"; - public override string ModuleVersion => "1.DZ.5"; + public override string ModuleVersion => "1.DZ.6"; public override void Load(bool hotReload) { CEntityIdentity_AcceptInputFunc.Hook(OnInput, HookMode.Pre);