unsafe public static ulong ReadULong(IPropertyContainer propertyContainer, uint key) { ulong output; propertyContainer.ReadProperty(key, new IntPtr(sizeof(ulong)), &output); return(output); }
unsafe public static IntPtr ReadIntPtr(IPropertyContainer propertyContainer, uint key) { IntPtr output; propertyContainer.ReadProperty(key, new IntPtr(sizeof(IntPtr)), &output); return(output); }
public static unsafe UInt64 ReadULong(IPropertyContainer propertyContainer, UInt32 key) { UInt64 output; propertyContainer.ReadProperty(key, new IntPtr(sizeof(UInt64)), &output); return(output); }
unsafe public static uint ReadUInt(IPropertyContainer propertyContainer, uint key) { uint output; propertyContainer.ReadProperty(key, new IntPtr(sizeof(uint)), &output); return(output); }
public static unsafe Int32 ReadInt(IPropertyContainer propertyContainer, UInt32 key) { Int32 output; propertyContainer.ReadProperty(key, new IntPtr(sizeof(Int32)), &output); return(output); }
public static unsafe String ReadString(IPropertyContainer propertyContainer, UInt32 key) { IntPtr size; String s; size = propertyContainer.GetPropertySize(key); var stringData = new Byte[size.ToInt64()]; fixed(Byte *pStringData = stringData) { propertyContainer.ReadProperty(key, size, pStringData); } s = Encoding.UTF8.GetString(stringData); var nullIndex = s.IndexOf('\0'); if (nullIndex >= 0) { return(s.Substring(0, nullIndex)); } else { return(s); } }
unsafe public static byte[] ReadBytes(IPropertyContainer propertyContainer, uint key) { IntPtr size; size = propertyContainer.GetPropertySize(key); byte[] data = new byte[size.ToInt64()]; fixed(byte *pData = data) { propertyContainer.ReadProperty(key, size, pData); } return(data); }
public static unsafe Byte[] ReadBytes(IPropertyContainer propertyContainer, UInt32 key) { IntPtr size; size = propertyContainer.GetPropertySize(key); var data = new Byte[size.ToInt64()]; fixed(Byte *pData = data) { propertyContainer.ReadProperty(key, size, pData); } return(data); }
unsafe public static void ReadPreAllocatedBytePtrArray(IPropertyContainer propertyContainer, uint key, byte[][] buffers) { GCHandle[] pinnedArrays = new GCHandle[buffers.Length]; // Pin arrays for (int i = 0; i < buffers.Length; i++) { pinnedArrays[i] = GCHandle.Alloc(buffers[i], GCHandleType.Pinned); } byte **pointerArray = stackalloc byte *[buffers.Length]; for (int i = 0; i < buffers.Length; i++) { pointerArray[i] = (byte *)(pinnedArrays[i].AddrOfPinnedObject().ToPointer()); } propertyContainer.ReadProperty(key, new IntPtr(sizeof(IntPtr) * buffers.Length), pointerArray); for (int i = 0; i < buffers.Length; i++) { pinnedArrays[i].Free(); } }
unsafe public static string ReadString(IPropertyContainer propertyContainer, uint key) { IntPtr size; string s; size = propertyContainer.GetPropertySize((uint)key); byte[] stringData = new byte[size.ToInt64()]; fixed(byte *pStringData = stringData) { propertyContainer.ReadProperty((uint)key, size, pStringData); } s = Encoding.UTF8.GetString(stringData); int nullIndex = s.IndexOf('\0'); if (nullIndex >= 0) { return(s.Substring(0, nullIndex)); } else { return(s); } }
public static unsafe ulong ReadULong(IPropertyContainer propertyContainer, uint key) { ulong output; propertyContainer.ReadProperty(key, new IntPtr(sizeof(ulong)), &output); return output; }
public static unsafe uint ReadUInt(IPropertyContainer propertyContainer, uint key) { uint output; propertyContainer.ReadProperty(key, new IntPtr(sizeof(uint)), &output); return output; }
public static unsafe string ReadString(IPropertyContainer propertyContainer, uint key) { IntPtr size; string s; size = propertyContainer.GetPropertySize((uint)key); byte[] stringData = new byte[size.ToInt64()]; fixed (byte* pStringData = stringData) { propertyContainer.ReadProperty((uint)key, size, pStringData); } s = Encoding.UTF8.GetString(stringData); int nullIndex = s.IndexOf('\0'); if (nullIndex >= 0) return s.Substring(0, nullIndex); else return s; }
public static unsafe void ReadPreAllocatedBytePtrArray(IPropertyContainer propertyContainer, uint key, byte[][] buffers) { GCHandle[] pinnedArrays = new GCHandle[buffers.Length]; // Pin arrays for( int i=0; i<buffers.Length; i++ ) pinnedArrays[i] = GCHandle.Alloc( buffers[i], GCHandleType.Pinned ); byte** pointerArray = stackalloc byte*[buffers.Length]; for( int i=0; i<buffers.Length; i++ ) pointerArray[i] = (byte*)(pinnedArrays[i].AddrOfPinnedObject().ToPointer()); propertyContainer.ReadProperty(key, new IntPtr(sizeof(IntPtr) * buffers.Length), pointerArray); for (int i = 0; i < buffers.Length; i++) pinnedArrays[i].Free(); }
public static unsafe IntPtr ReadIntPtr(IPropertyContainer propertyContainer, uint key) { IntPtr output; propertyContainer.ReadProperty(key, new IntPtr(sizeof(IntPtr)), &output); return output; }
public static unsafe byte[] ReadBytes(IPropertyContainer propertyContainer, uint key) { IntPtr size; size = propertyContainer.GetPropertySize(key); byte[] data = new byte[size.ToInt64()]; fixed (byte* pData = data) { propertyContainer.ReadProperty(key, size, pData); } return data; }