Skip to content
This repository has been archived by the owner on Jul 26, 2023. It is now read-only.

Commit

Permalink
Use C# sizeof wherever possible
Browse files Browse the repository at this point in the history
`sizeof(T)` is much faster than `Marshal.SizeOf<T>`, but it can only be safely used when `T` is a blittable type. This means all members are value types and have no `MarshalAs` attribute on them. This rule is recursive for all members.

Closes #475
  • Loading branch information
AArnott committed Jul 4, 2020
1 parent 51cba65 commit c2d9860
Show file tree
Hide file tree
Showing 35 changed files with 52 additions and 174 deletions.
2 changes: 1 addition & 1 deletion src/BCrypt.Tests/BCryptFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public unsafe void MultiHash()
using (hash)
{
var ops = new BCRYPT_MULTI_HASH_OPERATION[parallelism];
int opsSize = parallelism * Marshal.SizeOf<BCRYPT_MULTI_HASH_OPERATION>();
int opsSize = parallelism * sizeof(BCRYPT_MULTI_HASH_OPERATION);
fixed (byte* dataPtr = data)
{
for (int i = 0; i < ops.Length; i++)
Expand Down
6 changes: 1 addition & 5 deletions src/BCrypt/BCrypt+BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,7 @@ public static BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO Create()
{
return new BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO
{
#if NETSTANDARD2_0_ORLATER || NETFX_CORE
cbSize = Marshal.SizeOf<BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO>(),
#else
cbSize = Marshal.SizeOf(typeof(BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO)),
#endif
cbSize = sizeof(BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO),
dwInfoVersion = BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO_VERSION,
};
}
Expand Down
8 changes: 2 additions & 6 deletions src/BCrypt/BCrypt+BCRYPT_KEY_DATA_BLOB_HEADER.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,9 @@ public static byte[] InsertBeforeKey(byte[] keyMaterial)
return header.AddHeaderToKey(keyMaterial);
}

private byte[] AddHeaderToKey(byte[] keyMaterial)
private unsafe byte[] AddHeaderToKey(byte[] keyMaterial)
{
#if NETSTANDARD2_0_ORLATER || NETFX_CORE
int headerLength = Marshal.SizeOf<BCRYPT_KEY_DATA_BLOB_HEADER>();
#else
int headerLength = Marshal.SizeOf(typeof(BCRYPT_KEY_DATA_BLOB_HEADER));
#endif
int headerLength = sizeof(BCRYPT_KEY_DATA_BLOB_HEADER);
byte[] keyWithHeader = new byte[headerLength + keyMaterial.Length];
Array.Copy(BitConverter.GetBytes((uint)this.dwMagic), keyWithHeader, sizeof(uint));
Array.Copy(BitConverter.GetBytes(this.dwVersion), 0, keyWithHeader, sizeof(uint), sizeof(uint));
Expand Down
2 changes: 1 addition & 1 deletion src/CfgMgr32.Tests/CfgMgr32Facts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class CfgMgr32Facts
[Fact]
public void CM_NOTIFY_FILTER_Test()
{
Assert.Equal(0x1a0, Marshal.SizeOf<CM_NOTIFY_FILTER>());
Assert.Equal(0x1a0, CM_NOTIFY_FILTER.Create().cbSize);
}

[Fact]
Expand Down
8 changes: 1 addition & 7 deletions src/Fusion/MSCorEE+ASSEMBLY_INFO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ public unsafe partial struct ASSEMBLY_INFO
/// with the <see cref="cbAssemblyInfo"/> field initialized.
/// </summary>
/// <returns>The newly initialized struct.</returns>
public static ASSEMBLY_INFO Create()
{
return new ASSEMBLY_INFO
{
cbAssemblyInfo = (uint)Marshal.SizeOf(typeof(ASSEMBLY_INFO)),
};
}
public static ASSEMBLY_INFO Create() => new ASSEMBLY_INFO { cbAssemblyInfo = (uint)sizeof(ASSEMBLY_INFO) };
}
}
}
7 changes: 1 addition & 6 deletions src/Hid/Hid+HiddAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ public struct HiddAttributes
/// </summary>
public ushort VersionNumber;

