I been trying to find a masm example for getting the complete directory list, without filenames.  I'm still having no luck.  I need to know how to scan and generate FullPathName of all Folders on Win95 - XP systems.

I know that Windows has an complete list used by EXPLORER somewhere.  Is there a way to also get to that list and use that, including a way of generating the listing myself?
Posted on 2007-06-02 18:27:59 by numan
This is more difficult than i thought, I can't figure out how to do this .  I seriously need some help to find a way to keep count of each folder created on my machines, using asm code to include in a little tool i use.  I need to get FullPathName of each folder and add them to my count per drive.  There is a lot of information here about GetFileName with FindFirstFile but nothing i can see about finding folders FullPathName.  Would anyone know how to do this or have any suggestions.  I would really appreciate it.
Posted on 2007-06-02 23:52:11 by numan
By FullPathName do you mean something like "C:\WINDOWS"? If you're using a recursive search algo, making the full path should be easy enough.

Post some code and someone might be able to help.
Posted on 2007-06-03 01:00:22 by sinsi
I found these two sources that I have been working with and not getting anywhere.  One is  bitRAKEs that I can't get working and
the other one is by Mob that I can't seem to modify.

I'm trying to generate a Folder List, not a list of files.  Only a list of all Folders and Sub Folders for all drives. c,d,e,f etc

Than latter i want to do it for all files with a count of how many in each folder.

c:\Windows
c:\Windows\ADDINS
c:\Program Files
c:\Program Files\Internet Explorer
c:\Program Files\Internet Explorer\Connection Wizard
etc.

Thanks sinsi
Attachments:
Posted on 2007-06-03 01:53:46 by numan
numan,

Perhaps the following will help.
It's Fasm, but it is ASM.

It will print a list of directories in
whichever folder you run.  You
would need to add recursion to it.

Checking for FILE_ATTRIBUTE_DIRECTORY
is the key to getting only directories and
not files.

Maybe a starting point?

Mark


;****************
;* DirNames.asm *
;****************

format pe console
entry start

include 'C:\fasm\INCLUDE\win32a.inc'

section '.data' data readable writeable

    strMsg db 'Directory Names',13,10,0
    strDsh db '---------------',13,10,0
    strFormat db '%s',13,10,0
    strFileFirst db '.\*',0
    strCommand db 'Pause',0

    FindFileData WIN32_FIND_DATA
    hFind dd ?

section '.code' code readable executable

    start:

    cinvoke printf,strMsg
    cinvoke printf,strDsh
    invoke FindFirstFile,strFileFirst,FindFileData
    mov ,eax
    stdcall NameOut
@@:
    invoke FindNextFile,,FindFileData
    cmp eax,0
    je @f
    stdcall NameOut
    jmp @b
@@:
    invoke FindClose,hFind
    cinvoke system,strCommand
    invoke ExitProcess,0

proc NameOut
    cmp ,FILE_ATTRIBUTE_DIRECTORY
    jne @f
    cinvoke printf,strFormat,FindFileData.cFileName
@@:
    ret
endp

section '.idata' import data readable writeable

    library kernel32,'KERNEL32.DLL',\
            msvcrt,'MSVCRT.DLL'
         
    import kernel32,\
           FindFirstFile,'FindFirstFileA',\
           FindNextFile,'FindNextFileA',\
           FindClose,'FindClose',\
           ExitProcess,'ExitProcess'

    import msvcrt,\
           printf,'printf',\
           system,'system'


Oh yeah, you should probably check
for INVALID_HANDLE_VALUE after
the find file function calls.


Posted on 2007-06-03 02:07:52 by RotateRight
If you've got MASM32 look at C:\masm32\examples\exampl11\ftree.
If not, the code by RotateRight has the essentials.
Posted on 2007-06-03 02:15:44 by sinsi
Masm32 now got me confused .  It done turned into a macro fest.  It  looks like 30 difference macros being used for ftree, and it only works for the current directory it's in.  I wonder why masm32 is so into macros.  That's not real asm, is it.  It don't seem the way to go for introduction to new people interested in pure asm.  I'm still having problems catching on to the basics let along getting lost in a pile of macros.

