Skip to content

Commit

Permalink
Merge pull request #39 from IamWenboZhang/master
Browse files Browse the repository at this point in the history
Updating MAPIInspector with 12.11 protocol release
  • Loading branch information
IamWenboZhang committed Apr 1, 2019
2 parents 95e9559 + 3e7017d commit df71bce
Show file tree
Hide file tree
Showing 17 changed files with 707 additions and 129 deletions.
2 changes: 1 addition & 1 deletion MAPIInspector/Source/MAPIControl.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

512 changes: 447 additions & 65 deletions MAPIInspector/Source/MAPIInspector.cs

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions MAPIInspector/Source/MAPIInspector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -56,7 +56,6 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -66,7 +65,6 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
Expand All @@ -76,7 +74,6 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Be.Windows.Forms.HexBox">
Expand All @@ -85,6 +82,10 @@
<Reference Include="Fiddler">
<HintPath>..\..\..\..\..\AppData\Local\Programs\Fiddler\Fiddler.exe</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Test\MAPIAutomationTest\ExternalReference\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core">
Expand All @@ -101,9 +102,6 @@
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Xceed.Compression.Formats.v5.4">
<HintPath>..\..\..\..\..\AppData\Local\Programs\Fiddler\Xceed.Compression.Formats.v5.4.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="MAPIControl.cs">
Expand Down
15 changes: 12 additions & 3 deletions MAPIInspector/Source/Parsers/MSOXCMSG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1533,10 +1533,19 @@ public override void Parse(Stream s)
this.ResponseHandleIndex = this.ReadByte();
this.InputHandleIndex = this.ReadByte();
this.ReadFlags = (ReadFlags)this.ReadByte();

