News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

RCSC and .RES

Started by Nordwind64, September 12, 2011, 02:24:08 PM

Previous topic - Next topic

Nordwind64

Hi!

Doese anybody know, if a resource-table rcsc in a PE-File has the same structur as a .res file? Are there identical?
Or are there big diffences?

Sorry for my bad english...  :P
Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink

dedndave

can't say that i know the answer for sure
but it looks like it is the same thing
if you use PoLink to build an EXE, it uses the RES file directly
also, ResHacker seems to open it and recognize it as it would an rsrc section   :P

dedndave

after looking a little closer, i notice that the RES file has a header of sorts
that, and the fact that things seem to be rearranged
for example, the icon is placed first in the EXE while it is not in the RES
that is probably to make things easier for explorer.exe to find the icon

Nordwind64

Ah, ok. Thank you. Does anbody know a deep going tutorial about that? I want to rebuild exe-files with new resources from a res-file by my IDE. Using APi UpdateResource will make thinks harder.  ::)
Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink


wjr

As far as the individual resources go, yes, identical format there, but as mentioned different for the overall structure.

A RES files has a simple layout with the RESOURCEHEADER 'structure'. I'm going to go with big differences, as the rsrc section has a more complex set of various Directory, Data, and possible String entries, which can also have differences in arrangement depending upon the linker used...

Nordwind64

Ok, thanks. Seems, it's really better to enumerate the complete res-file and add each resource by UpdateResource. I will try that. Thank you for the links!

:thumbu
Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink

Nordwind64

#7
GoRG is able to build a .res and an .obj (coff) file from a .rc-resourcescript. On MSDN I readed: The linker reformats the .res file into a resource object file and then links it to the executable file of an application. Could it be, the obj is the same as the resource table rcsc?

EDIT: Looking with a hexeditor it seems, the coff-object was completly build in by the linker as rcsc-table.  :P
Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink

HenrySmblr

You first need a resource script file:

mywin.rc
#include "resource.h"
IDI_ICON                ICON    DISCARDABLE     "MYFIRSTI.ICO"


Then you should, of course, have the resource header file which will be also referenced in your source file
#define IDI_ICON    101


You should place your icon file in the same directory as the rc file. Otherwise, it will not add the icon to the
resource file.

rc.exe mywin.rc

That should produce a mywin.res file.

You'll need to include the resource.h file in your source file for your executable so that your compiler
knows the integer value of your icon.

And then you'll need the appropriate code in your .asm file to load the icon as a resource. Use the LoadIcon API
to load the icon. You'll need to implement this code when you register the Window Class. And also in the
Window Procedure in the WM_CREATE event. But basically, you'll need the handle to the window and use the
following syntax: LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON) ;

Then after compiling your object file, you'll link the obj and the resource file together to form an executable.

link /subsystem:windows mywin.obj mywin.res

And that should do it.




jcfuller

I'm not sure but this may do what you want?
http://basic-compiler.com/download/index.php?dir=&file=LinkRes2Exe.zip
It was written in bcx.
I've used it to replace and add res files to exe's.
Handy little utility
James

Nordwind64

@HenrySmblr: Yes, you're right, thanks. That is the best technique. But for an advanced function in my IDE I'm looking for a technique to insert resources after an exe has builded.  :wink

@jcfuller: I think, that's exactly what I'm looking for! Thank you. :-)
Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink

BATSoftware

I wrote a resource hacker program than reads, extracts and inserts into a PE .rsrc section. It can be downloaded and is free.

As for the format of a .rsrc section in a PE file, it is a tree with 3 levels(top to bottom): TYPE, NAME and LANGUAGE. The actual resource data is contained at the lowest level - LANGUAGE and will be the data portion of the .RES object. The NAME section is the name/ID of the resource, while the TYPE section is a an array of pointers to the NAME section. Strings for the TYPE, NAME and LANGUAGE levels are store separately at the end of the .rsrc section.

http://home.comcast.net/~batsoftware/RES2RC/htm/RES2RC.htm

ToutEnMasm

BATHack
Quote
Sorry, the page you were looking for could not be found.
Suggested Actions
Check the URL that you have typed and retry.

Nordwind64

Thanks, folks!  :thumbu
I rewrote the code from jcfuller for my own and it works very fine.  :bg

@BATSoftware: The link is broken, sorry.
Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink