Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8396797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:37:47+00:00 2026-06-09T20:37:47+00:00

Simple question I know, what I want to do is be able to get

  • 0

Simple question I know, what I want to do is be able to get the bytes of a file to use to add those bytes to an bit array, which I can then use to write to a file named bytes.exe and launch it. I know how to read the bytes of an existing file at runtime. But I don’t know how to get the bytes of a file to copy and paste into my bitarray[] at design time.

The goal is to be able to write the bites of bitarray[] to myfile.exe at runtime, and then launch said file. There are many bitarray[]'s I’ll be using, based on many different file types, so I’m looking for an easy method.

Is there some kind of decompiler that should be used? I just looked into resource scripts, but I don’t want to attach any dependencies to my main .exe.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:37:49+00:00Added an answer on June 9, 2026 at 8:37 pm

    If you are targeting Windows, the easiest way to do this is to embed myfile.exe as a resource, then load the resource at runtime and create a file and write the contents of the resource to your new file.

    If you can’t use resources, then you’ll need to create a source file (.c or .h) that initializes a byte array with the contents of myfile.exe and include that as part of your build. Check out this answer for one possible approach:

    https://stackoverflow.com/a/73653/333127

    EDIT: After further review, I don’t think the source code in the link I referenced above will work for binary input files. Here’s a quick alternative I just threw together:

    #include <stdio.h>
    #include <stdlib.h>
    
    #define BYTES_PER_LINE 70
    
    int main(int argc, char* argv[])
    {
        FILE* fp;
        int ch;
        int numBytes = 0;
    
        if (argc < 2) {
            printf("Usage: tobytes <file>\n");
            exit(1);
        }
    
        fp = fopen(argv[1], "rb");
        if (fp == NULL) {
            printf("Cannot open file %s\n", argv[1]);
            exit(1);
        }
    
        printf("char fileContents[] = {\n");
        while ((ch = fgetc(fp)) != EOF) {
            if (numBytes > 0)
                printf(",");
    
            ++numBytes;
            if (numBytes % BYTES_PER_LINE == 0)
                printf("\n");
    
            printf("0x%x", ch);
        }
        printf("\n};\n");
    
        fclose(fp);
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know, I am asking very simple and stupid question but i want to
Simple question, I know, but I can't seem to find a way to put
My question here is pretty simple: I want to know if processors try to
Simple question here: I like to know if a constraint in a oracle database
simple question really, i was wanting to know what naming conventions anybody puts on
I know this is a simple question, but I thought I'd give it a
I know this is a simple question, but either nobody is explaining it right,
I know it's a simple question, but I have strange behaviour in here. <pre>
I know this is a simple question, but I am new to ASP MVC
I know this is a simple question for someone out there, but I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.