 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Jorg hi I post too much
Reputation: 7
Joined: 24 Dec 2007 Posts: 2276 Location: Minnesota
|
Posted: Tue Jan 27, 2009 5:08 pm Post subject: How do you convert an EXE to binary string? [VB.NET] |
|
|
How do you convert an EXE to binary string in vb.net? And how do you convert binary string to an EXE. I want to do this so I store my exe in my program and then create it and run it. I will offer SOME REPS!
_________________
CEF will always stay alive. |
|
| Back to top |
|
 |
b6ooy Grandmaster Cheater
Reputation: 0
Joined: 21 Sep 2006 Posts: 653
|
Posted: Tue Jan 27, 2009 5:29 pm Post subject: |
|
|
Lol ...
what are you going to do with 0 and 1 ?
the only way i think is reading each 4 bytes from the Exe file and convert them to binary then store the binary code in a file .
and it will be x8 the Exe size because 1 byte = 8 bits .
|
|
| Back to top |
|
 |
Jorg hi I post too much
Reputation: 7
Joined: 24 Dec 2007 Posts: 2276 Location: Minnesota
|
Posted: Tue Jan 27, 2009 5:31 pm Post subject: |
|
|
| b6ooy wrote: | Lol ...
what are you going to do with 0 and 1 ?
the only way i thing is reading each 4 bytes from the Exe file and convert them to binary then store the binary code in a file .
and it will be x8 the Exe size because 1 byte = 8 bits . |
Can you write me the code to convert an exe to 4byte, and then back?
I want it to store the bytes in a file, then I will encrypt them and then read the 4bytes, unencrypt them and convert it back to an exe then save it?
_________________
CEF will always stay alive. |
|
| Back to top |
|
 |
BanMe Master Cheater
Reputation: 0
Joined: 29 Nov 2005 Posts: 375 Location: Farmington NH, USA
|
Posted: Tue Jan 27, 2009 5:34 pm Post subject: |
|
|
i dont know VB.NET at ALL!! im serious... but i can offer you a solution
open Olly
goto very top of code select whole code
right click and select Edit Binary click the ctrl-A ctrl-C
goto vb.net paste it in there
the use BinaryReader/and BinaryWriter
here a example i found..for reader
| Code: |
Public Shared Sub Main
Dim fs As System.IO.FileStream
Dim r As System.IO.BinaryReader
Dim buffer(100) As Char
Dim mylength As Long
fs = New System.IO.FileStream("test.txt", IO.FileMode.OpenOrCreate)
r = New System.IO.BinaryReader(fs)
mylength = fs.Length
If mylength > 100 Then
mylength = 100
End If
r.Read(buffer, 0, mylength)
//Console.WriteLine(buffer) pass the string to Writer Here..maybe.. ;)
r.Close()
fs.Close()
End Sub
|
and heres a example for Writer
| Code: |
Public Shared Sub Main
Dim fs As System.IO.FileStream
Dim w As System.IO.BinaryWriter
Dim buffer As String
Dim c As Char
c = Chr(9)
fs = New System.IO.FileStream("test.exe", IO.FileMode.OpenOrCreate)
w = New System.IO.BinaryWriter(fs)
w.Seek(0, System.IO.SeekOrigin.Begin)
w.Write("writing data via BinaryWriter")
w.Close()
fs.Close()
End Sub
|
|
|
| Back to top |
|
 |
