Y yangyang2008 Unregistered / Unconfirmed GUEST, unregistred user! 2008-08-25 #1 1、能够强制关闭所有正在运行的程序!<br>2、重新启动时不需要人为干预,比如点击某个按钮和输入密码等。
S szhcracker Unregistered / Unconfirmed GUEST, unregistred user! 2008-08-25 #2 function LoadLibrary16(LibraryName: PChar): THandle; stdcall; external kernel32 index 35;<br>procedure FreeLibrary16(HInstance: THandle); stdcall; external kernel32 index 36;<br>function GetProcAddress16(Hinstance: THandle; ProcName: PChar): Pointer; stdcall; external kernel32 index 37;<br>procedure QT_Thunk; cdecl; external kernel32 name 'QT_Thunk';<br>var<br> hInst16: THandle;<br> GFSR: Pointer;<br>function RestartWindows: WordBool;<br>var<br> ThunkTrash: array[0..$20] of Word;<br> dw: DWord;<br> w: Word;<br>begin<br> if Win32Platform = VER_PLATFORM_WIN32_NT then<br> begin<br> Result := False;<br> Exit;<br> end;<br> ThunkTrash[0] := hInst16; //Prevent the optimizer from getting rid of ThunkTrash<br> hInst16 := LoadLibrary16('user.exe');<br> if hInst16 < 32 then<br> raise Exception.Create('Cannot load USER.EXE');<br> FreeLibrary16(hInst16); //Decrement the usage count. This doesn't really free the library, since USER.EXE is always loaded<br> GFSR := GetProcAddress16(hInst16, 'ExitWindows'); //Get the function pointer for the 16-bit function in USER.EXE<br> if GFSR = nil then<br> raise Exception.Create('Cannot get address of ExitWindows');<br> dw := EW_RestartWindows;<br> w := 0;<br> asm //Thunk down to USER.EXE<br> push dw { push arguments }<br> push w<br> mov edx, GFSR { load 16-bit procedure pointer }<br> call QT_Thunk { call thunk }<br> mov Result, ax { save the result }<br> end;<br>end;<br>{$StackFrames Off}
function LoadLibrary16(LibraryName: PChar): THandle; stdcall; external kernel32 index 35;<br>procedure FreeLibrary16(HInstance: THandle); stdcall; external kernel32 index 36;<br>function GetProcAddress16(Hinstance: THandle; ProcName: PChar): Pointer; stdcall; external kernel32 index 37;<br>procedure QT_Thunk; cdecl; external kernel32 name 'QT_Thunk';<br>var<br> hInst16: THandle;<br> GFSR: Pointer;<br>function RestartWindows: WordBool;<br>var<br> ThunkTrash: array[0..$20] of Word;<br> dw: DWord;<br> w: Word;<br>begin<br> if Win32Platform = VER_PLATFORM_WIN32_NT then<br> begin<br> Result := False;<br> Exit;<br> end;<br> ThunkTrash[0] := hInst16; //Prevent the optimizer from getting rid of ThunkTrash<br> hInst16 := LoadLibrary16('user.exe');<br> if hInst16 < 32 then<br> raise Exception.Create('Cannot load USER.EXE');<br> FreeLibrary16(hInst16); //Decrement the usage count. This doesn't really free the library, since USER.EXE is always loaded<br> GFSR := GetProcAddress16(hInst16, 'ExitWindows'); //Get the function pointer for the 16-bit function in USER.EXE<br> if GFSR = nil then<br> raise Exception.Create('Cannot get address of ExitWindows');<br> dw := EW_RestartWindows;<br> w := 0;<br> asm //Thunk down to USER.EXE<br> push dw { push arguments }<br> push w<br> mov edx, GFSR { load 16-bit procedure pointer }<br> call QT_Thunk { call thunk }<br> mov Result, ax { save the result }<br> end;<br>end;<br>{$StackFrames Off}
R rwlin Unregistered / Unconfirmed GUEST, unregistred user! 2008-08-25 #3 {-----------------------------------------------------------------------------<br> 函数名称: ShutDown<br> 作者: Levon819@msn.com<br> 日期: 2007-四月-11<br> 参数: ShutWinTypeShutType; PForce:Boolean<br> 结果: None<br> 功能: 关闭,重启,注销,休眠,待机系统等;<br>-----------------------------------------------------------------------------}<br><br>Procedure ShutDown(OperateMode: Integer; PForce: BOOLEAN = True);<br>Var<br> hToken, hProcess: thandle;<br> tp, prev_tp: TTokenPrivileges;<br> Len, Flags: DWORD;<br> CanShutdown: BOOLEAN;<br>Begin<br> If Win32Platform = VER_PLATFORM_WIN32_NT Then<br> Begin<br> hProcess := OpenProcess(PROCESS_ALL_ACCESS, True, GetCurrentProcessId);<br> Try<br> If Not OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, hToken) Then<br> Exit;<br> Finally<br> CloseHandle(hProcess);<br> End;<br> Try<br> If Not LookupPrivilegeValue('', 'SeShutdownPrivilege',<br> tp.Privileges[0].Luid) Then<br> Exit;<br> tp.PrivilegeCount := 1;<br> tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;<br> If Not AdjustTokenPrivileges(hToken, false, tp, SizeOf(prev_tp),<br> prev_tp, Len) Then<br> Exit;<br> Finally<br> CloseHandle(hToken);<br> End;<br> End;<br> CanShutdown := True;<br> // DoQueryShutdown(CanShutdown);<br> If Not CanShutdown Then<br> Exit;<br> If PForce Then<br> Flags := EWX_FORCE<br> Else<br> Flags := 0;<br> Case OperateMode Of<br> 1: ExitWindowsEx(Flags Or EWX_POWEROFF, 0); //断电;<br> 2: ExitWindowsEx(Flags Or EWX_SHUTDOWN, 0); //关闭;<br> 3: ExitWindowsEx(Flags Or EWX_REBOOT, 0); //重启;<br> 4: ExitWindowsEx(Flags Or EWX_LOGOFF, 0); //注销<br> 5: SetSystemPowerState(True, PForce); //待机;<br> 6: SetSystemPowerState(false, PForce); //休眠;<br> End;<br>End;<br><br><br>window会由一个倒计时确认时间,就算你不点击或确认,时间一到,也会自动shutdown的
{-----------------------------------------------------------------------------<br> 函数名称: ShutDown<br> 作者: Levon819@msn.com<br> 日期: 2007-四月-11<br> 参数: ShutWinTypeShutType; PForce:Boolean<br> 结果: None<br> 功能: 关闭,重启,注销,休眠,待机系统等;<br>-----------------------------------------------------------------------------}<br><br>Procedure ShutDown(OperateMode: Integer; PForce: BOOLEAN = True);<br>Var<br> hToken, hProcess: thandle;<br> tp, prev_tp: TTokenPrivileges;<br> Len, Flags: DWORD;<br> CanShutdown: BOOLEAN;<br>Begin<br> If Win32Platform = VER_PLATFORM_WIN32_NT Then<br> Begin<br> hProcess := OpenProcess(PROCESS_ALL_ACCESS, True, GetCurrentProcessId);<br> Try<br> If Not OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, hToken) Then<br> Exit;<br> Finally<br> CloseHandle(hProcess);<br> End;<br> Try<br> If Not LookupPrivilegeValue('', 'SeShutdownPrivilege',<br> tp.Privileges[0].Luid) Then<br> Exit;<br> tp.PrivilegeCount := 1;<br> tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;<br> If Not AdjustTokenPrivileges(hToken, false, tp, SizeOf(prev_tp),<br> prev_tp, Len) Then<br> Exit;<br> Finally<br> CloseHandle(hToken);<br> End;<br> End;<br> CanShutdown := True;<br> // DoQueryShutdown(CanShutdown);<br> If Not CanShutdown Then<br> Exit;<br> If PForce Then<br> Flags := EWX_FORCE<br> Else<br> Flags := 0;<br> Case OperateMode Of<br> 1: ExitWindowsEx(Flags Or EWX_POWEROFF, 0); //断电;<br> 2: ExitWindowsEx(Flags Or EWX_SHUTDOWN, 0); //关闭;<br> 3: ExitWindowsEx(Flags Or EWX_REBOOT, 0); //重启;<br> 4: ExitWindowsEx(Flags Or EWX_LOGOFF, 0); //注销<br> 5: SetSystemPowerState(True, PForce); //待机;<br> 6: SetSystemPowerState(false, PForce); //休眠;<br> End;<br>End;<br><br><br>window会由一个倒计时确认时间,就算你不点击或确认,时间一到,也会自动shutdown的