News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

MasmBasic again

Started by clamicun, June 28, 2015, 10:35:33 PM

Previous topic - Next topic

clamicun

JJ,buon giorno !
long time, I was abroad for a while.
Back here, something strange happened. The searchprogram I had finished before taking off, doesn't function anymore. It did fine.

The funny thing is, that this happens only on "C:\".

Here is the basic version. (the real one selects the searchpath with "browse4folders" and shows the result in a listview window.

;safed as CountFolders.asm
;Sonntag, 28. Juni 2015Sonntag, 28. Juni 2015
include \masm32\MasmBasic\MasmBasic.inc     

.const
;start_path  TCHAR 'C:\',0                 ;goes down
;start_path  TCHAR 'C:\Users\',0        ;goes down

;start_path  TCHAR 'C:\Windows\',0         ;works
;start_path  TCHAR 'C:\Program Files\',0   ;works

start_path  TCHAR 'D:\',0                  ;all other drives work
msg         TCHAR 'cmc',0

.data
dir_counter dd ?
wsmsg       TCHAR 100 dup(?),0
result      TCHAR '%lu Folders found in %s',0

.code
  Init
  GetFolders offset start_path
  mov dir_counter,eax
 
  INVOKE wsprintf,offset wsmsg, offset result,dir_counter,offset start_path
  INVOKE MessageBox,0,offset wsmsg,offset msg,0
  Exit

end start 

P.S.
I have administration rights on C:\

jj2007

Hi Clamicun, Guten Abend!

Your code returned 0 folders for D:\, which is correct because I had no DVD inserted.

Then I tried C:\, and indeed, the program hangs! At least for a while, then, after some minutes, it shows a MsgBox cmc: 47086 folders found.

So either our computers are different, or you simply didn't wait long enough...

Let me know. You can try this, too:

  Init
  GfCallback cbGetFiles      ; define a callback function
  GetFolders offset start_path
  mov dir_counter,eax

  INVOKE wsprintf,offset wsmsg, offset result,dir_counter,offset start_path
  INVOKE MessageBox,0,offset wsmsg,offset msg,0
  Exit

cbGetFiles:
  test edx, 1023      ; file or folder counter
  .if Zero?
      Print At(1, 1) Str$(edx), Tb$, edi, Space$(20), Cr$
  .endif
  retn

end start

clamicun

JJ,
thanks for your answer.
No, on my computers it doesn't  hang (I waited).
It goes down absolutely.

jj2007

Strange. Which OS version, which assembler & linker?
I tested it with Win7-64 and Win8.1-64, no problem. What does "Problemdetails" show? Can you run it with Olly?

Attached my version. Can you zip your exe file and post it here, please?

clamicun

Buon giorno JJ,
yes - of course the confusion was on my computer.
Olly gave me the hint.
Stopped during GetFolders with the message "Can't find the path ...."

Windows7 - there were folders in "document and settings" which actually didn't exist.
So GetFolders went down.

Just one more question.
Is it possible to "config"  MasmBasic so that GetFolders does not includes "Recyclebin".
My searchprogram doesn't nedd the "recyclebin files".

jj2007

Quote from: clamicun on June 29, 2015, 08:09:19 PMIs it possible to "config"  MasmBasic so that GetFolders does not includes "Recyclebin".

You could simply delete them:

  Init
  GfCallback cbGetFiles      ; define a callback function
  GetFolders "C:\"   ; offset start_path
  mov dir_counter, eax
  xor ecx, ecx
  .Repeat
      .if Instr_(Files$(ecx), "\$Recycle", 1)
            PrintLine "deleted: ", Files$(ecx)
            Delete Files$(ecx)
            dec ecx
            dec dir_counter
      .endif
      inc ecx
  .Until ecx>=dir_counter
  Store "MyFile.txt", Files$()

  INVOKE wsprintf,offset wsmsg, offset result,dir_counter,offset start_path
  INVOKE MessageBox,0,offset wsmsg,offset msg,0
  Exit

cbGetFiles:
  test edx, 1023      ; file or folder counter
  .if Zero?
      Print At(1, 1) Str$(edx), Tb$, edi, Space$(20), Cr$
  .endif
  retn
end start


I am curious where and why Olly stopped with that complaint about non-existing folders. Code shouldn't crash for that. Can you post some details, e.g. copy a few lines from Olly? Thanks a lot.

clamicun

JJ,
unfortunatelay I can't show you the Olly Msg.

After I deleted the folders

"Windows7 - there were folders in "document and settings" which actually didn't exist.(50 or more with the same name...  "

I had to resetup the system on my testcomputer.

Mic