Paste: Correct use of UNION-STRUCT?

Author: tsculpt
Mode: factor
Date: Mon, 26 Oct 2009 17:17:00
Plain Text |
! The struct to translate:
! http://msdn.microsoft.com/en-us/library/ms791514.aspx
!
! typedef struct _REPARSE_DATA_BUFFER {
!   ULONG  ReparseTag;
!   USHORT  ReparseDataLength;
!   USHORT  Reserved;
!   union {
!     struct {
!       USHORT  SubstituteNameOffset;
!       USHORT  SubstituteNameLength;
!       USHORT  PrintNameOffset;
!       USHORT  PrintNameLength;
!       ULONG  Flags;
!       WCHAR  PathBuffer[1];
!       } SymbolicLinkReparseBuffer;
!     struct {
!       USHORT  SubstituteNameOffset;
!       USHORT  SubstituteNameLength;
!       USHORT  PrintNameOffset;
!       USHORT  PrintNameLength;
!       WCHAR  PathBuffer[1];
!       } MountPointReparseBuffer;
!     struct {
!       UCHAR  DataBuffer[1];
!     } GenericReparseBuffer;
!   };
! } REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;

! What I came up with:
STRUCT: SYMBOLIC_LINK_REPARSE_BUFFER
    { SubstituteNameOffset USHORT }
    { SubstituteNameLength USHORT }
    { PrintNameOffset USHORT }
    { PrintNameLength USHORT }
    { Flags ULONG }
    { PathBuffer WCHAR[1] } ;

STRUCT: MOUNT_POINT_REPARSE_BUFFER
    { SubstituteNameOffset USHORT }
    { SubstituteNameLength USHORT }
    { PrintNameOffset USHORT }
    { PrintNameLength USHORT }
    { PathBuffer WCHAR[1] } ;

STRUCT: GENERIC_REPARSE_BUFFER
    { DataBuffer UCHAR[1] } ;

UNION-STRUCT: REPARSE_DATA_UNION
    { SymbolicLinkReparseBuffer SYMBOLIC_LINK_REPARSE_BUFFER }
    { MountPointReparseBuffer MOUNT_POINT_REPARSE_BUFFER }
    { GenericReparseBuffer GENERIC_REPARSE_BUFFER } ;

STRUCT: REPARSE_DATA_BUFFER
    { ReparseTag ULONG }
    { ReparseDataLength USHORT }
    { Reserved USHORT }
    { ReparseDataUnion REPARSE_DATA_UNION } ;
TYPEDEF: REPARSE_DATA_BUFFER* PREPARSE_DATA_BUFFER

New Annotation

Summary:
Author:
Mode:
Body: