Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1512

VB6 - ResDecomp Class Decompiles RES Files

$
0
0
ResDecomp

This class reads a .RES (Resource) file as created by Visual Basic 6.0 or resource compilers such as RC.EXE and extracts resources.

This version decompiles RT_STRING resource StringTable data to UTF-16LE strings and ID values but does not attempt detailed decompilation of other types of resources.

While primarily addressing RT_STRING resources, the header fields and raw data payload of each resource are made available to the client program. In many cases this is enough, as can be seen in the demo program ResStrings when it fetches and decodes the custom resource type "UTF8TEXT" and reports it.

There isn't a huge ton of code involved. Most of the bulk of the attachment comes from sample data, icons, etc.


Samples

Two applications using the class are included:

ResStrings

Decompiles an included SAMPLE.res, reporting the results to a RichTextBox. Simple printing is implemented.

DecompStrings

Drag and drop a .RES file onto DecompString's Explorer icon or run DecompString from a command prompt passing the .RES file name as parameters. Decompiles the .RES file and exports Strings as a UTF-8 XML document, named the same as the input file but with an .XML extension.


Requirements

VB6 SP6 to compile.

DecompStrings: MSXML 3.0.

ResStrings: Richtx32.ocx (and RichEdit 2.0 at the system level, certainly Win2K SP3 and later, many Win9x systems).


Using ResDecomp.cls

Add the Class to your Project.

Create a WithEvents instance of the Class.

Call the .Extract() method passing the .RES file name.

The Started event is raised first, relaying the file name.

Then the Resource event is raised multiple times, passing a ResourceIndex value numbering the resources from 0 which may or may not be useful to you. Within this event's handler you can access the current resource's header field values, the raw header and data bytes, and arrays containing the string and string ID values if the resource is type RT_STRING as properties of your ResDecomp instance.

Finally the Finished event is raised at the end of the .RES file.

The advantage of this is that you can easily apply any filtering and formatting of resources as they are parsed out of the .RES file. The downside is that you must host instances of this Class in object modules (i.e. not static .BAS modules). But most programs where this Class would be useful can deal with that, or you could always rework things by moving the loop out from Extract() and into your client code.
Attached Files

Viewing all articles
Browse latest Browse all 1512

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>