SkillAgentSearch skills...

Bin2cpp

bin2cpp: The easiest way to embed small files into a c++ executable. bin2cpp converts text or binary files to C++ files (*.h, *.cpp) for easy access within the code.

Install / Use

/learn @end2endzone/Bin2cpp
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

bin2cpp logo

bin2cpp

License: MIT Github Releases

bin2cpp is a command line tool for embedding small files (like images, icons or raw data files) into a C or C++ executable.

When executed, bin2cpp takes binary file as input and outputs C or C++ code (a function) that when called allows a program to retrieve the content of the input binary file.

Status

Build:

| Service/Platform | Build | Tests | | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | AppVeyor | Build status | Tests status | | Windows Server 2019 | Build on Windows | Tests on Windows | | Ubuntu 20.04 | Build on Linux | Tests on Linux | | macOS 10.15 | Build on macOS | Tests on macOS |

Purpose

bin2cpp is not implemented using executable resources. Instead, bin2cpp creates a single function call for retrieving the content and the properties of a file which makes it harder to steal the executable's content. It also makes it even harder to replace an existing resource of the executable.

It is designed to be easy to use by developers and to provide easy call functions to get access to the data of the embedded files.

The generated functions that reads and extracts the embedded content does not rely on external libraries so you don't need to setup your projects to use any third party library to start using bin2cpp. All your embedded data can be accessed right away.

Features

The main features of the project are:

  • Easily converts small files to C or C++ source code for embedding into an executable.
  • Access content with a unique function call for each embedded file.
  • Supports multiple embedded files at once.
  • Keep the directory structure when embedding directories.
  • Supports encoding and extracting files with a custom directory structure.
  • Makes it harder for resource hacker to modify or steal the embedded files.
  • No third party libraries required for retrieving the data of the embedded files.
  • Supports different types of code generator: string, segment, array, win32 resources.
  • File's originals size, filename and relative path properties available from generated source code.
  • Control generated source code: choose your custom File interface and namespace.
  • Print a file encoded content to stdout. Useful for scripts and integration with third party application.
  • Generated code is C99 or C++98 standard-compliant.

Use cases

The following list show use cases where bin2cpp is useful:

  • Embedding default configuration files if none are provided.
  • Embedding GLSL shaders into the executable.
  • Embedding text or XML databases (gui layout, names, dictionaries or localization strings)
  • A portable alternative to C++11 raw string literals.
  • Prevent stealing copyrighted resources.
  • Embedding images/icons/sounds for a GUI application. The application executable can be shipped/copied as a single file.
  • Embedding a long PL/SQL code string.
  • Allowing an executable to be downloaded from an intranet server as a single file.
  • Distributing an application without an installer package. All configurations files and resources can be embedded and extracted at first launch of the application.

Usage

The following section shows how to use bin2cpp with code examples:

Command Line Usage

bin2cpp --file=<path> --output=<path> [--headerfile=<name>] [--identifier=<name>]
        [--generator=<name>] [--encoding=<name>] [--chunksize=<value>] [--namespace=<value>]
        [--baseclass=<name>] [--managerfile=<name>] [--registerfile] [--code] 
        [--reportedfilepath=<value>] [--plainoutput] [--override] [--noheader] [--quiet]
bin2cpp --dir=<path> --output=<path> [--keepdirs]
        [--generator=<name>] [--encoding=<name>] [--chunksize=<value>] [--namespace=<value>]
        [--baseclass=<name>] [--managerfile=<name>] [--registerfile] [--code]  
        [--dirincludefilter=<value>] [--direxcludefilter=<value>] 
        [--override] [--noheader] [--quiet]
bin2cpp --help
bin2cpp --version

| Argument | Description | |---------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | --help | Display this help message. | | --version | Display this application version. | | --file=<path> | Path of the input file used for embedding as C++ source code. | | --dir=<path> | Path of the input directory used for embedding all files of the directory as C++ source code. | | --output=<path> | Path of the output directory where to create generated code.<br>ie: ./generated_files | | --headerfile=<name> | File name or relative path of the generated C++ header file. If a relative path from the output directory is specified, the #include statement in the generated cpp file will match the relative path. <br>ie: SplashScreen.h<br>Default value: input file name (without extension) | | --identifier=<name> | Identifier of the function name that is used to get an instance of the file.<br>ie: SplashScreen<br>Default value is based on input file with format 'NameExt'. | | --generator=<name> | Name of the generator to use. Possible values are 'segment', 'string', 'array' and 'win32'.<br>[default: segment] | | --encoding=<name> | Name of the binary to string literal encoding to use. Possible values are 'oct' and 'hex'.<br>[default: o

View on GitHub
GitHub Stars91
CategoryDevelopment
Updated6mo ago
Forks10

Languages

C++

Security Score

92/100

Audited on Sep 25, 2025

No findings