This is a migrated thread and some comments may be shown as answers.

JustDecompile does not decompile correctly

1 Answer 48 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 26 Oct 2011, 08:48 PM
Hello all, I am new to this forum, and this software, but I wanted to point out something that I noticed.  I recently started with the company that I am working for and I have been put in charge of re-making some software that was created by a previous person.  They lost the source code, and so all I have to work with is the finished product.  Thankfully the code was originally written in .NET so I am able to use decompilers such as this one.  I was try to use JustDecompile to recreate a routine that was supposed to generate a string variable that contained XML data based on records from a database.  However, when I look at it through JD, I noticed that I never saw anything that was writing data into the variable.  I knew the program worked, because my company uses it on a daily basis several times a day.  So I downloaded another decompiler which showed me that there was much more code than what JD was showing me.


Here is JD's version of the decompiled code:
Public Shared Sub GetRS_WtiteToXML(ByRef 400_conn As Connection, ByRef strTableName As String, ByRef PolicyID As String, ByRef intFile As Short, ByRef QuoteXML As String)
    Dim str As String
    Dim str2 As String
    Dim str3 As String
    Dim strArrays As String()
    GetRS_WriteToXML.rs = String.Concat(New String() { "SELECT * FROM ", strTableName, " WHERE POLICYNUMBER = '", PolicyID, "'" }).Execute(Dim obj As Object = Missing.Value, obj, -1)
    If ((Not GetRS_WriteToXML.rs.EOF And Not GetRS_WriteToXML.rs.BOF) <> 0) Then
        GetRS_WriteToXML.rs.MoveFirst()
        Dim count As Short = CShort(GetRS_WriteToXML.rs.Fields.Count)
        Dim num1 As Short = 1
        While Not GetRS_WriteToXML.rs.EOF
            Dim i As Short = Dim num2 As Short = CShort(count - 1)
            Do
                Dim item As Field = GetRS_WriteToXML.rs.Fields(i)
                If ((Information.IsDBNull(RuntimeHelpers.GetObjectValue(item.Value)) Or StringType.StrCmp(Strings.Trim(StringType.FromObject(item.Value)), "", False) = 0) <> 0) Then
                    Continue Do
                End If
                item = Nothing
                Dim num3 As Short = intFile
                i = CShort(i + 1)
            Loop While i <= num2
            GetRS_WriteToXML.rs.MoveNext()
            num1 = CShort(num1 + 1)
        End While
    End If
    GetRS_WriteToXML.rs.Close()
    GetRS_WriteToXML.rs = Nothing
End Sub

And here is Dis#'s version of the decompiled code:
Public Shared Sub GetRS_WtiteToXML(ByRef 400_conn As Connection, ByRef strTableName As String, ByRef PolicyID As String, ByRef intFile As Short, ByRef QuoteXML As String)
            Dim s1 As String, s2 As String, s3 As String
  
            Dim obj1 As Object = Missing.Value
            GetRS_WriteToXML.rs = 400_conn.Execute("SELECT * FROM " + strTableName + " WHERE POLICYNUMBER = '" + PolicyID + "'", ByRef obj1, -1)
            If Not GetRS_WriteToXML.rs.EOF And Not GetRS_WriteToXML.rs.BOF Then
                GetRS_WriteToXML.rs.MoveFirst()
                strTableName = StringType.FromObject(GetRS_WriteToXML.rs.Fields(0).Value)
                Dim sh3 As Short = CShort(GetRS_WriteToXML.rs.Fields.Count)
                Dim sh1 As Short = 1
                While Not GetRS_WriteToXML.rs.EOF
                    QuoteXML = QuoteXML + "<" + strTableName + ">"
                    Dim sh5 As Short = CShort((sh3 - 1))
                    Dim sh4 As Short = 1
                    While sh4 <= sh5
                        Dim field1 As Field = GetRS_WriteToXML.rs.Fields(sh4)
                        If Information.IsDBNull(RuntimeHelpers.GetObjectValue(field1.Value)) Or (StringType.StrCmp(Strings.Trim(StringType.FromObject(field1.Value)), "", False) = 0) Then
                            QuoteXML = QuoteXML + "<" + field1.Name + "/>"
                        Else 
                            QuoteXML = QuoteXML + "<" + field1.Name + ">" + Strings.Trim(StringType.FromObject(field1.Value)) + "</" + field1.Name + ">"
                        End If
                        field1 = Nothing
                        Dim sh2 As Short = intFile
                        sh4 = CShort((sh4 + 1))
                    End While
                    QuoteXML = QuoteXML + "</" + strTableName + ">"
                    GetRS_WriteToXML.rs.MoveNext()
                    sh1 = CShort((sh1 + 1))
                End While
            End If
            GetRS_WriteToXML.rs.Close()
            GetRS_WriteToXML.rs = Nothing
        End Sub

As you can see there are SEVERAL differences between the two decompiles.  Firstly, where it executes the sql statement to fill the recordset you will notice that Dis# does it properly by using the connection variable to execute and fill the recordset.  JD has "some text".Execute?!  That doesn't make much sense.  Also, and this was what was catching me up, within the nested While statement "While sh4 <= sh5" (Dis#'s version), you will notice that there it is actually setting the QuoteXML variable to be equal to data retrieved from the recordset.  JD doesn't have ANYTHING as far as writing ANY data into that variable.

I understand that JD is free, and also that it is in the beta phase.  I am by no means disappointed with the product, especially since it is really the only free one that I have found.  I just wanted to let someone know that there is a major issue with the decomplation of the assembly's.  If this was intended to be this way, then I apologize for my post.

1 Answer, 1 is accepted

Sort by
0
Tsviatko Yovtchev
Telerik team
answered on 01 Nov 2011, 10:14 AM
Hi Eric,

 Thanks a bunch for letting us know about this. It's definitely not intended to be that way. What you see indicates a problem.

Is it possible that you send over the assembly where that code is? You could use tsviatko.yovtchev at telerik.com. Rather unfortunately that's the only way we can figure out what goes on there.

Regards,
Tsviatko Yovtchev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
General Discussions
Asked by
Eric
Top achievements
Rank 1
Answers by
Tsviatko Yovtchev
Telerik team
Share this question
or