| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Windows OS Issues Discussion of non-programming issues related to Windows. This includes migration issues, Security, Scalability, Windows DNA, etc. This is also a great place for those who are supporting mixed-mode networks. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Emergency shutdown
Microsoft GINA offers emergency shutdown functionality (see http://support.microsoft.com/support.../q279/1/34.asp).
How can I implement this in my GINA? |
|
#2
|
|||
|
|||
|
Re: Emergency shutdown
A quick look at msgina.dll import table shows a call to undocumented
NtShutdownSystem function. According to "Windows NT/2000 Native API Reference" by Gary Nebbet, this function does not notify services and user applications before it shuts down the system. The function prototype is as follows: NTSYSAPI NTSTATUS NTAPI NtShutdownSystem( IN SHUTDOWN_ACTION Action ); typedef enum _SHUTDOWN_ACTION { ShutdownNoReboot, ShutdownReboot, ShutdownPowerOff }SHUTDOWN_ACTION; The function is exported from ntdll.dll.
__________________
Russian Software Development Network -- http://www.rsdn.ru |
|
#3
|
|||
|
|||
|
Re: Emergency shutdown
Using NtShutdownSystem(ShutdownNoReboot), I got the error 1314 (A required privilege is not held by the client.) even if I have SE_SHUTDOWN_NAME privilege.
Must I have to use another function that AdjustTokenPrivileges? |
|
#4
|
|||
|
|||
|
Re: Emergency shutdown
I've just tried it and it works fine on my system. Here is my code:
HANDLE hToken; if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY|TOKEN_ADJUST_PRIVILEGES, &hToken)) { TOKEN_PRIVILEGES tkp; LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, 0); CloseHandle(hToken); } NtShutdownSystem(ShutdownNoReboot);
__________________
Russian Software Development Network -- http://www.rsdn.ru |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|