flat assembler
Message board for the users of flat assembler.
Index
> Windows > list files of a folder |
Author |
|
Walter 18 Sep 2017, 19:36
Code: ;***************** ;* Directory.asm * ;***************** format pe console entry start include 'win32ax.inc' section '.code' code readable executable start: cinvoke system,"Dir /B C:\Fasm" cinvoke system,"Pause" invoke ExitProcess,0 section '.idata' import data readable library kernel32,'KERNEL32.DLL',\ msvcrt,'MSVCRT.DLL' import kernel32,\ ExitProcess,'ExitProcess' import msvcrt,\ system,'system' |
|||
18 Sep 2017, 19:36 |
|
username 19 Sep 2017, 06:15
Thank you!
And how do I read the output in a buffer in my program (which is pe gui)? Also, is it possible not to show the console window? Appreciate the help! |
|||
19 Sep 2017, 06:15 |
|
Furs 19 Sep 2017, 16:58
Use CreateProcess to "cmd.exe" and send its stdout to a pipe that you read from your program. Pass the "dir" command above to cmd.exe's command line in CreateProcess.
Basically use CreatePipe, make the output to be cmd.exe's stdout and the input you read with ReadFile. There's guides out there on how to use pipes etc. Yeah, it's pretty convoluted, because of your weird requirements of not using Find*File APIs. |
|||
19 Sep 2017, 16:58 |
|
revolution 19 Sep 2017, 19:49
cmd.exe will just use those same APIs anyway. Not sure why the OP can't use them, but calling an external program to call them for you is going to be more work.
|
|||
19 Sep 2017, 19:49 |
|
username 22 Sep 2017, 08:25
All right
So are there any other API or anything else that don't use the 2 APIs? Something low level maybe? Is it possible to get access to HDD sectors and read from there the files and their contents? I don't know how the files are managed and stored by windows os "under the hood" |
|||
22 Sep 2017, 08:25 |
|
revolution 22 Sep 2017, 08:57
username wrote: Something low level maybe? username wrote: I don't know how the files are managed and stored by windows os "under the hood" |
|||
22 Sep 2017, 08:57 |
|
Picnic 22 Sep 2017, 11:42
Hi, here's a workaround that uses pipes.
Code: format PE gui 4.0 entry start include "..\include\win32ax.inc" section ".data" data readable writeable pipe dd 0 hMem dd 0 lpBuffer dd 0 cmd db "Dir /B C:\Fasm" section ".code" code readable executable start: cinvoke _popen, addr cmd, "rt" test eax, eax jz .exit mov dword [pipe], eax cinvoke malloc, 8192 test eax, eax jz .exit mov dword [hMem], eax add eax, MAX_PATH mov dword [lpBuffer], eax cinvoke memset, dword [hMem], 0, 8192 .loop: cinvoke fgets, dword [hMem], MAX_PATH, dword [pipe] test eax, eax jz .close cinvoke strcat, dword [lpBuffer], dword [hMem] jmp .loop .close: cinvoke _pclose, dword [pipe] invoke MessageBox, HWND_DESKTOP, dword [lpBuffer], addr cmd, MB_OK cinvoke free, dword [hMem] .exit: invoke ExitProcess, 0 section ".idata" import data readable writeable library\ kernel32,"kernel32.dll",\ user32,"user32.dll",\ msvcrt,"msvcrt.dll" import kernel32,\ ExitProcess,'ExitProcess' import user32,\ MessageBox,"MessageBoxA" import msvcrt,\ fgets,"fgets",\ free,"free",\ malloc,"malloc",\ memset,"memset",\ _popen,"_popen",\ _pclose,"_pclose",\ strcat,"strcat" |
|||
22 Sep 2017, 11:42 |
|
vivik 29 Sep 2017, 13:29
https://stackoverflow.com/questions/44658284/what-is-the-fastest-way-to-get-only-directory-list/44659843#44659843
NtQueryDirectoryFile This is probably related. Looks like quite a mindfuck though. |
|||
29 Sep 2017, 13:29 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.