How can I redirect execution to code on heap? OS: 64bit linux
What I tried is setting rip
to my array, I can't get it to compile though. My code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int len = 0;
char *t;
int chr;
printf("Input code length: ");
scanf("%d", &len);
t = (char*)malloc(len+1);
for (int i = 0; i < len; ++i) {
scanf("%x", &chr);
t[i] = chr;
}
t[len] = 0;
asm("movl %%rip, [%0]" : "=g"(t));
}