First, sorry about the length of post, second this is a code fragment adapted from Stephan Krause 'scan.exe' (win32asmnewbies.cjb.net) It should enumerate all directories on hard drive skipping files. It works well and finds most except it doesn't find \windows\cookies; \Recycled and I don't know what others. Here it is.
FindFile proc File:DWORD,Path:DWORD
LOCAL wfd:WIN32_FIND_DATA
LOCAL Buffer
LOCAL hFile:DWORD
invoke wsprintf,addr Buffer,offset szS,Path,File
invoke FindFirstFile,addr Buffer,addr wfd
cmp eax,INVALID_HANDLE_VALUE
jz @f
mov hFile, eax
jmp @dir
@next:
invoke FindNextFile,hFile,addr wfd
or eax,00h
jnz @dir
invoke FindClose,hFile
xor eax,eax
ret
@dir:
mov eax,wfd.dwFileAttributes
cmp eax,FILE_ATTRIBUTE_DIRECTORY
jnz @next
movzx eax,byte ptr
cmp al,2eh
jz @next
invoke wsprintf,addr Buffer,offset szS2,\
Path,addr wfd.cFileName
invoke DirPath,addr Buffer
invoke FindFile,File,addr Buffer
lea edi,Buffer
or ecx,-1
xor eax,eax
repne scasb
mov al,5ch
sub edi,3
std
repne scasb
cld
; mov dword ptr,002A2E2Ah
jmp @next
@@:
ret
FindFile endp
If anybody knows why it doesn't find all directories please let me know.
czDrillard
Hello,
this is just a guess (I don't really know what's wrong with it) but maybe the program doesn't find Folder that have other Attributes than being just a folder. Maybe they are HIDDEN or they are SYSTEM FILES (don't know how this is called, in Germany this is the Option System). As I said, just a guess, but maybe this helps. As far as I know, my Recycled folder for example is hidden and system.
Stefan