I cannot help with the specific problem right now, but to answer the general main question, "What is the mechanism that Windows machine 'knows' it is returning from sleep or hibernate?", I can answer that.
Computers use the "Advanced Configuration & Power Interface", which is a combination of computer hardware, firmware and driver software to handle power management, and that includes sleeping and hibernation.
http://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface (of particular interest to your question is the section "Power States")
http://www.acpi.info/
Here in an in-depth guide regarding computer power management:
http://eetd.lbl.gov/EA/Reports/39466/