| View previous topic :: View next topic |
| Author |
Message |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Sun Oct 19, 2003 9:10 pm Post subject: AbortSystemShutdown API Doesn't Work |
|
|
I want to do the same thing as SHUTDOWN.EXE -A in VDS using the
AbortSystemShutdown API. I understand that shutdown.exe uses
AbortSystemShutdown also.
Try running this example.
| Code: | # Initiate a shutdown using shutdown.exe, set the time before shutdown to several days so you have time to abort it.
run "shutdown.exe -s -t 99999999"
loadlib advapi32.dll
%A = @lib(advapi32,AbortSystemShutdownA,BOOL:,nil:)
freelib advapi32.dll
info Return Code: [%A] - Didn't work. Now I will do a shutdown.exe -a
run "shutdown.exe -a"
exit |
It doesn't work and I don't know what I'm doing wrong.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Mon Oct 20, 2003 3:30 am Post subject: |
|
|
Hi FF
It is not at all that simple as it seems.
NT security is really tight.
| W32.hlp wrote: | To stop the local computer from shutting down, the calling process must
have the SE_SHUTDOWN_NAME privilege.
To stop a remote computer from shutting down, the calling process must have the SE_REMOTE_SHUTDOWN_NAME privilege
on the remote computer. By default, users can enable the SE_SHUTDOWN_NAME privilege on the computer
they are logged onto, and administrators can enable the
SE_REMOTE_SHUTDOWN_NAME privilege on remote computers.
Failures of this function are typically due to an invalid computer name,
an inaccessible computer, or insufficient privilege. |
So to give your current process the required privilges U need to go for
other APIs to obtain and set the desired privilege on the current process.
In that AdjustTokenPrivileges API is the bottleneck.
This requires a TOKEN_PRIVILEGES structure and it contains an array
which is in turn a is an array of structures called LUID_AND_ATTRIBUTES
Now using @BIANRY() function and taking hekp of list as mindpower
suggested U can set the struct and array. Now U need to retrieve the
values where abscence of array in VDS causes problem as far as I
remember since this has been a long time back.
You can refer the topic if U want to try your hand on it.
http://developer.vdsworld.com/viewtopic.php?t=109 _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
| Back to top |
|
 |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Mon Oct 20, 2003 4:59 pm Post subject: |
|
|
Hi FF
BTW your command line script didn't work either.
I don't know how it worked in your case on XP
I got the error which I expected.
But it could be also that I have disabled the RPC
service after a virus attack.
"The operation completed successfully.
A required privilege is not held by the client."
Obviously first statement is false.
The API you are interested however seems to do fine
in other programming languages after adjusting privileges.
You never know... VDS itself may be having
additional undocumented parameters to EXITWIN
Try this do you get a error:
| Code: |
# Initiate a shutdown using shutdown.exe, set the time before shutdown to several days so you have time to abort it.
run "shutdown.exe -s -t 99999999" ,PIPE
INFO @PIPE()
loadlib advapi32.dll
%A = @lib(advapi32,AbortSystemShutdownA,BOOL:,nil:)
freelib advapi32.dll
info Return Code: [%A] - Didn't work. Now I will do a shutdown.exe -a
run "shutdown.exe -a" ,PIPE
INFO @PIPE()
exit
|
_________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Mon Oct 20, 2003 8:19 pm Post subject: |
|
|
Nothing came out of the PIPE but it did work...
Perhaps you don't have shutdown.exe? Which OS are you using?  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Tue Oct 21, 2003 2:06 am Post subject: |
|
|
XP Pro
Mostly the RPC disabling after a virus attack has caused this  _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue Oct 21, 2003 10:19 am Post subject: |
|
|
Also though if you're running this API on an admin account does it
need to have the priveleges set?  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Tue Oct 21, 2003 12:06 pm Post subject: |
|
|
Very much FF. The calling process should have the token privileges.
when you are using shutdown.exe the app has the code inside
which adjusts it's token privilges to do that.
BTW
Even a non admin account has shutdown privilges - but if it is disabled
for some reason then you can no way shutdown using API unless you
know the admin user/password and impersonate your app. _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue Oct 21, 2003 6:58 pm Post subject: |
|
|
Thanks for explaining this.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
|