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 put in some error code to be able to respond when the directory isn't there.
But it isn't working completely.

I am getting a "Cannot delete file: Cannot read from the source file or disk."


invoke RecycleFile,ADDR fname1
   
    .if eax != NULL
      invoke  MessageBox, NULL, addr msg_NotNT, addr AppName, MB_OK
      invoke  ExitProcess, NULL
    .endif
Have a great day,
                         Andy

dedndave

you might get that error if the file is in a ZIP or CAB, etc

clive

Quote from: MichaelW on April 18, 2010, 02:52:09 PM
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.

That seems very odd, could you post the source/executable.

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

MichaelW

#18
Quote from: clive on April 18, 2010, 08:42:03 PM
That seems very odd, could you post the source/executable.

Edit:

I finally woke up and realized that my test is not valid, because deltree is going to be looking for two arguments, not just one. And realizing that, I now recall making this same mistake several years ago.
eschew obfuscation

joemc

Basically what you want to do is provided at url below. except instead of print call DeleteFile and  RemoveDirectory
http://www.devasp.net/net/articles/display/652.html


Magnum

Quote from: MichaelW on April 19, 2010, 01:45:53 AM
Quote from: clive on April 18, 2010, 08:42:03 PM
That seems very odd, could you post the source/executable.

Edit:

I finally woke up and realized that my test is not valid, because deltree is going to be looking for two arguments, not just one. And realizing that, I now recall making this same mistake several years ago.

I am confused with your attachment.

It has both an .asm file and a .c file.

How can I make your .exe that you have?

I already have deltree.exe.







Have a great day,
                         Andy

joemc

#21
Magnum,
His deltree is just a dummy that was testing what ShellExecute was calling.
His edit is because he was just checking the first argument. not the whole command line

boils down to :

params    db "/Y ",22h,"C:\Documents and Settings\LU\Local Settings\Temp",22h,0
or as sinsi said:
db '/y "C:\Documents and Settings\LU\Local Settings\Temp"',0

should call it the same as your batch file did.

I personally would still write the code into your asm file instead of depending on a shell execute.
---------
a simple, short, and correct way to test command line in masm instead of C

include \masm32\include\masm32rt.inc
.code
start:
  call GetCommandLine
  print eax
  inkey
  exit
end start


joemc

Went ahead and wrote it real quick. successfully deletes non in use temporary files and directories on my system.

include \masm32\include\masm32rt.inc

.DATA
shellex   db "cmd",0
param     db '/k rmdir /s/q "C:\Documents and Settings\Administrator\Local Settings\Temp" ',0
; Close CMD window when done instead of stay open
;param    db '/c rmdir /s/q "C:\Documents and Settings\Administrator\Local Settings\Temp" ',0

.CODE
start:
  invoke ShellExecute,NULL,NULL,OFFSET shellex,offset param, NULL,SW_SHOW
  inkey
  exit
end start


May be a little more useful if it ran for any user, but not what you asked for. Windows keeps the current user's temporary directory in an environmental variable called "TEMP".
GetEnvironmentVariable http://msdn.microsoft.com/en-us/library/ms683188(VS.85).aspx

include \masm32\include\masm32rt.inc

.DATA
temp      db "TEMP",0
shellex   db "cmd",0
param     db "/k rmdir /s/q "
directory db 0 dup(MAX_PATH+1)

.CODE
start:
  invoke GetEnvironmentVariable, OFFSET temp, OFFSET directory,MAX_PATH
  invoke ShellExecute,NULL,NULL,OFFSET shellex, OFFSET param, NULL,SW_SHOW
  inkey
  exit
end start

clive

Quote from: MichaelW
I finally woke up and realized that my test is not valid, because deltree is going to be looking for two arguments, not just one. And realizing that, I now recall making this same mistake several years ago.

Fair enough. Generally when I'm trying to understand how an application is spawning another, I'd try to enumerate all parameters. There are enough cases where the ordering or number of parameters can be important. In some cases looking at the environment variables passed down can also be enlightening. @Magnum, using proxy applications to test the interaction is quite common, especially when the command DELETE, DELTREE, FORMAT, etc can be potentially destructive. It gives you some visibility which is otherwise difficult to achieve.

FreeDOS's deltree has several more options/switches
http://help.fdos.org/en/hhstndrd/base/deltree.htm

I'd tend to agree with Joe, I'd probably just implement it myself by traversing the tree (directory, registry, etc) and perform the operation directly, rather than spawn some third party application to do it. This can be quite useful if you are trying to log or debug the actions of your application at a more granular level.

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

Magnum

Quote from: joemc on April 19, 2010, 05:44:22 AM
Went ahead and wrote it real quick. successfully deletes non in use temporary files and directories on my system.

include \masm32\include\masm32rt.inc

.DATA
shellex   db "cmd",0
param     db '/k rmdir /s/q "C:\Documents and Settings\Administrator\Local Settings\Temp" ',0
; Close CMD window when done instead of stay open
;param    db '/c rmdir /s/q "C:\Documents and Settings\Administrator\Local Settings\Temp" ',0

.CODE
start:
  invoke ShellExecute,NULL,NULL,OFFSET shellex,offset param, NULL,SW_SHOW
  inkey
  exit
end start


Thanks, I used SHFileOperation to delete most directories.

I found a program call SetACL that should be able to let me view the system volume informtion directory.
It's  command line driven, but I can't figure out all the switches.

It's pretty complicated.



Have a great day,
                         Andy