CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Windows Central > Windows OS Issues
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    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.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old June 20th, 2001, 10:49 AM
    Didier VOINNET Didier VOINNET is offline
    Junior Member
     
    Join Date: Feb 2000
    Posts: 4
    Didier VOINNET is an unknown quantity at this point (<10)
    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?

    Reply With Quote
      #2    
    Old June 21st, 2001, 05:05 AM
    Alex Fedotov Alex Fedotov is offline
    Elite Member
    Power Poster
     
    Join Date: Apr 2000
    Location: San Francisco, California, USA
    Posts: 4,467
    Alex Fedotov is on a distinguished road (40+)
    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
    Reply With Quote
      #3    
    Old June 29th, 2001, 11:48 AM
    Didier VOINNET Didier VOINNET is offline
    Junior Member
     
    Join Date: Feb 2000
    Posts: 4
    Didier VOINNET is an unknown quantity at this point (<10)
    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?

    Reply With Quote
      #4    
    Old July 3rd, 2001, 08:12 PM
    Alex Fedotov Alex Fedotov is offline
    Elite Member
    Power Poster
     
    Join Date: Apr 2000
    Location: San Francisco, California, USA
    Posts: 4,467
    Alex Fedotov is on a distinguished road (40+)
    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
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Windows Central > Windows OS Issues


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 06:11 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009