我正在写一个C写的例子..这是我的函数头:
write2(char *str, int len){
}
这是我的汇编代码:
global write2
write2:
push ebp
mov ebp, esp
mov eax, 4 ;sys_write
mov ebx, 1 ;stdout
mov ecx, [ebp+8] ;string pointer
mov edx, [ebp+12] ;string size
int 0x80 ;syscall
leave
ret
我该怎么做才能将代码传递给C函数…我正在做这样的事情:
write2(char *str, int len){
asm ( "movl 4, %%eax;"
"movl 1, %%ebx;"
"mov %1, %%ecx;"
//"mov %2, %%edx;"
"int 0x80;"
:
: "a" (str), "b" (len)
);
}
那是因为我没有输出变量,所以我该如何处理呢?
此外,使用此代码:
global main
main:
mov ebx, 5866 ;PID
mov ecx, 9 ;SIGKILL
mov eax, 37 ;sys_kill
int 0x80 ;interruption
ret
如何将代码内联到我的代码中……所以我可以向用户请求pid ..就像这样..
这是我的预制
void killp(int pid){
asm ( "mov %1, %%ebx;"
"mov 9, %%ecx;"
"mov 37, %%eax;"
:
: "a" (pid) /* optional */
);
}
本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/zaignu-cneilianhuibianzhongbianxielinux-int-80hxitongdiaoyongbao.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 24, 2019 at 04:39 上午