Execute from data section?

I am developing an application in C which will generate machine code and execute it. My problem is: on Windows and Linux, I can't execute the generated code.

If I try to put the generated code in the code section (by creating dummy functions and overwriting them) I get a segfault for trying to write to a code section. If I allocate some memory, put it there, and try to call to it, I get a segfault for trying to execute in a data section.

Any ideas?

Comments

  • : I am developing an application in C which will generate machine code and execute it. My problem is: on Windows and Linux, I can't execute the generated code.
    :
    : If I try to put the generated code in the code section (by creating dummy functions and overwriting them) I get a segfault for trying to write to a code section. If I allocate some memory, put it there, and try to call to it, I get a segfault for trying to execute in a data section.
    :
    : Any ideas?
    :
    that's because your program does not have the necessary operating systerm permissions to do that. you need to write kernel-level code. under windows os your assembly code needs to use the flat memory model, which is unsegmented.
  • : : I am developing an application in C which will generate machine code and execute it. My problem is: on Windows and Linux, I can't execute the generated code.
    : :
    : : If I try to put the generated code in the code section (by creating dummy functions and overwriting them) I get a segfault for trying to write to a code section. If I allocate some memory, put it there, and try to call to it, I get a segfault for trying to execute in a data section.
    : :
    : : Any ideas?
    : :
    : that's because your program does not have the necessary operating systerm permissions to do that. you need to write kernel-level code. under windows os your assembly code needs to use the flat memory model, which is unsegmented.
    :
    [blue]You need to build your EXE file with a module definition file (DEF file) where you will specify the section attributes, so you can give the .DATA section 'executable' status. Also, specify the program entry point inside .DATA section - check your command line parameters for LINK-er - it should be there. BTW, I am not sure that free LINK-ers will provide that kind of flexibility... This type of build is usually done for encrypted self-modifying code (which is so interesting to crack!).[/blue]

  • : : : I am developing an application in C which will generate machine code and execute it. My problem is: on Windows and Linux, I can't execute the generated code.
    : : :
    : : : If I try to put the generated code in the code section (by creating dummy functions and overwriting them) I get a segfault for trying to write to a code section. If I allocate some memory, put it there, and try to call to it, I get a segfault for trying to execute in a data section.
    : : :
    : : : Any ideas?
    : : :
    : : that's because your program does not have the necessary operating systerm permissions to do that. you need to write kernel-level code. under windows os your assembly code needs to use the flat memory model, which is unsegmented.
    : :
    : [blue]You need to build your EXE file with a module definition file (DEF file) where you will specify the section attributes, so you can give the .DATA section 'executable' status. Also, specify the program entry point inside .DATA section - check your command line parameters for LINK-er - it should be there. BTW, I am not sure that free LINK-ers will provide that kind of flexibility... This type of build is usually done for encrypted self-modifying code (which is so interesting to crack!).[/blue]
    :
    :
    What does "BTW" mean?

  • : : : : I am developing an application in C which will generate machine code and execute it. My problem is: on Windows and Linux, I can't execute the generated code.
    : : : :
    : : : : If I try to put the generated code in the code section (by creating dummy functions and overwriting them) I get a segfault for trying to write to a code section. If I allocate some memory, put it there, and try to call to it, I get a segfault for trying to execute in a data section.
    : : : :
    : : : : Any ideas?
    : : : :
    : : : that's because your program does not have the necessary operating systerm permissions to do that. you need to write kernel-level code. under windows os your assembly code needs to use the flat memory model, which is unsegmented.
    : : :
    : : [blue]You need to build your EXE file with a module definition file (DEF file) where you will specify the section attributes, so you can give the .DATA section 'executable' status. Also, specify the program entry point inside .DATA section - check your command line parameters for LINK-er - it should be there. BTW, I am not sure that free LINK-ers will provide that kind of flexibility... This type of build is usually done for encrypted self-modifying code (which is so interesting to crack!).[/blue]
    : :
    : :
    : What does "BTW" mean?
    :

    "by the way"

    You can always use this web site, too:

    www.acronymfinder.com

    Matt.
    www.mpeavy.com
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories