Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Help VB.NET] value does not fall within the expected range

Featured Replies

Posted

Hello eveyone , i was coding an obfuscator , everything is working good , but when i start to deobfuscate , it says value does not fall within the expected range , can someone help me please , here is the code 

  Private Sub DesignButton8_Click(sender As Object, e As EventArgs) Handles DesignButton8.Click
        Try
            Dim S As New SaveFileDialog
            S.Filter = "|*.exe"
            If S.ShowDialog = vbOK Then
                If Protectpart2() = True Then
                    ASM.Write(S.FileName)
                        MsgBox("Sucessfully Obfuscated at: " & vbCrLf & S.FileName, MsgBoxStyle.Information)
                    Else
                        Exit Sub
 
                    End If
                End If
        Catch ex As Exception
        End Try
    End Sub
 
    Public Function Protectpart2() As Boolean
        Dim FilePath As String = ""
        Try
            ASM = AssemblyDefinition.ReadAssembly(FilePath)
            ASM.MainModule.Attributes = ModuleAttributes.Required32Bit
            Dim definition As TypeDefinition
            For Each definition In ASM.MainModule.Types
                If (definition.Name <> "<Module>") Then
                    Me.RenameTypesMethodsFields(definition, True, True, True)
                    Dim i As Integer
                    For i = 0 To 750 - 1
                        Dim item As New MethodDefinition(Me.SingleCharRename, (MethodAttributes.ReuseSlot Or MethodAttributes.Private), ASM.MainModule.Import(Type.GetType("System.Void")))
                        definition.Methods.Add(item)
                        item.Body.Instructions.Add(Instruction.Create(OpCodes.Br_S, CByte(&H2C)))
                        item.Body.Instructions.Add(Instruction.Create(OpCodes.Nop))
                        List.Items.Add(item)
                    Next i
                End If
            Next
            Dim definition3 As TypeDefinition
            For Each definition3 In ASM.MainModule.Types
                If (definition3.Namespace <> "") Then
                    Dim newValue As String = Me.SingleCharRename
                    Dim resource As Resource
                    For Each resource In ASM.MainModule.Resources
                        resource.Name = resource.Name.Replace(definition3.Namespace, newValue)
                    Next
                    definition3.Namespace = newValue
                End If
            Next
        Catch exception As Exception
            MessageBox.Show(exception.Message)
            Return False
        End Try
        Return True
    End Function
 

check your code more carefully and debug it


here is the problem :



Dim FilePath As String = ""

you've passed an empty path to "ReadAssembly"


Edited by n0th!ng

  • Author

check your code more carefully and debug it

here is the problem :


Dim FilePath As String = ""

you've passed an empty path to "ReadAssembly"

well , how can i fix it :D , sorry for my lazy brain im just new on vb.net

How on earth you code a obfuscator if you don't know basic coding....????


 


Replace:



Dim FilePath As String = ""

With:



Dim result As DialogResult = OpenFileDialog1.ShowDialog()
If result = Windows.Forms.DialogResult.OK Then
Dim FilePath As String = OpenFileDialog1.FileName.ToString
EndIf

This is when you execute trough a button.


 


Inside your bolean function you can:


1. Make fixed file path value:



Dim FilePath As String = "c:\assembly.exe"

or before passing the arguments to function just open the dialog and pass the result to a variable withch is later imported to your boolean variable.



Public Function Protectpart2( byval mypath as string) As Boolean


Dim FilePath As String = mypath

Edited by GIV

  • Author

 

How on earth you code a obfuscator if you don't know basic coding....????

 

Replace:

Dim FilePath As String = ""

With:

Dim result As DialogResult = OpenFileDialog1.ShowDialog()If result = Windows.Forms.DialogResult.OK ThenDim FilePath As String = OpenFileDialog1.FileName.ToStringEndIf

This is when you execute trough a button.

 

Inside your bolean function you can:

1. Make fixed file path value:

Dim FilePath As String = "c:\assembly.exe"

or before passing the arguments to function just open the dialog and pass the result to a variable withch is later imported to your boolean variable.

Public Function Protectpart2( byval mypath as string) As Boolean
Dim FilePath As String = mypath

like this u mean?

 

  Private Sub DesignButton8_Click(ByVal sender As Object, ByVal e As EventArgs) Handles DesignButton8.Click
        Try
            Dim File1 As New OpenFileDialog
            Dim FilePath As String = File1.FileName.ToString
            Dim result As DialogResult = File1.ShowDialog()
            If result = Windows.Forms.DialogResult.OK Then
                File1.FileName.ToString()
            End If
            Dim S As New SaveFileDialog
            S.Filter = "|*.exe"
            If S.ShowDialog = vbOK Then
                If Protectpart2() = True Then
                    ASM.Write(S.FileName)
                    ASM.Write(SavePath)
                    MsgBox("Sucessfully Obfuscated at: " & vbCrLf & S.FileName, MsgBoxStyle.Information)
                Else
                    Exit Sub
 
                End If
            End If
        Catch ex As Exception
        End Try
    End Sub
 
    Public Function Protectpart2() As Boolean
        Dim FilePath As String = "c:\...\...\desktop\"
        Try
            ASM = AssemblyDefinition.ReadAssembly(FilePath)
            ASM.MainModule.Attributes = ModuleAttributes.Required32Bit
            Dim definition As TypeDefinition
            For Each definition In ASM.MainModule.Types
                If (definition.Name <> "<Module>") Then
                    Me.RenameTypesMethodsFields(definition, True, True, True)
                    Dim i As Integer
                    For i = 0 To 750 - 1
                        Dim item As New MethodDefinition(Me.SingleCharRename, (MethodAttributes.ReuseSlot Or MethodAttributes.Private), ASM.MainModule.Import(Type.GetType("System.Void")))
                        definition.Methods.Add(item)
                        item.Body.Instructions.Add(Instruction.Create(OpCodes.Br_S, CByte(&H2C)))
                        item.Body.Instructions.Add(Instruction.Create(OpCodes.Nop))
                        List.Items.Add(item)
                    Next i
                End If
            Next
            Dim definition3 As TypeDefinition
            For Each definition3 In ASM.MainModule.Types
                If (definition3.Namespace <> "") Then
                    Dim newValue As String = Me.SingleCharRename
                    Dim resource As Resource
                    For Each resource In ASM.MainModule.Resources
                        resource.Name = resource.Name.Replace(definition3.Namespace, newValue)
                    Next
                    definition3.Namespace = newValue
                End If
            Next
        Catch exception As Exception
            MessageBox.Show(exception.Message)
            Return False
        End Try
        Return True
    End Function

Define a global variable as:

public FilePath  as string=""

Just before execute your code make a button with the code inside:

 

 

 

Dim result As DialogResult = OpenFileDialog1.ShowDialog()
If result = Windows.Forms.DialogResult.OK Then
Dim FilePath As String = OpenFileDialog1.FileName.ToString
EndIf

  • Author

Define a global variable as:

public FilePath  as string=""

Just before execute your code make a button with the code inside:

do u have skype?

Yep.

  • Author

name?


  • Author

add me : forzizo2010_1

  • Author

Yep.

please answer me or add

Look at my profile to see my Skype name.


Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.