C ++ performs a function from memory

I recently thought of a precompilation scripting language that will be translated into machine code during program loading.

Suppose I can generate this binary function myself. Now I need to somehow execute it. The general scheme will look like this:

char* binary = compile("script.sc");
pushArgsToStack(1,7);
memexec(binary);
int ret = getEax();

Is there a chance to make it work?

Also, will calling jmp to C ++ funcion address work as planned? I mean, after pressing args, returnAddr, etc., I want to somehow call this function from my compiled script.

Thanks for any answers.

+4
source share
1 answer

This can certainly be done.

compile, , ".sc" , . , , , llvm, . , , ( ) .

- . push- "".

:

int ret = memexec(binary);

, memexec , , ( , , - , , - )

, , 15-20 , " ", , malloc. , .

+3

Source: https://habr.com/ru/post/1542432/


All Articles