public static HiddAttributes Create()
{
var result = default(HiddAttributes);
result.Size = Marshal.SizeOf(result);
return result;
}
public unsafe static HiddAttributes Create() => new HiddAttributes { Size = sizeof(HiddAttributes) };
}
}
}
8 changes: 4 additions & 4 deletions src/IPHlpApi.Tests/IPHlpApiFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
public class IPHlpApiFacts
{
[Fact]
public void StructSizeTest()
public unsafe void StructSizeTest()
{
Assert.Equal(0x04, Marshal.SizeOf<IPHlpApi.MIB_TCPTABLE_OWNER_PID>());
Assert.Equal(0x18, Marshal.SizeOf<IPHlpApi.MIB_TCPROW_OWNER_PID>());
Assert.Equal(0x04, sizeof(IPHlpApi.MIB_TCPTABLE_OWNER_PID));
Assert.Equal(0x18, sizeof(IPHlpApi.MIB_TCPROW_OWNER_PID));
}

[Fact]
Expand All @@ -32,7 +32,7 @@ public unsafe void GetExtendedTcpTableTest()
if (IPHlpApi.GetExtendedTcpTable(tcpTablePtr, ref tcpTableLength, bOrder: true, AddressFamily.InterNetwork, IPHlpApi.TCP_TABLE_CLASS.TCP_TABLE_OWNER_PID_ALL, 0) == Win32ErrorCode.ERROR_SUCCESS)
{
IPHlpApi.MIB_TCPTABLE_OWNER_PID* tcpTable = (IPHlpApi.MIB_TCPTABLE_OWNER_PID*)tcpTablePtr;
var tableSize = Marshal.SizeOf<IPHlpApi.MIB_TCPTABLE_OWNER_PID>();
var tableSize = sizeof(IPHlpApi.MIB_TCPTABLE_OWNER_PID);

IPHlpApi.MIB_TCPROW_OWNER_PID* tcpRow = (IPHlpApi.MIB_TCPROW_OWNER_PID*)(tcpTablePtr + tableSize);

Expand Down
9 changes: 1 addition & 8 deletions src/Kernel32/Kernel32+OSVERSIONINFOEX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,7 @@ public unsafe partial struct OSVERSIONINFOEX
/// the right pre-initialization for <see cref="dwOSVersionInfoSize"/>
/// </summary>
/// <returns>A newly initialzed instance of <see cref="OSVERSIONINFOEX"/></returns>
public static OSVERSIONINFOEX Create() => new OSVERSIONINFOEX
{
#if NETSTANDARD2_0_ORLATER || NETFX_CORE
dwOSVersionInfoSize = Marshal.SizeOf<OSVERSIONINFOEX>()
#else
dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX))
#endif
};
public static OSVERSIONINFOEX Create() => new OSVERSIONINFOEX { dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX) };
}
}
}
12 changes: 1 addition & 11 deletions src/Kernel32/Kernel32+SECURITY_ATTRIBUTES.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,7 @@ public struct SECURITY_ATTRIBUTES
/// Initializes a new instance of the <see cref="SECURITY_ATTRIBUTES"/> struct.
/// </summary>
/// <returns>A new instance of <see cref="SECURITY_ATTRIBUTES"/>.</returns>
public static SECURITY_ATTRIBUTES Create()
{
return new SECURITY_ATTRIBUTES
{
#if NETSTANDARD2_0_ORLATER || NETFX_CORE
nLength = Marshal.SizeOf<SECURITY_ATTRIBUTES>(),
#else
nLength = Marshal.SizeOf(typeof(SECURITY_ATTRIBUTES)),
#endif
};
}
public static unsafe SECURITY_ATTRIBUTES Create() => new SECURITY_ATTRIBUTES { nLength = sizeof(SECURITY_ATTRIBUTES) };
}
}
}
5 changes: 3 additions & 2 deletions src/Kernel32/Kernel32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,9 @@ public static extern unsafe SafeObjectHandle CreateMutex(
/// </summary>
/// <param name="lpVersionInformation">
/// A pointer to an OSVERSIONINFOEX structure containing the operating system version requirements to compare. The <paramref name="dwTypeMask"/>
/// parameter indicates the members of this structure that contain information to compare.You must set the
/// <see cref="OSVERSIONINFOEX.dwOSVersionInfoSize"/> member of this structure to <code>Marshal.SizeOf(typeof(OSVERSIONINFOEX))</code>. You must
/// parameter indicates the members of this structure that contain information to compare. You must set the
/// <see cref="OSVERSIONINFOEX.dwOSVersionInfoSize"/> member of this structure to <code>Marshal.SizeOf(typeof(OSVERSIONINFOEX))</code>
/// or create it with <see cref="OSVERSIONINFOEX.Create"/>. You must
/// also specify valid data for the members indicated by <paramref name="dwTypeMask"/>. The function ignores structure members for which the
/// corresponding <paramref name="dwTypeMask"/> bit is not set
/// </param>
Expand Down
6 changes: 1 addition & 5 deletions src/Kernel32/storebanned/Kernel32+MODULEENTRY32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ public static MODULEENTRY32 Create()
{
return new MODULEENTRY32
{
#if NETSTANDARD2_0_ORLATER
dwSize = Marshal.SizeOf<MODULEENTRY32>(),
#else
dwSize = Marshal.SizeOf(typeof(MODULEENTRY32)),
#endif
dwSize = sizeof(MODULEENTRY32),
th32ModuleID = 1,
};
}
Expand Down
12 changes: 1 addition & 11 deletions src/Kernel32/storebanned/Kernel32+PROCESSENTRY32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,7 @@ public string ExeFile
/// with <see cref="dwSize" /> set to the correct value.
/// </summary>
/// <returns>An instance of <see cref="PROCESSENTRY32"/>.</returns>
public static PROCESSENTRY32 Create()
{
return new PROCESSENTRY32
{
#if NETSTANDARD2_0_ORLATER
dwSize = Marshal.SizeOf<PROCESSENTRY32>(),
#else
dwSize = Marshal.SizeOf(typeof(PROCESSENTRY32)),
#endif
};
}
public static PROCESSENTRY32 Create() => new PROCESSENTRY32 { dwSize = sizeof(PROCESSENTRY32) };
}
}
}
12 changes: 1 addition & 11 deletions src/Kernel32/storebanned/Kernel32+StartupInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,7 @@ public unsafe partial struct STARTUPINFO
/// Initializes a new instance of the <see cref="STARTUPINFO"/> struct.
/// </summary>
/// <returns>An initialized instance of the struct.</returns>
public static STARTUPINFO Create()
{
return new STARTUPINFO
{
#if NETSTANDARD2_0_ORLATER
cb = Marshal.SizeOf<STARTUPINFO>(),
#else
cb = Marshal.SizeOf(typeof(STARTUPINFO)),
#endif
};
}
public static STARTUPINFO Create() => new STARTUPINFO { cb = sizeof(STARTUPINFO) };
}
}
}
10 changes: 8 additions & 2 deletions src/Magnification.Tests/MagnificationFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ public void InitializeThenDeinitialize()
}

