← Learn

Load Resources

Author
Moise Medici
Updated
22 Jan 2026 · Completed

Create and embed a resource

Embedding a resource in an executable is straightforward. The following components are needed:

  1. A .exe to “take” the embedded file
  2. A file to embed in the .exe
  3. A .rc file to “describe” the resource. An example will be presented shortly; for more details on .rc files, see 1

For this demo, a file called calc.ico is used, which is the output of:

Terminal window
msfvenom --payload windows/exec CMD=calc.exe -f raw -o calc.ico`

The .rc file is a simple description of the resource file, where the version, the name of the product, and the language are defined:

load_resource.rc
#include <windows.h>
CALCICO RCDATA "calc.ico"
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "FileDescription", "Moise"
VALUE "ProductName", "ProductMoise"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 1200
END
END

These two files and the first payload are then bundled together during compilation. The result is a single .exe, which contains the resource and the logic to extract it.

Before examining the code of the resource extraction logic, it is useful to open the resulting .exe file in pestudio and observe the resource in the “resources” section. From there, the resource can be saved locally by right-clicking on it → instance → dump to file.

pestudio's resources page for load_resource_rsrc.exe, where the rcdata entry named CALCICO holds 193 bytes that pestudio cannot identify.
Fig. 1: pestudio's resources page for load_resource_rsrc.exe, where the rcdata entry named CALCICO holds 193 bytes that pestudio cannot identify.