Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

How to get variables and values of method using mono.cecil?

My code get
Code
 
Imports Mono.Cecil
Imports Mono.Cecil.Cil
Dim nasm As AssemblyDefinition  
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim assembly As AssemblyDefinition = AssemblyDefinition.ReadAssembly(TextBox1.Text)

       For Each t As TypeDefinition In Assembly.MainModule.Types

           For Each f As FieldDefinition In t.Fields
               TextBox2.Text = TextBox2.Text & f.Name & vbNewLine
           Next

           For Each l As PropertyDefinition In t.Properties
               TextBox3.Text = TextBox3.Text & l.Name & vbNewLine
           Next



           For Each x As TypeDefinition In t.NestedTypes
               TextBox4.Text = TextBox4.Text & x.Name & vbNewLine
           Next

         

           For Each m As MethodDefinition In t.Methods

               For Each v As GenericParameter In m.GenericParameters
                   TextBox5.Text = TextBox5.Text & v.Name & vbNewLine
               Next

               For Each c As ParameterDefinition In m.Parameters
                   TextBox6.Text = TextBox6.Text & c.Name & vbNewLine
               Next

               If m.IsConstructor = False Then
                   TextBox7.Text = TextBox7.Text & m.Name & vbNewLine
               End If
               For Each c1 As VariableDefinition In m.Body.Variables
                   TextBox8.Text = TextBox8.Text & c1.Name & vbNewLine
               Next
         
           Next
Next
End Sub
End Class

My Code Test
Code
Module Module1
   Dim a1 As String = "eeee"
   Dim a2 As Integer = 1
   Sub main()
       Dim a33 As String = "3333"
       MsgBox(aaa(1, 2))
   End Sub
   Public Function aaa(ByVal b As Integer, ByVal c As Integer) As Integer
       Dim d As Integer = 222
       Return b + c + d
   End Function
End Module
Help me get the variables names and value  in my code Test after compiling to .exe
I want get a33,"3333",d,222

Thank you so much
Here's a way in c#, but I recommend switching to dnlib because it has a lot of features already built in.
[Image: Syr3DlV.png]
thank you so much,let me test it
(Jul 29, 2019 06:53 AM)mutchim Wrote:  The above code works incorrectly to my requirements

help me for my VB .NET code works,thank you so much


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Source] by HackersNov 19, 2024 01:51 PM 15 683 Nov 19, 2024 01:51 PM
Last Post: Hackers
[C#] by GrootyAug 18, 2024 06:15 PM 1 201 Aug 18, 2024 06:15 PM
Last Post: Lookdadon
[Javascript]  by Z3R00NDATOct 16, 2023 01:24 PM 3 134 Oct 16, 2023 01:24 PM
Last Post: Disease