if (((byte)DecodingContext.SessionLogonFlagMapLogId[MapiInspector.MAPIInspector.ParsingSession.id][this.LogonId] & (byte)LogonFlags.Private) != (byte)LogonFlags.Private)
if(!MapiInspector.MAPIInspector.IsFromFiddlerCore(MapiInspector.MAPIInspector.ParsingSession))
{
this.ClientData = this.ConvertArray(this.ReadBytes(24));
if (((byte)DecodingContext.SessionLogonFlagMapLogId[MapiInspector.MAPIInspector.ParsingSession.id][this.LogonId] & (byte)LogonFlags.Private) != (byte)LogonFlags.Private)
{
this.ClientData = this.ConvertArray(this.ReadBytes(24));
}
}
else
{
if (((byte)DecodingContext.SessionLogonFlagMapLogId[int.Parse(MapiInspector.MAPIInspector.ParsingSession["VirtualID"])][this.LogonId] & (byte)LogonFlags.Private) != (byte)LogonFlags.Private)
{
this.ClientData = this.ConvertArray(this.ReadBytes(24));
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions MAPIInspector/Source/Parsers/MSOXCNOTIF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,10 @@ public override void Parse(Stream s)
if (this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified && (this.TableEventType == TableEventTypeEnum.TableRowAdded || this.TableEventType == TableEventTypeEnum.TableRowModified))
{
int parsingSessionID = MapiInspector.MAPIInspector.ParsingSession.id;
if(MapiInspector.MAPIInspector.IsFromFiddlerCore(MapiInspector.MAPIInspector.ParsingSession))
{
parsingSessionID = int.Parse(MapiInspector.MAPIInspector.ParsingSession["VirtualID"]);
}
if (!(DecodingContext.Notify_handlePropertyTags.Count > 0 && DecodingContext.Notify_handlePropertyTags.ContainsKey(this.notificationHandle) && DecodingContext.Notify_handlePropertyTags[this.notificationHandle].ContainsKey(parsingSessionID)
&& DecodingContext.Notify_handlePropertyTags[this.notificationHandle][parsingSessionID].Item1 == MapiInspector.MAPIInspector.ParsingSession.RequestHeaders.RequestPath
&& DecodingContext.Notify_handlePropertyTags[this.notificationHandle][parsingSessionID].Item2 == MapiInspector.MAPIInspector.ParsingSession.LocalProcess
Expand Down
10 changes: 9 additions & 1 deletion MAPIInspector/Source/Parsers/MSOXCPRPT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,15 @@ public override void Parse(Stream s)

if ((ErrorCodes)this.ReturnValue == ErrorCodes.Success)
{
PropertyTag[] proTags = DecodingContext.GetPropertiesSpec_propertyTags[MapiInspector.MAPIInspector.ParsingSession.id][this.InputHandleIndex].Dequeue();
PropertyTag[] proTags = new PropertyTag[0];
if (!MapiInspector.MAPIInspector.IsFromFiddlerCore(MapiInspector.MAPIInspector.ParsingSession))
{
proTags = DecodingContext.GetPropertiesSpec_propertyTags[MapiInspector.MAPIInspector.ParsingSession.id][this.InputHandleIndex].Dequeue();
}
else
{
proTags = DecodingContext.GetPropertiesSpec_propertyTags[int.Parse(MapiInspector.MAPIInspector.ParsingSession["VirtualID"])][this.InputHandleIndex].Dequeue();
}
this.RowData = new PropertyRow(proTags);
this.RowData.Parse(s);
}
Expand Down
100 changes: 98 additions & 2 deletions MAPIInspector/Source/Parsers/MSOXCROPS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,10 @@ public override void Parse(Stream s)
List<uint> ropRemainSize = new List<uint>();
List<uint> tempServerObjectHandleTable = new List<uint>();
int parsingSessionID = MapiInspector.MAPIInspector.ParsingSession.id;

if (MapiInspector.MAPIInspector.IsFromFiddlerCore(MapiInspector.MAPIInspector.ParsingSession))
{
parsingSessionID = int.Parse(MapiInspector.MAPIInspector.ParsingSession["VirtualID"]);
}
long currentPosition = s.Position;
s.Position += this.RopSize - 2;

Expand Down Expand Up @@ -1118,6 +1121,72 @@ public override void Parse(Stream s)
}
}
}
else if(MapiInspector.MAPIInspector.IsFromFiddlerCore(MapiInspector.MAPIInspector.ParsingSession))
{
if (MapiInspector.MAPIInspector.ParsingSession["X-ResponseCode"] == "0")
{
uint outputHandle;

try
{
MapiInspector.MAPIInspector.IsOnlyGetServerHandle = true;
outputHandle = MapiInspector.MAPIInspector.ParseResponseMessageSimplely(MapiInspector.MAPIInspector.ParsingSession, ropSetColumnsRequest.InputHandleIndex);
}
finally
{
MapiInspector.MAPIInspector.IsOnlyGetServerHandle = false;
}

if (MapiInspector.MAPIInspector.TargetHandle.Count > 0)
{
Dictionary<ushort, Dictionary<int, uint>> target = MapiInspector.MAPIInspector.TargetHandle.Peek();

if ((RopIdType)target.First().Key == RopIdType.RopQueryRows || (RopIdType)target.First().Key == RopIdType.RopFindRow || (RopIdType)target.First().Key == RopIdType.RopExpandRow)
{
// This is for Row related rops
Dictionary<int, Tuple<string, string, string, PropertyTag[]>> sessionTuples = new Dictionary<int, Tuple<string, string, string, PropertyTag[]>>();
Tuple<string, string, string, PropertyTag[]> tuples;

if (DecodingContext.RowRops_handlePropertyTags.ContainsKey(outputHandle))
{
sessionTuples = DecodingContext.RowRops_handlePropertyTags[outputHandle];
DecodingContext.RowRops_handlePropertyTags.Remove(outputHandle);

if (sessionTuples.ContainsKey(parsingSessionID))
{
sessionTuples.Remove(parsingSessionID);
}
}

tuples = new Tuple<string, string, string, PropertyTag[]>(MapiInspector.MAPIInspector.ParsingSession.RequestHeaders.RequestPath, MapiInspector.MAPIInspector.ParsingSession.LocalProcess, MapiInspector.MAPIInspector.ParsingSession.RequestHeaders["X-ClientInfo"], ropSetColumnsRequest.PropertyTags);
sessionTuples.Add(parsingSessionID, tuples);
DecodingContext.RowRops_handlePropertyTags.Add(outputHandle, sessionTuples);
}

if ((RopIdType)target.First().Key == RopIdType.RopNotify)
{
// This is for ROPNotify
Dictionary<int, Tuple<string, string, string, PropertyTag[], string>> sessionTuples = new Dictionary<int, Tuple<string, string, string, PropertyTag[], string>>();
Tuple<string, string, string, PropertyTag[], string> tuples;

if (DecodingContext.Notify_handlePropertyTags.ContainsKey(outputHandle))
{
sessionTuples = DecodingContext.Notify_handlePropertyTags[outputHandle];
DecodingContext.Notify_handlePropertyTags.Remove(outputHandle);

if (sessionTuples.ContainsKey(parsingSessionID))
{
sessionTuples.Remove(parsingSessionID);
}
}

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);
sessionTuples.Add(parsingSessionID, tuples);
DecodingContext.Notify_handlePropertyTags.Add(outputHandle, sessionTuples);
}
}
}
}
else if (MapiInspector.MAPIInspector.ParsingSession.ResponseHeaders["X-ResponseCode"] == "0")
{
uint outputHandle;
Expand Down Expand Up @@ -1969,6 +2038,18 @@ public override void Parse(Stream s)

this.RopsList = ropsList.ToArray();

if (this.RopsList.Length != 0)
{
object[] roplist = RopsList;
foreach (object obj in roplist)
{
if (MapiInspector.MAPIInspector.AllRopsList.Count <= 0 || !MapiInspector.MAPIInspector.AllRopsList.Contains(obj.GetType().Name))
{
MapiInspector.MAPIInspector.AllRopsList.Add(obj.GetType().Name);
}
}
}

while (s.Position < s.Length)
{
uint serverObjectHandle = this.ReadUint();
Expand Down Expand Up @@ -2107,7 +2188,10 @@ public override void Parse(Stream s)
long currentPosition = s.Position;
s.Position += this.RopSize - 2;
int parsingSessionID = MapiInspector.MAPIInspector.ParsingSession.id;

if (MapiInspector.MAPIInspector.IsFromFiddlerCore(MapiInspector.MAPIInspector.ParsingSession))
{
parsingSessionID = int.Parse(MapiInspector.MAPIInspector.ParsingSession["VirtualID"]);
}
while (s.Position < s.Length)
{
uint serverObjectTable = this.ReadUint();
Expand Down Expand Up @@ -3061,6 +3145,18 @@ public override void Parse(Stream s)

this.RopsList = ropsList.ToArray();

if (this.RopsList.Length != 0)
{
object[] roplist = RopsList;
foreach (object obj in roplist)
{
if (MapiInspector.MAPIInspector.AllRopsList.Count <= 0 || !MapiInspector.MAPIInspector.AllRopsList.Contains(obj.GetType().Name))
{
MapiInspector.MAPIInspector.AllRopsList.Add(obj.GetType().Name);
}
}
}

while (s.Position < s.Length)
{
uint serverObjectHandle = this.ReadUint();
Expand Down
14 changes: 12 additions & 2 deletions MAPIInspector/Source/Parsers/MSOXCSTOR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1687,9 +1687,19 @@ public override void Parse(Stream s)
this.DataOffset = this.ReadUint();
this.DataSize = this.ReadUshort();
this.Data = this.ReadBytes((int)this.DataSize);
if (this.DataOffset == 0 && (((byte)DecodingContext.SessionLogonFlagMapLogId[MapiInspector.MAPIInspector.ParsingSession.id][this.LogonId] & (byte)LogonFlags.Private) == (byte)LogonFlags.Private))
if(!MapiInspector.MAPIInspector.IsFromFiddlerCore(MapiInspector.MAPIInspector.ParsingSession))
{
this.ReplGuid = this.ReadGuid();
if (this.DataOffset == 0 && (((byte)DecodingContext.SessionLogonFlagMapLogId[MapiInspector.MAPIInspector.ParsingSession.id][this.LogonId] & (byte)LogonFlags.Private) == (byte)LogonFlags.Private))
{
this.ReplGuid = this.ReadGuid();
}
}
else
{
if (this.DataOffset == 0 && (((byte)DecodingContext.SessionLogonFlagMapLogId[int.Parse(MapiInspector.MAPIInspector.ParsingSession["VirtualID"])][this.LogonId] & (byte)LogonFlags.Private) == (byte)LogonFlags.Private))
{
this.ReplGuid = this.ReadGuid();
}
}
}
}
Expand Down
68 changes: 68 additions & 0 deletions MAPIInspector/Source/Utilities.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace MapiInspector
{
using Newtonsoft.Json;
using System;
using System.Collections.Generic;

Expand Down Expand Up @@ -89,5 +90,72 @@ public static byte[] GetPaylodFromChunkedBody(byte[] responseBodyFromFiddler)
while (chunkSize > 0);
return payload.ToArray();
}

/// <summary>
/// The SealTheObject Class is used to sealing the parse result.
/// </summary>
public class SealTheObject
{
private string title;

private string message;

private object obj;

public string Title
{
get
{
return title;
}
set
{
title = value;
}
}

public string Message
{
get
{
return message;
}
set
{
message = value;
}
}

public object Obj
{
get
{
return obj;
}
set
{
obj = value;
}
}

public SealTheObject(int id, bool isRequest, object obj)
{
title = "Frame" + id + (isRequest ? "Request" : "Response");
message = obj.GetType().Name;
Obj = obj;
}
}
/// <summary>
/// Method to seal parse result to Json string
/// </summary>
/// <param name="id">The id of Fiddler session</param>
/// <param name="isRequest">Bool value indicates the session is a HttpRequest message or HttpResponse message</param>
/// <param name="obj">The object of parse result</param>
/// <returns>Json string converted by parse result</returns>
public static string ConvertCSharpToJson(int id, bool isRequest, object obj)
{
SealTheObject sealTheObject = new SealTheObject(id, isRequest, obj);
return JsonConvert.SerializeObject((object)sealTheObject);
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 5 additions & 2 deletions MAPIInspector/Test/MAPIAutomationTest/MAPIAutomationTest.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.28307.106
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MAPIAutomationTest", "MAPIAutomationTest\MAPIAutomationTest.csproj", "{CA888FB1-9266-4DE7-BCE8-4C238672726E}"
EndProject
Expand All @@ -19,4 +19,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F535D721-9153-476E-9923-DA295363D1AA}
EndGlobalSection
EndGlobal
Loading

0 comments on commit df71bce

Please sign in to comment.