Apr 8, 2010 01:57 AM
(This post was last modified: Apr 8, 2010 02:41 AM by cysto.)
Welcome HF coders,
This is my first tutorial on HF, so I hope you like it!
Goal: Know how to make a built-in stub without dropping it out on the hard disk.
Let's start:
Step 1:
-------
Take any builder project you have (binder\crypter\...), and open it.
Step 2:
-------
In the solution explorer, right click your project, hover your mouse over "Add", and press "Existing item..." from the sub-menu:
[img]http://img232.imageshack.us/img232/487/96689237.jpg[/img]
Step 3:
-------
Browse for your stub, and press "Add"
P.S: Be sure that the file type is: "Executable Files (*.exe; *.dll; *.ocx)
Step 4:
-------
In the solution explorer, right click your stub, and press "Properties"
The Properties panel will get focus.
Step 5:
-------
Change the stub's "Build Action" to "Embedded Resource":
[img]http://img189.imageshack.us/img189/478/propk.jpg[/img]
Optional: You can rename your stub to any other name, even another extension, by changing its property "File Name" to your desired name.
Step 6:
-------
Add this Function to your code:
Credits to Deathader
Step 7:
-------
Now, I'm sure that MOST of you coders declare the "stub" As String. This is going to change now. Declare it As Byte(), like this:
And delete this piece of code that gets the stub its value:
And replace it with this code:
Step 8:
-------
After the above replacement, an error in the error list will appear, warning you that "&" cannot be used with 1-dimensional array of Byte and String.
For that reason, we're going to change this code:
To this code:
This finishes our tutorial for making a built-in stub!
Hope you learned something from it!
Enjoy!!
This is my first tutorial on HF, so I hope you like it!
Goal: Know how to make a built-in stub without dropping it out on the hard disk.
Let's start:
Step 1:
-------
Take any builder project you have (binder\crypter\...), and open it.
Step 2:
-------
In the solution explorer, right click your project, hover your mouse over "Add", and press "Existing item..." from the sub-menu:
[img]http://img232.imageshack.us/img232/487/96689237.jpg[/img]
Step 3:
-------
Browse for your stub, and press "Add"
P.S: Be sure that the file type is: "Executable Files (*.exe; *.dll; *.ocx)
Step 4:
-------
In the solution explorer, right click your stub, and press "Properties"
The Properties panel will get focus.
Step 5:
-------
Change the stub's "Build Action" to "Embedded Resource":
[img]http://img189.imageshack.us/img189/478/propk.jpg[/img]
Optional: You can rename your stub to any other name, even another extension, by changing its property "File Name" to your desired name.
Step 6:
-------
Add this Function to your code:
Code
Private Function ReadExeFromResources(ByVal filename As String) As Byte()
Dim CurrentAssembly As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly()
Dim Resource As String = String.Empty
Dim ArrResources As String() = CurrentAssembly.GetManifestResourceNames()
For Each Resource In ArrResources
If Resource.IndexOf(filename) > -1 Then Exit For
Next
Dim ResourceStream As IO.Stream = CurrentAssembly.GetManifestResourceStream(Resource)
If ResourceStream Is Nothing Then
Return Nothing
End If
Dim ResourcesBuffer(CInt(ResourceStream.Length) - 1) As Byte
ResourceStream.Read(ResourcesBuffer, 0, ResourcesBuffer.Length)
ResourceStream.Close()
Return ResourcesBuffer
End FunctionStep 7:
-------
Now, I'm sure that MOST of you coders declare the "stub" As String. This is going to change now. Declare it As Byte(), like this:
Code
Dim stub As Byte()Code
FileOpen(1, Application.ExecutablePath, OpenMode.Binary, OpenAccess.Read)
stub = Space(LOF(1))
FileGet(1, stub)
FileClose(1)Code
stub = ReadExeFromResources("the name of the stub in the resources, with extension")Step 8:
-------
After the above replacement, an error in the error list will appear, warning you that "&" cannot be used with 1-dimensional array of Byte and String.
For that reason, we're going to change this code:
Code
FilePut(2, stub & fileSplit & cryptedFile & etc...)Code
FilePut(2, stub)
FilePut(2, fileSplit & cryptedFile & etc...)This finishes our tutorial for making a built-in stub!
Hope you learned something from it!
Enjoy!!



