The MASM Forum

General => The Workshop => Topic started by: xiahan on June 07, 2012, 05:38:22 AM

Title: rsrc section any explanation
Post by: xiahan on June 07, 2012, 05:38:22 AM

anyone can give me some doc about how rec file is embedded into the exe and how the CONTROL kind of statements to form a control in  the final UI
thanks ! :biggrin:
Title: Re: rsrc section any explanation
Post by: Mr Hippy on June 07, 2012, 05:43:17 AM
The resource-definition script is compiled. A linker then puts the compiled resources into the executable's resource segment.

Here are the resource-definition statements: http://msdn.microsoft.com/en-us/library/windows/desktop/aa381043%28v=vs.85%29.aspx

It's easier to use a visual resource editor (Visual Studio) than it is to write out the statements by hand.
Title: Re: rsrc section any explanation
Post by: xiahan on June 07, 2012, 06:16:28 AM
first i confess i'm a boy like to broke up a electronic device rather than just use it

i know there are many good UI designes and know how to use it

i want to know how the control is formed?

must be CreateWindow stuff any help doc?
Title: Re: rsrc section any explanation
Post by: qWord on June 07, 2012, 06:41:45 AM
The dialogs are described by so called "dialog box templates", which can be created at runtime or loaded from the resource section: About Dialog Boxes (http://msdn.microsoft.com/en-us/library/windows/desktop/ms644994(v=vs.85).aspx#templates)
Title: Re: rsrc section any explanation
Post by: MichaelW on June 07, 2012, 07:41:22 AM
The MASM32 package includes a system of macros (see \masm32\include\dialogs.inc and \masm32\help\imdialog.chm) that allow you to easily construct a dialog template in allocated memory, and then create a modal or modeless dialog from the template. See  DialogBoxIndirectParam (http://msdn.microsoft.com/en-us/library/windows/desktop/ms645461(v=vs.85).aspx) and  CreateDialogIndirectParam (http://msdn.microsoft.com/en-us/library/windows/desktop/ms645441(v=vs.85).aspx).

The attachment contains a simple example.

Title: Re: rsrc section any explanation
Post by: dedndave on June 07, 2012, 10:13:55 AM
i don't think he has a problem creating them, Michael
i think he wants to know how they are stored in the resource section of the PE
and how the OS interprets that section

we rarely deal with it - we let the OS handle it   :P
you can use a program like ResHacker or something to examine them
but - that doesn't really show you the low-level implementation
Title: Re: rsrc section any explanation
Post by: MichaelW on June 07, 2012, 10:20:41 AM
AFAIK they are stored in at least more or less the same format, whether in a resource section or in a memory template.

The attachment is my crude attempt to compare a resource template to an in-memory template. I'm out of time to work on this, but they at least look very similar.
Title: Re: rsrc section any explanation
Post by: hutch-- on June 07, 2012, 11:25:28 AM
If I remember correctly Donkey posted a set of structures for the RES file format some years ago and I think this type of data is probably what xiahan is after. It seems to have a directory tree type structure with various components stored within the dialog at addresses accessible from the tree.
Title: Re: rsrc section any explanation
Post by: P1 on June 07, 2012, 12:36:42 PM
Quote from: xiahan on June 07, 2012, 05:38:22 AManyone can give me some doc about how rec file is embedded into the exe and how the CONTROL kind of statements to form a control in  the final UI thanks ! :biggrin:
http://www.madwizard.org/programming/snippets?id=55 (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 ???

Regards,  P1   8)
Title: Re: rsrc section any explanation
Post by: xiahan on June 07, 2012, 06:11:40 PM
seems like many of us are concerned about this and have made some explore ,aha

i also found MichaelW's achievements, as showing here

00000BF0  40  00  C8  10  01  00  06  00  06  00 C4  00  72   00  00  00
00000C00 00  00  46  00  6F  00  6E  00  74  00  20  00  4D  00  65  00    F  o  n  t    M  e
00000C10 6E  00  75  00  00  00  08  00  00  00  00  00  4D  00  53  00 n u               M  S
00000C20 20  00  53  00  61  00  6E  00  73  00  20  00  53  00  65  00    S  a  n  s    S   e
00000C30 72  00  69  00  66  00  00  00  00  00  00  00  00  02  00  00 r  i   f
00000C40 04  10  01  50  02  00  00  00  BE  00  5E  00  E9  03  00  00      P   
00000C50 FF   FF  81  00  00  00  00  00  00  00  00  00  00  00  00  00

1000 DIALOGEX 6,6,196,114
CAPTION "Font Menu"
FONT 8,"MS Sans Serif"
STYLE 0x10C80000
EXSTYLE 0x00000080
BEGIN
  CONTROL "",1001,"Edit",0x50011004,2,0,190,94,0x00000200
END

the above hex number are dumped from a exe file you can see that from [00000BF0] 40 00 C8 10 01 00 06 00 06 start
the 06 is just 6 the C4 00 7200 are just 196 114

at run time these parameters are possible load by the OS and execute to form the Dialog ,this part of work is what i what to know

i search the google there have resource directory tree(must be the key to the underground work ) 
Title: Re: rsrc section any explanation
Post by: sinsi on June 07, 2012, 06:54:59 PM
All you need is Microsoft's version of a PE file
http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx (http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx)
Describes the layout of the .rsrc section.
Title: Re: rsrc section any explanation
Post by: dedndave on June 08, 2012, 12:38:02 AM
here it is in PDF form...

http://masm32.com/board/index.php?topic=240.0 (http://masm32.com/board/index.php?topic=240.0)
Title: Re: rsrc section any explanation
Post by: xiahan on June 08, 2012, 01:22:11 AM
Quote from: sinsi on June 07, 2012, 06:54:59 PM
All you need is Microsoft's version of a PE file
http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx (http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx)
Describes the layout of the .rsrc section.
thanks :greensml:
Title: Re: rsrc section any explanation
Post by: Dubby on June 09, 2012, 02:03:22 PM
Also check "Peview" tool by Wayne J. Radburn here:
http://www.magma.ca/~wjr/
Title: Re: rsrc section any explanation
Post by: xiahan on June 14, 2012, 01:00:26 AM
i checked the program, it seems like what i have looked for. thanks so much Dubby! :bgrin: