Detach the EXE file from the SWF File

Source: Internet
Author: User
Tags readfile

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.