Skip to content

Commit

Permalink
Fix #427
Browse files Browse the repository at this point in the history
  • Loading branch information
dahall committed Sep 15, 2023
1 parent aa34fe9 commit de3e905
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions PInvoke/Kernel32/WinBase.File.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.IO;
using System.Numerics;
using System.Threading;

namespace Vanara.PInvoke;
Expand Down Expand Up @@ -4047,17 +4048,15 @@ public struct FILE_FULL_DIR_INFO
public string FileName;
}

/// <summary>
/// <para>Defines a 128-bit file identifier.</para>
/// </summary>
/// <summary>Defines a 128-bit file identifier.</summary>
// https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ns-winnt-_file_id_128 typedef struct _FILE_ID_128 { BYTE
// Identifier[16]; } FILE_ID_128, *PFILE_ID_128;
[PInvokeData("winnt.h", MSDNShortId = "254ea6a9-e1dd-4b97-91f7-2693065c4bb8")]
[StructLayout(LayoutKind.Sequential)]
public readonly struct FILE_ID_128
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct FILE_ID_128
{
private readonly ulong id0;
private readonly ulong id1;
private ulong id0;
private ulong id1;

/// <summary>
/// <para>A byte array containing the 128 bit identifier.</para>
Expand All @@ -4066,13 +4065,16 @@ public byte[] Identifier
{
get
{
using PinnedObject pin = new(id0);
return ((IntPtr)pin).ToByteArray(16)!;
var ret = new byte[16];
BitConverter.GetBytes(id0).CopyTo(ret, 0);
BitConverter.GetBytes(id1).CopyTo(ret, 8);
return ret;
}
set
{
using PinnedObject pin = new(id0);
Marshal.Copy(value, 0, pin, 16);
if (value.Length != 16) throw new ArgumentOutOfRangeException("Array must be 16 bytes long.", nameof(value));
id0 = BitConverter.ToUInt64(value, 0);
id1 = BitConverter.ToUInt64(value, 8);
}
}
}
Expand Down

0 comments on commit de3e905

Please sign in to comment.