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?
Printable View
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?
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.
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.
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.
I'd like to ask what is the "hexcode" you mentioned already twice here?Quote:
If i write the hexcode in it, it doesnt work.
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...
Well what i did was, i made a simple program
opened it up in hex editorCode:#include <iostream>
#include <conio.h>
int main()
{
std::cout << "watever" << std::endl;
_getch();
}
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?
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.
First, you install some C++ compiler, then you build your program, like this (VC++ sample):Quote:
Any suggestions how i could get that to work?
Code:cl.exe mycoolprogram.cpp /link /out:coolprog.exe
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.
Oh, yes, now I see I was wrong. Sorry.