Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Windows Shutdown [modified]

Windows Shutdown [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hxhl95
    wrote on last edited by
    #1

    Hello all, Firstly, does anyone have any info regarding the NtSetSystemPowerState function? I can't seem to find any documentation. Secondly, is there any way to shutdown which is faster than calling ExitWindowsEx, but slightly better than calling NtShutdownSystem from the kernel? Oh, and finally, can anyone provide me with some information on the entire windows shutdown process, beginning with the call to ExitWindowsEx? Thanks in advance. :)

    modified on Saturday, March 14, 2009 3:10 PM

    N 2 Replies Last reply
    0
    • H hxhl95

      Hello all, Firstly, does anyone have any info regarding the NtSetSystemPowerState function? I can't seem to find any documentation. Secondly, is there any way to shutdown which is faster than calling ExitWindowsEx, but slightly better than calling NtShutdownSystem from the kernel? Oh, and finally, can anyone provide me with some information on the entire windows shutdown process, beginning with the call to ExitWindowsEx? Thanks in advance. :)

      modified on Saturday, March 14, 2009 3:10 PM

      N Offline
      N Offline
      NeoAks007
      wrote on last edited by
      #2

      I don't have much idea regarding this function but you may try at this.[^].... :-D

      H 1 Reply Last reply
      0
      • N NeoAks007

        I don't have much idea regarding this function but you may try at this.[^].... :-D

        H Offline
        H Offline
        hxhl95
        wrote on last edited by
        #3

        Too bad that's for ReactOS ;P I wonder if the function params are the same on Windows, since ReactOS has almost the same kernel...

        1 Reply Last reply
        0
        • H hxhl95

          Hello all, Firstly, does anyone have any info regarding the NtSetSystemPowerState function? I can't seem to find any documentation. Secondly, is there any way to shutdown which is faster than calling ExitWindowsEx, but slightly better than calling NtShutdownSystem from the kernel? Oh, and finally, can anyone provide me with some information on the entire windows shutdown process, beginning with the call to ExitWindowsEx? Thanks in advance. :)

          modified on Saturday, March 14, 2009 3:10 PM

          N Offline
          N Offline
          NeoAks007
          wrote on last edited by
          #4

          hxhl95 wrote:

          Oh, and finally, can anyone provide me with some information on the entire windows shutdown process, beginning with the call to ExitWindowsEx?

          Some info is available here.[^] :)

          hxhl95 wrote:

          I wonder if the function params are the same on Windows, since ReactOS has almost the same kernel...

          It's quite possible since ReactOS is designed in such a way that existing windows program can run on it. So, for this the API parameters must be same... This can be verified by calling this function assuming those parameters are correct. If call succeeds then you have got the solution... :-D

          H 1 Reply Last reply
          0
          • N NeoAks007

            hxhl95 wrote:

            Oh, and finally, can anyone provide me with some information on the entire windows shutdown process, beginning with the call to ExitWindowsEx?

            Some info is available here.[^] :)

            hxhl95 wrote:

            I wonder if the function params are the same on Windows, since ReactOS has almost the same kernel...

            It's quite possible since ReactOS is designed in such a way that existing windows program can run on it. So, for this the API parameters must be same... This can be verified by calling this function assuming those parameters are correct. If call succeeds then you have got the solution... :-D

            H Offline
            H Offline
            hxhl95
            wrote on last edited by
            #5

            Well, I did try calling the function with those params... Here's my code (after typedef-ing POWER_ACTION and SYSTEM_POWER_STATE:

            typedef DWORD (WINAPI* lpNtSetSystemPowerState)(POWER_ACTION SystemAction,SYSTEM_POWER_STATE MinSystemState, ULONG Flags);
            hNTDLL = LoadLibrary("NTDLL.DLL");
            lpNtSetSystemPowerState NtSetSystemPowerState = (lpNtSetSystemPowerState)GetProcAddress(hNTDLL, "NtSetSystemPowerState");
            NtSetSystemPowerState(PowerActionShutdown,PowerSystemShutdown,NULL);

            The only param I don't get is flags, which I put NULL for. Not working. ;P

            N 1 Reply Last reply
            0
            • H hxhl95

              Well, I did try calling the function with those params... Here's my code (after typedef-ing POWER_ACTION and SYSTEM_POWER_STATE:

              typedef DWORD (WINAPI* lpNtSetSystemPowerState)(POWER_ACTION SystemAction,SYSTEM_POWER_STATE MinSystemState, ULONG Flags);
              hNTDLL = LoadLibrary("NTDLL.DLL");
              lpNtSetSystemPowerState NtSetSystemPowerState = (lpNtSetSystemPowerState)GetProcAddress(hNTDLL, "NtSetSystemPowerState");
              NtSetSystemPowerState(PowerActionShutdown,PowerSystemShutdown,NULL);

              The only param I don't get is flags, which I put NULL for. Not working. ;P

              N Offline
              N Offline
              NeoAks007
              wrote on last edited by
              #6

              hxhl95 wrote:

              The only param I don't get is flags, which I put NULL for

              Flags is of type ULONG. Instead of putting it NULL you may try substituting it with some unsigned value like 0x123.... :) And since it's hit and trial approach after all, this might not work. Instead you may try looking for actual kernel calls and then finding right parameter values using tools like process explorer etc. Best of luck!!! :)

              H 1 Reply Last reply
              0
              • N NeoAks007

                hxhl95 wrote:

                The only param I don't get is flags, which I put NULL for

                Flags is of type ULONG. Instead of putting it NULL you may try substituting it with some unsigned value like 0x123.... :) And since it's hit and trial approach after all, this might not work. Instead you may try looking for actual kernel calls and then finding right parameter values using tools like process explorer etc. Best of luck!!! :)

                H Offline
                H Offline
                hxhl95
                wrote on last edited by
                #7

                I just found out that NtSetSystemPowerState returns STATUS_NOT_IMPLEMENTED in NT 4.0. Now I'm wondering if it's implemented in 5.1 and above. I know for a fact that it's in Vista though. :laugh: All my calls to NtSetSystemPowerState have been returning 0xC00000EF. STATUS_NOT_IMPLEMENTED is 0xC0000002. If my research is correct, 0xC00000EF is NT_STATUS_INVALID_PARAMETER_1 :( Anyone have clues regarding the parameters? I can't find any calls to it inside anything.

                modified on Saturday, March 14, 2009 6:53 PM

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups