Search code examples
c#winapiwake-on-lan

How to recognize a WOL (Wake On Lan) request while the PC is running


I wonder if its possible to check if a WOL-request has been
received during the computer is already turned on. (pInvoke, c#?)

If the computer receives a magic paket and boots, Windows writes an corresponding event-log entry to the System-Log.

The way i'm looking for is not to listen to my UDP-Traffic by my own - if its possible i want to know how to receive a kind of system event (IRQ?) or something.. And thats all when receiving PC is already turned on.


Solution

  • I agree with Duston that WOL is a Layer 2 combined with hardware thing. On a normal working PC, there is little chance that the NIC hardware will pass this on to the drivers, as it is exactly the task of this hardware to only disturb your CPU if really needed. You best chance to see a magic packet on a working PC would be : install and run sniffer (packet analyzer) software. That will force a supportive NIC into a special mode that transfers every packet to the CPU. If you can now see the magic packet in the output, next step would be to configure the sniffer to alert you in case it sees a magic packet. Done. All this will be quite CPU-intensive. You could write software that performs all this, but that would essentially be rewriting the complete sniffer with fixed query instead of a configurable one.