Resource extractor plugin

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

User avatar
Athari
Junior Member
Junior Member
Posts: 24
Joined: 2004-01-08, 15:12 UTC

Resource extractor plugin

Post by *Athari »

I've seen plugin that extracts resources, but he has LOTS of disadvantages. So here's mine.

You shouldn't register it for particular extension, instead of it register it for something like "pe_res_dummy". This will allow you to enter self-extracting executables. I think there's no need to get resources of such files.

Plugin can dowloaded from here (211 KB).

EDIT: Suggestions and bug lists send here

Features:

Extracts resources from 32-bit executables (exe, dll, cpl, scr, ocx, bpl...) and resource files (res, dcr).

Detects if file can be opened. So DLL and EXE with any extension will be opened, for example WCX will be opened too. RES files are detected only by extension, they don't have any 'MZ' thing and this causes a lot of errors, hangups etc.

You don't have to look into subdirs, resources with main language are dublicated into main dir of resource type. ('Main': plugin looks for keyboard layouts, then searches resources with such languages. If none found, it searches for language-neutral resource. If it doesn't exist, selects the first in the alphabetical order. Just try, you'll understand what I mean.)

Cursors are with 'cur' extension, Delphi/Builder forms - with 'dfm', icons with 'ico' etc. All files with unknown format can be extracted as binary data with 'bin' extension. It helps to avoid confilct between names when you extract all resources.

Cursors and icons can be extracted as a whole or as individual images. Sub-images of icons and cursors are named by their format, i.e. '16x16 256 Colors' or '48x48 True Color (XP)'. '(XP)' means that icon is 32-bit RGBA (it has alpha channel).

Delphi/Builder form resources are decompiled into text. String tables and version information are decomipled into RC format (I think).

Features that will be added:

Renaming, deleting and adding of resources.

App to set settings. There's plenty of them.

Disadvantages:

Dialogs, menus, accelerator and message tables are not decompiled. I just don't know how to do it. If someone knows, please email me.

Packed files can't be opened, even if some resources aren't packed.

I'm not so sure with string tables' and version's format, but this looks very similar to Borland C++. Language id's are extracted as hex numbers, just because of my lazyness.

To the Author:
Plugin loads the whole file into the memory for faster access. It would be great, if future releases of TC allowed to extract files without calling ReadHeader on each preceding file, just by file name. That would be faster.

Plugins should be able to change user interface, at least add custom commands like 'cm_...'. Some plugins have properties dialog, but I can't add it to toolbar, for example. Packer plugins can't add dialog for options on unpacking at all. Lister plugins should be able to integrate into main menu.
Last edited by Athari on 2004-01-24, 10:30 UTC, edited 1 time in total.
Excuse me for my bad English, my native language is C++
User avatar
djk
Power Member
Power Member
Posts: 1651
Joined: 2003-03-17, 11:33 UTC
Location: Poland
Contact:

Re: Resource extractor plugin

Post by *djk »

Athari wrote:I've seen plugin that extracts resources, but he has LOTS of disadvantages. So here's mine.
Thanks for it.
Athari wrote: Suggestions and bug lists send to athari<at>land.ru
Don't you think it's better to do it here. Just for your convenience - instead of getting report for the same bug from several users you will see one post here :-)
Athari wrote: Features that will be added:
Renaming, deleting and adding of resources.
Waiting for it :-)
DJK
Totally addicted to Total Commander
totalcmd.pl
en.totalcmd.pl
User avatar
Athari
Junior Member
Junior Member
Posts: 24
Joined: 2004-01-08, 15:12 UTC

Post by *Athari »

  • Now resources can be deleted. But I would NOT recommend you to do this using this plugin. Don't use Resource Explorer either, instead use Resource Hacker or other. Resource Explorer is VERY BUGGY. As my plugin is based on its sources, all bugs are copied. TC itself adds some bugs, because no one intended that files in archive can be doubled.

    Sometimes plugin is unable to save exe file after deleting some resources. And sometimes deleting some resources makes plugin unable to read file. Resource Hacker opens it, however. Don't delete the last resource, plugin throws an exception and I couldn't get rid of it.

    If you delete the last resource of particular type, TC doesn't update view. It updates only after entering ".." dir. Also if you enter "Version Info\1" dir, for example, and delete the only resource of that type, you wouldn't be able to exit from file. You'll have to use history (Alt+DOWN ARROW) or enter dir manually (click on the panel title). I'll try to add dirs into the list, but I'm not sure it would help - this will show empty dirs. This happens to simple dirs too when I disable access to them using Discreen, so Author should think about exiting from nonexistent directories.

    Because of all that plugin saves backups with the name "filename.ext.!!!" if you delete resources.
  • I've realised that there's no way to rename file in archive. I hope TC in the future would intend this ability of packers.
  • After adding ability to delete resources I've realized that it is bad idea to add files using plugin. This would cause a lot of errors. Until I find something less buggy, packer wouldn't include this feature.
