遍历 NASM x86 目录中的文件
我到处寻找类似的问题,但没有结果。 我正在尝试在 Ubuntu 中使用 NASM 来熟悉 x86 ASM。 我想编写一个仅针对具有 .txt 扩展名的文件的程序,因此我想迭代当前目录,将这些文件保存到数组(或只是将它们推入堆栈),然后迭代它们,使用 sys_open 修改它们和文件描述符。
现在我无法弄清楚如何找到这些文件,所以我想也许有一种方法可以只调用 /bin/find 并使用结果,但碰上了另一堵墙,因为我很确定你不能访问/使用通过中断/系统调用返回的内容。
%include 'functions.asm'
SECTION .data
cmd db '/bin/find', 0h
arg1 db '.', 0h
arg2 db '-type', 0h
arg3 db 'f', 0h
arg4 db '-name', 0h
arg5 db '*.txt', 0h
args dd cmd
dd arg1
dd arg2
dd arg3
dd arg4
dd arg5
dd 0h
environment dd 0h
SECTION .text
global _start
_start:
mov edx, environment
mov ecx, args
mov ebx, cmd
mov eax, 11
int 80h
call quit
这就是我调用 /bin/find 来基本上列出当前目录中所有 .txt 文件的方式。
谁能帮我找到一种方法来做到这一点?有什么推荐的阅读材料吗?同样,目标是文件名或文件描述符的“数组”,以便我可以迭代这些特定文件。
I looked everywhere for any question like this, to no avail.
I am trying to get acquainted with x86 ASM, using NASM in Ubuntu.
I want to write a program targeting only files with a .txt extension, so I want to iterate through the current directory, save these files to an array (or just push them on the stack), and iterate through them, modifying them using sys_open and the file descriptors.
Now I could not figure out for the life of me how to find the files, so I thought maybe there is a way to just call /bin/find and just use the results, but hit another wall, as I am pretty certain you cannot access/use the things that are returned through an interrupt/syscall.
%include 'functions.asm'
SECTION .data
cmd db '/bin/find', 0h
arg1 db '.', 0h
arg2 db '-type', 0h
arg3 db 'f', 0h
arg4 db '-name', 0h
arg5 db '*.txt', 0h
args dd cmd
dd arg1
dd arg2
dd arg3
dd arg4
dd arg5
dd 0h
environment dd 0h
SECTION .text
global _start
_start:
mov edx, environment
mov ecx, args
mov ebx, cmd
mov eax, 11
int 80h
call quit
This is how I called /bin/find to basically list all .txt files in the current directory.
Can anyone help me out in finding a way to do this? Any reading material that is recommended? Again, the goal is an 'array' of file names or file descriptors so that I can iterate through those specific files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论