Click to See Complete Forum and Search --> : Creating a binary
Chiesi
June 21st, 2010, 06:57 PM
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?
olivthill2
June 22nd, 2010, 04:54 AM
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.
Chiesi
June 22nd, 2010, 06:38 AM
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.
hoxsiew
June 22nd, 2010, 08:46 AM
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.
Igor Vartanov
June 22nd, 2010, 02:25 PM
If i write the hexcode in it, it doesnt work.I'd like to ask what is the "hexcode" you mentioned already twice here?
S_M_A
June 22nd, 2010, 02:29 PM
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...
Chiesi
June 22nd, 2010, 05:15 PM
I'd like to ask what is the "hexcode" you mentioned already twice here?
Well what i did was, i made a simple program
#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?
Igor Vartanov
June 23rd, 2010, 01:05 AM
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):
cl.exe mycoolprogram.cpp /link /out:coolprog.exe
GameZelda
June 25th, 2010, 05:22 PM
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.
Igor Vartanov
June 26th, 2010, 06:36 AM
Oh, yes, now I see I was wrong. Sorry.
Chiesi
June 30th, 2010, 10:20 AM
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 :(
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.