附加一个具有int 0x80的文件(访问位?) [英] Appending a File with int 0x80 (Access bits?)

查看:95
本文介绍了附加一个具有int 0x80的文件(访问位?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的NASM教科书中,Dandamundi的"Linux汇编编程指南" 中,系统调用5(打开文件)使用以下参数进行了描述.

In my NASM textbook, "Guide to Assembly Programming in Linux" by Dandamundi, system call 5 (opening a file) is described with the following parameters.

EAX = 5
EBX = file name
ECX = file access mode (read, write, read/write)
EDX = file permissions

它并没有弄清楚访问码(我假设是八进制)实际上是什么.假定0200Q和02000Q不起作用.我正在尝试将一个文件的内容附加到另一个文件上.

It does not clarify what the access codes (octal, I'm assuming) actually are. 0200Q and 02000Q assumedly do not work. I am trying to append the contents of one file onto another file.

推荐答案

查看/usr/include/asm/unistd_32.h后,很明显系统调用5解析为open.反过来,查看man 2 open表示第二个参数必须包含O_RDONLY(00),O_WRONLY(01)或O_RDWR(02).通过将它们进行或"运算,还可以包括许多额外的标志,这些标志记录在该手册页上.

After looking at /usr/include/asm/unistd_32.h, it's clear that system call number 5 resolves to open. In turn, looking at man 2 open says that the second parameter must include O_RDONLY (00), O_WRONLY (01) or O_RDWR (02). It may also include a number of extra flags by ORing them together, which are documented on the said manual page.

在您的情况下,您可能希望能够写入文件并追加到该文件.因此,O_WRONLY | O_APPEND是可取的.在查看了头文件之后,该操作将产生值02001,这是应该放入ecx寄存器中的内容.

In your case, you probably want to be able to write to a file and append to it. Therefore, O_WRONLY | O_APPEND would be desirable. After looking at the header files, that operation yields the value 02001 and this is what you should put in the ecx register.

这篇关于附加一个具有int 0x80的文件(访问位?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