Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Finding Shared Directorys Problem

Finding Shared Directorys Problem

Finding Shared Directorys Problem

For my next project, I am making a program which searches for all of the shared directories on a computer. My idea is if the directory contains the string "share", then it must be shared.

Program Breakdown:
1. change directory to C:\ drive
2. find first directory
3. convert directory name to upper-case
4. compare upper-case directory character-by-character for the string "SHARE"
5. if the string is found, display the directory name (with a message box)
6. if the string is not found, goto step 2
7. if there are no more directories on the C:\ drive, exit

Each one of these functions works on their own (converting to upper-case, looking for "SHARE", enumerating all directories on the C:\ drive).  When I put them all together, I get errors.  The program executes fine until it finds a shared directory, then it fails.

Any idea what's wrong with my code?



EXTRN    FindFirstFileA        :PROC
EXTRN    MessageBoxA        :PROC
EXTRN    FindNextFileA        :PROC
EXTRN    FindClose        :PROC
EXTRN    SetCurrentDirectoryA    :PROC
EXTRN    lstrcpyA        :PROC

MAX_PATH            equ    256

    dwFileAttributes    dd ?
    ftCreationTime        dq ?
    ftLastAccessTime    dq ?
    ftLastWriteTime        dq ?
    nFileSizeHigh        dd ?
    nFileSizeLow        dd ?
    Reserved0        dd ?
    Reserved1        dd ?
    cFileName        db MAX_PATH dup(?)
    cAlternateFileName    db 14 dup(?)

    hFind        dd ?
    szMask        db "*.*", 0
    szBackDir    db "..", 0
    szDirectory    db MAX_PATH dup(?)
    win32FindData    WIN32_FIND_DATA <?>
    szDrive        db "C:\", 0

    push    offset szDrive
    call    SetCurrentDirectoryA

    push    offset win32FindData
    push    offset szMask
    call    FindFirstFileA                ; find first file in C:\ drive
    mov    [hFind], eax

    cmp    eax, 0                    ; no files?
    je    downDirectory
    cmp    byte ptr [win32FindData.cFileName], "."
    je    findNextFile
    cmp    [win32FindData.dwFileAttributes], 10h
    je    upDirectory
    cmp    [win32FindData.dwFileAttributes], 30h
    je    upDirectory

    push    offset win32FindData
    push    [hFind]
    call    FindNextFileA
    jmp    checkType

    push    offset win32FindData.cFileName
    push    offset szDirectory
    call    lstrcpyA

    mov    eax, offset szDirectory

    cmp    byte ptr [eax], 90                ; already uppercase? (90 = Z)
    jle    toUpperCase
    xor    byte ptr [eax], 32                ; convert

    inc    eax
    cmp    byte ptr [eax], 0                ; at end of string?
    je    endOfString
    cmp    byte ptr [eax], 90                ; already uppercase?
    jle    toUpperCase
    xor    byte ptr [eax], 32                ; convert
    jmp    toUpperCase

    mov    eax, 0
    mov    eax, offset szDirectory

    inc    eax
    cmp    byte ptr [eax], 0                ; end of string?
    jne    noShare
    cmp    byte ptr [eax], "S"                ; check for S
    jne    searchShare
    cmp    byte ptr [eax + 1], "H"                ; check for H
    jne    searchShare
    cmp    byte ptr [eax + 2], "A"                ;
    jne    searchShare
    cmp    byte ptr [eax + 3], "R"                ;
    jne    searchShare
    cmp    byte ptr [eax + 4], "E"                ;
    jne    searchShare

    push    0
    push    offset szDirectory
    push    offset szDirectory
    push    0
    call    MessageBoxA                    ; display directory

    push    offset szDirectory
    call    SetCurrentDirectoryA
    cmp    eax, 0
    je    findNextFile

    push    hFind
    jmp    findFirstFile

    push    offset szBackDir
    call    SetCurrentDirectoryA
    push    [hFind]
    call    FindClose
    pop    [hFind]
    cmp    [hFind], 0
    jne    findNextFile

    END    MAIN

I am using TASM 5.0 and Tlink32: Checkpoint Software: Firewall-1 Links to compile.

Thanks in advance!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close