[Fact]
public void MAGCOLOREFFECT_IsRightSize()
public unsafe void MAGCOLOREFFECT_IsRightSize()
{
Assert.Equal(sizeof(float) * 5 * 5, Marshal.SizeOf<MAGCOLOREFFECT>());
#pragma warning disable xUnit2000 // Constants and literals should be the expected argument
Assert.Equal(sizeof(float) * 5 * 5, sizeof(MAGCOLOREFFECT));
#pragma warning restore xUnit2000 // Constants and literals should be the expected argument
}

[Fact]
Expand All @@ -43,9 +46,12 @@ public void MAGCOLOREFFECT_MultidimensionalArray()
}

[Fact]
public void MAGTRANSFORM_IsRightSize()
public unsafe void MAGTRANSFORM_IsRightSize()
{
Assert.Equal(sizeof(float) * 3 * 3, Marshal.SizeOf<MAGTRANSFORM>());
#pragma warning disable xUnit2000 // Constants and literals should be the expected argument
Assert.Equal(sizeof(float) * 3 * 3, sizeof(MAGTRANSFORM));
#pragma warning restore xUnit2000 // Constants and literals should be the expected argument
}

[Fact]
Expand Down
12 changes: 1 addition & 11 deletions src/NCrypt/NCrypt+NCRYPT_KEY_BLOB_HEADER.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,7 @@ public enum MagicNumber : uint
/// with the <see cref="cbSize"/> field set appropriately.
/// </summary>
/// <returns>An initialized instance of the struct.</returns>
public static NCRYPT_KEY_BLOB_HEADER Create()
{
return new NCRYPT_KEY_BLOB_HEADER
{
#if NETSTANDARD2_0_ORLATER || NETFX_CORE
cbSize = Marshal.SizeOf<NCRYPT_KEY_BLOB_HEADER>(),
#else
cbSize = Marshal.SizeOf(typeof(NCRYPT_KEY_BLOB_HEADER)),
#endif
};
}
public unsafe static NCRYPT_KEY_BLOB_HEADER Create() => new NCRYPT_KEY_BLOB_HEADER { cbSize = sizeof(NCRYPT_KEY_BLOB_HEADER) };
}
}
}
8 changes: 1 addition & 7 deletions src/NTDll/NTDll+OBJECT_ATTRIBUTES.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,7 @@ public enum ObjectHandleAttributes
/// Initializes a new instance of the <see cref="OBJECT_ATTRIBUTES"/> structure.
/// </summary>
/// <returns>An <see cref="OBJECT_ATTRIBUTES"/> instance with <see cref="Length"/> initialized.</returns>
public static OBJECT_ATTRIBUTES Create()
{
return new OBJECT_ATTRIBUTES
{
Length = Marshal.SizeOf(typeof(OBJECT_ATTRIBUTES)),
};
}
public static OBJECT_ATTRIBUTES Create() => new OBJECT_ATTRIBUTES { Length = sizeof(OBJECT_ATTRIBUTES) };
}
}
}
8 changes: 2 additions & 6 deletions src/SetupApi/SetupApi+SP_DEVICE_INTERFACE_DATA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace PInvoke
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

/// <content>
Expand Down Expand Up @@ -43,12 +44,7 @@ public struct SP_DEVICE_INTERFACE_DATA
/// Create an instance with <see cref="Size" /> set to the correct value.
/// </summary>
/// <returns>An instance of <see cref="SP_DEVICE_INTERFACE_DATA" /> with it's <see cref="Size" /> member set.</returns>
public static SP_DEVICE_INTERFACE_DATA Create()
{
var result = default(SP_DEVICE_INTERFACE_DATA);
result.Size = Marshal.SizeOf(result);
return result;
}
public static unsafe SP_DEVICE_INTERFACE_DATA Create() => new SP_DEVICE_INTERFACE_DATA { Size = sizeof(SP_DEVICE_INTERFACE_DATA) };
}
}
}
8 changes: 1 addition & 7 deletions src/SetupApi/SetupApi+SP_DEVINFO_DATA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,7 @@ public struct SP_DEVINFO_DATA
/// with <see cref="cbSize" /> set to the correct value.
/// </summary>
/// <returns>An instance of <see cref="SP_DEVINFO_DATA"/>.</returns>
public static SP_DEVINFO_DATA Create()
{
return new SP_DEVINFO_DATA
{
cbSize = Marshal.SizeOf(typeof(SP_DEVINFO_DATA)),
};
}
public static unsafe SP_DEVINFO_DATA Create() => new SP_DEVINFO_DATA { cbSize = sizeof(SP_DEVINFO_DATA) };
}
}
}
8 changes: 1 addition & 7 deletions src/SetupApi/SetupApi+SP_DEVINSTALL_PARAMS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,7 @@ public string DriverPathString
/// with <see cref="cbSize" /> set to the correct value.
/// </summary>
/// <returns>An instance of <see cref="SP_DEVINSTALL_PARAMS"/>.</returns>
public static SP_DEVINSTALL_PARAMS Create()
{
return new SP_DEVINSTALL_PARAMS
{
cbSize = Marshal.SizeOf(typeof(SP_DEVINSTALL_PARAMS)),
};
}
public static SP_DEVINSTALL_PARAMS Create() => new SP_DEVINSTALL_PARAMS { cbSize = sizeof(SP_DEVINSTALL_PARAMS) };
}
}
}
2 changes: 1 addition & 1 deletion src/SetupApi/SetupApi+SP_DRVINFO_DATA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public unsafe struct SP_DRVINFO_DATA
/// with <see cref="cbSize" /> set to the correct value.
/// </summary>
/// <returns>An instance of <see cref="SP_DRVINFO_DATA"/>.</returns>
public static SP_DRVINFO_DATA Create() => new SP_DRVINFO_DATA { cbSize = Marshal.SizeOf(typeof(SP_DRVINFO_DATA)) };
public static SP_DRVINFO_DATA Create() => new SP_DRVINFO_DATA { cbSize = sizeof(SP_DRVINFO_DATA) };
}
}
}
2 changes: 1 addition & 1 deletion src/User32.Tests/User32Facts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void SetWindowLongPtr_Test()
}

