Skip to content

Commit a0006c0

Browse files
Replace CountWideEnum with PropertyCountContext (#260)
* Replace CountWideEnum with PropertyCountContext Add EntryID size count missing field in ModLinkAttRequests (not in spec) * nitpicks * another nit
1 parent fab0c45 commit a0006c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+448
-362
lines changed

MAPIInspector/Source/MAPIInspector.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@
106106
<Compile Include="MAPIControl.Events.cs">
107107
<SubType>UserControl</SubType>
108108
</Compile>
109+
<Compile Include="Parsers\MSOXCDATA\2.11 Property Values\PropertyCountContext.cs" />
110+
<Compile Include="Parsers\MSOXCDATA\2.12 Restrictions\CommentRestriction.cs" />
109111
<Compile Include="Parsers\MSOXCFXICS\LexicalBase\Partial\MissingPartialInformationException.cs" />
110112
<Compile Include="Parsers\MSOXCFXICS\LexicalBase\Partial\PartialContextInformation.cs" />
111113
<Compile Include="Parsers\MSOXCFXICS\LexicalBase\Partial\Partial.cs" />
@@ -143,7 +145,6 @@
143145
<Compile Include="Parsers\MSOXCDATA\2.1 AddressList Structures\AddressList.cs" />
144146
<Compile Include="Parsers\MSOXCDATA\2.12 Restrictions\AndRestriction.cs" />
145147
<Compile Include="Parsers\MSOXCDATA\2.12 Restrictions\BitMaskRestriction.cs" />
146-
<Compile Include="Parsers\MSOXCDATA\2.12 Restrictions\CommentRestriction.cs" />
147148
<Compile Include="Parsers\MSOXCDATA\2.12 Restrictions\ComparePropertiesRestriction.cs" />
148149
<Compile Include="Parsers\MSOXCDATA\2.12 Restrictions\ContentRestriction.cs" />
149150
<Compile Include="Parsers\MSOXCDATA\2.12 Restrictions\CountRestriction.cs" />
@@ -206,7 +207,6 @@
206207
<Compile Include="Parsers\MSOXCDATA\2.11 Property Values\TypedPropertyValue.cs" />
207208
<Compile Include="Parsers\MSOXCDATA\2.11 Property Values\TypedString.cs" />
208209
<Compile Include="Parsers\MSOXCDATA\BlockGuid.cs" />
209-
<Compile Include="Parsers\MSOXCDATA\2.11 Property Values\CountWideEnum.cs" />
210210
<Compile Include="Parsers\MSOXCDATA\2.4 Error Codes\HelpMethod.cs" />
211211
<Compile Include="Parsers\MSOXCDATA\BlockGuidExtensions.cs" />
212212
<Compile Include="Parsers\MSOXCFOLD\enums\ContentsTableFlags.cs" />
@@ -710,6 +710,7 @@
710710
<Compile Include="Parsers\MSOXCTABL\rops\RopSortTableRequest.cs" />
711711
<Compile Include="Parsers\MSOXCTABL\rops\RopSortTableResponse.cs" />
712712
<Compile Include="Parsers\MSOXNSPI\enum\DisplayTypeValues.cs" />
713+
<Compile Include="Parsers\MSOXNSPI\struct\EntryID.cs" />
713714
<Compile Include="Parsers\MSOXNSPI\struct\EphemeralEntryID.cs" />
714715
<Compile Include="Parsers\MSOXNSPI\struct\MinimalEntryID.cs" />
715716
<Compile Include="Parsers\MSOXCTABL\rops\RopSetCollapseStateResponse.cs" />

MAPIInspector/Source/Parsers/MSOXCDATA/2.11 Property Values/CountWideEnum.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

MAPIInspector/Source/Parsers/MSOXCDATA/2.11 Property Values/FlaggedPropertyValue.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@ public class FlaggedPropertyValue : Block
1818
public Block _PropertyValue;
1919

2020
/// <summary>
21-
/// The Property data type.
21+
/// The parsing context that determines count field widths.
2222
/// </summary>
23-
private PropertyDataType propertyType;
23+
private readonly PropertyCountContext context;
2424

2525
/// <summary>
26-
/// The Count wide size.
26+
/// An unsigned integer that specifies the data type of the property value, according to the table in section 2.11.1.
2727
/// </summary>
28-
private CountWideEnum countWide;
28+
private PropertyDataType propertyType;
2929

3030
/// <summary>
3131
/// Initializes a new instance of the FlaggedPropertyValue class
3232
/// </summary>
33-
/// <param name="propertyType">The Property data type.</param>
34-
/// <param name="ptypMultiCountSize">The Count wide size.</param>
35-
public FlaggedPropertyValue(PropertyDataType _propertyType, CountWideEnum ptypMultiCountSize = CountWideEnum.twoBytes)
33+
/// <param name="_propertyType">The property type</param>
34+
/// <param name="countContext">The parsing context that determines count field widths</param>
35+
public FlaggedPropertyValue(PropertyDataType _propertyType, PropertyCountContext countContext = PropertyCountContext.RopBuffers)
3636
{
37+
context = countContext;
3738
propertyType = _propertyType;
38-
countWide = ptypMultiCountSize;
3939
}
4040

4141
/// <summary>
@@ -46,11 +46,11 @@ protected override void Parse()
4646
Flag = ParseT<byte>();
4747
if (Flag == 0x00)
4848
{
49-
_PropertyValue = PropertyValue.ReadPropertyValue(propertyType, parser, countWide);
49+
_PropertyValue = PropertyValue.ReadPropertyValue(propertyType, parser, context);
5050
}
5151
else if (Flag == 0x0A)
5252
{
53-
_PropertyValue = PropertyValue.ReadPropertyValue(PropertyDataType.PtypErrorCode, parser, countWide);
53+
_PropertyValue = PropertyValue.ReadPropertyValue(PropertyDataType.PtypErrorCode, parser, context);
5454
}
5555
}
5656

