@@ -81,11 +81,18 @@ protected virtual List<NdrStructureMember> PopulateMembers()
8181 int current_offset = 0 ;
8282 foreach ( var type in _base_members )
8383 {
84- if ( ! ( type is NdrStructurePaddingTypeReference ) )
84+ if ( type is NdrStructureAlignTypeReference align )
8585 {
86- members . Add ( new NdrStructureMember ( type , current_offset , $ "Member{ current_offset : X} ") ) ;
86+ current_offset = align . Align ( current_offset ) ;
87+ }
88+ else
89+ {
90+ if ( ! ( type is NdrStructurePaddingTypeReference ) )
91+ {
92+ members . Add ( new NdrStructureMember ( type , current_offset , $ "Member{ current_offset : X} ") ) ;
93+ }
94+ current_offset += type . GetSize ( ) ;
8795 }
88- current_offset += type . GetSize ( ) ;
8996 }
9097 return members ;
9198 }
@@ -311,6 +318,34 @@ public override int GetSize()
311318 }
312319 }
313320
321+ [ Serializable ]
322+ public sealed class NdrStructureAlignTypeReference : NdrBaseTypeReference
323+ {
324+ internal NdrStructureAlignTypeReference ( NdrFormatCharacter format ) : base ( format )
325+ {
326+ }
327+
328+ internal int Align ( int offset )
329+ {
330+ switch ( Format )
331+ {
332+ case NdrFormatCharacter . FC_ALIGNM2 :
333+ return ( offset + 1 ) & ~ 1 ;
334+ case NdrFormatCharacter . FC_ALIGNM4 :
335+ return ( offset + 3 ) & ~ 3 ;
336+ case NdrFormatCharacter . FC_ALIGNM8 :
337+ return ( offset + 7 ) & ~ 7 ;
338+ default :
339+ throw new InvalidOperationException ( "Format must be an alignment." ) ;
340+ }
341+ }
342+
343+ public override int GetSize ( )
344+ {
345+ return 0 ;
346+ }
347+ }
348+
314349 [ Serializable ]
315350 public sealed class NdrPointerInfoInstance
316351 {
0 commit comments