[Fact]
public void MENUBARINFO_MarshalSizeAsExpected()
public unsafe void MENUBARINFO_MarshalSizeAsExpected()
{
MENUBARINFO info = default;
int expectedSize = IntPtr.Size == 4 ? 0x20 : 0x30;
Expand Down
4 changes: 2 additions & 2 deletions src/User32/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ PInvoke.User32.MENUBARINFO.hMenu -> System.IntPtr
PInvoke.User32.MENUBARINFO.hwndMenu -> System.IntPtr
PInvoke.User32.MENUBARINFO.rcBar -> PInvoke.RECT
PInvoke.User32.MENUINFO
PInvoke.User32.MENUINFO.Create() -> PInvoke.User32.MENUINFO
PInvoke.User32.MENUINFO.MENUINFO() -> void
PInvoke.User32.MENUINFO.cbSize -> int
PInvoke.User32.MENUINFO.cyMax -> uint
Expand Down Expand Up @@ -215,6 +214,7 @@ static PInvoke.User32.LoadCursor(System.IntPtr hInstance, char[] lpCursorName) -
static PInvoke.User32.LoadImage(System.IntPtr hInst, System.IntPtr name, PInvoke.User32.ImageType type, int cx, int cy, PInvoke.User32.LoadImageFlags fuLoad) -> System.IntPtr
static PInvoke.User32.LoadImage(System.IntPtr hInst, char[] name, PInvoke.User32.ImageType type, int cx, int cy, PInvoke.User32.LoadImageFlags fuLoad) -> System.IntPtr
static PInvoke.User32.MENUBARINFO.Create() -> PInvoke.User32.MENUBARINFO
static PInvoke.User32.MENUINFO.Create() -> PInvoke.User32.MENUINFO
static PInvoke.User32.MsgWaitForMultipleObjectsEx(uint nCount, System.IntPtr pHandles, uint dwMilliseconds, PInvoke.User32.WakeMask dwWakeMask, PInvoke.User32.MsgWaitForMultipleObjectsExFlags dwFlags) -> uint
static PInvoke.User32.MsgWaitForMultipleObjectsEx(uint nCount, System.IntPtr[] pHandles, uint dwMilliseconds, PInvoke.User32.WakeMask dwWakeMask, PInvoke.User32.MsgWaitForMultipleObjectsExFlags dwFlags) -> uint
static PInvoke.User32.SetMenuItemInfo(System.IntPtr hMenu, uint uItem, bool fByPosition, PInvoke.User32.MENUITEMINFO lpmii) -> bool
Expand Down Expand Up @@ -281,4 +281,4 @@ static readonly PInvoke.User32.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 -> Sys
static readonly PInvoke.User32.DPI_AWARENESS_CONTEXT_SYSTEM_AWARE -> System.IntPtr
static readonly PInvoke.User32.DPI_AWARENESS_CONTEXT_UNAWARE -> System.IntPtr
static readonly PInvoke.User32.DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED -> System.IntPtr
static readonly PInvoke.User32.SafeCursorHandle.Null -> PInvoke.User32.SafeCursorHandle
static readonly PInvoke.User32.SafeCursorHandle.Null -> PInvoke.User32.SafeCursorHandle
2 changes: 1 addition & 1 deletion src/User32/USer32+HELPINFO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public struct HELPINFO
public uint dwContextId;
public POINT MousePos;

public static HELPINFO Create() => new HELPINFO { cbSize = Marshal.SizeOf(typeof(HELPINFO)) };
public static unsafe HELPINFO Create() => new HELPINFO { cbSize = sizeof(HELPINFO) };
}
}
}
2 changes: 1 addition & 1 deletion src/User32/User32+CURSORINFO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public struct CURSORINFO
/// <returns>
/// An instance of the structure.
/// </returns>
public static CURSORINFO Create() => new CURSORINFO { cbSize = Marshal.SizeOf(typeof(CURSORINFO)) };
public static unsafe CURSORINFO Create() => new CURSORINFO { cbSize = sizeof(CURSORINFO) };
}
}
}
2 changes: 1 addition & 1 deletion src/User32/User32+DISPLAY_DEVICE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public unsafe struct DISPLAY_DEVICE
/// <returns>
/// An instance of the structure.
/// </returns>
public static DISPLAY_DEVICE Create() => new DISPLAY_DEVICE { cb = (uint)Marshal.SizeOf(typeof(DISPLAY_DEVICE)) };
public static DISPLAY_DEVICE Create() => new DISPLAY_DEVICE { cb = (uint)sizeof(DISPLAY_DEVICE) };
}
}
}
8 changes: 1 addition & 7 deletions src/User32/User32+FLASHWINFO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,7 @@ public struct FLASHWINFO
/// Create a new instance of <see cref="FLASHWINFO"/> with <see cref="cbSize"/> set to the correct value.
/// </summary>
/// <returns>A new instance of <see cref="FLASHWINFO"/> with <see cref="cbSize"/> set to the correct value.</returns>
public static FLASHWINFO Create()
{
return new FLASHWINFO
{
cbSize = Marshal.SizeOf(typeof(FLASHWINFO))
};
}
public static unsafe FLASHWINFO Create() => new FLASHWINFO { cbSize = sizeof(FLASHWINFO) };
}
}
}
Loading

0 comments on commit c2d9860

Please sign in to comment.