I found a shorter way to restart NT systems.
Of course, ExitProcess could be excised as well.
; Fast_NT_Restart.asm Fastest way to Restart an NT System
;
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\advapi32.inc
include \masm32\include\ntdll.inc
include \masm32\macros\macros.asm
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\advapi32.lib
includelib \masm32\lib\ntdll.lib
.data
.code
start:
push esp
invoke RtlAdjustPrivilege,19,2,0,esp
invoke NtShutdownSystem,1 ; 2 = power off
invoke ExitProcess,NULL
end start
Of course, ExitProcess could be excised as well.
; Fast_NT_Restart.asm Fastest way to Restart an NT System
;
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\advapi32.inc
include \masm32\include\ntdll.inc
include \masm32\macros\macros.asm
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\advapi32.lib
includelib \masm32\lib\ntdll.lib
.data
.code
start:
push esp
invoke RtlAdjustPrivilege,19,2,0,esp
invoke NtShutdownSystem,1 ; 2 = power off
invoke ExitProcess,NULL
end start
iirc NtShutdownSystem doesn't notify running processes that the system is shutting down... this does mean the system will shut down faster, but also that running processes will have no chance to save configuration etc.
iirc NtShutdownSystem doesn't notify running processes that the system is shutting down... this does mean the system will shut down faster, but also that running processes will have no chance to save configuration etc.
I make sure nothing is open when I use it.