News:

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

error_mod_not_found

Started by Magnum, April 17, 2010, 11:08:39 PM

Previous topic - Next topic

Magnum

I got an error_mod_not_found on this file.
New one for me.

Can someone help me fix this.
The works fine in a batch file, so it should work.


; error_mod_not_found
; Delete_ALL.asm Open a cmd window
;  deltree.exe Deletes a directory and all the subdirectories and              files in it.
;
; To delete one or more files and directories:
; DELTREE [/Y] [drive:]path [[drive:]path[...]]
;
;   /Y              Suppresses prompting to confirm you want to delete
;                   the subdirectory.
;   [drive:]path    Specifies the name of the directory you want to delete.
;
; Note: Use DELTREE cautiously. Every file and subdirectory within the
; specified directory will be deleted.
;                               
;
.386
.MODEL FLAT, STDCALL
OPTION CASEMAP: NONE


    include \masm32\include\windows.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc
    include \masm32\include\advapi32.inc
    include \masm32\include\shlwapi.inc
    include \masm32\include\shell32.inc
    include \masm32\macros\macros.asm

    includelib  \masm32\lib\kernel32.lib
    includelib  \masm32\lib\user32.lib
    includelib  \masm32\lib\advapi32.lib
    includelib  \masm32\lib\shlwapi.lib
    includelib  \masm32\lib\shell32.lib

BREAK equ int 1h ;Breakpoint for debugging apps

.DATA

szOpen    DB "open",0
cmd       DB "C:\Spec_Progs\deltree.exe",0
params    db "/Y C:\Documents and Settings\LU\Local Settings\Temp",0
directory db "C:",0

.CODE

Internal_Notes  db "A.K. 2010"

start:

invoke ShellExecute,NULL,NULL,OFFSET cmd,offset params,OFFSET directory,SW_SHOW

invoke ExitProcess,0

end start

Have a great day,
                         Andy

clive

Quote from: Magnum
params    db "/Y C:\Documents and Settings\LU\Local Settings\Temp",0

You might want to put paths with spaces in quotes.

params    db "/Y ""C:\Documents and Settings\LU\Local Settings\Temp""",0

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

MichaelW

Quote from: clive on April 18, 2010, 12:37:45 AM
You might want to put paths with spaces in quotes.

params    db "/Y ""C:\Documents and Settings\LU\Local Settings\Temp""",0


That will assemble, but the passed command line is broken after the /F. This syntax will assemble and pass the entire command line (note that I had to place the space after the /Y inside the inner quotes):

params    db '/Y" C:\Documents and Settings\LU\Local Settings\Temp"',0

eschew obfuscation

joemc

makes more sense to me to write as:

params    db "/Y ",22h,"C:\Documents and Settings\LU\Local Settings\Temp",22h,0

and i would pass a NULL or C:\ instead of C: for lpDirectory. 
Quote from: MSDN
pDirectory [in, optional]
LPCTSTR
A pointer to a null-terminated string that specifies the default (working) directory for the action. If this value is NULL, the current working directory is used. If a relative path is provided at lpFile, do not use a relative path for lpDirectory.

sinsi

You might look at SHFileOperation to delete files, not sure about directories though.
Light travels faster than sound, that's why some people seem bright until you hear them.

MichaelW

Quote from: joemc on April 18, 2010, 06:12:58 AM
makes more sense to me to write as:

params    db "/Y ",22h,"C:\Documents and Settings\LU\Local Settings\Temp",22h,0

The passed command line is broken after the /Y. My problem with that syntax is that it requires you to know the character code for a double quote.
eschew obfuscation

joemc

Quote from: MichaelW on April 18, 2010, 06:32:26 AM
The passed command line is broken after the /Y.
Thats seems like a strange way for them to parse the string.
i will have to test but maybe:
db 22h,"/Y ",22h,"C:\Documents and Settings\LU\Local Settings\Temp",22h,22h,0

Quote from: MichaelW on April 18, 2010, 06:32:26 AM
My problem with that syntax is that it requires you to know the character code for a double quote.
I can't get ASCII out of my head, wish that it were a problem for me. Maybe an EQU would make it cleaner though. or a comment.

MichaelW

For:

db 22h,"/Y ",22h,"C:\Documents and Settings\LU\Local Settings\Temp",22h,22h,0

The passed command line is:

/Y C:\Documents
eschew obfuscation

sinsi

Just use the ' character to enclose the whole thing and use the " character as the literal in the command line.
db '/y "C:\Documents and Settings\LU\Local Settings\Temp"',0
The /y doesn't need to be in quotes but any path with spaces does.

Of course if you don't have access to that path it won't work anyway.
Light travels faster than sound, that's why some people seem bright until you hear them.

joemc

