Giter Site home page Giter Site logo

bin2coff's Introduction

bin2coff

bin2coff is a tool to create COFF object files containing binary data, which is useful e.g. to embed a binary file in a C/C++ project.

The code on which this project is based was originally created by Pete Batard as part of the libwdi project and modified by Artifex Software Inc. and included in the MuPDF source code.

I translated the original code to C# and added support for producing ARM64 compatible object files (which, in addition to a different flag in the file header, also require the data to be aligned to 4-byte boundaries).

Usage

bin2coff bin obj [label] [64bit|Win32|x64|arm64]
  • bin: source binary data.
  • obj: target object file, in MS COFF format.
  • label: identifier for the extern data. If not provided, the name of the binary file without extension is used.
  • 64bit / Win32 / x64 / arm64 / ARM64: produce an object that is compatible with the specified architecture.For 64bit/x64 and arm64, symbols are generated without leading underscores, and for arm64 the data is aligned to 4-byte boundaries; machine type is set appropriately.

With your linker set properly, typical access from a C source is:

extern uint8_t  label[]     /* binary data         */
extern uint32_t label_size  /* size of binary data */

This program aims to be a drop-in replacement for other bin2coff versions (e.g. the one included with MuPDF): simply place the executable in the place where the toolchain expects it to be to make it possible to generate arm64-compatible obj files. For x86 and x64 targets, the binaries produced by this program should be identical to the original bin2coff.

Building from source

To build the program from the source code, you will need the .NET 6 SDK or higher. You should use a Windows machine.

  1. Download the source code: bin2coff-1.0.0.tar.gz (or clone the repository).
  2. Open a command prompt in the folder where you have downloaded the source code, type BuildBinaries and press enter. This will build the binaries for the x64, x86 and arm64 versions of the program (each version can produce object files for all platforms - use the one that corresponds to the host architecture). You can find them in the Release folder.
  3. (Optional) To sign the binaries, you will need to have the signtool utility installed and in your PATH. You can get this e.g. by opening a Visual Studio Developer command prompt in the folder with the source code. Use the command SignBinaries <path_to_certificate.p12> <certificate_password> to sign the binaries.

bin2coff's People

Contributors

arklumpus avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

linecode

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.