gpt4 book ai didi

c - x86 程序集读/写文件

转载 作者:太空宇宙 更新时间:2023-11-04 06:34:05 24 4
gpt4 key购买 nike

到目前为止,我正在尝试写入一个文件,我有以下代码可以附加到该文件。有人知道为什么这不起作用吗?它运行良好,但到最后什么都没有改变。

filewritemode: .asciz "a"
filelocation: .asciz "/h/test.txt"

_main:

push $filelocation
push $filewritemode
call _fopen
push $blabla
push %eax
call _fprintf

push $result
call _printf
push $0
call _exit # exit the program

gcc 用于将源文件转换为 .exe$blabla 目前是带有一些随机字符的字符串,用于测试

最佳答案

它不起作用,因为您以错误的顺序推送了 fopen 的参数。参数必须从最后推到第一个。除此之外,您会反复推送参数,但不会再次删除它们。在这种情况下,这是可行的,因为您潜入 exit,但如果相反,您会返回 ret 指令,您会发现这会导致崩溃因为您会跳转到推送的参数之一。

关于c - x86 程序集读/写文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16942219/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com