Skip to content

Commit df71bce

Browse files
Merge pull request #39 from IamWenboZhang/master
Updating MAPIInspector with 12.11 protocol release
2 parents 95e9559 + 3e7017d commit df71bce

File tree

17 files changed

+707
-129
lines changed

17 files changed

+707
-129
lines changed

MAPIInspector/Source/MAPIControl.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MAPIInspector/Source/MAPIInspector.cs

Lines changed: 447 additions & 65 deletions
Large diffs are not rendered by default.

MAPIInspector/Source/MAPIInspector.csproj

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<ErrorReport>prompt</ErrorReport>
4747
<WarningLevel>4</WarningLevel>
4848
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
49-
<Prefer32Bit>false</Prefer32Bit>
49+
<LangVersion>7.2</LangVersion>
5050
</PropertyGroup>
5151
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
5252
<DebugType>pdbonly</DebugType>
@@ -56,7 +56,6 @@
5656
<ErrorReport>prompt</ErrorReport>
5757
<WarningLevel>4</WarningLevel>
5858
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
59-
<Prefer32Bit>false</Prefer32Bit>
6059
</PropertyGroup>
6160
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
6261
<DebugSymbols>true</DebugSymbols>
@@ -66,7 +65,6 @@
6665
<PlatformTarget>x86</PlatformTarget>
6766
<ErrorReport>prompt</ErrorReport>
6867
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
69-
<Prefer32Bit>false</Prefer32Bit>
7068
</PropertyGroup>
7169
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
7270
<OutputPath>bin\x86\Release\</OutputPath>
@@ -76,7 +74,6 @@
7674
<PlatformTarget>x86</PlatformTarget>
7775
<ErrorReport>prompt</ErrorReport>
7876
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
79-
<Prefer32Bit>false</Prefer32Bit>
8077
</PropertyGroup>
8178
<ItemGroup>
8279
<Reference Include="Be.Windows.Forms.HexBox">
@@ -85,6 +82,10 @@
8582
<Reference Include="Fiddler">
8683
<HintPath>..\..\..\..\..\AppData\Local\Programs\Fiddler\Fiddler.exe</HintPath>
8784
</Reference>
85+
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
86+
<SpecificVersion>False</SpecificVersion>
87+
<HintPath>..\Test\MAPIAutomationTest\ExternalReference\Newtonsoft.Json.dll</HintPath>
88+
</Reference>
8889
<Reference Include="System" />
8990
<Reference Include="System.Configuration" />
9091
<Reference Include="System.Core">
@@ -101,9 +102,6 @@
101102
<Reference Include="System.Data" />
102103
<Reference Include="System.Windows.Forms" />
103104
<Reference Include="System.Xml" />
104-
<Reference Include="Xceed.Compression.Formats.v5.4">
105-
<HintPath>..\..\..\..\..\AppData\Local\Programs\Fiddler\Xceed.Compression.Formats.v5.4.dll</HintPath>
106-
</Reference>
107105
</ItemGroup>
108106
<ItemGroup>
109107
<Compile Include="MAPIControl.cs">

MAPIInspector/Source/Parsers/MSOXCMSG.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,10 +1533,19 @@ public override void Parse(Stream s)
15331533
this.ResponseHandleIndex = this.ReadByte();
15341534
this.InputHandleIndex = this.ReadByte();
15351535
this.ReadFlags = (ReadFlags)this.ReadByte();
1536-
1537-
if (((byte)DecodingContext.SessionLogonFlagMapLogId[MapiInspector.MAPIInspector.ParsingSession.id][this.LogonId] & (byte)LogonFlags.Private) != (byte)LogonFlags.Private)
1536+
if(!MapiInspector.MAPIInspector.IsFromFiddlerCore(MapiInspector.MAPIInspector.ParsingSession))
15381537
{
1539-
this.ClientData = this.ConvertArray(this.ReadBytes(24));
1538+
if (((byte)DecodingContext.SessionLogonFlagMapLogId[MapiInspector.MAPIInspector.ParsingSession.id][this.LogonId] & (byte)LogonFlags.Private) != (byte)LogonFlags.Private)
1539+
{
1540+
this.ClientData = this.ConvertArray(this.ReadBytes(24));
1541+
}
1542+
}
1543+
else
1544+
{
1545+
if (((byte)DecodingContext.SessionLogonFlagMapLogId[int.Parse(MapiInspector.MAPIInspector.ParsingSession["VirtualID"])][this.LogonId] & (byte)LogonFlags.Private) != (byte)LogonFlags.Private)
1546+
{
1547+
this.ClientData = this.ConvertArray(this.ReadBytes(24));
1548+
}
15401549
}
15411550
}
15421551
}

