Jump to content

How to reboot Win PE in my Application ( vc )


Recommended Posts

Posted

Hi,

Now I need reboot function in my application.

I have try to use ExitWindowsEx( , ) and "rundll32 shell32,exitwindows", but it doesn' t work.

How can I do? I write my application in vc++.

thx.


Posted

I managed to get WinPE to reboot by calling NtShutdownSystem, exported from NTDLL.DLL

something like this:

typedef enum _SHUTDOWN_ACTION

{

ShutdownNoReboot,

ShutdownReboot,

ShutdownPowerOff

} SHUTDOWN_ACTION;

typedef DWORD (WINAPI* lpNtShutdownSystem)(SHUTDOWN_ACTION Action);

HMODULE hNTDLL = LoadLibrary("NTDLL.DLL");

if (hNTDLL)

{

lpNtShutdownSystem NtShutdownSystem = (lpNtShutdownSystem)GetProcAddress(hNTDLL, "NtShutdownSystem");

if (NtShutdownSystem)

{

if (msg.wParam & EWX_SHUTDOWN)

NtShutdownSystem((msg.wParam & EWX_POWEROFF) ? ShutdownPowerOff : ShutdownNoReboot);

if (msg.wParam & EWX_REBOOT)

NtShutdownSystem(ShutdownReboot);

}

}

FreeLibrary(hNTDLL);

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...