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 6037361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:03:43+00:00 2026-05-23T06:03:43+00:00

So I would like to load a set of assembly instructions from a file,

  • 0

So I would like to load a set of assembly instructions from a file, and execute those instructions.

OR

I would like to load already compiled machine code again from a file (non-exe)

My Thoughts:

So far I’ve learned enough inline asm to work with c/c++ variables easily.

  asm volatile (
    "mov     %1, %%ecx;" // yes unnecessary, I know
    "add     %2, %%ecx;" // I know they're already loaded in a register
    "mov     %%ecx ,%0 ;"// just demonstrating what I've learned
    :"=r"(address)
    :"r"(address),"r"(offset)
    :"%ecx"
  );

I’ve begun to learn about op-codes, and I’ve gotten some x86 manuals. I understand (somewhat) how the hardware works at a basic level.

I know that I can load the file into memory with c++ with fstream, and I’m wondering if there’s a way to execute memory from that space, or if it’s in a non-executable portion of memory or something..

Reason:

Currently there are several reasons I’d like to do this. I have a desire to create a basic encyption for my program, for a simple key to run the program. And while I can easily encrypt and decrypt the actual code, I want the program to be unencrypted every run and never stored on the harddrive. I am aware of several problems, however I’m very interested in doing so.

Final Questions:

Can I execute machine code from memory space in a program from c++ in asm?

Is asm necessary?

Are there other ways to accomplish this task more efficiently, if so, what are those methods?

I’m also reading up on some DLL injection for a mouse sharing program that I’m making (two computers next to each other, both have monitors, however you only have one mouse/keyboard. And I’m wondering where I can find some good resources on the topic? Google has been helpful, however I’m interested in perhaps some IRC channels or something similar. Anyways, thanks for reading!

  • 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-23T06:03:44+00:00Added an answer on May 23, 2026 at 6:03 am

    This sounds like you kind of want some JIT compiling of some x86 assembly in a separate file?

    I might have misunderstood, when you say ‘memory space’, your encapsulating a very broad term. I assume you don’t mean that you want to compile it with a specific set of assembly but be able to interchange the assembly instructions at runtime?

    Have a read over the following Dynamically generating and executing x86 code

    You’ll see

    #include <stdio.h>
    #include <stdint.h>
    #include <stdlib.h>
    #include <string.h>
    #include <sys/mman.h>
    
     int main(int argc, char *argv[]) {
         uint8_t *buf = mmap(NULL, 1000, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
    
         buf[0] = 0xb8;
         uint32_t u32 = 42;
         memcpy(buf + 1, &u32, 4);
         buf[5] = 0xc3;
    
         if (mprotect(buf, 1000, PROT_EXEC | PROT_READ) < 0) {
             fprintf(stderr, "mprotect failed: %s\n", strerror(errno));
             return 1;
         }
         int (*ptr)(void) = (int (*)(void)) buf;
    
         printf("return is %d\n", ptr());
    
         return 0; }
    

    Here you are allocating memory for a buffer. Putting the instructions into the buffer, then creating a function pointer from the allocated memory. Notice the memory is being protected also.

    Read over the article for a better understanding, it also gives you some Windows equivalents.

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

Sidebar

Related Questions

I have an assembly I would like to load from a sub-folder of the
$('#selector').click(function() { // here I would like to load a javascript file // let's
Using the HTML5 <canvas> element, I would like to load an image file (PNG,
I have a class variable that I would like to set from an initilizer
I would like to load images into a gallery view from a url? I
I would like to know how can I load a new nib file after
I would like to load a random document out of a set of documents
I would like to load a HTML document and modify it's text in PHP.
i would like to load xml into dataset with only 2 columns (name, price)
I have several PDF templates that I would like to load and modify and

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.