This commit is contained in:
2025-04-03 02:30:16 +08:00
parent 142adb61c6
commit bee7af1732
14907 changed files with 1009130 additions and 13 deletions

View File

@ -0,0 +1,7 @@
namespace MindPowerSdk
{
public static class GlobalDefine
{
public static string ClientDir = "";
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7fc62595d74a4f958f1aaed2f48adb47
timeCreated: 1727962264

View File

@ -0,0 +1,51 @@
using System.IO;
using System.Runtime.InteropServices;
namespace MindPowerSdk
{
public static class StructReader
{
public static T ReadStruct<T>(BinaryReader reader)
{
byte[] bytes = reader.ReadBytes(Marshal.SizeOf(typeof(T)));
GCHandle handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
T theStructure = (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T));
handle.Free();
return theStructure;
}
public static T ReadStructFromArray<T>(byte[] bytes)
{
GCHandle handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
T theStructure = (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T));
handle.Free();
return theStructure;
}
public static T[] ReadStructArray<T>(BinaryReader reader, int size)
{
T[] theStructures = new T[size];
for (int i = 0; i < size; i++)
{
theStructures[i] = ReadStruct<T>(reader);
}
return theStructures;
}
public static T[] ReadStructArray<T>(BinaryReader reader, uint size)
{
T[] theStructures = new T[size];
for (uint i = 0; i < size; i++)
{
theStructures[i] = ReadStruct<T>(reader);
}
return theStructures;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 635ded6c26144e1b85bd47293dd9409d
timeCreated: 1727962573