//use struct with LayoutKind.Explicit Attribute to simulate the union in C/C++
[StructLayout(LayoutKind.Explicit)]
public struct Misc
{
[FieldOffset(0)]
public System.UInt32 PhysicalAddress;
[FieldOffset(0)]
public System.UInt32 VirtualSize;
}
[StructLayout(LayoutKind.Sequential)]
internal struct IMAGE_SECTION_HEADER
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]
public string Name;
public Misc Misc;
public UInt32 VirtualAddress;
public UInt32 SizeOfRawData;
public UInt32 PointerToRawData;
public UInt32 PointerToRelocations;
public UInt32 PointerToLinenumbers;
public UInt16 NumberOfRelocations;
public UInt16 NumberOfLinenumbers;
public UInt32 Characteristics;
}
' use struct with LayoutKind.Explicit Attribute to simulate the union in C/C++
<StructLayout(LayoutKind.Explicit)> _
Public Structure IMAGE_SECTION_HEADER_Misc
<FieldOffset(0)> _
Public PhysicalAddress As System.UInt32
<FieldOffset(0)> _
Public VirtualSize As System.UInt32
End Structure
<StructLayout(LayoutKind.Sequential)> _
Public Structure IMAGE_SECTION_HEADER
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=8)> _
Public Name As String
Public Misc As IMAGE_SECTION_HEADER_Misc
Public VirtualAddress As UInt32
Public SizeOfRawData As UInt32
Public PointerToRawData As UInt32
Public PointerToRelocations As UInt32
Public PointerToLinenumbers As UInt32
Public NumberOfRelocations As UInt16
Public NumberOfLinenumbers As UInt16
Public Characteristics As UInt32
End Structure
None.
None.