To avoid the shellexec I would just stick to FindFirstFile http://msdn.microsoft.com/en-us/library/aa364418(VS.85).aspx
and DeleteFile http://msdn.microsoft.com/en-us/library/aa363915(VS.85).aspx
and if desire RemoveDirectory http://msdn.microsoft.com/en-us/library/aa365488(VS.85).aspx
that way you know what your program is doing. shell exec could do anything if the target has been modified and creates an unnecessary process.

Sinsi,
I believe that would be the same as my first attempt.

MichaelW

Quote from: sinsi on April 18, 2010, 07:04:34 AM
The /y doesn't need to be in quotes but any path with spaces does.

It looks to me like the /Y is part of the command line that needs to be passed to deltree. For my tests I coded an app that displays its command line, named it deltree.exe and placed it on the specified path. I then ran the posted code to see what command line ShellExecute is passing. So far, my syntax is the only one that will pass the entire command line.

eschew obfuscation

joemc

perhaps the proper way would be

szOpen    DB "open",0
cmd       DB "C:\Spec_Progs\deltree.exe",0               
params    db "/Y \Temp*",0       ; can't imagine would need to be db 22h,"/Y \Temp*",22h,0   
directory db 22h,"C:\Documents and Settings\LU\Local Settings\",22h,0

clive

Here's how the original, and my paired double quote method work with the standard MSVC command line parser. I'll note that the paired double quote method is one that has worked in a great many computer languages since '82. As such I'd classify it as one of the more portable methods. Of course you have to understand it, but that's true of many techniques and representations. It is agnostic to ASCII, EBCDIC, etc encoding, and languages where the single quote means something else. Paired single quotes should also work.

ARG : 'ARGV[ARG]'
0 : 'z:\dev\asm\args.exe'
1 : '/Y'
2 : 'C:\Documents'
3 : 'and'
4 : 'Settings\LU\Local'
5 : 'Settings\Temp'


0 : 'z:\dev\asm\args.exe'
1 : '/Y'
2 : 'C:\Documents and Settings\LU\Local Settings\Temp'


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

Magnum

Quote from: sinsi on April 18, 2010, 06:31:02 AM
You might look at SHFileOperation to delete files, not sure about directories though.

You get the gold star. I didn't like the clunky ShellExecute anyway.  :lol


; Delete_ALL.asm 
;              Help from Sinsi,Hutch,Clive,joemc,Michael,
;
    .486                       ; create 32 bit code
    .model flat, stdcall       ; 32 bit memory model
    option casemap :none       ; case sensitive

    include \masm32\include\windows.inc
    include \masm32\include\masm32.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc
    include \masm32\include\shell32.inc
    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib
    includelib \masm32\lib\shell32.lib
    include \masm32\macros\macros.asm

    RecycleFile PROTO :DWORD

    .data

  fname1 db "C:\Documents and Settings\LU\Local Settings\Temp",0,0     
             
  buffer  db 30 dup (0)     

    .code

start:
     
    invoke RecycleFile,ADDR fname1

    push eax
    invoke GetLastError
    invoke dw2a,eax,ADDR buffer
    print SADD(13,10,"GetLastError returned ")
    print ADDR buffer
    pop eax
    invoke ExitProcess,0

; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
; This proc calls the SHFileOperation function to delete
; the specified file or files to the recycle bin. Each file
; must be specified with a fully qualified path (otherwise,
; the file will simply be deleted, without being placed in
; the recycle bin). Multiple files can specified by
; separating the individual paths with a null, and appending
; an additional null to the end of the final path.
;
; Returns zero for success, or nonzero for failure.
;
; Initializing the hwnd element to NULL proved to be
; necessary so the SHFileOperation function could delete
; a file that was created by the calling process.
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
RecycleFile proc pszFullPath:DWORD
    LOCAL fo:SHFILEOPSTRUCT
   
    mov fo.hwnd,  NULL
    mov fo.wFunc, FO_DELETE
    m2m fo.pFrom, pszFullPath
    mov fo.pTo,   NULL
    mov fo.fFlags,FOF_ALLOWUNDO
    invoke SHFileOperation,ADDR fo

    ret
RecycleFile endp

end start

; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

; * Note WORD element *:

SHFILEOPSTRUCTA STRUCT
  hwnd                  DWORD      ?
  wFunc                 DWORD      ?
  pFrom                 DWORD      ?
  pTo                   DWORD      ?
  fFlags                FILEOP_FLAGS ?
  fAnyOperationsAborted DWORD      ?
  hNameMappings         DWORD      ?
  lpszProgressTitle     DWORD      ?
SHFILEOPSTRUCTA ENDS
FILEOP_FLAGS            typedef WORD



Have a great day,
                         Andy

MichaelW

Compiling my dummy app with the Microsoft Visual C++ 2003 Toolkit does not change my results. The /Y must be included within the paired quotes or the space following it will terminate the command line.
eschew obfuscation