diff --git a/MAPIInspector/Source/Parsers/BaseStructure.cs b/MAPIInspector/Source/Parsers/BaseStructure.cs index 3ec0b58..e703971 100644 --- a/MAPIInspector/Source/Parsers/BaseStructure.cs +++ b/MAPIInspector/Source/Parsers/BaseStructure.cs @@ -153,7 +153,7 @@ public static TreeNode AddNodesForTree(string nodeName, object obj, int startInd { offset = ad.Size; res.Text = ad.ToString(); - foreach(var parsedValue in ad.parsedValues) + foreach (var parsedValue in ad.parsedValues) { var alternateParsingNode = new TreeNode($"{parsedValue.Key}:{parsedValue.Value}"); alternateParsingNode.Tag = new Position(current, offset); @@ -162,82 +162,6 @@ public static TreeNode AddNodesForTree(string nodeName, object obj, int startInd return res; } - else if (t.Name == "MAPIStringAddressBook") - { - FieldInfo[] infoString = t.GetFields(); - - // MagicByte node - if (infoString[1].GetValue(obj) != null) - { - TreeNode nodeMagic = new TreeNode(string.Format("{0}:{1}", infoString[1].Name, infoString[1].GetValue(obj))); - Position positionStringMagic = new Position(current, 1); - nodeMagic.Tag = positionStringMagic; - res.Nodes.Add(nodeMagic); - current += 1; - } - - // value node - string terminator = (string)infoString[3].GetValue(obj); - int os = 0; - TreeNode node = new TreeNode(string.Format("{0}:{1}", infoString[0].Name, infoString[0].GetValue(obj))); - - // If the Encoding is Unicode. - if (infoString[2].GetValue(obj).ToString() == "System.Text.UnicodeEncoding") - { - // If the StringLength is not equal 0, the StringLength will be OS value. - if (infoString[4].GetValue(obj).ToString() != "0") - { - os = ((int)infoString[4].GetValue(obj)) * 2; - } - else - { - if (infoString[0].GetValue(obj) != null) - { - os = ((string)infoString[0].GetValue(obj)).Length * 2; - } - - if (infoString[5].GetValue(obj).ToString() != "False") - { - os -= 1; - } - - os += terminator.Length * 2; - } - } - else - { - // If the Encoding is ASCII. - if (infoString[4].GetValue(obj).ToString() != "0") - { - // If the StringLength is not equal 0, the StringLength will be OS value. - os = (int)infoString[4].GetValue(obj); - } - else - { - if (infoString[0].GetValue(obj) != null) - { - os = ((string)infoString[0].GetValue(obj)).Length; - } - - os += terminator.Length; - } - } - - Position positionString = new Position(current, os); - node.Tag = positionString; - res.Nodes.Add(node); - - if (infoString[1].GetValue(obj) != null) - { - offset = os + 1; - } - else - { - offset = os; - } - - return res; - } // Check whether the data type is simple type if (Enum.IsDefined(typeof(DataType), t.Name)) diff --git a/MAPIInspector/Source/Parsers/MSOXCDATA.cs b/MAPIInspector/Source/Parsers/MSOXCDATA.cs index 4b4d4dd..252d006 100644 --- a/MAPIInspector/Source/Parsers/MSOXCDATA.cs +++ b/MAPIInspector/Source/Parsers/MSOXCDATA.cs @@ -4098,7 +4098,7 @@ public override int Size /// /// The MAPIString class to record the related attributes of string. /// - public class MAPIStringAddressBook : BaseStructure + public class MAPIStringAddressBook : AnnotatedData { /// /// The string value @@ -4113,7 +4113,7 @@ public class MAPIStringAddressBook : BaseStructure /// /// The string Encoding : ASCII or Unicode /// - private Encoding Encode; + public Encoding Encode; /// /// The string Terminator. Default is "\0". @@ -4130,20 +4130,13 @@ public class MAPIStringAddressBook : BaseStructure /// public bool ReducedUnicode; - /// - /// Initializes a new instance of the MAPIStringAddressBook class without parameters. - /// - public MAPIStringAddressBook() - { - } - /// /// Initializes a new instance of the MAPIStringAddressBook class with parameters. /// /// The encoding type /// The string terminator /// The string length - /// INdicate whether the terminator is reduced + /// Indicate whether the terminator is reduced public MAPIStringAddressBook(Encoding encode, string terminator = "\0", int stringLength = 0, bool reducedUnicode = false) { this.Encode = encode; @@ -4170,6 +4163,62 @@ public override void Parse(Stream s) this.Value = this.ReadString(this.Encode, this.Terminator, this.StringLength, this.ReducedUnicode); } + public override string ToString() => Value; + public override int Size + { + get + { + var len = 0; + + if (Encode == Encoding.Unicode) + { + // If the StringLength is not equal 0, the StringLength will be basis for size + if (StringLength != 0) + { + len = StringLength * 2; + } + else + { + if (Value != null) + { + len = Value.Length * 2; + } + + if (ReducedUnicode) + { + len -= 1; + } + + len += Terminator.Length * 2; + } + } + else + { + // If the Encoding is ASCII. + if (StringLength != 0) + { + // If the StringLength is not equal 0, the StringLength will be basis for size + len = StringLength; + } + else + { + if (Value != null) + { + len = Value.Length; + } + + len += Terminator.Length; + } + } + + if (HasValue != null) + { + len += 1; + } + + return len; + } + } } #region 2.1 AddressList Structures diff --git a/MAPIInspector/Source/Parsers/MSOXCMAPIHTTP.cs b/MAPIInspector/Source/Parsers/MSOXCMAPIHTTP.cs index 604cd77..e95af2b 100644 --- a/MAPIInspector/Source/Parsers/MSOXCMAPIHTTP.cs +++ b/MAPIInspector/Source/Parsers/MSOXCMAPIHTTP.cs @@ -1,5 +1,6 @@ namespace MAPIInspector.Parsers { + using MapiInspector; using System; using System.Collections.Generic; using System.IO; @@ -4307,6 +4308,11 @@ public class AddressBookPropertyValue : BaseStructure /// private CountWideEnum countWide; + /// + /// Source property tag information + /// + public AnnotatedComment PropertyTag; + /// /// Initializes a new instance of the AddressBookPropertyValue class. /// @@ -4367,13 +4373,18 @@ public class AddressBookTaggedPropertyValue : BaseStructure /// /// An unsigned integer that identifies the property. /// - public ushort PropertyId; + public PidTagPropertyEnum PropertyId; /// /// An AddressBookPropertyValue structure /// public AddressBookPropertyValue PropertyValue; + /// + /// Source property tag information + /// + public AnnotatedComment PropertyTag; + /// /// Parse the AddressBookTaggedPropertyValue structure. /// @@ -4382,10 +4393,11 @@ public override void Parse(Stream s) { base.Parse(s); this.PropertyType = (PropertyDataType)this.ReadUshort(); - this.PropertyId = this.ReadUshort(); + this.PropertyId = (PidTagPropertyEnum)this.ReadUshort(); AddressBookPropertyValue addressBookValue = new AddressBookPropertyValue(this.PropertyType); addressBookValue.Parse(s); this.PropertyValue = addressBookValue; + this.PropertyTag = $"{PropertyType}:{Utilities.EnumToString(PropertyId)}"; } } #endregion @@ -4445,6 +4457,11 @@ public class AddressBookTypedPropertyValue : BaseStructure /// public AddressBookPropertyValue PropertyValue; + /// + /// Source property tag information + /// + public AnnotatedComment PropertyTag; + /// /// Parse the AddressBookTypedPropertyValue structure. /// @@ -4481,6 +4498,11 @@ public class AddressBookFlaggedPropertyValue : BaseStructure /// private PropertyDataType propertyDataType; + /// + /// Source property tag information + /// + public AnnotatedComment PropertyTag; + /// /// Initializes a new instance of the AddressBookFlaggedPropertyValue class. /// @@ -4540,6 +4562,11 @@ public class AddressBookFlaggedPropertyValueWithType : BaseStructure /// public AddressBookPropertyValue PropertyValue; + /// + /// Source property tag information + /// + public AnnotatedComment PropertyTag; + /// /// Parse the AddressBookFlaggedPropertyValueWithType structure. /// @@ -4628,12 +4655,14 @@ public override void Parse(Stream s) { AddressBookPropertyValue propValue = new AddressBookPropertyValue(propTag.PropertyType, this.ptypMultiCountSize); propValue.Parse(s); + propValue.PropertyTag = $"{propTag.PropertyType}:{Utilities.EnumToString(propTag.PropertyId)}"; addrRowValue = propValue; } else { AddressBookTypedPropertyValue typePropValue = new AddressBookTypedPropertyValue(); typePropValue.Parse(s); + typePropValue.PropertyTag = $"{propTag.PropertyType}:{Utilities.EnumToString(propTag.PropertyId)}"; addrRowValue = typePropValue; } } @@ -4643,12 +4672,14 @@ public override void Parse(Stream s) { AddressBookFlaggedPropertyValue flagPropValue = new AddressBookFlaggedPropertyValue(propTag.PropertyType); flagPropValue.Parse(s); + flagPropValue.PropertyTag = $"{propTag.PropertyType}:{Utilities.EnumToString(propTag.PropertyId)}"; addrRowValue = flagPropValue; } else { AddressBookFlaggedPropertyValueWithType flagPropValue = new AddressBookFlaggedPropertyValueWithType(); flagPropValue.Parse(s); + flagPropValue.PropertyTag = $"{propTag.PropertyType}:{Utilities.EnumToString(propTag.PropertyId)}"; addrRowValue = flagPropValue; } }