flat assembler
Message board for the users of flat assembler.

Index > Windows > force shutdown nt

Author
Thread Post new topic Reply to topic
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
i need someone to port this code to fasm
i need a small exe to use in my php code to shutdown the windows xp machines whatever it takes (i mean force shutdown)

i know this process, i am just asking for someone to convert this code to fasm becouse i really dont have time, but if noone helps then i am sure gonna make it one day becouse i need this very small open source exe file

the code below it masm code, and there is also ann app in ;
http://spiff.tripnet.se/~iczelion/files/Time%20ShutDown%20v1.0.zip
that does the same

what i want is when i run the program with no arguments like "shutdown.exe" it should shutdown without any msg dialogs or anything else
if someone can do this before me i will be very happy trying to finish the php code part

ps:it should be able to shutdown both win9x and winnt oses as below


Windows Xp Shutdown
This Should do what you need
have a good day



code:--------------------------------------------------------------------------------
.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
Post 07 Aug 2004, 22:23
View user's profile Send private message ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
i thought shutdown can be forced just by invoking some (undocumented i think) procedure from some win's DLL. Can't remember name.
Post 08 Aug 2004, 12:10
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
in nt/xp/2003 without privilages?
Post 08 Aug 2004, 12:25
View user's profile Send private message ICQ Number Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
Here is an example of "quick exit"

Qexit.asm from masm32 package

Code:
      .386
      .model flat, stdcall
      option casemap :none   ; case sensitive

      include \masm32\include\windows.inc
      include \masm32\include\user32.inc
      include \masm32\include\kernel32.inc

      includelib \masm32\lib\user32.lib
      includelib \masm32\lib\kernel32.lib

    .code

start:

        invoke ExitWindowsEx,1 or EWX_FORCE,0
        invoke ExitProcess,eax

end start

        ; Flags for ExitWindowEx

        ; EWX_LOGOFF    equ 0
        ; EWX_SHUTDOWN  equ 1
        ; EWX_REBOOT    equ 2
        ; EWX_FORCE     equ 4
        ; EWX_POWEROFF  equ 8
    

_________________
Code it... That's all...
Post 08 Aug 2004, 15:22
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Vortex, that won't work under NT Based OSes - you need to enable the correct privilege (security token, whatever) first... like the code above.
Post 09 Aug 2004, 13:36
View user's profile Send private message Visit poster's website Reply with quote
Kevin_Zheng



Joined: 04 Jul 2003
Posts: 125
Location: China
Kevin_Zheng
Dear All:
I have writed a tool for shutdown windows. It can support win9x/winnt/win2k/win2003/winxp. Please see the below link:
http://board.flatassembler.net/topic.php?t=1151

I have finished the new version for this tool kit to fit fasm 1.54, I will update the package to thisk suite after I have tested it completely.

Best regards.

Kevin Zheng
Post 11 Aug 2004, 00:57
View user's profile Send private message MSN Messenger Reply with quote
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle
Kevin,
will it close the window when you are loged only as a user not an admin?


best regards,

_________________
Microsoft: brings power of yesterday to computers of today.
Post 16 Aug 2004, 08:49
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.