Thanks RotateRight, but I could not translate your code to masm.  This new attachment shows how far i got.  What am I'm doing wrong?
Attachments:
Posted on 2007-06-03 04:42:44 by numan
I got things working after i got frustrated trying to translates all those macros.  I said to myself Fasm or Macros knowing macros is way out of my league.  So i did good with Fasm and got your code working in masm RotateRight.  Now i know a little more about Fasm.
Thanks you both a lot for the help.
Posted on 2007-06-03 06:22:56 by numan
I have one more problem.  I like Mob code because it is set up to do the entire hard drive.  I marked the points where I made changes with ;@@@@@@@@@@@@@@@@ and i added a buffer call BUFFERxxx

I included GetCurrentDirectory api and it works but it is repeating between 4 - 17 lines per Folder when it write the file. 
Could somebody please help correct the code in this new attachment.     
Attachments:
Posted on 2007-06-03 07:12:14 by numan
Never mind.  It's was doing what i want all the time and I'm just realizing it :O
Posted on 2007-06-03 13:32:06 by numan
I hope there is no animosity concerning my opinion about the over use of macros in masm32 new examples.  I don't understand macros.  That don't mean I don't want to never learn how to use them.  I commented in hope that the author would take into consideration for future examples by creating a separate section for macros and console  programs.  Nothing more, nothing less.  How I said it shouldn't be a issue.  I did not major in speech writing or Law to be able to say things the way others wants to hear it in order to acquire acceptances.

I needed to say something about this now instead of waiting to see what happens later which would be many people acting all surprised than complaining.  This was the only thing that came to mind to pass the word.  No disrespect or backstabbing.

There was nothing like assembling a masm32 example and running the program and understanding things quickly.  I'm sure that what got everyone interested from the start.

I just hope masm32 continue to improve while keeping it original style as it advance.  Which only means to include some new form of organization to keep inexperience people interested without any confusion.  I don't know much about the deep working of ASM but i'm here to learn and I want to stick with it.

For now i wish someone would help me to list all the folders on my hard drive.  I been trying for a long time and can't get things to work the way it should.  Everything i founded and tried is about listing  files and directory which I understand but FOLDERS only i don't know how. I get

c:\unzipped\Fireworks
......

I need

c:\unzipped
c:\unzipped\Fireworks
......

If a folder don't include a file it give you the sub folders. and if there is no sub folder or file, it give you nothing.

That's the problem.

I found this and it seems like something i'm trying to do.  Other than this and the examples here their is nothing that i can find or do that even comes close.  If anyone know how could you please help me out.

Thanks

http://www.asmcommunity.net/board/index.php?PHPSESSID=f2133e7fec0bf91f207845a9ddc86291&topic=21562.0


Posted on 2007-06-09 04:51:44 by numan
I've been looking at trying to do a 16 bit version for months.

It beats crosswords any day of the week. :D

Still not got there yet tho, I keep changing my approach.

There are multiple decision parameters as you search, and trying to do the lot in a single pass is a real brain teaser.

There is something called file control blocks which might make it easier but I am trying to only use string manipulation/decisions.
The folders on the root may need multiple passes but it should be possible to do a single pass in each folder tree.

The limit for 16bit string manipulation could be the 64 byte return from
int21-47 get current dir, so to achieve something that searches deeper than that it would be worth some prior research to make sure that a, say, 70byte path would work with int21-3B change current directory.

So you're not alone in the world as you struggle with this stuff.
Have fun. I certainly am.  ;)

edit:
btw theres a DOS HDD search utility on the net called findit.com, if you can findit :)
Posted on 2007-06-09 14:14:19 by eek