Except for deleting resources plugin should work correctly. ;)
Excuse me for my bad English, my native language is C++
User avatar
Aezay
Senior Member
Senior Member
Posts: 269
Joined: 2003-02-12, 07:27 UTC
Location: Denmark
Contact:

Post by *Aezay »

Very useful plugin you've made there, I like it :wink:
I think you should include a readme file with the release.

Why is each resource listed both as directory and a file?

I think the resources that a named after their value in hex, should have $ added in front (or 0x Mr C++ man :lol:) just so you can tell the difference.
Of all the planets I've been to, this one is my favorite.
User avatar
Athari
Junior Member
Junior Member
Posts: 24
Joined: 2004-01-08, 15:12 UTC

Post by *Athari »

Why is each resource listed both as directory and a file?
All languages of particular resource are in the dir. The language, that in my opinion :) should be choosen by Windows, is extracted as file. You know, I often just look throgh all resources of executable. If files are extracted from dirs, it is much easier.
I think the resources that a named after their value in hex, should have $ added in front
Wonder what's for you need it. Neither of resource extractors I've got do this... OK, I'll add option to do it.

For now can decompile menus, dialogs, accelerator tables, message tables, toolbars. Detects wav, gif, avi, htm, html, vxd, dib, exe. I'll upload new version soon.
Excuse me for my bad English, my native language is C++
User avatar
Ergo
Senior Member
Senior Member
Posts: 204
Joined: 2003-02-05, 12:20 UTC
Location: Belarus
Contact:

Post by *Ergo »

2Athari
Could you contact me webmaster@wincmd.ru so that to update&upload your plugins to http://wincmd.ru
Wincmd.ru WWW.TOTALCMD.NET
I see that future is near...
User avatar
Athari
Junior Member
Junior Member
Posts: 24
Joined: 2004-01-08, 15:12 UTC

Post by *Athari »

I've uploaded new version at last. :) You can download it from here: http://www.wincmd.ru/download.php?id=resextract

Quote from 'ReadMe.txt':

____________________________________

RESOURCE EXTRACTOR PLUGIN
Version 1.0
____________________________________

FEATURES
____________________________________

