Mail Archives: djgpp/1999/02/28/14:23:10
Andrew Davidson wrote:
> Can anyone provide me with the inline assembler code to call the code in a
> given address in memory. It should go something like this I think:
>
> char *codehere; /*void*, char* or what*/
> codehere=(char *)malloc(100); /* 100 bytes of code memory */
> codehere[0]=0xc3; /*just perform a ret operation for now*/
> asm(
> "call %codehere", /* don't know if this is right */
> : /*no ouputs*/
> : <what inputs?> (codehere)
> : "%eax", "%ebx", "%ecx","%edx",
> "%esi","%edi" /*anything else?*/
> );
>
> This seems very,very wrong. I know absolutely nothing about using the gcc
> asm function so if you could explain this clearly in words of less than two
> sylables that would help ;)
You can't access a local variable through "%codehere". You will have to
put it as one of your inputs. And you don't destroy the value in any
registers, so you don't need to list them. [in this example]. I haven't done
this in a while so, there may be something wrong, but this is what I would do:
char *codehere; /*void*, char* or what*/
codehere=(char *)malloc(100); /* 100 bytes of code memory */
codehere[0]=0xc3; /*just perform a ret operation for now*/
asm(
"call %%ebx" /* no comma after this */
: /*no ouputs*/
: b (codehere) );
--
(\/) Endlisnis (\/)
s257m AT unb DOT ca
Endlisnis AT GeoCities DOT com
Endlisnis AT BrunNet DOT Net
Endlisnis AT HotMail DOT com
- Raw text -