The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,595 other followers

Resource decompiler – converting/decompiling/extracting .RES files into .RC files and separate resources

Posted by jpluimers on 2016/07/07

via: Resource decompiler

One day I’m going to need ResourceHacker as it has an -extract option to extract resources.

The above link even has a batch file that can server as a start automating that process:

@echo off
set file="GeneSys"

if exist %file%.rc del %file%.rc

ResHacker.exe -extract %file%.res, %file%.rc,  Bitmap,,
ResHacker.exe -extract %file%.res, temp.rc,  Icon,,
type temp.rc >>%file%.rc
ResHacker.exe -extract %file%.res, temp.rc,  Dialog,,
type temp.rc >>%file%.rc
ResHacker.exe -extract %file%.res, temp.rc,  Menu,,
type temp.rc >>%file%.rc
ResHacker.exe -extract %file%.res, temp.rc,  StringTable,,
type temp.rc >>%file%.rc
ResHacker.exe -extract %file%.res, temp.rc,  Accelerators,,
type temp.rc >>%file%.rc
ResHacker.exe -extract %file%.res, temp.rc,  VersionInfo,,
type temp.rc >>%file%.rc
del temp.rc

I save it as extract.bat and a commandline usage: extract GeneSys will extract all the resources from GeneSys.res

–jeroen

PS: as the MASM forum sometimes nags with logins, I saved the above page in the wayback machine.

I’ve verified that [WayBack] ResourceHacker and the downloads ([WayBack] installer and [WayBack] portable) are there too.

PS: 20190507

In the mean time, the commandline syntax changed, and I discovered that resource extraction requires the target file to be of type .rc (otherwise you get an error Error: Inappropriate file extension for this resource type.
Success!
) with no output file at all, and that binary resources (including any RCDATA) are extracted as binary files..

The syntax is this:

>D:\bin\bin\resource_hacker\ResourceHacker.exe -help commandline


====================================
Resource Hacker Command Line Syntax:
====================================

Command line instructions ...

Switch     Parameter
=========  ====================================================================
-open    : filename - the name of the file that is to be modified ...
           Windows PE file (*.exe, *.dll etc) or resouce file (*.res or *.rc)
-save    : filename - the new name of the modified or newly created file ...
           either a modified opened file or an extracted resource
-resource: filename - contains a resource being added to the opened file.
-action  : action to be performed on the opened file
           add             - add a resource, fails if it already exists
           addoverwrite - add a resource, overwrites if it already exists
           addskip        - add a resource, skips if it already exists
           compile        - compiles a text resource file (*.rc)
           delete          - delete a resource
           extract         - extract a resource
           modify         - modify a resource
           changelanguage(langID) - changes the language of ALL resources (nb: avoid any spaces)

-mask    : resource mask - Type,Name,Language
           commas are mandatory but each of type, name & language are optional
-log     : filename or CONSOLE or NUL
           CONSOLE: can be abbreviated to CON
           logs details of the operation performed
           switch is optional - if omited, defaults to resourcehacker.log
-script  : filename - contains a multi-command script, NOT a resource script
           for more info: -help script
           other switches are ignored.
-help    : options - commandline or script (always logged to CONSOLE)
           other switches are ignored.
=========  ====================================================================

Notes:
1. Switch identifiers may be abbreviated down to a single char (eg -res or -r).
2. Switch instructions do not have to be in any particular order.
3. File names that contain spaces must be encased within double quotes.
4. The changelanguage action changes the language ID of ALL resources irrespective of any mask.

Extracting all resources is like this:

D:\bin\bin\resource_hacker\ResourceHacker.exe -open "D:\Path with spaces\Binary.res" -save "D:\Path with spaces\Resources.rc" -action extract -mask

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: