The MASM Forum

General => The Campus => Topic started by: xwwwx on August 08, 2012, 05:32:51 AM

Title: Embedding & extracting files in masm.
Post by: xwwwx on August 08, 2012, 05:32:51 AM
I need to create an application that after pressing a button it should extract a few files into the specified location (no it will not extract and execute another .exe file don't worry, it's for a game update, images and some other files I don't even know what they are).

I was thinking about just adding the files encoded with hex, and then using some hex 2 bin function to convert it back and write the file to the disk, would this work?

If not, could someone point me in the right direction on how to create, embed and extract resource files on masm?

You may be wondering why I want to use masm if I don't know what the heck i am doing, well mostly because I want to learn how to use it, and I like the fact that it would use the windows apis without any extra dependency which caused problems to me in the past in c++ with programs not working in some computers.
Title: Re: Embedding & extracting files in masm.
Post by: P1 on August 08, 2012, 06:43:27 AM
http://www.madwizard.org/programming/snippets?id=55

Here is a code snippet, I did a while back to extract a file from resources.  Does this meet your need ???

This is only one of many ways to do this.

Regards,  P1   8)
Title: Re: Embedding & extracting files in masm.
Post by: xwwwx on August 08, 2012, 06:47:52 AM
It does help, thank you.

But how do i ADD a resource in masm?
Title: Re: Embedding & extracting files in masm.
Post by: qWord on August 08, 2012, 06:54:15 AM
You need a resource file (e.g. rsrc.rc), which is processed with the resource compiler rc.exe. The resulting *.res is added to the linker call.
The resource file could be:
QuoteResID RCDATA "whatever.file"
Title: Re: Embedding & extracting files in masm.
Post by: xwwwx on August 08, 2012, 07:01:08 AM
Thanks!!
Title: Re: Embedding & extracting files in masm.
Post by: Vortex on August 09, 2012, 04:20:36 AM
Hi xwwwx,

Another option is to use a tool like fda.exe , File Data Assembler.
Title: Re: Embedding & extracting files in masm.
Post by: hfheatherfox07 on August 10, 2012, 05:17:39 AM
@ xwwwx are you looking for an installer written in masm by any chance? if you embed the files into the rsrc.rc your app.exe will be big!

here is an installer in masm32 that was posted on the old forum --- Easy Installation System   http://code.google.com/p/eis/

Revisions 2-4


Revision 2:

http://code.google.com/p/eis/source/browse/?r=2

Revision 3:

http://code.google.com/p/eis/source/browse/?r=3

Revision 4:

http://code.google.com/p/eis/source/browse/?r=4

Click on the folder called "trunk" .... From there you can navigate to download all sub folders....

you might want to view all the folders carefully so you do not miss any thing that may not be in the release folder , called "_DISTRIBUTE"


Here is the source code that you can download



Revision 2  : http://eis.googlecode.com/svn-history/r2/trunk/_DISTRIBUTE/eissrc1301.RAR

Revision 3  : http://eis.googlecode.com/svn-history/r3/trunk/_DISTRIBUTE/eissrc1301.RAR

Revision 4  : http://eis.googlecode.com/svn-history/r4/trunk/_DISTRIBUTE/eissrc1301.RAR
Title: Re: Embedding & extracting files in masm.
Post by: hfheatherfox07 on August 11, 2012, 03:45:14 AM
Here is something that I have not seen before on the Masm forum I have this in my Goodies tool Box and I feel like sharing   :t
Title: Re: Embedding & extracting files in masm.
Post by: Vortex on August 11, 2012, 04:27:07 AM
Hi Hi xwwwx,

Here is an example for you :



include     Extract.inc
include     test.inc

.data

filename    db 'test.htm',0
msg         db 'test.htm is extracted.',13,10,0

.code

start:

    invoke  WriteFileToDisc,ADDR filename,ADDR HtmFile,ln_HtmFile
    invoke  StdOut,ADDR msg
    invoke  ExitProcess,0

END start