Skip to content

Commit caa9b5f

Browse files
Better parsing of RopFastTransferSourceGetBufferResponse errors (#213)
unified interesting block concept for junk/exceptions Mad aux error trace interesting
1 parent 5d739bb commit caa9b5f

File tree

7 files changed

+42
-33
lines changed

7 files changed

+42
-33
lines changed

MAPIInspector/Source/BlockParser/BlockException.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace BlockParser
44
{
5-
public class BlockException : Block
5+
public class BlockException : BlockInteresting
66
{
7-
public static readonly Color BackColor = Color.LightPink;
7+
public override Color BackColor => Color.LightPink;
8+
public override string InterestingLabel => "Exceptions found in this block";
89

910
public static BlockException Create(string message, System.Exception ex, long offset)
1011
{
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Drawing;
2+
3+
namespace BlockParser
4+
{
5+
/// <summary>
6+
/// Represents an interesting block of data.
7+
/// </summary>
8+
public abstract class BlockInteresting : Block
9+
{
10+
public virtual Color BackColor => Color.PaleVioletRed;
11+
public virtual string InterestingLabel => "Interesting block";
12+
}
13+
}

MAPIInspector/Source/BlockParser/BlockJunk.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace BlockParser
44
{
5-
public class BlockJunk : Block
5+
public class BlockJunk : BlockInteresting
66
{
7-
public static readonly Color BackColor = Color.Coral;
7+
public override Color BackColor => Color.Coral;
8+
public override string InterestingLabel => "Exceptions found in this block";
89

910
string Label;
1011
BlockBytes junkData;

MAPIInspector/Source/MAPIInspector.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
<Reference Include="System.Xml" />
102102
</ItemGroup>
103103
<ItemGroup>
104+
<Compile Include="BlockParser\BlockInteresting.cs" />
104105
<Compile Include="ByteArrayConverter.cs" />
105106
<Compile Include="MAPIControl.Events.cs">
106107
<SubType>UserControl</SubType>

MAPIInspector/Source/Parsers/BaseStructure.cs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,12 @@ public partial class BaseStructure
2727
public static TreeNode AddBlock(Block block, bool debug)
2828
{
2929
var node = AddBlock(block, 0, debug);
30-
if (HasBlock<BlockException>(node))
30+
var interestingBlock = FindInterestingBlock(node);
31+
if (interestingBlock != null)
3132
{
32-
var exNode = new TreeNode("Exceptions found in this block")
33+
var exNode = new TreeNode(interestingBlock.InterestingLabel)
3334
{
34-
BackColor = BlockException.BackColor,
35-
Tag = "ignore"
36-
};
37-
exNode.Nodes.Add(node);
38-
return exNode;
39-
}
40-
41-
if (HasBlock<BlockJunk>(node))
42-
{
43-
var exNode = new TreeNode("Unparsed data found in this block")
44-
{
45-
BackColor = BlockJunk.BackColor,
35+
BackColor = interestingBlock.BackColor,
4636
Tag = "ignore"
4737
};
4838
exNode.Nodes.Add(node);
@@ -156,8 +146,7 @@ private static TreeNode AddBlock(Block block, int blockRootOffset, bool debug)
156146
}
157147
}
158148

159-
if (block is BlockException) ColorNodes(node, BlockException.BackColor);
160-
if (block is BlockJunk) ColorNodes(node, BlockJunk.BackColor);
149+
if (block is BlockInteresting interestingBlock) ColorNodes(node, interestingBlock.BackColor);
161150

162151
return node;
163152
}
@@ -210,23 +199,24 @@ private static TreeNode TreeNodeForCompressed(TreeNode node, int current, int co
210199
return node;
211200
}
212201

213-
private static bool HasBlock<T>(TreeNode node) where T : Block
202+
private static BlockInteresting FindInterestingBlock(TreeNode node)
214203
{
215204
var pos = node.Tag as Position;
216-
if (pos?.SourceBlock is T)
205+
if (pos?.SourceBlock is BlockInteresting interestingBlock)
217206
{
218-
return true;
207+
return interestingBlock;
219208
}
220209

221210
foreach (TreeNode child in node.Nodes)
222211
{
223-
if (HasBlock<T>(child))
212+
var foundBlock = FindInterestingBlock(child);
213+
if (foundBlock != null)
224214
{
225-
return true;
215+
return foundBlock;
226216
}
227217
}
228218

229-
return false;
219+
return null;
230220
}
231221
}
232222
}

MAPIInspector/Source/Parsers/MSOXCFXICS/rops/RopFastTransferSourceGetBufferResponse.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,14 @@ protected override void Parse()
6767
RopId = ParseT<RopIdType>();
6868
InputHandleIndex = ParseT<byte>();
6969
ReturnValue = ParseT<ErrorCodes>();
70+
TransferStatus = ParseT<TransferStatus>();
71+
InProgressCount = ParseT<ushort>();
72+
TotalStepCount = ParseT<ushort>();
73+
Reserved = ParseT<byte>();
74+
TransferBufferSize = ParseT<ushort>();
7075

7176
if (ReturnValue == ErrorCodes.Success)
7277
{
73-
TransferStatus = ParseT<TransferStatus>();
74-
InProgressCount = ParseT<ushort>();
75-
TotalStepCount = ParseT<ushort>();
76-
Reserved = ParseT<byte>();
77-
TransferBufferSize = ParseT<ushort>();
78-
7978
parser.PushCap(TransferBufferSize);
8079

8180
var transferBufferList = new List<Block>();

MAPIInspector/Source/Parsers/MSOXCMAPIHTTP/auxiliary/AUX_EXCEPTION_TRACE.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
using BlockParser;
22
using System.Collections.Generic;
3+
using System.Drawing;
34

45
namespace MAPIInspector.Parsers
56
{
67
/// <summary>
78
/// A class indicates the AUX_TYPE_EXCEPTION_TRACE Auxiliary Block Structure
89
/// </summary>
9-
public class AUX_EXCEPTION_TRACE : Block
10+
public class AUX_EXCEPTION_TRACE : BlockInteresting
1011
{
12+
public override Color BackColor => Color.Salmon;
13+
public override string InterestingLabel => "Aux Exception Trace found in this block";
14+
1115
/// <summary>
1216
/// A flag that indicates that the server combines capabilities on a single endpoint.
1317
/// </summary>

0 commit comments

Comments
 (0)