MAPIInspector/Source/Parsers/MSOXCDATA/2.11 Property Values/FlaggedPropertyValueWithType.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,17 @@ public class FlaggedPropertyValueWithType : Block
2323
public Block _PropertyValue;
2424

2525
/// <summary>
26-
/// The Count wide size.
26+
/// The parsing context that determines count field widths.
2727
/// </summary>
28-
private CountWideEnum countWide = CountWideEnum.twoBytes;
28+
private readonly PropertyCountContext context;
2929

3030
/// <summary>
3131
/// Initializes a new instance of the FlaggedPropertyValueWithType class
3232
/// </summary>
33-
public FlaggedPropertyValueWithType() { }
34-
35-
/// <summary>
36-
/// Initializes a new instance of the FlaggedPropertyValueWithType class
37-
/// </summary>
38-
/// <param name="ptypMultiCountSize">The Count wide size.</param>
39-
public FlaggedPropertyValueWithType(CountWideEnum ptypMultiCountSize)
33+
/// <param name="countContext">The parsing context that determines count field widths</param>
34+
public FlaggedPropertyValueWithType(PropertyCountContext countContext = PropertyCountContext.RopBuffers)
4035
{
41-
countWide = ptypMultiCountSize;
36+
context = countContext;
4237
}
4338

