CommonUtils/PointerUtil.cs
(完整代码) 880Busing System;
using System.Runtime.InteropServices;
namespace CommonUtils
{
/// <summary>
/// 指针操作
/// </summary>
public static class PointerUtil
{
public static IntPtr GetFunctionPointer(Delegate d)
=> Marshal.GetFunctionPointerForDelegate(d);
public static IntPtr GetIUnknownPointer(object o)
=> Marshal.GetIUnknownForObject(o);
public static T GetObject<T>(IntPtr p)
=> Marshal.PtrToStructure<T>(p);
public static byte[] GetBytes(IntPtr p, int length)
{
byte[] bytes = new byte[length];
Marshal.Copy(p, bytes, 0, length);
return bytes;
}
/// <summary>
/// todo 指针互转测试
/// </summary>
public static void UseCase()
{
var bytes = new byte[] { 1, 2, 3 };
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。