Skip to content

Commit 1cd6f84

Browse files
Merge pull request #43 from stephenegriffin/fixparser
MAPIInspector.Partial Throws when VirtualID not present
2 parents bbc2b48 + e53629c commit 1cd6f84

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

MAPIInspector/Source/MAPIInspector.cs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,8 @@ public static uint ParseResponseMessageSimplely(Session currentSession, int outp
403403
if (IsMapihttpSession(currentSession, TrafficDirection.Out))
404404
{
405405
byte[] bytesForHexView;
406-
object mapiResponse;
407-
mapiResponse = ParseHTTPExecuteResponsePayload(currentSession.ResponseHeaders, currentSession, currentSession.responseBodyBytes, TrafficDirection.Out, out bytesForHexView);
406+
object mapiResponse;
407+
mapiResponse = ParseHTTPExecuteResponsePayload(currentSession.ResponseHeaders, currentSession, currentSession.responseBodyBytes, TrafficDirection.Out, out bytesForHexView);
408408
int rgbOutputBufferCount = (mapiResponse as ExecuteResponseBody).RopBuffer.RgbOutputBuffers.Length;
409409

410410
for (int i = 0; i < rgbOutputBufferCount; i++)
@@ -464,13 +464,13 @@ public static object ParseHTTPExecuteResponsePayload(HTTPHeaders headers, Sessio
464464
{
465465
if (direction == TrafficDirection.Out && MapiInspector.MAPIInspector.IsFromFiddlerCore(currentSession))
466466
{
467-
if(currentSession["Transfer-Encoding"] != null && currentSession["Transfer-Encoding"] == "chunked")
467+
if (currentSession["Transfer-Encoding"] != null && currentSession["Transfer-Encoding"] == "chunked")
468468
{
469469
bytesFromHTTP = Utilities.GetPaylodFromChunkedBody(bytesFromHTTP);
470470
bytes = bytesFromHTTP;
471471
}
472472
}
473-
else if(direction == TrafficDirection.Out && headers.Exists("Transfer-Encoding") && headers["Transfer-Encoding"] == "chunked")
473+
else if (direction == TrafficDirection.Out && headers.Exists("Transfer-Encoding") && headers["Transfer-Encoding"] == "chunked")
474474
{
475475
bytesFromHTTP = Utilities.GetPaylodFromChunkedBody(bytesFromHTTP);
476476
bytes = bytesFromHTTP;
@@ -529,9 +529,9 @@ public static bool IsMapihttpSession(Session currentSession, TrafficDirection di
529529
}
530530
}
531531
}
532-
else if(direction == TrafficDirection.Out && currentSession["X-ResponseCode"] != null)
532+
else if (direction == TrafficDirection.Out && currentSession["X-ResponseCode"] != null)
533533
{
534-
string responseCode = currentSession["X-ResponseCode"];
534+
string responseCode = currentSession["X-ResponseCode"];
535535
if (responseCode == "0")
536536
{
537537
return currentSession["Content-Type"] != null && currentSession["Content-Type"] == "application/mapi-http";
@@ -540,7 +540,7 @@ public static bool IsMapihttpSession(Session currentSession, TrafficDirection di
540540
{
541541
return currentSession["Content-Type"] != null && currentSession["Content-Type"] == "text/html";
542542
}
543-
}
543+
}
544544
}
545545

546546
return false;
@@ -1054,7 +1054,7 @@ public void HandleContextInformation(ushort sourceRopID, out object obj, out byt
10541054
}
10551055
else
10561056
{
1057-
currentSession = AllSessions[Convert.ToInt32(thisSession["Number"]) - 1];
1057+
currentSession = AllSessions[Convert.ToInt32(thisSession["Number"]) - 1];
10581058
if (MapiInspector.MAPIInspector.IsFromFiddlerCore(currentSession))
10591059
{
10601060
currentSessionID = int.Parse(currentSession["VirtualID"]);
@@ -1353,7 +1353,7 @@ public object Partial(RopIdType ropID, uint parameters, out byte[] bytes)
13531353
if (MapiInspector.MAPIInspector.IsFromFiddlerCore(thisSession))
13541354
{
13551355
thisSessionID = int.Parse(thisSession["VirtualID"]);
1356-
}
1356+
}
13571357

13581358
if (ropID == RopIdType.RopFastTransferSourceGetBuffer)
13591359
{
@@ -1467,7 +1467,8 @@ public object Partial(RopIdType ropID, uint parameters, out byte[] bytes)
14671467
}
14681468

14691469
currentSession = AllSessions[Convert.ToInt32(currentSession["Number"]) + 1];
1470-
if (currentSessionID == currentSession.id || currentSessionID == int.Parse(currentSession["VirtualID"])) break;
1470+
if (currentSessionID == currentSession.id ||
1471+
(currentSession["VirtualID"] != null && currentSessionID == int.Parse(currentSession["VirtualID"]))) break;
14711472
if (MapiInspector.MAPIInspector.IsFromFiddlerCore(currentSession))
14721473
{
14731474
currentSessionID = int.Parse(currentSession["VirtualID"]);
@@ -1533,7 +1534,7 @@ public object Partial(RopIdType ropID, uint parameters, out byte[] bytes)
15331534
if (MapiInspector.MAPIInspector.IsFromFiddlerCore(currentSession))
15341535
{
15351536
currentSessionID = int.Parse(currentSession["VirtualID"]);
1536-
}
1537+
}
15371538
if (ropID == RopIdType.RopFastTransferDestinationPutBuffer)
15381539
{
15391540
int sessionPutContextCount = HandleWithSessionPutContextInformation.Count;
@@ -1787,7 +1788,7 @@ public object ParseResponseMessage(Session currentSession, out byte[] hexViewByt
17871788
{
17881789
object mapiResponse = null;
17891790
hexViewBytes = new byte[0];
1790-
if(!MapiInspector.MAPIInspector.IsFromFiddlerCore(currentSession))
1791+
if (!MapiInspector.MAPIInspector.IsFromFiddlerCore(currentSession))
17911792
{
17921793
if (IsMapihttpSession(currentSession, TrafficDirection.Out) && currentSession.ResponseHeaders["X-ResponseCode"] == "0")
17931794
{
@@ -1869,7 +1870,7 @@ public object ParseResponseMessage(Session currentSession, out byte[] hexViewByt
18691870
}
18701871
}
18711872
}
1872-
1873+
18731874

18741875
if (isLooper)
18751876
{
@@ -1942,7 +1943,7 @@ public object ParseHTTPPayload(HTTPHeaders headers, Session currentSession, byte
19421943
bytes = bytesFromHTTP;
19431944
}
19441945
}
1945-
else if (direction == TrafficDirection.Out && headers.Exists("Transfer-Encoding") && headers["Transfer-Encoding"] == "chunked")
1946+
else if (direction == TrafficDirection.Out && headers.Exists("Transfer-Encoding") && headers["Transfer-Encoding"] == "chunked")
19461947
{
19471948
bytesFromHTTP = Utilities.GetPaylodFromChunkedBody(bytesFromHTTP);
19481949
bytes = bytesFromHTTP;
@@ -2507,7 +2508,7 @@ private void UpdateView()
25072508
Session session0 = new Session(new byte[0], new byte[0]);
25082509
Session[] sessionsInFiddler = FiddlerApplication.UI.GetAllSessions();
25092510
allSessionsList.AddRange(sessionsInFiddler);
2510-
FiddlerApplication.OnLoadSAZ += this.AfterCallDoImport;
2511+
FiddlerApplication.OnLoadSAZ += this.AfterCallDoImport;
25112512
allSessionsList.Sort(delegate (Session p1, Session p2)
25122513
{
25132514
return p1.id.CompareTo(p2.id);
@@ -2540,7 +2541,7 @@ private void UpdateView()
25402541

25412542
this.DisplayObject(parserResult, bytesForHexView);
25422543
}
2543-
catch(Exception e)
2544+
catch (Exception e)
25442545
{
25452546
parserResult = e.ToString();
25462547
}
@@ -2567,7 +2568,7 @@ private void UpdateView()
25672568
public static bool IsFromFiddlerCore(Session session)
25682569
{
25692570
bool result = false;
2570-
if(session.id == 0)
2571+
if (session.id == 0)
25712572
{
25722573
result = true;
25732574
}

0 commit comments

Comments
 (0)