Skip to content

GH-Rake/Binary-To-AOB

Repository files navigation

Binary To Array Of Byte

Generate an array of bytes and stores it in an easy to use header file from a binary file on disk.

image

Why?

Maybe you don't want to ship your .exe with additional files or want to load the file from memory for obscurity.

Usage

Drag and drop your binary onto BinaryToAOB.exe and the generated header file will be placed in the same folder as the binary.

Full article here: AOB Dumper

Introduction

Binary-To-AOB is a console application designed to simplify the process of embedding files into your C++ projects. It eliminates the need to deal with Windows resources, offering a more portable solution across platforms. The application achieves this by converting an entire file into an array of bytes (AOB) and generating a header file that can be easily integrated into your application.

Features

  1. Drag-and-Drop Functionality: Binary-To-AOB is designed with simplicity in mind. To convert a binary file to an array of bytes, all you need to do is drag and drop the file onto the application.

  2. Automatic Header File Generation: Upon conversion, the application automatically generates a header file with the same name as the binary file. This header file contains the array of bytes representing the binary file, making it ready for use in your C++ projects.

  3. Cross-Platform Portability: Unlike dealing with Windows resources, the array of bytes generated by Binary-To-AOB can be used across different platforms, increasing the portability of your C++ projects.

How It Works

Binary-To-AOB operates by opening a file stream with the flag std::ios::binary, iterating over all of the bytes in the file, and writing them to a file along with some C syntax formatting. Here's a step-by-step breakdown of the process:

  1. File Stream Creation: The application creates an input file stream using the binary file you provide. It opens the file in binary mode and positions the file pointer at the end (std::ios::binary | std::ios::ate).

  2. Array of Bytes (AOB) Creation: It then determines the size of the file and creates an array of bytes (aob) of the same size to store the file bytes.

  3. File Reading: The application moves the file pointer back to the beginning of the file and reads the entire file into the aob. After reading, it closes the binary file.

  4. Header File Creation: Binary-To-AOB creates a header file with the same filename as the binary file. It opens a file stream for this header file.

  5. Writing to Header File: The application writes the contents of the aob to the header file in a specific format. Each byte is written as a hexadecimal value, followed by a comma. After writing all the bytes, it closes the header file and deletes the aob.

  6. Completion Message: Finally, the application prints a message indicating that the AOB header file has been created.

User Experience Level

Binary-To-AOB is designed to be user-friendly and does not require extensive programming knowledge to use. However, to fully understand and modify the source code, a basic understanding of C++ and file I/O operations is recommended.

End Goal

The primary goal of Binary-To-AOB is to simplify the process of embedding binary files into C++ projects. It does this by converting binary files into an array of bytes (AOB) and generating a header file that can be easily included in your C++ code. This approach bypasses the need to deal with Windows resources, making your code more portable across different platforms.

Official GH Tools

Frequently Asked Questions (FAQ)

Q1: What is an Array of Bytes (AOB)?

An Array of Bytes (AOB) is essentially a sequence of bytes, where each byte is usually represented as a hexadecimal value. In the context of Binary-To-AOB, an AOB is a representation of a binary file that can be easily embedded into a C++ project.

Q2: How do I use the generated header file in my C++ project?

The generated header file contains an array named binary[] that holds the byte representation of your binary file. To use it in your C++ project, simply include the header file using the #include directive. You can then access the binary[] array in your code.

Q3: Can I use Binary-To-AOB with non-binary files?

Yes, Binary-To-AOB can be used with any file type. The application treats all files as binary data and converts them into an array of bytes.

Q4: Why am I seeing a message saying "You must drag and drop your binary onto this .exe"?

This message appears when you run the application without providing a binary file. To use Binary-To-AOB, you need to drag and drop your binary file onto the application.

Glossary of Terms

  1. Binary File: A binary file is a file that contains binary data -- that is, data that is stored in binary format. This data can represent various types of information, including text, images, audio, and executable code.

  2. Array of Bytes (AOB): An AOB is a sequence of bytes, where each byte is usually represented as a hexadecimal value. In the context of Binary-To-AOB, an AOB is a representation of a binary file that can be easily embedded into a C++ project.

  3. Header File: In C and C++, a header file is a file with a .h extension that contains C function declarations and macro definitions to be shared between several source files.

  4. File Stream: In C++, a file stream is an object of one of the file stream classes (ifstream, ofstream, fstream) used to read from and write to files.

  5. Hexadecimal Value: Hexadecimal is a base-16 number system. It uses sixteen distinct symbols, most often the symbols "0"--"9" to represent values zero to nine, and "A"--"F" to represent values ten to fifteen.

  6. Windows Resources: In the context of programming, Windows resources are data embedded in the executable file of a Windows application. These can include icons, cursors, strings, etc.

Releases

No releases published

Packages

No packages published

Languages