How in Winlogon notification DLL Reboot XPe

A

andy zheng

Has anybody know How
in Winlogon notificatin funtion Reboot XPe

//Entrance function for the DLL
BOOL WINAPI LibMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
{
//Disable DLL_THREAD_ATTACH & DLL_THREAD_DETACH
//notification calls. This is a performance optimization
//for multi-threaded applications that do not need
//thread-level notifications of attachment or detachment.

DisableThreadLibraryCalls (hInstance);
}
break;
}

return TRUE;
}

//Event handler for the Winlogon Logon event
VOID WLXventLogon (PWLX_NOTIFICATION_INFO pInfo)
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;

if( Check_HW_is_change() == false) return;

OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hT
oken);
LookupPrivilegeValue(0, SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,false,&tkp,0,(PTOKEN_PRIVILEGES)NULL,0);

// Now call the Win32 API to force windows to shutdown and restart.
ExitWindowsEx(EWX_REBOOT|EWX_FORCE,0);
}

the result XPe show CTRL+ALT+DEL screen.


Any help is appreciated. Thanks in advance.
-andy zheng
 
K

KM

andy,

This might not help you at all but still...

Try to play with the values "Asynchronous" and "Impersonate" (set 0 and/or
1) of the [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Winlogon\Notify\....] regsitry key you set to register
your WinLogon Notification library. Does it make a difference?

Also, try to handle "StartShell" event instead "Logon" event. There may be a
timing issue.

Btw, have you tried you notification library on XP Pro machine? Did it work?

KM
 
A

andy zheng

KM,
Thanks for the info.

I am try out you suggest but stell not work
1. try in "StartShell" same to "Logon" event.
2. try in "StartUP" result the XPe to shutdown but not restart.
3. Try to play with the values "Asynchronous" (set 1) the result windows
show ERROR DialogBox.



-andy zheng.


KM said:
andy,

This might not help you at all but still...

Try to play with the values "Asynchronous" and "Impersonate" (set 0 and/or
1) of the [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Winlogon\Notify\....] regsitry key you set to register
your WinLogon Notification library. Does it make a difference?

Also, try to handle "StartShell" event instead "Logon" event. There may be a
timing issue.

Btw, have you tried you notification library on XP Pro machine? Did it work?
KM

Has anybody know How
in Winlogon notificatin funtion Reboot XPe

//Entrance function for the DLL
BOOL WINAPI LibMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
{
//Disable DLL_THREAD_ATTACH & DLL_THREAD_DETACH
//notification calls. This is a performance optimization
//for multi-threaded applications that do not need
//thread-level notifications of attachment or detachment.

DisableThreadLibraryCalls (hInstance);
}
break;
}

return TRUE;
}

//Event handler for the Winlogon Logon event
VOID WLXventLogon (PWLX_NOTIFICATION_INFO pInfo)
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;

if( Check_HW_is_change() == false) return;
OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hT
oken);
LookupPrivilegeValue(0, SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,false,&tkp,0,(PTOKEN_PRIVILEGES)NULL,0);

// Now call the Win32 API to force windows to shutdown and restart.
ExitWindowsEx(EWX_REBOOT|EWX_FORCE,0);
}

the result XPe show CTRL+ALT+DEL screen.


Any help is appreciated. Thanks in advance.
-andy zheng
 
K

KM

andy,

I don't really have a clue why it does not work for you.

Again, let's guess:

1. Can you check error codes from all the APIs called (OpenProcessToken, LookupPrivilegeValue, AdjustTokenPrivileges, !
ExitWindowsEx)?
2. What error code you see in your item#3?
3. Did you try the library on XP Pro? How did it work?
4. Instead of ExitWindowsEx, try to use NtShutdownSystem (use ShutdownReboot as a SHUTDOWN_ACTION). More info here:
http://undocumented.ntinternals.net/UserMode/Undocumented Functions/Hardware/NtShutdownSystem.html

--
KM,
BSquare Corporation
andy zheng said:
KM,
Thanks for the info.

I am try out you suggest but stell not work
1. try in "StartShell" same to "Logon" event.
2. try in "StartUP" result the XPe to shutdown but not restart.
3. Try to play with the values "Asynchronous" (set 1) the result windows
show ERROR DialogBox.



-andy zheng.


KM said:
andy,

This might not help you at all but still...

Try to play with the values "Asynchronous" and "Impersonate" (set 0 and/or
1) of the [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Winlogon\Notify\....] regsitry key you set to register
your WinLogon Notification library. Does it make a difference?

Also, try to handle "StartShell" event instead "Logon" event. There may be a
timing issue.

Btw, have you tried you notification library on XP Pro machine? Did it work?
KM

Has anybody know How
in Winlogon notificatin funtion Reboot XPe

//Entrance function for the DLL
BOOL WINAPI LibMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
{
//Disable DLL_THREAD_ATTACH & DLL_THREAD_DETACH
//notification calls. This is a performance optimization
//for multi-threaded applications that do not need
//thread-level notifications of attachment or detachment.

DisableThreadLibraryCalls (hInstance);
}
break;
}

return TRUE;
}

//Event handler for the Winlogon Logon event
VOID WLXventLogon (PWLX_NOTIFICATION_INFO pInfo)
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;

if( Check_HW_is_change() == false) return;
OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hT
oken);
LookupPrivilegeValue(0, SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,false,&tkp,0,(PTOKEN_PRIVILEGES)NULL,0);

// Now call the Win32 API to force windows to shutdown and restart.
ExitWindowsEx(EWX_REBOOT|EWX_FORCE,0);
}

the result XPe show CTRL+ALT+DEL screen.


Any help is appreciated. Thanks in advance.
-andy zheng
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top