Interesting

Dec 6, 2009 at 3:55 PM

Been looking for a replacement for Charles...this seems to be heading in the right direction. Nice work.

At the moment, it seems that only the headers are captured...is that right? I.e. I cant see any of the actual request or response's at the moment....

...or am I missing something?

Jan 12, 2010 at 9:27 PM

I'm seeing requests decoded, but it seems to be having problems with responses.  Going to take a look at the code myself and see what might be the issue....

 

Jan 19, 2010 at 4:14 AM

OK, I'm using BlazeDS in debug mode, and when I get response data from it it's wrapped in a "DSK" object that the plugin doesn't handle.  I resolved that by modifying a portion of the ReadAMF3Object method so it reads (added code in green):

if (ReturnValue.IsExternalizable == 1)
        {
            switch (ReturnValue.TypeIdentifier)
            {
                case "flex.messaging.io.ArrayCollection":
                case "flex.messaging.io.ObjectProxy":
                    ReadAMF3Data();
                    break;
                case "DSK":
                    // skip two bytes
                    Offset++;
                    Offset++;
                    ReturnValue.ClassMemberDefinitions.Add("Amf3Object");
                    ReturnValue.Parameters.Add(ReadAMF3Data());
                    break;

                default:
                    DebugStr += Prefix + "Can't read " + ReturnValue.TypeIdentifier;
                    break;
            }
        }

 

I'm also see an issue where the plugin is only reading about half of the string value data.  Looking into that now.

Jan 19, 2010 at 5:45 AM

Actually, this works a bit better for the DSK, because it picks up the name of the next object correctly:

           case "DSK":
                    // skip two bytes
                    Offset++;
                    Offset++;
                    // Read the inner type and add it
                    TypeAndData StartType = ReadAMF3Data();
                    String StartClass = ((AMF3Object)StartType.Data).TypeIdentifier;
                    ReturnValue.ClassMemberDefinitions.Add(StartClass);
                    ReturnValue.Parameters.Add(StartType);
                    break;

Also, discovered that the issue with string values is that the method to read strings wasn't implemented for references (AMF passes unique strings.  Subsequent references to the same string value reference the first instance of it).  To handle that, I added a member to AMFDataParser:

    ArrayList StringRefs;

Initialize it in the ProcessData method:

    StringRefs = new ArrayList();

And then use it within the ReadAMF3String method:

public string ReadAMF3String()
    {
        Level++;
        string Prefix = new string(' ', Level);
        uint StrRef = ReadAMF3Int();
        string Str;

        if (DebugLevel > 4)
            DebugStr += String.Format("{0}{1}: StrRef: {2:G}\r\n", Prefix, System.Reflection.MethodBase.GetCurrentMethod().Name, StrRef);
        if ((StrRef & 1) == 1)
        {
            uint StrLen = StrRef >> 1;

            Str = ReadBuffer((int)StrLen);
            if (DebugLevel > 4)
                DebugStr += Prefix + Str + "\r\n";
            Level--;

            if ( Str != null ) {
                StringRefs.Add(Str);
            }

        }
        else
        {
            uint j = StrRef >> 1;
            Str = (string)StringRefs[(int)j];

        }
        //Level--;
        return Str;
        
    }

Now I've noticed that Dates and Doubled are being read, but not displayed properly in the result.  Working on that now.

 

 

Jan 19, 2010 at 7:24 AM

Well, one of the problems with Doubles and Dates is that Dates was dependent on Doubles (number of milliseconds since 1/1/1970) and there was a bug in the method being used to evaluate Doubles that affected them both.  I modified it to use the BitConverter method rather than correct the values being used for the shfits:

public double ReadDouble()
    {
        //return Data[Offset++] << 48 | Data[Offset++] << 44 | Data[Offset++] << 40 | Data[Offset++] << 32 | Data[Offset++] << 24 | Data[Offset++] << 16 | Data[Offset++] << 8 | Data[Offset++];
        byte[] bytes = { Data[Offset+7], Data[Offset+6], Data[Offset+5], Data[Offset+4], Data[Offset+3], Data[Offset+2], Data[Offset+1], Data[Offset] };
        Offset = Offset + 8;
        Double value = BitConverter.ToDouble(bytes, 0);
        return value;
    }

The ReadAMF3Date method was also returning a Double, which made it difficult when it came to display the data whether the original data was a Double or a Date.  I modified it to return a DateTime:

public DateTime ReadAMF3Date()
    {
        Level++;
        string Prefix = new string(' ', Level);
        //UserMangement(Set Password).saz 29
        // 01 42 72 4a 68 9f f0 40 00 08 01 42 72 4c a9 68   30 40 00 06
        //DebugStr += Prefix + System.Reflection.MethodBase.GetCurrentMethod().Name + " TODO: Amf3Date\r\n";
        //DumpHex(Offset, 20);

        uint ReferncePtr = ReadAMF3Int();
        uint InLine = ReferncePtr&0x1;
        ReferncePtr >>= 1;

        DateTime DateValue = new DateTime(1970, 1, 1);

        if (InLine == 1)
        {
            DateValue = DateValue.AddMilliseconds ( ReadDouble() );
        }
        else
        {
            //TODO: Referencing
        }
        Level--;
        return DateValue ;
    }

Finally, in DumpData, I added additional blocks to handle the Double and DateTime data:

            else if (DataType == "Double")
            {
                Double Value = (Double)AObject;
                DebugStr += Prefix + Value + "\r\n";
                CurrentNode = ParentNode.Nodes.Add(Value.ToString());
            }
            else if (DataType == "DateTime")
            {
                DateTime Value = (DateTime)AObject;
                DebugStr += Prefix + Value + "\r\n";
                CurrentNode = ParentNode.Nodes.Add(Value.ToString());
            }

So, now I've got some Arrays that aren't displaying correctly.  Moving on to those....

Coordinator
Feb 13, 2010 at 9:45 PM

Cool. Do you want to check in the code. I need time to figure out how I can setup that.

Just let me know.

Mar 3, 2010 at 9:39 PM

I just finally got the time to finish up the fixes, including:

  • Add handling of DSK object when using BlazeDS
  • Add handling of string references
  • Add handling of DateTime values
  • Correct handling of Double values
  • Better display of arrays
  • Some performance improvements

I checked in the code changes as well as put up a 1.1.0 release.  Let me know what you think.

Coordinator
Mar 3, 2010 at 9:41 PM
Great work, buddy!
Sounds cool. I'll try when I have some time... I'm up to other stuff these days.

On Wed, Mar 3, 2010 at 1:39 PM, brucearmstrong
<notifications@codeplex.com> wrote:
> From: brucearmstrong
>
> I just finally got the time to finish up the fixes, including:
>
> Add handling of DSK object when using BlazeDS
> Add handling of string references
> Add handling of DateTime values
> Correct handling of Double values
> Better display of arrays
> Some performance improvements
>
> I checked in the code changes as well as put up a 1.1.0 release.  Let me
> know what you think.
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com



--
-matt
Visit http://darungrim.org for free and opensource binary diffing tool.