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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:00:50+00:00 2026-05-15T13:00:50+00:00

This is not something most people would probably use, but it just came to

  • 0

This is not something most people would probably use, but it just came to mind and was bugging me.

Is it possible to have some machine code in say, a c-string, and then cast its address to a function pointer and then use it to run that machine code?

  • 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-15T13:00:50+00:00Added an answer on May 15, 2026 at 1:00 pm

    In theory you can, per Carl Norum. This is called “self-modifying code.”

    In practice what will usually stop you is the operating system. Most of the major modern operating systems are designed to make a distinction between “readable”, “readwriteable”, and “executable” memory. When this kind of OS kernel loads a program, it puts the code into a special “executable” page which is marked read-only, so that a user application cannot modify it; at the same time, trying to GOTO an address that is not in an “executable” page will also cause a fault exception. This is for security purposes, because many kinds of malware and viruses and other hacks depend upon making the program jump into modified memory. For example, a hacker might feed an app data that causes some function to write malicious code into the stack, and then run it.

    But at heart, what the operating system itself does to load a program is exactly what you describe — it loads code into memory, flags the memory as executable, and jumps into it.

    In the embedded hardware world, there may not be an OS to get in your way, and so some platforms use this pretty regularly. On the PlayStation 2 I used to do this all the time — if there was some code that was specific to, say, the desert level, and used nowhere else, I wouldn’t keep it in memory all the time — instead I’d load it along with the desert level, and fix up my function pointers to the right executable. When the user left the level, I’d dump that code from memory, set all those function pointers to an exception handler, and load the code for the next level into the same space.

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

Sidebar

Related Questions

I've seen several examples of code like this: if not someobj: #do something But
Is there any reason something like this would not work? This is the logic
This code does not seem to compile, I just need to write something to
There's something wrong with my code or I'm just not understanding this fully. I
I'm trying something like this, but this example does not work. jsObj = {};
So this is something that I have not been able to find any documentation
This is something simple I came up with for this question . I'm not
I feel like this may be a trivial problem for most people but I'm
I want to know i can do something similar to this (not working) code
I am not sure why this is not working. Perhaps I am missing something

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.