MAPIInspector/Source/Parsers/MSOXCNOTIF.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,10 @@ public override void Parse(Stream s)
586586
if (this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified && (this.TableEventType == TableEventTypeEnum.TableRowAdded || this.TableEventType == TableEventTypeEnum.TableRowModified))
587587
{
588588
int parsingSessionID = MapiInspector.MAPIInspector.ParsingSession.id;
589+
if(MapiInspector.MAPIInspector.IsFromFiddlerCore(MapiInspector.MAPIInspector.ParsingSession))
590+
{
591+
parsingSessionID = int.Parse(MapiInspector.MAPIInspector.ParsingSession["VirtualID"]);
592+
}
589593
if (!(DecodingContext.Notify_handlePropertyTags.Count > 0 && DecodingContext.Notify_handlePropertyTags.ContainsKey(this.notificationHandle) && DecodingContext.Notify_handlePropertyTags[this.notificationHandle].ContainsKey(parsingSessionID)
590594
&& DecodingContext.Notify_handlePropertyTags[this.notificationHandle][parsingSessionID].Item1 == MapiInspector.MAPIInspector.ParsingSession.RequestHeaders.RequestPath
591595
&& DecodingContext.Notify_handlePropertyTags[this.notificationHandle][parsingSessionID].Item2 == MapiInspector.MAPIInspector.ParsingSession.LocalProcess

MAPIInspector/Source/Parsers/MSOXCPRPT.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,15 @@ public override void Parse(Stream s)
171171

172172
if ((ErrorCodes)this.ReturnValue == ErrorCodes.Success)
173173
{
174-
PropertyTag[] proTags = DecodingContext.GetPropertiesSpec_propertyTags[MapiInspector.MAPIInspector.ParsingSession.id][this.InputHandleIndex].Dequeue();
174+
PropertyTag[] proTags = new PropertyTag[0];
175+
if (!MapiInspector.MAPIInspector.IsFromFiddlerCore(MapiInspector.MAPIInspector.ParsingSession))
176+
{
177+
proTags = DecodingContext.GetPropertiesSpec_propertyTags[MapiInspector.MAPIInspector.ParsingSession.id][this.InputHandleIndex].Dequeue();
178+
}
179+
else
180+
{
181+
proTags = DecodingContext.GetPropertiesSpec_propertyTags[int.Parse(MapiInspector.MAPIInspector.ParsingSession["VirtualID"])][this.InputHandleIndex].Dequeue();
182+
}
175183
this.RowData = new PropertyRow(proTags);
176184
this.RowData.Parse(s);
177185
}

MAPIInspector/Source/Parsers/MSOXCROPS.cs

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,10 @@ public override void Parse(Stream s)
800800
List<uint> ropRemainSize = new List<uint>();
801801
List<uint> tempServerObjectHandleTable = new List<uint>();
802802
int parsingSessionID = MapiInspector.MAPIInspector.ParsingSession.id;
803-
803+
if (MapiInspector.MAPIInspector.IsFromFiddlerCore(MapiInspector.MAPIInspector.ParsingSession))
804+
{
805+
parsingSessionID = int.Parse(MapiInspector.MAPIInspector.ParsingSession["VirtualID"]);
806+
}
804807
long currentPosition = s.Position;
805808
s.Position += this.RopSize - 2;
806809

@@ -1118,6 +1121,72 @@ public override void Parse(Stream s)
11181121
}
11191122
}
11201123
}
1124+
else if(MapiInspector.MAPIInspector.IsFromFiddlerCore(MapiInspector.MAPIInspector.ParsingSession))
1125+
{
1126+
if (MapiInspector.MAPIInspector.ParsingSession["X-ResponseCode"] == "0")
1127+
{
1128+
uint outputHandle;
1129+
1130+
try
1131+
{
1132+
MapiInspector.MAPIInspector.IsOnlyGetServerHandle = true;
1133+
outputHandle = MapiInspector.MAPIInspector.ParseResponseMessageSimplely(MapiInspector.MAPIInspector.ParsingSession, ropSetColumnsRequest.InputHandleIndex);
1134+
}
1135+
finally
1136+
{
1137+
MapiInspector.MAPIInspector.IsOnlyGetServerHandle = false;
1138+
}
1139+
1140+
if (MapiInspector.MAPIInspector.TargetHandle.Count > 0)
1141+
{
1142+
Dictionary<ushort, Dictionary<int, uint>> target = MapiInspector.MAPIInspector.TargetHandle.Peek();
1143+
1144+
if ((RopIdType)target.First().Key == RopIdType.RopQueryRows || (RopIdType)target.First().Key == RopIdType.RopFindRow || (RopIdType)target.First().Key == RopIdType.RopExpandRow)
1145+
{
1146+
// This is for Row related rops
1147+
Dictionary<int, Tuple<string, string, string, PropertyTag[]>> sessionTuples = new Dictionary<int, Tuple<string, string, string, PropertyTag[]>>();
1148+
Tuple<string, string, string, PropertyTag[]> tuples;
1149+
1150+
if (DecodingContext.RowRops_handlePropertyTags.ContainsKey(outputHandle))
1151+
{
1152+
sessionTuples = DecodingContext.RowRops_handlePropertyTags[outputHandle];
1153+
DecodingContext.RowRops_handlePropertyTags.Remove(outputHandle);
1154+
1155+
if (sessionTuples.ContainsKey(parsingSessionID))
1156+
{
1157+
sessionTuples.Remove(parsingSessionID);
1158+
}
1159+
}
1160+
1161+
tuples = new Tuple<string, string, string, PropertyTag[]>(MapiInspector.MAPIInspector.ParsingSession.RequestHeaders.RequestPath, MapiInspector.MAPIInspector.ParsingSession.LocalProcess, MapiInspector.MAPIInspector.ParsingSession.RequestHeaders["X-ClientInfo"], ropSetColumnsRequest.PropertyTags);
1162+
sessionTuples.Add(parsingSessionID, tuples);
1163+
DecodingContext.RowRops_handlePropertyTags.Add(outputHandle, sessionTuples);
1164+
}
1165+
1166+
if ((RopIdType)target.First().Key == RopIdType.RopNotify)
1167+
{
1168+
// This is for ROPNotify
1169+
Dictionary<int, Tuple<string, string, string, PropertyTag[], string>> sessionTuples = new Dictionary<int, Tuple<string, string, string, PropertyTag[], string>>();
1170+
Tuple<string, string, string, PropertyTag[], string> tuples;
1171+
1172+
if (DecodingContext.Notify_handlePropertyTags.ContainsKey(outputHandle))
1173+
{
1174+
sessionTuples = DecodingContext.Notify_handlePropertyTags[outputHandle];
1175+
DecodingContext.Notify_handlePropertyTags.Remove(outputHandle);
1176+
1177+
if (sessionTuples.ContainsKey(parsingSessionID))
1178+
{
1179+
sessionTuples.Remove(parsingSessionID);
1180+
}
1181+
}
1182+
1183+
tuples = new Tuple<string, string, string, PropertyTag[], string>(MapiInspector.MAPIInspector.ParsingSession.RequestHeaders.RequestPath, MapiInspector.MAPIInspector.ParsingSession.LocalProcess, MapiInspector.MAPIInspector.ParsingSession.RequestHeaders["X-ClientInfo"], ropSetColumnsRequest.PropertyTags, string.Empty);
1184+
sessionTuples.Add(parsingSessionID, tuples);
1185+
DecodingContext.Notify_handlePropertyTags.Add(outputHandle, sessionTuples);
1186+
}
1187+
}
1188+
}
1189+
}
11211190
else if (MapiInspector.MAPIInspector.ParsingSession.ResponseHeaders["X-ResponseCode"] == "0")
11221191
{
11231192
uint outputHandle;
@@ -1969,6 +2038,18 @@ public override void Parse(Stream s)
19692038

19702039
this.RopsList = ropsList.ToArray();
19712040

2041+
if (this.RopsList.Length != 0)
2042+
{
2043+
object[] roplist = RopsList;
2044+
foreach (object obj in roplist)
2045+
{
2046+
if (MapiInspector.MAPIInspector.AllRopsList.Count <= 0 || !MapiInspector.MAPIInspector.AllRopsList.Contains(obj.GetType().Name))
2047+
{
2048+
MapiInspector.MAPIInspector.AllRopsList.Add(obj.GetType().Name);
2049+
}
2050+
}
2051+
}
2052+
19722053
while (s.Position < s.Length)
19732054
{
19742055
uint serverObjectHandle = this.ReadUint();
@@ -2107,7 +2188,10 @@ public override void Parse(Stream s)
21072188
long currentPosition = s.Position;
21082189
s.Position += this.RopSize - 2;
21092190
int parsingSessionID = MapiInspector.MAPIInspector.ParsingSession.id;
2110-
2191+
if (MapiInspector.MAPIInspector.IsFromFiddlerCore(MapiInspector.MAPIInspector.ParsingSession))
2192+
{
2193+
parsingSessionID = int.Parse(MapiInspector.MAPIInspector.ParsingSession["VirtualID"]);
2194+
}
21112195
while (s.Position < s.Length)
21122196
{
21132197
uint serverObjectTable = this.ReadUint();
@@ -3061,6 +3145,18 @@ public override void Parse(Stream s)
30613145

30623146
this.RopsList = ropsList.ToArray();
30633147

3148+
if (this.RopsList.Length != 0)
3149+
{
3150+
object[] roplist = RopsList;
3151+
foreach (object obj in roplist)
3152+
{
3153+
if (MapiInspector.MAPIInspector.AllRopsList.Count <= 0 || !MapiInspector.MAPIInspector.AllRopsList.Contains(obj.GetType().Name))
3154+
{
3155+
MapiInspector.MAPIInspector.AllRopsList.Add(obj.GetType().Name);
3156+
}
3157+
}
3158+
}
3159+
30643160
while (s.Position < s.Length)
30653161
{
30663162
uint serverObjectHandle = this.ReadUint();

MAPIInspector/Source/Parsers/MSOXCSTOR.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,9 +1687,19 @@ public override void Parse(Stream s)
16871687
this.DataOffset = this.ReadUint();
16881688
this.DataSize = this.ReadUshort();
16891689
this.Data = this.ReadBytes((int)this.DataSize);
1690-
if (this.DataOffset == 0 && (((byte)DecodingContext.SessionLogonFlagMapLogId[MapiInspector.MAPIInspector.ParsingSession.id][this.LogonId] & (byte)LogonFlags.Private) == (byte)LogonFlags.Private))
1690+
if(!MapiInspector.MAPIInspector.IsFromFiddlerCore(MapiInspector.MAPIInspector.ParsingSession))
16911691
{
1692-
this.ReplGuid = this.ReadGuid();
1692+
if (this.DataOffset == 0 && (((byte)DecodingContext.SessionLogonFlagMapLogId[MapiInspector.MAPIInspector.ParsingSession.id][this.LogonId] & (byte)LogonFlags.Private) == (byte)LogonFlags.Private))
1693+
{
1694+
this.ReplGuid = this.ReadGuid();
1695+
}
1696+
}
1697+
else
1698+
{
1699+
if (this.DataOffset == 0 && (((byte)DecodingContext.SessionLogonFlagMapLogId[int.Parse(MapiInspector.MAPIInspector.ParsingSession["VirtualID"])][this.LogonId] & (byte)LogonFlags.Private) == (byte)LogonFlags.Private))
1700+
{
1701+
this.ReplGuid = this.ReadGuid();
1702+
}
16931703
}
16941704
}
16951705
}

MAPIInspector/Source/Utilities.cs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace MapiInspector
22
{
3+
using Newtonsoft.Json;
34
using System;
45
using System.Collections.Generic;
56

@@ -89,5 +90,72 @@ public static byte[] GetPaylodFromChunkedBody(byte[] responseBodyFromFiddler)
8990
while (chunkSize > 0);
9091
return payload.ToArray();
9192
}
93+
94+
/// <summary>
95+
/// The SealTheObject Class is used to sealing the parse result.
96+
/// </summary>
97+
public class SealTheObject
98+
{
99+
private string title;
100+
101+
private string message;
102+
103+
private object obj;
104+
105+
public string Title
106+
{
107+
get
108+
{
109+
return title;
110+
}
111+
set
112+
{
113+
title = value;
114+
}
115+
}
116+
117+
public string Message
118+
{
119+
get
120+
{
121+
return message;
122+
}
123+
set
124+
{
125+
message = value;
126+
}
127+
}
128+
129+
public object Obj
130+
{
131+
get
132+
{
133+
return obj;
134+
}
135+
set
136+
{
137+
obj = value;
138+
}
139+
}
140+
141+
public SealTheObject(int id, bool isRequest, object obj)
142+
{
143+
title = "Frame" + id + (isRequest ? "Request" : "Response");
144+
message = obj.GetType().Name;
145+
Obj = obj;
146+
}
147+
}
148+
/// <summary>
149+
/// Method to seal parse result to Json string
150+
/// </summary>
151+
/// <param name="id">The id of Fiddler session</param>
152+
/// <param name="isRequest">Bool value indicates the session is a HttpRequest message or HttpResponse message</param>
153+
/// <param name="obj">The object of parse result</param>
154+
/// <returns>Json string converted by parse result</returns>
155+
public static string ConvertCSharpToJson(int id, bool isRequest, object obj)
156+
{
157+
SealTheObject sealTheObject = new SealTheObject(id, isRequest, obj);
158+
return JsonConvert.SerializeObject((object)sealTheObject);
159+
}
92160
}
93161
}
Binary file not shown.

0 commit comments

Comments
 (0)