In any teaching process, repetition is necessary to make learning stick so please allow me to do a small recap on working with file resources.
This workshop started here with a follow up here.
Working with resources is interesting for among other things not have to right-click the file and choose ‘Run as Administrator’ every time or to avoid sending a touchy AV skyrocketing with false positives. The latter may be caused by packers as well, but that is a little too advanced subject to cover in greater detail without becoming too technical.
This time I have found an interesting candidate for you to work with. Unless there are questions, this is the last time we will revisit the Resource Hacker application in this thread and I am going to collect a few loose threads to make you see that this does not have to be any advance task to undertake for you in the future. I will tech you how to cheat
These are the downloads to be done but if you followed the two other tutorials, you do not need to download Resource Hacker unless you have deleted it of course…
Resource Hacker homepage - Portable version - Installer
FOX Calculator homepage - Application executable download
Our test application this time looks like this, you may want to start it before we start the tutorial to make sure the download went ok
Quit the calculator if it is running, start Resource Hacker and drag and drop calculator.exe on the Resource Hacker window to open it.
As you can see there is nothing here, the FOX calculator does not have any resources at all, but nothing to worry about, this time we are going to add all resources ourselves
Let us start off by adding an icon for the application. This is as far as I can tell where we hit a limitation in the Resource Hacker applicatiom as far as working with a mouse. The website states:
"ICON and CURSOR resources cannot be manipulated directly but are added, deleted, modified and extracted by using their respective ICONGROUP or CURSORGROUP. ICON and CURSOR can still be used but Resource Hackerâ„¢ will assume ICONGROUP or CURSORGROUP was intended."
In other words, not imported from a .ico source when none is present.
There is information on the homepage how to add it, but to not make this recap unnecessary complicated I have prepared the resource for you. Simply unpack the ‘Foxcalc_resources.zip’ archive to somewhere.
There are more files available, but for now we’ll concentrate on the icon resource.
Select the Action menu and choose ‘Add from a Resource file (*.res, *.dll, *.exe)’
Browse for ‘Icon Group_NEW_ICON.res’, select it,
check the box before ‘Icon Group’ and click ‘Import’
That adds our icon resource. You may want to hold on to the provided resource as you can use it for future projects. You can then simply replace the icon resources after adding it which you are allowed to do in Resource Hacker using your mouse only. You may have to save first and then reopen the file before being able to replace the icon, but you’ll soon enough get the hang of when that is necessary.
The sizes included in the resource are the full Windows 10 spec: 16x16, 32x32, 48x48, 256x256, 768x768.
O.k. since this file does not have any resources to begin with, we ought to add version info as we can make a remark thereof in this section.
Select the ‘Action’ menu again, but this time, select 'Add using ‘Script Template …’.
Select ‘VERSION_INFO’ in the drop down menu and click on ‘Add Resource’ as shown.
I have prepared the content below, all info taken from the calculator itself. As you can see, We are not about to steal the credit, we are just making a note of the fact that we have added a resource section to the file. You should change the Xercus name below to yours, that is it. The programming credit lies with Jeroen Van Der Zijp who should retain his copyright in the version info.
leave the following alone below: ‘FILEOS 0x4’, ‘FILETYPE 0x2’, ‘VALUE “Translation”, 0x0000 0x04E4’ for future projects you do as they only say that this is a 32-bit app which is language neutral (0x0000) and uses the 1252 (0x04E4) Multilingual charset. The actual data should be pretty straight forward to understand, but if anything is unclear, please ask
Copy the contents below and replace the default found in Resource Hacker.
VALUE "CompanyName", "FOX-Toolkit"
VALUE "FileDescription", "A Programmer's Desktop Calculator"
VALUE "FileVersion", "188.8.131.52"
VALUE "InternalName", "Calculator"
VALUE "LegalCopyright", "Â© 2001, Jeroen van der Zijp"
VALUE "LegalTrademarks", ""
VALUE "OriginalFilename", "calculator.exe"
VALUE "ProductName", "FOX Calculator"
VALUE "ProductVersion", "184.108.40.206"
VALUE "Comments", "Resources added 2016, Xercus"
VALUE "Additional comment", "Download original from fox-toolkit.org. Private use only. "
VALUE "Translation", 0x0000 0x04E4
Click the green ‘Play’ button or press [F5] to compile your script
O.k. Now let us add the manifest. Select the ‘Action’ menu again and select 'Add using ‘Script Template …’.
Select ‘MANIFEST’ in the drop down menu and click on ‘Add Resource’.
I do find it a tad over-complicating that the resource presented comes ‘defaulting’ to a styled or themed manifest discussed in the previous post, but since this file does not initialize ComCtl32.dll we are going to remove it. For some even small programs, adding this may actually cause them to fail, but by any means try, then check your work by means of SXSTrace.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
As per previous post, the theme part is stripped out and one section added.
Click the green ‘Play’ button or tap [F5] to compile your script
here is a short recap of the part in the CODE section above.
<trustInfo… to </trustInfo> - What privelege does our application need? (“asInvoker”, “highestAvailable”, “requireAdministrator”) I always add this section, even when it is default like here. This is where you avoid having to right-click and select ‘Run as Administrator’.
<compatibility… to </compatibility> - supported operating systems, from top to bottom Windows version (Vista, 7, 8, 8.1, 10). If this is not provided, the compatibility assistand is triggered.
<application… to </application> - should be used to opt out of Windows display scaling virtualization (true/false). This is as scaleable as is possible and does not at all need windows’ help. Try to resize the window and you will understand what I mean.
The above sections can be found separately as snippets and reused in future projects of your own or to create a favorite for reuse. There’s absolutely no need to reinvent the wheel These are the extra text files found in the ‘Foxcalc_resources.zip’ archive. Start by opening ‘0read first.txt’ to get instructions thereof.
You are done, click the Diskette button or press [Ctrl]+[S] to save the program and then quit Resource Hacker.
Back in the folder where calculator.exe is, hit [F5] to refresh the window if needed, and you will see that it now has an icon
I dare say it’s appearance in windows comes forth as a little more inviting (large icons used above)
Now if you right-click calculator.exe and choose ‘Properties’, then select the ‘Details’ tab, you can see some of the details we added in the version information. Note that the comment we added does not show, it is in there though, just not displayed which is o.k.
If you open the calculator.exe in an application like CFF Explorer
and go to ‘Section Headers’ (above), you can see (if you compare to the original) that we have actually added a new .rsrc section to the file which is missing from the original. Now you can probably better understand why I say the resources is not part of the executable code… They may be be indirectly though, there are few limitations to this section
The choice of files for these tutorials can be questioned of course, but was chosen due to having the correct features for the tutorial, more so than being real world examples.
The tutorial found on the Resource Hacker homepage does not seem to cover topics found in these three tutorials and so I thought why not the user/operating system point of view.