News:

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

Reboot consequences if EWX_FORCE is used

Started by skywalker, January 09, 2006, 09:13:46 PM

Previous topic - Next topic

skywalker

; reboot an nt system
    .386
    .model  flat,stdcall
    option  casemap:none

    ;----------------------------------------------------------------
    ; with ReqNTPrivilege call, we ask for the 'SeShutdownPrivilege'
    ; note string names of possible privilege are in windows.inc
    ;----------------------------------------------------------------
    invoke  ReqNTPrivilege, SADD("SeShutdownPrivilege")
    .if eax == FALSE
      invoke  MessageBox,NULL,addr msg_NotPL,addr AppName,MB_OK
      invoke  ExitProcess,NULL
    .endif
    invoke  ExitWindowsEx, EWX_REBOOT   , 0 ; For Reboot, use EWX_REBOOT
    invoke  ExitProcess,NULL

What are the possible consequences if I use the EWX-FORCE here. There is a printer program in memory that is delaying the reboot process.

Thanks.

P1

AFAIK, the file/output will be re-spooled/re-started upon re-boot.

Regards,  P1  :8)

skywalker

Quote from: P1 on January 09, 2006, 10:59:55 PM
AFAIK, the file/output will be re-spooled/re-started upon re-boot.

Regards,  P1  :8)

This isn't quite working. Do I need to combine it with EWX_REBOOT and if so, how would I do it.

invoke  ExitWindowsEx, EWX_FORCE, 0 ; For Reboot, use EWX_REBOOT
    invoke  ExitProcess,NULL

Thanks.

P1

skywalker,

Here's mine.  You will need to add variables.  I also had a timeout MessageBox in my program, just in case someone was using the computer at the appointed re-boot time.

Regards,  P1  :8)

Clipped from working Code:
;Exit_Reboot:
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
   
invoke ExitWindowsEx,EWX_REBOOT or EWX_FORCE,0

skywalker

Quote from: P1 on January 10, 2006, 03:52:57 PM
skywalker,

Here's mine.  You will need to add variables.  I also had a timeout MessageBox in my program, just in case someone was using the computer at the appointed re-boot time.

Regards,  P1  :8)

Clipped from working Code:
;Exit_Reboot:
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
   
invoke ExitWindowsEx,EWX_REBOOT or EWX_FORCE,0


Thanks.

I just used your last invoke statement above. It rebooted a lot quicker and had no effect on a paused print job
either.