Note: This program is a small game written in flash and released as an EXE file (such as the famous Game "mechanical Maze"). It is a pure entertainment game, if you are playing with it, you will not talk about the algorithm. You will understand the code. Running Environment Visual Studio C ++ 2005; directly add the code
# Include "stdafx. H"
# Include <windows. h>
// SWF file toys
Typedef struct tagswfid {
Unsigned long int ID;
Unsigned long int swffilesize;
} Swfid;
Int _ tmain (INT argc, _ tchar * argv [])
{
// Toy Program 2 ---- convert an executable file EXE into a SWF file. For some games written in flash and finally published as EXE files, this program can automatically strip the SWF File
// Joke program, a fool's day gift, but absolutely available
// The executable SWF file to be converted (suffix. .exe)
Const char iswffilename [] = "samorost2.exe"; // original SWF File
Handle hfile = createfile (iswffilename, generic_read, file_assist_read, null, open_existing,
File_attribute_normal, null );
If (hfile! = Invalid_handle_value)
{
Int nfilesize = getfilesize (hfile, null );
Setfilepointer (hfile, nfilesize-8, null, file_begin );
Swfid;
DWORD numberofbytesread;
If (readfile (hfile, & swfid, 8, & numberofbytesread, null ))
{
If (numberofbytesread = 8 & swfid. ID = 0xfa123456)
{
// Move to the SWF file header and generate a new SWF File
Setfilepointer (hfile, nfilesize-swfid.swf filesize-8, null, file_begin );
Unsigned char * buffer = NULL;
Buffer = (unsigned char * datagmalloc(swfid.swf filesize + 16 );
Readfile (hfile, buffer, swfid.swf filesize, & numberofbytesread, null );
Const char outputfile [] = "outswffile.swf"; // output SWF File
Handle hswffile = createfile (outputfile, generic_write, 0, null, create_always, file_flag_write_through, null );
If (hswffile! = Invalid_handle_value)
{
DWORD nwritebytes;
Writefile (hswffile, buffer, swfid.swf filesize, & nwritebytes, null );
Closehandle (hswffile );
}
Free (buffer );
}
}
Closehandle (hfile );
}
Return 1;
}
The program is relatively small and purely entertaining.