forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


AbortSystemShutdown API Doesn't Work

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Help for VDS 5 & Up
View previous topic :: View next topic  
Author Message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Oct 19, 2003 9:10 pm    Post subject: AbortSystemShutdown API Doesn't Work Reply with quote

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. Confused

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Mon Oct 20, 2003 3:30 am    Post subject: Reply with quote

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
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Mon Oct 20, 2003 4:59 pm    Post subject: Reply with quote

Hi FF

BTW your command line script didn't work either.
I don't know how it worked in your case on XP Question
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
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Mon Oct 20, 2003 8:19 pm    Post subject: Reply with quote

Nothing came out of the PIPE but it did work...

Perhaps you don't have shutdown.exe? Which OS are you using? Smile

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Tue Oct 21, 2003 2:06 am    Post subject: Reply with quote

XP Pro
Mostly the RPC disabling after a virus attack has caused this Question

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Tue Oct 21, 2003 10:19 am    Post subject: Reply with quote

Also though if you're running this API on an admin account does it
need to have the priveleges set? Smile

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Tue Oct 21, 2003 12:06 pm    Post subject: Reply with quote

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
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Tue Oct 21, 2003 6:58 pm    Post subject: Reply with quote

Thanks for explaining this. Smile
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Help for VDS 5 & Up All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group