Hi, I wonder if there is a possibility to shut down Windows XP machine.
i tried standard ExitWindowsEx but It is not working?!!
Why? how can i shut it down or restart?
THX Raguru?.
i tried standard ExitWindowsEx but It is not working?!!
Why? how can i shut it down or restart?
THX Raguru?.
search button yadda yadda... anyway... check a few posts down "a few questions" I think it was... I linked to two examples on Iczelions site that should do the trick... the point is that you have to give the process rights to do so...
This Should do what you need
have a good day
have a good day
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
include \masm32\include\advapi32.inc
includelib \masm32\lib\advapi32.lib
.data
szMessage db "Would you like to Shutdown Windows now?",0
szTitle db "Shutdown",0
szShut db "SeShutdownPrivilege",0
.data?
ovi OSVERSIONINFO <>
tkp TOKEN_PRIVILEGES <>
hToken dd ?
.code
start:
invoke MessageBox,NULL,ADDR szMessage,ADDR szTitle,MB_ICONINFORMATION+MB_YESNO
.IF eax==IDYES
mov ovi.dwOSVersionInfoSize, sizeof ovi
invoke GetVersionEx,ADDR ovi
.if ovi.dwPlatformId == VER_PLATFORM_WIN32_NT
invoke GetCurrentProcess
invoke OpenProcessToken,eax,TOKEN_ADJUST_PRIVILEGES+TOKEN_QUERY,ADDR hToken
invoke LookupPrivilegeValue,NULL,ADDR szShut,addr tkp.Privileges[0].Luid
mov tkp.PrivilegeCount,1
mov tkp.Privileges[0].Attributes,SE_PRIVILEGE_ENABLED
invoke AdjustTokenPrivileges,hToken,FALSE, ADDR tkp, 0, NULL, 0
.endif
invoke ExitWindowsEx,EWX_SHUTDOWN,NULL
.if ovi.dwPlatformId == VER_PLATFORM_WIN32_NT
mov tkp.Privileges[0].Attributes,0
invoke AdjustTokenPrivileges,hToken,FALSE,ADDR tkp,0,NULL,0
invoke CloseHandle,hToken
.endif
.ENDIF
invoke ExitProcess,NULL
ret
end start
invoke OpenProcessToken,eax,TOKEN_ADJUST_PRIVILEGES+TOKEN_QUERY ,ADDR hToken
TOKEN_QUERY
thank you Betraye :alright:
TOKEN_QUERY
thank you Betraye :alright: