@@ -81,11 +81,18 @@ protected virtual List<NdrStructureMember> PopulateMembers()
81
81
int current_offset = 0 ;
82
82
foreach ( var type in _base_members )
83
83
{
84
- if ( ! ( type is NdrStructurePaddingTypeReference ) )
84
+ if ( type is NdrStructureAlignTypeReference align )
85
85
{
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 ( ) ;
87
95
}
88
- current_offset += type . GetSize ( ) ;
89
96
}
90
97
return members ;
91
98
}
@@ -311,6 +318,34 @@ public override int GetSize()
311
318
}
312
319
}
313
320
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
+
314
349
[ Serializable ]
315
350
public sealed class NdrPointerInfoInstance
316
351
{
0 commit comments