- Decompilation of 32-bit PE executables (EXE SCR) and libraries (DLL OCX CPL BPL), resource files (RES DCR).
- Automatic detection of 32-bit executables and libraries by format. Resource files are detected only by extension.
- Resources with primary language are placed in both resource directory and resource type directory. 'Primary' means the following: plugin searches for resource that better fits keyboard layouts.
- Resources can be deleted either internally (fast, but not safe; file may be damaged) or using Resource Hacker (you can get it from http://www.users.on.net/johnson/resourcehacker/). Backup copy with name 'filename.ext.!!!' is created.
- Supports almost all standard resources. Styles for common controls can be decompiled as named constants.
- Decompilation process is fully customizable.

____________________________________

INSTALLATION
____________________________________

You should not register it for any particular extension. Instead, register it for extension like 'pe_res_dummy'. It will allow entering self-executable archives.
- Configuration -> Options... -> Packer -> Additional packers -> Configure packer extension WCX's
- Enter 'pe_res_dummy' into the edit box
- Press 'New type', browse for plugin, and press 'open'
- Press on all 'OK' buttons

____________________________________

USAGE
____________________________________

When your cursor is over one of the files with supported format (see above), press 'Ctrl + Page Down' to enter file. You can copy resources from file and delete resources. To delete resource completely delete directory, not file. Otherwise, only resource with primary language will be deleted.

____________________________________

RESOURCES THAT CAN BE DECOMPILED
____________________________________

- Icons (ICO) and cursors (CUR). They can be extracted as a whole or as particular format. Formats have names like '16x16 256 Colors' or '48x48 True Color (XP)'. '(XP)' mark in the format name means that it is 32-bit icon with alpha channel.
- Dialogs - both standard and extended (RC). Types and styles are decompiled as named constants for controls: Button, Static, Edit, ScrollBar, ListBox, ComboBox, ToolbarWindow32, RichEdit, SysAnimate32, SysDateTimePick32, SysHeader32, SysListView32, SysMonthCal32, SysPager, SysTabControl32, SysTreeView32, msctls_hotkey32, msctls_progress32, msctls_statusbar32, msctls_trackbar32, msctls_updown32, ComboBoxEx32, ReBarWindow32, ToolbarWindow32, RichEdit20A. Styles for unknown controls are decompiled as hex values. All window styles are decompiled as named constants.
- Menus - both standard and extended (RC)
- Borland forms (DFM) are decompiled into the text format.
- Version information (RC)
- String and message tables (RC)
- Accelerator tables (RC). Keys are decompiled into the 'VK_' constants.
- XP Manifests (XML)
- Toolbars (RC)
- Registry (REG). They are not actually 'reg' files, but I have no idea what extension to give them.
- Registry installation (INI)

____________________________________

AUTOMATICALLY DETECTED FORMATS
____________________________________

- Bitmaps (BMP DIB)
- Text (TXT). If the first KB of resource does not contain non-printable symbols, it is detected as text
- Web resources (HTM HTML GIF JPG JPEG XSL)
- AVI video files (AVI)
- Wave sound files (WAV)
- Metafiles (WMF)
- Executables (EXE)
- Virtual devices (VXD)
- Resources with unknown format have 'BIN' extension

____________________________________

CONFIGURATION
____________________________________

All lists (extensions, languages) are words separated by spaces. All numbers (languages, resource types) are decimal. If you have already used plugin in this session of Total Commander, for changes to take place you must restart it or call 'cm_UnloadPlugins' command. Total Commander caches archive contents, so if options change list of the resources, 'cm_UnloadPlugins' will not help, you will have to restart program. Options are saved in the registry under the following key: HKEY_CURRENT_USER\SOFTWARE\Athari\res_wcx.wcx. You can use Regedit to import and export options.

OPTIONS tab

Plugin looks for current keyboard layouts and chooses resource to be extracted out of language directory. If you want to extract all resources of a file, you can disable this feature. Resource files cannot be detected by content; they are detected only by extension. If you have resource files with another extensions, you can add this extension to the list. Warning: do not try open file registered as RES, that does not have RES format; it may cause errors.

RESOURCE NAMES tab

Options in this tab affect only resource names and extensions. The first way to set extension is after the name of resource type. These strings have format 'type=extension', without spaces. Type can be string or decimal number defining resource type. If resource have already got dot in the name (I've seen only web resources with extensions), adding of 'BIN' extension can be disabled.

DECOMPILATION FORMAT tab

This tab is for compatibility with other resource compilers. Some of them do not understand some statements. For example, Resource Hacker does not understand 'SEPARSTOR' and a few styles; Borland C++ does not understand most styles of non-standard controls etc. If your resource compiler has any problems using decompiled resources, you can press 'Compatibility mode' button. All values will be extracted as hex values, which are understood by every normal compiler. However, resources will lose readability.

EDITING tab

Instead of using internal method of deleting resources you should use Resource Hacker?, because it is much more reliable. You can download it free from http://www.users.on.net/johnson/resourcehacker/. However, it cannot delete icon formats and it is slower. If you want to delete icon formats, you can temporarily disable option 'Use Resource Hacker'. Warning: if you use internal method do not delete the last resource, file will be damaged.

____________________________________

KNOWN PROBLEMS
____________________________________

- If you delete the last resource of particular type, Total Commander does not update the view. It updates only after entering ".." dir. I cannot fix it. Author of Total Commander should fix it.

- If you enter language subdirectory of the only resource of particular type and delete that language, you would not be able to exit from file. You will have to use history (Alt + Down arrow) or enter dir manually (click on the panel title). I cannot fix it too. Therefore, if you want to delete Version Info, you should not enter language subdirectory to do it.

- Opening of one file of 200 causes an exception to be thrown. If you choose 'yes', work can be continued without any problems. In addition, I have found two files on my system that makes Total Commander to show 'Abnormal program termination' error. In this case, it just closes. However, it happens very rarely, I have tried to open more than thousand files. To the point, with other decompilers it does not happen more rarely.

____________________________________

WRITTEN BY
____________________________________

Prohorov Alexander aka Athari

Send suggestions, bug reports to athari(at)land.ru or to the Total Commander's forum http://ghisler.ch/board/viewtopic.php?t=3098 If you want some resource to be decompiled and know its format, or if you want some resource format to be detected, or if you have found any grammatical mistakes contact me.

____________________________________

VERSION HISTORY
____________________________________

Version 1.0 - 29.01.04
- Decompilation of almost all standard resources and some resources specific for particular compilers
- Detecting of almost all standard file formats in resources
- Deleting using Resource Hacker
- Application for configuration
- Search for text inside archive is enabled

Version 0.9 - 23.01.04
- First release
Excuse me for my bad English, my native language is C++
User avatar
za222
Member
Member
Posts: 146
Joined: 2003-03-11, 17:19 UTC
Location: Germany

Post by *za222 »

You Plugin works very fine!
But please, could you save Options in an ini-file instead of the registry?
That is useful if you have your TC on an USB-Stick for example.


Something else:
Your ReadMe.txt says
____________________________________

RESOURCE EXTRACTOR PLUGIN
Version 2.0
____________________________________
but the Plugin ist 1.0?
User avatar
Athari
Junior Member
Junior Member
Posts: 24
Joined: 2004-01-08, 15:12 UTC

Post by *Athari »

2za222
I don't understand those USB things... You mean TC is one computer, but you use it on another? I don't see the difference between registry and ini file. In both cases data which saved on the computer, where TC is run, is used, isn't it?
Excuse me for my bad English, my native language is C++
User avatar
Lefteous
Power Member
Power Member
Posts: 9535
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2Athari

INI files can be simply copied, but registry entries have to be exported, copied and imported to use them on another computer.
User avatar
za222
Member
Member
Posts: 146
Joined: 2003-03-11, 17:19 UTC
Location: Germany

Post by *za222 »

Another reason, why ini-files are better than the registry:

I myself make backups of my TC-Dir often.
An when I have to reinstall my OS, for example, i simply restore my Backup to Program Files.
But if any settings are saved to registry, i have do export and save them as well.
So when using ini-files, copying the TC-Dir is all you have to do
User avatar
djk
Power Member
Power Member
Posts: 1651
Joined: 2003-03-17, 11:33 UTC
Location: Poland
Contact:

Post by *djk »

For other opinions on ini vs registry look also here.
DJK
Totally addicted to Total Commander
totalcmd.pl
en.totalcmd.pl
User avatar
Athari
Junior Member
Junior Member
Posts: 24
Joined: 2004-01-08, 15:12 UTC

Post by *Athari »

I've created component that saves states of all components a long time ago. When I use it, I just add line 'RegControl->SaveProps()' to save and 'RegControl->LoadProps()' to load properties of components. To add support for INI files I'll have to save all options myself... Yes, I'm lazy. :) OK, I'll add support for INI files.
Excuse me for my bad English, my native language is C++
User avatar
Athari
Junior Member
Junior Member
Posts: 24
Joined: 2004-01-08, 15:12 UTC

Post by *Athari »

WinCmd works again:
http://www.wincmd.ru/download.php?id=resextract

- Packed files can be opened (that does not mean that all of their resources can be extracted)
- Plugin is much more stable; errors like "Abnormal program termination" should be in the past
- Resources whose data beyond the end of the file have "!!!" extension
- Resources whose data seems to be incorrect, for example bitmaps without normal header, have "!" extension. They can't decompiled; they are extracted as binary data
- Ini-file support
- Support for Borland controls: BorBtn, BorRadio, BorRadio, BorCheck, BorStatic, BorShade
- "LANGUAGE" statement is decompiled
- Configuration application can be called from the "Pack Files" dialog (that does not mean plugin can pack resources)
- Some small improvements: time of the resources is set to the file time, registry scripts have "RGS" extension, added "DS_3DLOOK" style, some additional options etc.
Excuse me for my bad English, my native language is C++
User avatar
za222
Member
Member
Posts: 146
Joined: 2003-03-11, 17:19 UTC
Location: Germany

Post by *za222 »

Athari wrote:- Ini-file support
Great!
But why is the ini-file only used, if it is in %COMMANDER_PATH%\Plugins ?

I have only the following dirs:

\Plugins_FS
\Plugins_Lister
\Plugins_Packer

So Ressource Extracter is located in \Plugins_Packer\RessourceExtractor\

It would be fine, if the ini-file could be in this directory or at least in %COMMANDER_PATH% itself, for those who don't have \Plugins ;)
Post Reply