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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:36:35+00:00 2026-05-20T18:36:35+00:00

I have a program written in C, which includes 2 functions, one function is

  • 0

I have a program written in C, which includes 2 functions, one function is main() and the other function is a pre-compiled function which stored as byte array (let’s call it varFunc()). The pointer to the array is casted in the main function to a function pointer and then it is called from the main function. (see code below)

Now, I know that there are operating systems and some processors that won’t allow executing code from data section, and my varFunc should be just there…

Is there a way using C language to make C compiler to add some variables to code/text section? if not, is there a way to enforce that by compiler in most compilers?

    char varFuncArr[] = { 0xDE, 0x67, 0x6F, 0x6F, 0xAC, 0x13, 0x05, 0x01, 0xDA, 0xF0, 0xBD, 0x79, 0xA9, 0x10, 0x00, 0x00, 0xB8, 0x74, 0x00, 0x00, 0x00, 0x3F, 0x58, 0x13, 0xEA, 0x0A, 0x2E, 0xEE, 0xC7, 0x01, 0x05, 0xD0, 0x6E, 0xB8, 0x9E};

    typedef unsigned long (*funcPtr)(void* d[]);

    int main(int argc, char** argv)
    {
        unsigned int ra[8];
        funcPtr varFunc;
        for (i=0; i<8; i++)
             ra[i] = 0;
        varFunc = (funcPtr)varFuncArr;
        return varFunc(ra);
    }

Note 1: I know that this is a very clumsy way to call a function and it also make it super platform and compiler, but I show this example to make it simpler, actual use include an encrypted function instead of varFuncArr().

Note 2: Don’t try to run this code, varFuncArr is encrypted in this example 🙂

Thanks,
Binyamin

  • 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-20T18:36:35+00:00Added an answer on May 20, 2026 at 6:36 pm

    On GCC, you can use __attribute__((section("text"))) to put something in a particular section; see here for documentation. Visual C++ has __declspec(allocate("section")); see here for documentation.

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

Sidebar

Related Questions

I am compiling an ancient program called SCOL (written in 1997) which comes pre-packged
I have a small scripting engine written which can run basic code. I want
I have written a program to process some data written to disk in big-endian
I know how to use $.each in my program which is written in Java
Working in Linux and using C++. I have a program which initiates a thread.
I have a script that appends some rows to a table. One of the
I have a login.jsp page which contains a login form. Once logged in the
i have a input tag which is non editable, but some times i need
We have a large suite of products that include: Desktop apps written in VB6.
I have a java program where certain parts are computationally intensive. I wish to

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.