News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Searching file on HardDrive

Started by Farabi, November 07, 2010, 09:41:56 AM

Previous topic - Next topic

Farabi

Hi all,
Anyone know how to search a file on harddrive?
I mean, search on every folder.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Vortex

Hi Onan,

Here is a nice tool :

SearchMyFiles v1.55 - Alternative to 'Search For Files And Folders' module of Windows + Duplicates Search

http://www.nirsoft.net/utils/search_my_files.html


clive

It could be a random act of randomness. Those happen a lot as well.

oex

We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

lol - maybe that's what he meant
in that case, a nice recursive is in order   :P

too funny - we all give him names of our favorite search tools

ToutEnMasm

If it is in asm,I have one who can do that (write by me)
else,more simple is the dos command "dir /S/B nameoffile.ext" on all the disk

Farabi

I guess I need to learn about recursive.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

ToutEnMasm

a recursive search is a search in all directories.All you have to do is recall the same function (the function call itsef))when you find a directory.Take care of the stack,she can grow fast.
needed stack space=(Stack space needed by the function) * (Number of directories)

Farabi

Quote from: ToutEnMasm on November 08, 2010, 09:04:44 AM
a recursive search is a search in all directories.All you have to do is recall the same function (the function call itsef))when you find a directory.Take care of the stack,she can grow fast.
needed stack space=(Stack space needed by the function) * (Number of directories)

How much space windows spare for stack?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

donkey

Hi farabi,

Stack space is not really an issue, since a recursive directory search function only needs to set aside space on the stack for a single handle there is space on the normal Windows stack for a lot of recursions. Also since the recursion is through the chain of directories the stack is loaded while moving down through nested directories and is unloaded while moving up. So the only way you could have a stack overflow is if you have a folder that is nested thousands deep, not a likely scenario. I have a recursive directory search with callback in my files.lib library that works pretty well.

Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ToutEnMasm

Quote
How much space windows spare for stack?
Quote
Stack space is not really an issue
The space required in stack is the total size of arguments passed to the proc + the size of locals variables+ few dwords to put the return adress save ebp ...
Windows take care of stack overflow with an enough amount of stack memory and some others features,not a reason to ignore it.

ToutEnMasm

To fix idea:
a windows prog,compiled wit ml 10 begin with a 3000h size of stack = 49 * MAX_PATH
You can verify this with the attached file

donkey

Quote from: ToutEnMasm on November 08, 2010, 02:31:35 PM
To fix idea:
a windows prog,compiled wit ml 10 begin with a 3000h size of stack = 49 * MAX_PATH
You can verify this with the attached file


I never actually said it could be ignored, it simply isn't an issue with so small of an amount of stack based data. There are only 24 bytes pushed onto the stack in a recursive folder search, 3 parameters, the return address, EBP and one handle (WFD). Not sure why you are worried about MAX_PATH, there is never a need to push a file name onto the stack or anything that large.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

theunknownguy

This is a source i once do for search for a specific kind of file and encrypt it + recursive search:


        .Data
  ScanType DB "*.*", 0
  DataPath         DB "./data/", 0

       .Code
        FindFiles Proc Path:DWord
Local Info:WIN32_FIND_DATA
Local fHandle:DWord
Local ArchiveNoFileOff:DWord
Local PathLastFolderOff:DWord
Invoke szCopy, Path, Offset ArchivePath
Invoke szLen, Offset ArchivePath
Lea Edx, ArchivePath
Add Edx, Eax
Sub Edx, 3
Mov ArchiveNoFileOff, Edx
Invoke szLen, Path
Mov Edx, Path
Add Edx, Eax
Sub Edx, 3
Mov PathLastFolderOff, Edx
Invoke FindFirstFile, Path, Addr Info
.If (Eax == INVALID_HANDLE_VALUE)
Xor Eax, Eax
Jmp @End
.EndIf
Mov fHandle, Eax
.Repeat
.If (Info.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
.If (Byte Ptr Info.cFileName == '.')
Invoke FindNextFile, fHandle, Addr Info
.If (Eax == 0)
.Break
.EndIf
.Continue
.EndIf
Invoke szCopy, Addr Info.cFileName, PathLastFolderOff
Invoke szLen, Path
Mov Edx, Path
Mov Byte Ptr [Edx+Eax], '/'
Mov Byte Ptr [Edx+Eax+1], 0
Invoke szCatStr, Path, Offset ScanType
Invoke FindFiles, Path
Invoke FindNextFile, fHandle, Addr Info
.If (Eax == 0)
.Break
.EndIf
.Else
Invoke FindExtension, Addr Info.cFileName
.If (Eax == 0)
Invoke FindNextFile, fHandle, Addr Info
.Continue
.ElseIf (Eax == 1)
Invoke szCopy, Addr Info.cFileName, ArchiveNoFileOff
Invoke FindPath, Offset ArchivePath
.If (Eax == 0)
Invoke FindNextFile, fHandle, Addr Info
.Continue
.Endif
.Else
Invoke szCopy, Addr Info.cFileName, ArchiveNoFileOff
.Endif
Invoke ReadThisFile, Offset ArchivePath
.If (Eax == NULL)
Invoke FindNextFile, fHandle, Addr Info
.Continue
.EndIf
Invoke EncrypThisFile, Eax, Edx, Ecx
Invoke FindNextFile, fHandle, Addr Info
.EndIf
.Until (Eax == 0)
@End:
Ret
FindFiles EndP


FindExtension is just a proc for find the extension of the file (no need for paste it here).

Anyway hope it could help you.  :U