Nofication Problem with Win10 sleep messages RRS feed

  • Question

  • Hello - I'm looking for advice please!

    Nothing I do, other than writing my own trick code, can identify if Windows 10 Creators Update has gone to sleep or resumed from sleep. I'm not sure how earlier Windows 10 versions behave right now.

    Calling RegisterSuspendResumeNotification  with a Window Handle, and DEVICE_NOTIFY_WINDOW_HANDLE allows all the relevant messages to be received via WM_POWERBROADCAST when the system is hibernating, and resuming from hibernation, but not when sleeping or resuming from sleep.

    Windows 7 windows get this WM_POWERBROADCAST all the time for sleep and hibernation. Why the change so notification is now needed ?

    Why no sleep messages on Windows 10 (at least on the creators update version)  ? Is this simply a bug which needs fixing urgently ?

    It has implications for security software which needs to know the computer was left unattended.

    I am running this on a Microsoft Surface Pro 4 i7 machine.

    Many thanks for any advice received. :-)

    Monday, August 14, 2017 12:39 PM

All replies

  • Hi,

    In advance, sorry if I misunderstand your question.

    I suppose it causes from "Modern Standby" newly added in Windows 10.
    Please refer to the following article: "Modern Standby"

    Alas! I cannot answer your question.
    I'm searching the way to know System Power States (S0, S1 Low Power Idle, S1, etc) especially "S1 Low Power Idle". I suppose Modern Standby is S1 Low Power Idle.



    Tuesday, August 15, 2017 1:24 AM
  • Hello Ashidacchi

    Thank you so much for your answer and the link for which I am really grateful.

    At some stage the OS might transition to a lower power state. - At this point we really should get a notification, at least for resume to full operation - Perhaps after the length of time had elapsed when the operating system has decided that the time has elapsed when one would have to re-enter the windows login password, if one was using it.

    "Modern  Standby" or not, it doesn't seem very "Modern" at all, to me, not to notify applications who REALLY need to know their app has slept especially for some time. Also wouldn't it be a good idea for Microsoft to document all this on the WM_POWERBROADCAST pages ?

    For example,  one application (I will not mention my own here) which would surely need these notifications is managing USB devices where  code signing is done by Extended Validation certificates, stored on a USB token. The app that manages such a token optionally allows the user to type in the token's password once per session. This avoids the user having to keep entering the password to sign several components during a build. After switching the computer to sleep/standby or hibernate the user is required to enter the password again to continue signing, and it doesn't happen on the SP4 in standby. I think there's a good very reason in this case, why this password needs to be re-entered...

    Thank you so much again.

    I'll leave the thread open for now, in case there's any more comments.




    Wednesday, August 16, 2017 10:45 AM
  • Sorry but what is the problem here actually? The app can always query the current time, local or network, at any moment (when it can run, of course). Let the app remember the last time when user entered the password, and calculate delta from now to that time. No obscure messages involved, no complications.

    Even better, let the hardware token itself timeout after certain period of inactivity and require reactivation from the software. This way the policy can be enforced more reliably - no matter whether the computer sleeps or not.

    -- pa

    • Edited by Pavel A Wednesday, August 16, 2017 4:25 PM
    Wednesday, August 16, 2017 4:22 PM
  • Hi Shaun Hollingworth,

    In advance, sorry if I misunderstand your question or what you want to do.
    (I'm poor at English, and studying English via this or that forum)

    I've just found an article (written in Japanese).
    モダンスタンバイがサポートされた Windows 10 環境でスリープイベントが取得できない場合がある

    Its title says that we have a case where we can't catch a sleep event in Windows 10 which supports Modern Standby.
    But I'm not sure if I can translate the article into English correctly. Please use machine translation.



    Thursday, August 17, 2017 3:40 AM
  • Re: Can't see the problem

    Yes but how can you find out that the machine is GOING to sleep by making such queries as you suggest ? A crystal ball would surely be needed, but that's not part of the OS yet! :-) The only way you can find out the machine is GOING to sleep is by such a notification that it's about to happen, not that you have much time to deal with a lot when it does. But other solutions are like shutting the stable door when the horse has bolted.

    But in the absence of such a message, then keys, hashes  and maybe even whole passwords would be left in memory for unaware security apps, to be woken later, without even a requirement to log back in at least for something like 10 or 15 minutes.  What happens with Bitlocker encrypted "none system" drives during the suspend resume cycle ?

    In any case what about existing apps which are currently in use ?

    With all due respect, to me, having to query timers and botch around like that is a lot less clean and much messier and error prone than getting a simple power message sent to a window handler. To me it would certainly be a solution of last resort, and believe me I've thought about it.

    We should really be able to switch the machine to some kind of "standard" behaviour mode. The "Sleep" option  on the desktop should certainly be able to put the machine in a Windows 7 style sleep with all the sane, reasonable and potentially helpful messages they sent around. As soon as the time arrives that a password would optionally be required on the login screen, the same should happen. The machine has been left idle, and their might be sensitive data in there.

    Regards and thanks for the reply.


    Thursday, August 17, 2017 11:03 AM
  • But in the absence of such a message, then keys, hashes  and maybe even whole passwords would be left in memory for unaware security apps, to be woken later, 

    Well. IIRC a kernel driver can get notification on a "sleep" (but not sure about Connected Standby).  This does not help to existing software, unfortunately. 

    Given the current state of hacking, it is simply not advisable to leave sensitive data in memory for any prolonged time.

    -- pa

    • Edited by Pavel A Thursday, August 17, 2017 2:02 PM
    Thursday, August 17, 2017 1:56 PM