|
-
June 21st, 2010, 06:57 PM
#1
Creating a binary
Hey, i need to create an executable somehow, preferably by using its hexcode, how would i possibly do that in c++ ?
Lets say i take the hexcode of notepad.exe, how would i be able to create it?
-
June 22nd, 2010, 04:54 AM
#2
Re: Creating a binary
Open a file in binary mode, with fopen() and "wb" flag. Write data in your file with fwrite(). Close your file with fclose().
Then you will ask yourself what data shall I write inside the file. Then, you will discover it is easier to use a compiler and a linker.
If you want to create a virus, then don't.
-
June 22nd, 2010, 06:38 AM
#3
Re: Creating a binary
I know how to write to a file... i just dont know what to write in there.
If i write the hexcode in it, it doesnt work.
And lol at the writing a virus part, yes every person on the internet whos asking for help is trying to write a virus.
Stereotypical bullcrap.
-
June 22nd, 2010, 08:46 AM
#4
Re: Creating a binary
The old .com image executable is the closest you'll get to that and I don't even know if modern OS's support it anymore.
-
June 22nd, 2010, 02:25 PM
#5
Re: Creating a binary
If i write the hexcode in it, it doesnt work.
I'd like to ask what is the "hexcode" you mentioned already twice here?
Best regards,
Igor
-
June 22nd, 2010, 02:29 PM
#6
Re: Creating a binary
I would expect the com format to be supported in all OS's that support 16-bit exe's. After all, it's not that much that differ between them especially not compared with a tiny model exe.
As olivthill indicated, there's a lot of stuff you have to write into that file to get it to be executable. You could start off by googling on details of the PE header for instance. All that stuff has to be written into the file and then there's the actual program...
-
June 22nd, 2010, 05:15 PM
#7
Re: Creating a binary
 Originally Posted by Igor Vartanov
I'd like to ask what is the "hexcode" you mentioned already twice here?
Well what i did was, i made a simple program
Code:
#include <iostream>
#include <conio.h>
int main()
{
std::cout << "watever" << std::endl;
_getch();
}
opened it up in hex editor
http://paste2.org/followup/888430
and tried to paste it to a txt which did not work as expected.
So i googled for hex to binary which only made converters pop up which was expected so i came here..
Any suggestions how i could get that to work?
-
June 23rd, 2010, 01:05 AM
#8
Re: Creating a binary
Okay, what I see from your description is: you have a text (program code in C++), you convert the text to another text with hexadecimal notation, you write that what you finally get to a file... and expect the file working like executable binary???
Man, you have a lot of things to know about how C++ program text becomes executable module. Try to get some reading on compiling and linking.
Any suggestions how i could get that to work?
First, you install some C++ compiler, then you build your program, like this (VC++ sample):
Code:
cl.exe mycoolprogram.cpp /link /out:coolprog.exe
Last edited by Igor Vartanov; June 23rd, 2010 at 01:11 AM.
Best regards,
Igor
-
June 25th, 2010, 05:22 PM
#9
Re: Creating a binary
I think that what he's trying to do is to convert a text file which contains an executable binary in hexadecimal code to a executable binary (like the one he put on paste2.org).
Open the input and the output files (remember that for the output file you'll need to set binary mode), then just read each pair of characters from the input, convert from hex string to a byte, and write it to the output.
Anyway, I'm not sure about why would he want to do that.
-
June 26th, 2010, 06:36 AM
#10
Re: Creating a binary
Oh, yes, now I see I was wrong. Sorry.
Best regards,
Igor
-
June 30th, 2010, 10:20 AM
#11
Re: Creating a binary
 Originally Posted by GameZelda
I think that what he's trying to do is to convert a text file which contains an executable binary in hexadecimal code to a executable binary (like the one he put on paste2.org).
Open the input and the output files (remember that for the output file you'll need to set binary mode), then just read each pair of characters from the input, convert from hex string to a byte, and write it to the output.
Anyway, I'm not sure about why would he want to do that.
Thanks!
Thats exactly what i needed, and thanks to the others for trying to understand me
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|