4439
/// <summary>
@@ -50,11 +45,11 @@ protected override void Parse()
5045
Flag = ParseT<byte>();
5146
if (Flag == 0x00)
5247
{
53-
_PropertyValue = PropertyValue.ReadPropertyValue(PropertyType, parser, countWide);
48+
_PropertyValue = PropertyValue.ReadPropertyValue(PropertyType, parser, context);
5449
}
5550
else if (Flag == 0x0A)
5651
{
57-
_PropertyValue = PropertyValue.ReadPropertyValue(PropertyDataType.PtypErrorCode, parser, countWide);
52+
_PropertyValue = PropertyValue.ReadPropertyValue(PropertyDataType.PtypErrorCode, parser, context);
5853
}
5954
}
6055

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace MAPIInspector.Parsers
2+
{
3+
/// <summary>
4+
/// Defines the parsing context that determines count field width for property values.
5+
/// Based on [MS-OXCDATA] 2.11.1.1 COUNT Data Type Values specification.
6+
/// </summary>
7+
public enum PropertyCountContext
8+
{
9+
/// <summary>
10+
/// ROP buffers context - PtypBinary uses 16-bit count, PtypMultiple uses 32-bit count.
11+
/// Used in RopGetPropertiesSpecific ROP ([MS-OXCROPS] section 2.2.8.3).
12+
/// </summary>
13+
RopBuffers,
14+
15+
/// <summary>
16+
/// Extended rules context - Both PtypBinary and PtypMultiple use 32-bit count.
17+
/// Used in [MS-OXORULE] section 2.2.4.
18+
/// </summary>
19+
ExtendedRules,
20+
21+
/// <summary>
22+
/// MAPI extensions for HTTP context - Both PtypBinary and PtypMultiple use 32-bit count.
23+
/// Used in [MS-OXCMAPIHTTP] section 2.2.5.
24+
/// </summary>
25+
MapiHttp,
26+
27+
/// <summary>
28+
/// Address book context - Uses same rules as MAPI HTTP context.
29+
/// </summary>
30+
AddressBook
31+
}
32+
}

MAPIInspector/Source/Parsers/MSOXCDATA/2.11 Property Values/PropertyValue.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public class PropertyValue : Block
1414
public Block Value;
1515

1616
/// <summary>
17-
/// The Count wide size of ptypMutiple type.
17+
/// The parsing context that determines count field widths.
1818
/// </summary>
19-
private CountWideEnum countWide;
19+
private readonly PropertyCountContext context;
2020

