using System; using System.Runtime.InteropServices; namespace PkmnLibSharp.Utilities { internal static class MarshalHelper { internal static IntPtr ToPtr(this string? s) { if (s == null) return IntPtr.Zero; return Marshal.StringToHGlobalAnsi(s); } internal static string? PtrString(this IntPtr i) { if (i == IntPtr.Zero) return null; return Marshal.PtrToStringAnsi(i); } internal static IntPtr ArrayPtr(this Array a) { return Marshal.UnsafeAddrOfPinnedArrayElement(a, 0); } internal const byte True = 1; internal const byte False = 0; internal static byte ToNative(this bool b) { return b ? True : False; } } }