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

Commit 2b6bbcf

Browse files
committed
Fix marshaling of LOADED_IMAGE
Fixes #398
1 parent 4be0bc1 commit 2b6bbcf

File tree

3 files changed

+47
-21
lines changed

3 files changed

+47
-21
lines changed

src/DbgHelp/DbgHelp+LOADED_IMAGE.cs

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
namespace PInvoke
55
{
66
using System;
7+
using System.Diagnostics;
78
using System.Runtime.InteropServices;
89

10+
#pragma warning disable SA1623 // Property summary documentation must match accessors
11+
#pragma warning disable SA1300 // Element must begin with upper-case letter
12+
#pragma warning disable SA1202 // Elements must be ordered by access
13+
914
/// <content>
1015
/// Contains the <see cref="LOADED_IMAGE"/> nested type.
1116
/// </content>
@@ -59,24 +64,14 @@ public unsafe partial struct LOADED_IMAGE
5964
/// </summary>
6065
public Characteristics Characteristics;
6166

62-
/// <summary>
63-
/// If the image is a kernel mode executable image, this value is TRUE.
64-
/// </summary>
65-
[MarshalAs(UnmanagedType.Bool)]
66-
public bool fSystemImage;
67+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
68+
private byte fSystemImageByte;
6769

68-
/// <summary>
69-
/// If the image is a 16-bit executable image, this value is TRUE.
70-
/// </summary>
71-
[MarshalAs(UnmanagedType.Bool)]
72-
public bool fDOSImage;
70+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
71+
private byte fDOSImageByte;
7372

74-
/// <summary>
75-
/// If the image is read-only, this value is TRUE.
76-
/// Prior to Windows Vista: This member is not included in the structure.
77-
/// </summary>
78-
[MarshalAs(UnmanagedType.Bool)]
79-
public bool fReadOnly;
73+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
74+
private byte fReadOnlyByte;
8075

8176
/// <summary>
8277
/// The version string.
@@ -92,7 +87,35 @@ public unsafe partial struct LOADED_IMAGE
9287
/// <summary>
9388
/// The size of the image, in bytes.
9489
/// </summary>
95-
public int SizeOfImage;
90+
public uint SizeOfImage;
91+
92+
/// <summary>
93+
/// If the image is a kernel mode executable image, this value is TRUE.
94+
/// </summary>
95+
public bool fSystemImage
96+
{
97+
get => this.fSystemImageByte != 0;
98+
set => this.fSystemImageByte = value ? (byte)1 : (byte)0;
99+
}
100+
101+
/// <summary>
102+
/// If the image is a 16-bit executable image, this value is TRUE.
103+
/// </summary>
104+
public bool fDOSImage
105+
{
106+
get => this.fDOSImageByte != 0;
107+
set => this.fDOSImageByte = value ? (byte)1 : (byte)0;
108+
}
109+
110+
/// <summary>
111+
/// If the image is read-only, this value is TRUE.
112+
/// Prior to Windows Vista: This member is not included in the structure.
113+
/// </summary>
114+
public bool fReadOnly
115+
{
116+
get => this.fReadOnlyByte != 0;
117+
set => this.fReadOnlyByte = value ? (byte)1 : (byte)0;
118+
}
96119
}
97120
}
98121
}

src/DbgHelp/PublicAPI.Shipped.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ PInvoke.DbgHelp.LOADED_IMAGE.NumberOfSections -> int
1818
PInvoke.DbgHelp.LOADED_IMAGE.Sections -> PInvoke.IMAGE_SECTION_HEADER*
1919
PInvoke.DbgHelp.LOADED_IMAGE.Sections_IntPtr.get -> System.IntPtr
2020
PInvoke.DbgHelp.LOADED_IMAGE.Sections_IntPtr.set -> void
21-
PInvoke.DbgHelp.LOADED_IMAGE.SizeOfImage -> int
21+
PInvoke.DbgHelp.LOADED_IMAGE.SizeOfImage -> uint
2222
PInvoke.DbgHelp.LOADED_IMAGE.Version -> byte
23-
PInvoke.DbgHelp.LOADED_IMAGE.fDOSImage -> bool
24-
PInvoke.DbgHelp.LOADED_IMAGE.fReadOnly -> bool
25-
PInvoke.DbgHelp.LOADED_IMAGE.fSystemImage -> bool
2623
PInvoke.DbgHelp.LOADED_IMAGE.hFile -> System.IntPtr

src/DbgHelp/PublicAPI.Unshipped.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
PInvoke.DbgHelp.LOADED_IMAGE.fDOSImage.get -> bool
2+
PInvoke.DbgHelp.LOADED_IMAGE.fDOSImage.set -> void
3+
PInvoke.DbgHelp.LOADED_IMAGE.fReadOnly.get -> bool
4+
PInvoke.DbgHelp.LOADED_IMAGE.fReadOnly.set -> void
5+
PInvoke.DbgHelp.LOADED_IMAGE.fSystemImage.get -> bool
6+
PInvoke.DbgHelp.LOADED_IMAGE.fSystemImage.set -> void

0 commit comments

Comments
 (0)