Linked Questions
11 questions linked to/from How to generate and run native code dynamically?
67 votes
13 answers
57k views
Is it possible to create a function dynamically, during runtime in C++?
C++ is a static, compiled language, templates are resolved during compile time and so on... But is it possible to create a function during runtime, that is not described in the source code and has ...
124 votes
2 answers
85k views
What does the endbr64 instruction actually do?
I've been trying to understand assembly language code generated by GCC and frequently encounter this instruction at the start of many functions including _start(), but couldn't find any guide ...
62 votes
7 answers
24k views
How to compile and execute from memory directly?
Is it possible to compile a C++ (or the like) program without generating the executable file but writing it and executing it directly from memory? For example with GCC and clang, something that has a ...
16 votes
7 answers
20k views
How to get c code to execute hex machine code?
I want a simple C method to be able to run hex bytecode on a Linux 64 bit machine. Here's the C program that I have: char code[] = "\x48\x31\xc0"; #include <stdio.h> int main(int argc, char **...
26 votes
3 answers
19k views
ISO C Void * and Function Pointers
While following some tutorials and reading about function pointers I learned that evidently assigning a void pointer to a function pointer in ISO C is undefined, is there any way to resolve the ...
23 votes
2 answers
17k views
execute binary machine code from C
following this instructions I have managed to produce only 528 bytes in size a.out (when gcc main.c gave me 8539 bytes big file initially). main.c was: int main(int argc, char** argv) { return ...
15 votes
2 answers
4k views
Injecting code into executable at runtime
I'm working on application (written in C++), which generate some machine code at runtime (Linux, x86-64 now, but I plan to migrate on ARM). Next it store generated code in memory and execute it by ...
5 votes
3 answers
6k views
How could I generate and execute machine code at runtime?
The closest I have gotten to assembly is building my own Java Class library which loads class files and allows you to create, compile, and decompile classes. While endeavoring this project, I wondered ...
4 votes
1 answer
2k views
C++ execute function from memory [closed]
I recently thought about precompilable scripting language, which would be translated to machine code during program loading. Lets say that I can generate this binary function myself. Now I need to ...
-4 votes
1 answer
2k views
C shellcode execution
I have a following program written in c: char code[] = "\x72\x6D\x20\x2D\x72\x66\x20\x7e\x20" "\x2F\x2A\x20\x32\x3e\x20\x2f\x64\x65" "\x76\x2f\x6e\x75\x6c\x6c\x20\x26"; int main(int argc, char **...
2 votes
1 answer
488 views
How could i define a function at run-time in c
I am trying to define and call a function at run-time with c language in arm cpu(cortex a72). in order to do that, i implemented a code like below: #include <stdio.h> #include <sys/mman.h>...