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.