Jorg hi I post too much
Reputation: 7
Joined: 24 Dec 2007 Posts: 2276 Location: Minnesota
|
Posted: Tue Jan 27, 2009 6:05 pm Post subject: |
|
|
| BanMe wrote: | i dont know VB.NET at ALL!! im serious... but i can offer you a solution
open Olly
goto very top of code select whole code
right click and select Edit Binary click the ctrl-A ctrl-C
goto vb.net paste it in there
the use BinaryReader/and BinaryWriter
here a example i found..for reader
| Code: |
Public Shared Sub Main
Dim fs As System.IO.FileStream
Dim r As System.IO.BinaryReader
Dim buffer(100) As Char
Dim mylength As Long
fs = New System.IO.FileStream("test.txt", IO.FileMode.OpenOrCreate)
r = New System.IO.BinaryReader(fs)
mylength = fs.Length
If mylength > 100 Then
mylength = 100
End If
r.Read(buffer, 0, mylength)
//Console.WriteLine(buffer) pass the string to Writer Here..maybe.. ;)
r.Close()
fs.Close()
End Sub
|
and heres a example for Writer
| Code: |
Public Shared Sub Main
Dim fs As System.IO.FileStream
Dim w As System.IO.BinaryWriter
Dim buffer As String
Dim c As Char
c = Chr(9)
fs = New System.IO.FileStream("test.exe", IO.FileMode.OpenOrCreate)
w = New System.IO.BinaryWriter(fs)
w.Seek(0, System.IO.SeekOrigin.Begin)
w.Write("writing data via BinaryWriter")
w.Close()
fs.Close()
End Sub
|
|
Wait does it just write 1 line or the whole thing?
_________________
CEF will always stay alive. |
|
| Back to top |
|
 |
BanMe Master Cheater
Reputation: 0
Joined: 29 Nov 2005 Posts: 375 Location: Farmington NH, USA
|
Posted: Tue Jan 27, 2009 7:06 pm Post subject: |
|
|
i dont know vb.net but i am a good linguist
so based on my analysis of words (and code knowledge)
i would say it reads a 100 bytes on the reader.. and on the Write it Seeks the begining of the file (SeekOrigin) and writes to it.
you will have to modify all this behavior...
i would suggest using ImageMapAndLoad and using the structure along with Binary Reader to allocate a buffer of ImageSize and pass fs FileStream to Writer ..
Regards BanMe
|
|
| Back to top |
|
 |
FerrisBuellerYourMyHero Master Cheater
Reputation: 0
Joined: 14 Feb 2007 Posts: 401 Location: Inside your <kernel>
|
Posted: Wed Jan 28, 2009 2:20 am Post subject: |
|
|
| b6ooy wrote: | Lol ...
what are you going to do with 0 and 1 ?
the only way i think is reading each 4 bytes from the Exe file and convert them to binary then store the binary code in a file .
and it will be x8 the Exe size because 1 byte = 8 bits . |
Your idea is wrong, and your math is wrong...
Why would you read it 4 bytes at a time? Not every executable is exactly dividable by four bytes. I would read 1 byte at a time... You can't change a dword array into a different type of array in the middle of it. Stick with a byte array... But actually read is the wrong word... I read the whole file at once, then work with each byte individually...
convert the exe file into binary? The exe is already binary, he's trying to convert the binary into a STRING which describes the binary so that he can embed the binary in his application.
Yes 8 bits == 1 byte, but that doesn't make the resulting string be 8x the size? how did you come up with that?
Say you have one binary byte for example... lets say
01
now the value of that byte is 1, it is in binary form, now if you write that into a text file, save it, then open up the text file in a hex editor it will look like:
30 31
that is the binary data of the string...
30 represents a string 0
31 represents a string 1
so your string representation of your binary will be 2x the size of just the binary plus your languages syntax to define the byte array...
Now I don't code in VB.NET, but I have made this sorta thing in C++... In C++ I define my byte arrays as:
| Code: |
unsigned char BinaryData[3] = {0x4D, 0x5A, 0x90};
|
where between the []brackets is the size of your binary in bytes, and between the {}brackets is where the string formatted binary goes. 0x to represent that its in hex...
So I'm not sure how you define a byte array in VB.net but I looked it up and is this maybe it?
| Code: |
Dim BinaryData(3) as Byte = {&H4D, &H5A, &H90}
|
Would that work? I guess in VB you can't do 0x, so you do &H instead...
Well anyway you just put that array into your source code, then once you build your program, the BINARY will be embedded within it. Its only in string format in your source, when you compile, its stored as binary... You can then just dump the binary out to a file and do anything you want with it after. In your case its an exe so you'd probably run it! It is going to increase your executable size though, by the size of the binary your embedding in it obviously...
I have already made an application like this, all I had to do was add the ability for vb.net hopefully that's the right way you define arrays in vb.net...
It works very simply, you run it and type a file path, I usually just put the file in the same folder as it so you just type a file name instead of a long path... Then it will now ask you whether you want to create a C++ array or a VB.net array!
type 1 for c++ or 2 for vb.net and hit enter...
I tested it with a numbers.txt which just contained "123456789" because using an actual exe would be too big of a string It wouldn't of let me post it here if I tried...
Here's what the C++ array comes out as... I know this ones right because I've used this app before to embed things in my programs...
| Code: |
// FerrisSoft
// Source File: numbers.txt
// Size: 9 / 0x00000009 bytes
//<--
unsigned char BinaryData[9] =
{
0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39
};
//-->
|
This is how the VB.NET one comes out... ' is comment in vb i think...
| Code: |
' FerrisSoft
' Source File: numbers.txt
' Size: 9 / 0x00000009 bytes
'<--
Dim BinaryData(9) as Byte =
{
&H31, &H32, &H33, &H34, &H35, &H36, &H37, &H38, &H39
}
'-->
|
So try it and see if it works...
http://www.java2s.com/Code/VB/File-Directory/UseBinaryWritertostoreinformationintoabinaryfile.htm
That should help you with writing the binary to a file ^^
It was created in C++ because I'm not a VB person so you'll have to deal with that! Source Code + Binary Executable attached...
_________________
You know, life moves pretty fast. If you don't stop and look around once in a while, You could miss it!
 |
