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

  • SEARCH
  • Home
  • 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 7664403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:17:44+00:00 2026-05-31T14:17:44+00:00

In C. I need a way to execute computer instructions DIRECTLY while a program

  • 0

In C. I need a way to execute computer instructions DIRECTLY while a program is running. The only way I know how to make computer instructions in binary is through a hex editor, then you run the file as an application. How would I write the binary using a program and then execute it from their without having to create a new process for execution. It seems like their should be a simple way to do this but no matter where I look I can’t find it.

The only other way I can think of doing this is through inline assembly, but in my current project that would be a drawback, executing directly with binary is the best way to go. (would this possibly require a driver on windows? how to do on linux? in other words a cross-platform method would be nice)

Thank you.

  • 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-05-31T14:17:46+00:00Added an answer on May 31, 2026 at 2:17 pm

    What you want to do is a bit problematic and is liable to make a lot of people ask “Why are you doing that?”

    Assuming you have an operating system WITHOUT memory protection (which is very rare), you can just point a function to array of bytes and call the function. Here’s the gist of it:

    unsigned char* code_to_execute = "\xB8\x13\x00\xCD\x10";
    void (*runCode)();
    
    runCode = code_to_execute;
    
    runCode();
    

    But, there are SO MANY THINGS to worry about when doing something like this. You need to know how your C compiler is setting up function call frames and respect that in your “binary code”. It’s impossible to create cross-platform code in this manner. Even making it run in multiple C compilers on a single platform would be tricky. And then there’s memory protection. Most modern operating systems simply won’t let you arbitrarily execute data as code. You need to explicitly mark the memory as executable and many operating systems won’t let you do that without special permission. There is no cross-platform way to do this either.

    Again, I want to stress that this is really not a good idea. You would be better off using inline assembly language. Or better yet, don’t use assembly language at all. Maybe you could explain a little more about your project and why it’s important to write “binary code” directly in your C program. It would help us craft an answer or recommendation that could help you considerably.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a way to determine whether the computer running my program is joined
I need a way to allow each letter of a word to rotate through
I'd like to know how to restart a computer in such a way that
i cannot find any way to execute this - all i need is to
I just want to know which is the best way to execute an external
Need a way to allow sorting except for last item with in a list.
I need a way to easily export and then import data in a MySQL
I need a way to recursively delete a folder and its children. Is there
I need a way to update the month value on a dateTime field in
I need a way to bind POJO objects to an external entity, that could

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.