2121
/// <summary>
2222
/// An unsigned integer that specifies the data type of the property value, according to the table in section 2.11.1.
@@ -32,11 +32,11 @@ public class PropertyValue : Block
3232
/// Initializes a new instance of the PropertyValue class
3333
/// </summary>
3434
/// <param name="_propertyType">The property type</param>
35-
/// <param name="ptypMultiCountSize">The Count wide size of ptypMutiple type</param>
35+
/// <param name="countContext">The parsing context that determines count field widths</param>
3636
/// <param name="addressBook">Whether it is AddressBook related property</param>
37-
public PropertyValue(PropertyDataType _propertyType, CountWideEnum ptypMultiCountSize = CountWideEnum.twoBytes, bool addressBook = false)
37+
public PropertyValue(PropertyDataType _propertyType, PropertyCountContext countContext = PropertyCountContext.RopBuffers, bool addressBook = false)
3838
{
39-
countWide = ptypMultiCountSize;
39+
context = countContext;
4040
propertyType = _propertyType;
4141
isAddressBook = addressBook;
4242
}
@@ -46,7 +46,7 @@ public PropertyValue(PropertyDataType _propertyType, CountWideEnum ptypMultiCoun
4646
/// </summary>
4747
protected override void Parse()
4848
{
49-
Value = ReadPropertyValue(propertyType, parser, countWide);
49+
Value = ReadPropertyValue(propertyType, parser, context, isAddressBook);
5050
}
5151

5252
protected override void ParseBlocks()
@@ -67,9 +67,10 @@ protected override void ParseBlocks()
6767
/// </summary>
6868
/// <param name="dataType">The Property data type.</param>
6969
/// <param name="parser">A BinaryParser containing the PropertyValue structure</param>
70-
/// <param name="ptypMultiCountSize">The Count wide size of ptypMutiple type.</param>
70+
/// <param name="countContext">The parsing context that determines count field widths</param>
71+
/// <param name="bIsAddressBook">Whether this is for address book parsing</param>
7172
/// <returns>The object of PropertyValue.</returns>
72-
static public Block ReadPropertyValue(PropertyDataType dataType, BinaryParser parser, CountWideEnum ptypMultiCountSize = CountWideEnum.twoBytes, bool bIsAddressBook = false)
73+
static public Block ReadPropertyValue(PropertyDataType dataType, BinaryParser parser, PropertyCountContext countContext = PropertyCountContext.RopBuffers, bool bIsAddressBook = false)
7374
{
7475
switch (dataType)
7576
{
@@ -89,21 +90,21 @@ static public Block ReadPropertyValue(PropertyDataType dataType, BinaryParser pa
8990
case PropertyDataType.PtypServerId: return Parse<PtypServerId>(parser);
9091
case PropertyDataType.PtypRestriction:
9192
{
92-
var tempPropertyValue = new RestrictionType(ptypMultiCountSize);
93+
var tempPropertyValue = new RestrictionType(countContext);
9394
tempPropertyValue.Parse(parser);
9495
return tempPropertyValue;
9596
}
9697
case PropertyDataType.PtypRuleAction:
9798
{
98-
var tempPropertyValue = new RuleAction(ptypMultiCountSize);
99+
var tempPropertyValue = new RuleAction(countContext);
99100
tempPropertyValue.Parse(parser);
100101
return tempPropertyValue;
101102
}
102103
case PropertyDataType.PtypUnspecified: return Parse<PtypUnspecified>(parser);
103104
case PropertyDataType.PtypNull: return Parse<PtypNull>(parser);
104105
case PropertyDataType.PtypBinary:
105106
{
106-
var tempPropertyValue = new PtypBinary(ptypMultiCountSize, false);
107+
var tempPropertyValue = new PtypBinary(countContext);
107108
tempPropertyValue.Parse(parser);
108109
return tempPropertyValue;
109110
}
@@ -116,26 +117,26 @@ static public Block ReadPropertyValue(PropertyDataType dataType, BinaryParser pa
116117
case PropertyDataType.PtypMultipleInteger64: return Parse<PtypMultipleInteger64>(parser);
117118
case PropertyDataType.PtypMultipleString:
118119
{
119-
var tempPropertyValue = new PtypMultipleString(ptypMultiCountSize, bIsAddressBook);
120+
var tempPropertyValue = new PtypMultipleString(bIsAddressBook);
120121
tempPropertyValue.Parse(parser);
121122
return tempPropertyValue;
122123
}
123124
case PropertyDataType.PtypMultipleString8:
124125
{
125-
var tempPropertyValue = new PtypMultipleString8(ptypMultiCountSize, bIsAddressBook);
126+
var tempPropertyValue = new PtypMultipleString8(bIsAddressBook);
126127
tempPropertyValue.Parse(parser);
127128
return tempPropertyValue;
128129
}
129130
case PropertyDataType.PtypMultipleTime: return Parse<PtypMultipleTime>(parser);
130131
case PropertyDataType.PtypMultipleGuid: return Parse<PtypMultipleGuid>(parser);
131132
case PropertyDataType.PtypMultipleBinary:
132133
{
133-
var tempPropertyValue = new PtypMultipleBinary(ptypMultiCountSize, bIsAddressBook);
134+
var tempPropertyValue = new PtypMultipleBinary(countContext, bIsAddressBook);
134135
tempPropertyValue.Parse(parser);
135136
return tempPropertyValue;
136137
}
137-
138-
case PropertyDataType.PtypObject_Or_PtypEmbeddedTable: return Parse<PtypObject_Or_PtypEmbeddedTable>(parser);
138+
case PropertyDataType.PtypObject_Or_PtypEmbeddedTable:
139+
return Parse<PtypObject_Or_PtypEmbeddedTable>(parser);
139140
}
140141

141142
return null;

MAPIInspector/Source/Parsers/MSOXCDATA/2.11 Property Values/PtypBinary.cs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,34 @@ public class PtypBinary : Block
2424
public BlockT<bool> HasValue;
2525

2626
/// <summary>
27-
/// The Count wide size.
27+
/// Whether to use 32-bit count (true) or 16-bit count (false).
2828
/// </summary>
29-
private CountWideEnum countWide;
29+
private bool usesFourByteCount;
3030

3131
private readonly bool isAddressBook = false;
3232

3333
/// <summary>
3434
/// Initializes a new instance of the PtypBinary class
3535
/// </summary>
36-
/// <param name="wide">The Count wide size of PtypBinary type.</param>
37-
public PtypBinary(CountWideEnum wide, bool isAddressBook)
36+
/// <param name="context">The parsing context that determines count field width.</param>
37+
/// <param name="isAddressBook">Whether this is for address book parsing.</param>
38+
public PtypBinary(PropertyCountContext context, bool isAddressBook = false)
3839
{
39-
countWide = wide;
40+
// Determine count width based on context
41+
switch (context)
42+
{
43+
case PropertyCountContext.RopBuffers:
44+
usesFourByteCount = false; // 16 bits wide
45+
break;
46+
case PropertyCountContext.ExtendedRules:
47+
case PropertyCountContext.MapiHttp:
48+
case PropertyCountContext.AddressBook:
49+
usesFourByteCount = true; // 32 bits wide
50+
break;
51+
default:
52+
usesFourByteCount = false; // Default to ROP buffer behavior
53+
break;
54+
}
4055
this.isAddressBook = isAddressBook;
4156
}
4257

@@ -52,15 +67,13 @@ protected override void Parse()
5267
if (!HasValue) return;
5368
}
5469

55-
switch (countWide)
70+
if (!usesFourByteCount)
5671
{
57-
case CountWideEnum.twoBytes:
58-
Count= ParseAs<ushort,uint>();
59-
break;
60-
default:
61-
case CountWideEnum.fourBytes:
62-
Count = ParseT<uint>();
63-
break;
72+
Count = ParseAs<ushort, uint>();
73+
}
74+
else
75+
{
76+
Count = ParseT<uint>();
6477
}
6578

6679
Value = ParseBytes(Count);

MAPIInspector/Source/Parsers/MSOXCDATA/2.11 Property Values/PtypMultipleBinary.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,23 @@ public class PtypMultipleBinary : Block
3030
public PtypBinary[] Value;
3131

3232
/// <summary>
33-
/// The Count wide size.
33+
/// The parsing context that determines count field widths.
3434
/// </summary>
35-
private CountWideEnum countWide;
35+
private readonly PropertyCountContext context;
3636

37+
/// <summary>
38+
/// Bool value indicates if this property value is for address book.
39+
/// </summary>
3740
private readonly bool isAddressBook = false;
3841

3942
/// <summary>
4043
/// Initializes a new instance of the PtypMultipleBinary class
4144
/// </summary>
42-
/// <param name="wide">The Count wide size of PtypMultipleBinary type.</param>
43-
public PtypMultipleBinary(CountWideEnum wide, bool isAddressBook)
45+
/// <param name="countContext">The parsing context that determines count field width.</param>
46+
/// <param name="isAddressBook">Whether this is for address book parsing.</param>
47+
public PtypMultipleBinary(PropertyCountContext countContext, bool isAddressBook = false)
4448
{
45-
countWide = wide;
49+
context = countContext;
4650
this.isAddressBook = isAddressBook;
4751
}
4852

@@ -51,17 +55,16 @@ public PtypMultipleBinary(CountWideEnum wide, bool isAddressBook)
5155
/// </summary>
5256
protected override void Parse()
5357
{
54-
Count = ParseT<uint>();
55-
56-
List<PtypBinary> tempvalue = new List<PtypBinary>();
58+
Count = ParseT<uint>(); // Always 32-bit for multiple types
59+
var tempBinary = new List<PtypBinary>();
5760
for (int i = 0; i < Count; i++)
5861
{
59-
var binary = new PtypBinary(countWide, isAddressBook);
62+
var binary = new PtypBinary(context, isAddressBook);
6063
binary.Parse(parser);
61-
tempvalue.Add(binary);
64+
tempBinary.Add(binary);
6265
}
6366

64-
Value = tempvalue.ToArray();
67+
Value = tempBinary.ToArray();
6568
}
6669

6770
protected override void ParseBlocks()

0 commit comments

Comments
 (0)