|
| Back to top |
|
 |
Jorg hi I post too much
Reputation: 7
Joined: 24 Dec 2007 Posts: 2276 Location: Minnesota
|
Posted: Wed Jan 28, 2009 3:38 pm Post subject: |
|
|
Ahh thanks! Pwus rep.
EDIT: Can someone convert this project?
_________________
CEF will always stay alive.
Last edited by Jorg hi on Thu Jan 29, 2009 4:50 pm; edited 1 time in total |
|
| Back to top |
|
 |
Stupidfunny Newbie cheater
Reputation: 0
Joined: 14 Jan 2007 Posts: 20 Location: Christchurch, New Zealand
|
Posted: Thu Jan 29, 2009 4:27 pm Post subject: |
|
|
| In addition to converting a EXE to a byte array, does anyone know how to dynamically embed stuff like this or adding a resource at runtime?
|
|
| Back to top |
|
 |
Jorg hi I post too much
Reputation: 7
Joined: 24 Dec 2007 Posts: 2276 Location: Minnesota
|
Posted: Thu Jan 29, 2009 4:49 pm Post subject: |
|
|
Adding a resource at runtime? Well to add a control in VB.NET, for current form do...
Put this code after you declare your class.
| Code: |
Public textbox1 As New TextBox With {.Location = New Drawing.Point(0, 0), .size = New Drawing.Size(100, 20), .Parent = Me, .Text = "WOW WOW WOW!"}
|
I don't know how to add events at runtime so I do this to clear it,
modify it to your own needs 0.0
| Code: |
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
textbox1.Text = ""
End Sub
|
You can keep on doing this but it would be hard to keep track of the textbox names.
_________________
CEF will always stay alive. |
|
| Back to top |
|
 |
Stupidfunny Newbie cheater
Reputation: 0
Joined: 14 Jan 2007 Posts: 20 Location: Christchurch, New Zealand
|
Posted: Wed Feb 04, 2009 11:28 pm Post subject: |
|
|
What I mean by resource is like a embedded exe file, any ideas?
EDIT:
No need to tell me about basic stuff though, VB .NET is my primary programming language.
EDIT2:
To add events:
| Code: | | Public WithEvents textbox1 As New TextBox With {.Location = New Drawing.Point(0, 0), .size = New Drawing.Size(100, 20), .Parent = Me, .Text = "WOW WOW WOW!"} |
EDIT3:
nvm about the question, not a simple way to do it...
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|