Hi,
Is there any way or code to create another .exe file during program execution? If it's possible, can i hard-code all the codings needed in the new executable?
Hi,
Is there any way or code to create another .exe file during program execution? If it's possible, can i hard-code all the codings needed in the new executable?
guess what a compiler is an example of...
What about packing all the binary in the code, and then output it as a file and rename it as .exe ? or are there any other ways?
Well, theoretically you could write a file within a program (containing lots of MQ@% characters) and save it as binary and naming it XXX.exe. However I highly doubt there is an easy way to do this.
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
i got all these unterminated characters errors during compile ii think it's because the binary is too long.
I tried save the funny character into a text file, read it one character at a time and output it as .exe but output is incorrect.
>I tried save the funny character into a text file, read it one character at a time and output it as .exe but output is incorrect.<
Did you open the new file in text or binary mode? Anyway, to answer your first question, you could have an array of hexidecimal numbers, each representing an ASCII character. Just write these to a file (that was opened in binary mode). Give it the appropriate extension and viola.
i dunno how to do hex. And i did open the new file using mode "wb"
thnx
Unless you're going to be modifying the way the file is written, and its all constants, just copy and paste each line of the file (the best option would be EDIT.com from Dos,), and then use each of the lines in between ""'s in a printf or cout statement.
>i dunno how to do hex. And i did open the new file using mode "wb"<
If you can't do hex, just do an array of ASCII characters (decimal form). I don't even know why I said hex in the first place - decimal would do just as good.
>then use each of the lines in between ""'s in a printf or cout statement.<
That wouldn't work because an executable file has characters that don't like to be treated as C/C++ strings (null characters, quotes, those weird looking characters, etc.). That's why hexadecimal or decimal would be a good choice.
Okay, here's a sample I whipped up. I hope this is what you were talking about. Sorry I used hex, but it was the easiest for me. If it's too much of a problem, I can fix it.
You'll notice (when you compile and run it) that it creates a file named "program.exe". Run it. It's the winhelp.exe program found in Windows, so you'll need that devil to run it. Hope this helps.
hey that worked perfectly. One question. How do u convert decimal stuff to hex, in other words, how do u know the hex equivalent. ALso, do u havta use array? And did u copy and paste each element? Coz there are commas between each one. Anyway that was exactly what i wanted and i'll appreciate it if u tell me how u did it.
thnx
First a wrote simple program that converts a program into a text file that is hexadecimal with commas. Then I just copied that into an array.
This is the program that converts an executable to user readable hexadecimal:
You have to open the file it creates and delete ", ffff, " at the end. Then copy the whole file into an array.Code:#include <stdio.h> int main() { FILE *file; FILE *file2; signed short int ch = 0; file = fopen("program.exe", "rb"); file2 = fopen("program.txt", "w"); while(ch != EOF) { ch = fgetc(file); fprintf(file2, "%x, ", ch); } fcloseall(); return 0; }
why is there ffff?
also, is it possible to make a program delete itself after executation?
Aghh....so that's what your your up to........Originally posted by Nutshell
also, is it possible to make a program delete itself after executation?
Just out of curiosity..........
But i do hav one application. Say i want to let my friend have a look at a project i've done - a normal school project in a word file. But i don't want him to copy and paste anything in it. SO if i convert the text file into an image file and display in a program which deletes itself after say 5 minutes then he won't have time to do anything except having a look?
pls i wanna know, and i have no bad intention what so ever