Hallo,
warum funktioniert dieser code nicht?
es soll eine datei in den speicher geladen und ausgeführt werden.
danke für tipps
warum funktioniert dieser code nicht?
es soll eine datei in den speicher geladen und ausgeführt werden.
danke für tipps
Code:
typedef int (*myproc1)(void*);
typedef int (*myproc2)(int);
void ExecMapFile(void (*ptr)(void))
{
int fd;
struct stat attr;
myproc2 callback;
if ((fd = open("z.bin",O_RDONLY)) < 0)
{
fprintf(stderr,"%s : Konnte Eingabedatei nicht öffnen\n",strerror(errno));
}
if (fstat(fd, &attr) == -1)
{
fprintf(stderr,"Fehler bei fstat.......\n");
}
lseek(fd,0,0);
printf("0x%x\n",ptr);
callback = mmap(0x401015, attr.st_size, PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0);
close(fd);
printf("0x%x\n",callback);
callback((int)callback);
}