重启Windows2000/NT系统_VB.net_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

重启Windows2000/NT系统

作者:黑客防线网安VB教程基地 来源:黑客防线网安VB教程基地 浏览次数:0

本篇关键词:系统AsLong'&
黑客防线网安网讯:RebootsaWindows2000PC.ManyexamplesshelltothekernelandjustkillthePC.Thisdoesitproperlyandtakesintoaccountauserprivilages.    'APICallsusedforRebootPC    PrivateConst...
RebootsaWindows2000PC.ManyexamplesshelltothekernelandjustkillthePC.Thisdoesitproperlyandtakesintoaccountauserprivilages.
  
  'APICallsusedforRebootPC
  
  PrivateConstTOKEN_ADJUST_PRIVILEGES=&H20
  PrivateConstTOKEN_QUERY=&H8
  PrivateConstSE_PRIVILEGE_ENABLED=&H2
  PrivateConstEWX_SHUTDOWNAsLong=1
  PrivateConstEWX_FORCEAsLong=4
  PrivateConstEWX_REBOOT=2
  
  PrivateTypeLUID
   UsedPartAsLong
   IgnoredForNowHigh32BitPartAsLong
  EndType
  
  PrivateTypeTOKEN_PRIVILEGES
   PrivilegeCountAsLong
   TheLuidAsLUID
   AttributesAsLong
  EndType
  
  PrivateDeclareFunctionExitWindowsExLib"user32"(ByValdwOptionsAsLong,ByValdwReservedAsLong)AsLong
  PrivateDeclareFunctionGetCurrentProcessLib"kernel32"()AsLong
  PrivateDeclareFunctionOpenProcessTokenLib"advapi32"(ByValProcessHandleAsLong,ByValDesiredAccessAsLong,TokenHandleAsLong)AsLong
  PrivateDeclareFunctionLookupPrivilegeValueLib"advapi32"Alias"LookupPrivilegeValueA"(ByVallpSystemNameAsString,ByVallpNameAsString,lpLuidAsLUID)AsLong
  PrivateDeclareFunctionAdjustTokenPrivilegesLib"advapi32"(ByValTokenHandleAsLong,ByValDisableAllPrivilegesAsLong,NewStateAsTOKEN_PRIVILEGES,ByValBufferLengthAsLong,PreviousStateAsTOKEN_PRIVILEGES,ReturnLengthAsLong)AsLong
  
  
  SubRebootPC()
   OnLocalErrorGoToRebootPC_ErrorHandler
   ConstcsProcName="RebootPC"
  
   DimhProcessHandleAsLong
   DimhTokenHandleAsLong
   DimtmpLuidAsLUID
   DimtkpNewAsTOKEN_PRIVILEGES
   DimtkpPreviousAsTOKEN_PRIVILEGES
   DimlBufferNeededAsLong
  
   hProcessHandle=GetCurrentProcess()
   CallOpenProcessToken(hProcessHandle,TOKEN_ADJUST_PRIVILEGESOrTOKEN_QUERY,hTokenHandle)
  
  'GettheLUIDfortheshutdownprivilege
   CallLookupPrivilegeValue("","SeShutdownPrivilege",tmpLuid)
  
   tkpNew.PrivilegeCount=1'Oneprivilegetoset
   tkpNew.TheLuid=tmpLuid
   tkpNew.Attributes=SE_PRIVILEGE_ENABLED
  
  'Enabletheshutdownprivilegeintheaccesstokenofthisprocess.
   lBufferNeeded=0
   CallAdjustTokenPrivileges(hTokenHandle,False,tkpNew,Len(tkpPrevious),tkpPrevious,lBufferNeeded)
  
  'ForceaReboot(nooptiontosavefilestocancelout)
   CallExitWindowsEx(EWX_FORCEOrEWX_REBOOT,&HFFFF)
  
   ExitSub
  RebootPC_ErrorHandler:
   CallRaiseError(csModName,csProcName,Err.Number,Err.Description)
  EndSub->

    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-14520-1.html
网站维护教程更新时间:2012-04-03 01:08:21  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer