News:

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

Rebooting comp and using arrays

Started by sportskid300, June 04, 2007, 04:12:06 AM

Previous topic - Next topic

sportskid300

Hey guys.
Another question thread, sorry  ::)
2 questions this time:
(1) What is the most effecient way to force a shutdown of the comouter.
(1.5) Does this way effect other operating systems besides windows?
(2) How can I use arrays to delete files in a directory?
Say theres 20 files, and I dont want to use fdelete on them all.
I've heard theres a way to use arrays, but dont know how.
I can't wait to make windows...

Tedd

Questions, questions.. isn't that why we're here?

1) Pull out the power cable :cheekygreen: (but maybe safer to use "ExitWindowsEx(EWX_FORCE,NULL)")
1b) Only if you are running another OS at the same time (virtual machine? then the virtualization software should handle it - so either way, no it shouldn't.)
2) Fill the array with a list of the files you want to delete, then loop through the array deleting each one as you go. Though you might as well just skip the array, loop through the files in whichever way you plan to fill the array, but just delete instead of putting the name in the array. You can use "SHFileOperation" to delete multiple files, but you'd still need make the list of files first.


Keep 'em coming :wink
No snowflake in an avalanche feels responsible.

sportskid300

hey thanks!
do you have msn or aim?
That would be really nice, instant contact  ::)
In any case, all of the files are in one folder.
However, rmdir seems to only affect empty folders, hence the need to delete single files.
Is there a command to delete an entire directory, regardless of how full it is?
Also, the 'qexit' in examples is invoke ExitWindowsEx,1 or EWX_FORCE,0
Which way is more effective, yours or this?
Thanks again!
I can't wait to make windows...

Tedd

Quote from: sportskid300 on June 04, 2007, 10:20:36 PM
In any case, all of the files are in one folder.
However, rmdir seems to only affect empty folders, hence the need to delete single files.
Is there a command to delete an entire directory, regardless of how full it is?
"rmdir /s /q" ?

Quote
Also, the 'qexit' in examples is invoke ExitWindowsEx,1 or EWX_FORCE,0
Which way is more effective, yours or this?
Sorry, that one's correct, I missed off the EWX_SHUTDOWN flag (which is what the '1' is) so it should be invoke ExitWindowsEx, EWX_SHUTDOWN or EWX_FORCE,NULL (and then they're both the same thing.)
No snowflake in an avalanche feels responsible.

Vortex

Another way to force shutdown is to use DOS' shutdown command with administrator privileges.

sportskid300

Quote from: Tedd on June 05, 2007, 11:48:04 AM
"rmdir /s /q" ?
If I was deleting "C:/Program Files/Test", where would I put the /s and /q?

Thanks again.

And vortex, is your way more or less effective than the usual one?


Lastly, how do I loop through arrays?
How do I define what is to be in the array?
I can't wait to make windows...

ic2

Quote(1) What is the most effecient way to force a shutdown of the comouter.

I got a lot of help here concerning FORCE SHUTDOWN.  I tested for weeks.  If you can get pass all the confusing posting i did,  you will find your answer.  I don't remember everything right-off but  nearly every example works... but most examples DOES effect the BIOS but not serious enough to hurt anything.  You may see that if  you play with them than when you re-start the computer ...

I ended up using this code below, and it never did affect ANYTHING.  If it did, it would not be inside my project right now and forever.  It works PERFECTLY with no after effects.

;PUSH  esp
;PUSH  0
;PUSH  2
;PUSH  19
;CALL  RtlAdjustPrivilege


;PUSH  2
;CALL  NtShutdownSystem




http://www.masm32.com/board/index.php?PHPSESSID=8431cf304c913fca071a6aa300315a7b&topic=6388.0

ic2

I better explain what is meant when i said "it DOES effect the BIOS but not serious enough to hurt anything" ..... because forcing  stuff is serious when it comes to computing.

What would happen in a real Force Shutdown with most of those example is it will do the job but when you re-start computer it lock to dos screen [PRESS F1 to continue:] ... this is not usually, so that along shows that something got thrown off, but nothing that prove serious enough to cause machine damage.

You would never have that problem with the by calling the right api's with the proper PUSH's as posted above...

So if you need to save something, just do all you need to do  before the call and you should have total success.



sportskid300

Alright thanks.
I think I got it now, so thanks again haha.
I can't wait to make windows...

ic2

Quotehaha: a loud laugh that sounds like a horse neighing.

Do this mean that you now got what you need do some damage?

sportskid300

I was laughing (haha) because I said thanks 2 times in 2 sentences.
I still dont get the looping through arrays, or deleting a folder sontaining files.
Whatevr.
I can't wait to make windows...

ic2

#11
I know DELETE, not sure about ARRAY .  I'm new to using it.

I had problems trying to delete my own short-cuts out of my own personal folder.  I seek help.  Nothing i did would work and no one  knew how or why.

I found this latter.   Actually only a few days ago, so we both are lucky.  I don't know why i really saved it, because I use something just like this for years that work on standard file but not ico files.

Notice:  He call GetDeskTopWindow and the code lay-out must be perfect because it delete anything anytime with-out fault.... I made one for COPY, RE-NAME etc and dumped my old code.

Also, it don't really need to call GetDeskTopWindow.  Only for special cases or problems i guest...  I forgot why...  Anyway, there a lot of lay out the use SHFileOperationA that look just like this, you can hardly tell the difference. so don't be confused any longer.  This one do it all.


; ############################################
; ############################################
x_Delete:                        ;  by arkane

CALL GetDesktopWindow
;.......
;.......
    mov     CopyParms.hwnd,  eax
    mov     CopyParms.wFunc, 3h     ;  FO_DELETE
    push   _TEMP_0                  ;  Source
    pop     CopyParms.pFrom
    push   _TEMP_1                  ;  Destination
    pop     CopyParms.pTo
    mov     CopyParms.fFlags, 10h   ;  FOF_NOCONFIRMATION

PUSH offset CopyParms
CALL SHFileOperationA
    mov eax, CopyParms.fAnyOperationsAborted

    ret


I thought you were on a seek and destroy mission just to get back at someone.  Glad that it was not the case.  I had gotten really nervous.

Than, we had a surge of nearly a hundred extra people last night.  I bet many were  hackers  following a link for FORCE SHUTDOWN and dirty deeds.  They moved in as quick as they moved on, just a while ago ... Word travel fast i see.  I don't  really know.  I'm just guesting thing out as usually.