Hey ;D
I got my own Injector and I wanna add a Save/Load function that will use a ini file.
I got already a code but I need help to save the dll path and use it again...
Heres my code:
Code:
Private Sub Button6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim INI As New INIDatei, i As Integer
INI.Pfad = My.Application******.DirectoryPath & "\savedlls.ini"
For i = 1 To Dlls.Items.Count
INI.WertSchreiben("Files", "Number of Files", Dlls.Items.Count)
INI.WertSchreiben("Files", CStr(i), Dlls.tostring)
Next i
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Dim INI As New INIDatei, max As Integer, i As Integer
INI.Pfad = My.Application******.DirectoryPath & "\savedlls.ini"
max = CInt(INI.WertLesen("Files", "Number of Files"))
For i = 1 To max
Dlls.Items.Add(INI.WertLesen("Files", CStr(i)))
Next i
End Sub
INI.wertlesen = read ini files.
INI.wertschreiben = write into ini files.
INI.pfad = the place where the ini will be loaded or created
I need help at the part of dll.tostring I get this message in the ini file:
Code:
[Files]
Number of Files=2
1=System.Windows.Forms.ListBox, Items.Count: 2, Items[0]: Mpgh CrossFire.dll
2=System.Windows.Forms.ListBox, Items.Count: 2, Items[0]: Mpgh CrossFire.dll
But I used 2 different dlls.
It can only save this and not the path...
Can someone help me ?
The Save and Load feature is only in my Project because I need help at it ^^
I try to answer you eh:
The user browse it and it will be added to the listbox. There is only shown the name. And my new function have to save it and load it later ^^
Okay I got this.
Add this to your "Browse" button.
[php]
Dim ofd As New OpenFileDialog
ofd.Title = "Browse for your .dlls..."
ofd.RestoreDirectory = True
ofd.Filter = ".DLL files (*.dll)|*.dll"
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim raw As String = ofd.FileName
Dim mod1 As String = raw.Replace(".dll", "")
Dim q1 As Integer = mod1.LastIndexOf("\") + 1
This will add your .dll to the listbox, and save the path.
Now to inject you need the path of the .dll, so declare this at the top of the form just underneath "Public Class Form1"
[php]
dim dllLoc as String
[/php]
And add this to your "ListBox1_SelectedIndexChanged" sub
[php]
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
dllLoc = GetSetting("InjectorDLLs", "Dlls", ListBox1.SelectedItem)
End Sub
[/php]
This will give you the path of the selected .dll.
NOW, saving all this to a .ini
first declare this underneath "Public Class Form1"
[php]
dim path as string = (Application.StartupPath & "\SavedDlls.ini")
[/php]
THEN
add this sub to your project
[php]
Private Sub SaveList()
Using sWrite As New IO.StreamWriter(path)
For Each p As String In ListBox1.Items
sWrite.WriteLine(p)
Next
End Using
End Sub
[/php]
That will save all your listbox items.
Now this sub to load them
[php]
Private Sub LoadList()
Using sRead As New IO.StreamReader(path)
Do
Dim lbDLL As String = sRead.ReadLine()
If IsNothing(lbDLL) Then Exit Do
ListBox1.Items.Add(lbDLL)
Loop
End Using
End Sub
[/php]
This will add all your items back to the listbox.
so whenever you need to save the list simply type
[php]
SaveList()
[/php]
and whenever you need to load the list
[php]
LoadList()
[/php]
And that's it.
Problems, just ask.
testing right now ;D thank you for you help, Ill pm you if I got problems thannnkkk you
IT WORKS THANK YA D
But where the ini gets saved :O ? ^^
Originally Posted by XxDragonSharKxX
testing right now ;D thank you for you help, Ill pm you if I got problems thannnkkk you
No problems, any time.
Just remember that dllLoc contains the location of your currently .dll file.
So to inject make sure you're injecting dllLoc, it will be constantly updated to whichever .dll is selected in the listbox.