Skip to content

Commit

Permalink
Fixed alignment of SET_VIRTUAL_DISK_INFO (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
dahall committed Dec 22, 2022
1 parent 97c6db5 commit 5c48d15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 4 additions & 8 deletions PInvoke/VirtDisk/VirtDisk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2505,20 +2505,16 @@ public struct RESIZE_VIRTUAL_DISK_PARAMETERS_Version1
// ULONG ChildDepth; PCWSTR ParentFilePath; } ParentPathWithDepthInfo; ULONG VhdPhysicalSectorSize; GUID VirtualDiskId; BOOL
// ChangeTrackingEnabled; struct { GUID LinkageId; PCWSTR ParentFilePath; } ParentLocator; }; } SET_VIRTUAL_DISK_INFO, *PSET_VIRTUAL_DISK_INFO;
[PInvokeData("virtdisk.h", MSDNShortId = "NS:virtdisk._SET_VIRTUAL_DISK_INFO")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode,
#if x64
Pack = 8
#else
Pack = 4
#endif
)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SET_VIRTUAL_DISK_INFO
{
private IntPtr ver;

/// <summary>
/// A SET_VIRTUAL_DISK_INFO_VERSION enumeration that specifies the version of the SET_VIRTUAL_DISK_INFO structure being passed to
/// or from the VHD functions. This determines the type of information set.
/// </summary>
public SET_VIRTUAL_DISK_INFO_VERSION Version;
public SET_VIRTUAL_DISK_INFO_VERSION Version { get => (SET_VIRTUAL_DISK_INFO_VERSION)ver.ToInt32(); set => ver = new((int)value); }

private UNION union;

Expand Down
6 changes: 6 additions & 0 deletions UnitTests/PInvoke/VirtDisk/VirtDiskTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public class VirtDiskTests
private static readonly string tmpcfn = Vanara.PInvoke.Tests.TestCaseSources.TempDirWhack + "TestVHD - Diff.vhdx";
private static readonly string tmpfn = Vanara.PInvoke.Tests.TestCaseSources.TempDirWhack + "TestVHD.vhdx";

[Test]
public void _StructTest()
{
TestHelper.DumpStructSizeAndOffsets<SET_VIRTUAL_DISK_INFO>();
}

[Test()]
public void AttachVirtualDiskTest()
{
Expand Down

0 comments on commit 5c48d15

Please sign in to comment.