How can I provoke Windows to hang (freeze)?
Solution 1:
Maybe this can help: Forcing a System Crash from the Keyboard
With USB keyboards, you must enable the keyboard-initiated crash in the registry. In the registry key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\kbdhid\Parameters, create a value named CrashOnCtrlScroll, and set it equal to a REG_DWORD value of 0x01.
You must restart the system for these settings to take effect.
After this is completed, the keyboard crash can be initiated by using the following hotkey sequence: Hold down the rightmost CTRL key, and press the SCROLL LOCK key twice.
Or you could start a fork bomb: see this SO question
There is also NotMyFault
Notmyfault is a tool that you can use to crash, hang, and cause kernel memory leaks on your Windows system. It’s useful for learning how to identify and diagnose device driver and hardware problems, and you can also use it to generate blue screen dump files on misbehaving systems.
Solution 2:
It sounds like you're testing the reaction of an external device to an OS becoming unresponsive.
If your hardware can be connected to a virtualized Windows install, then you can pause and resume the virtual machine as many times as you like. Install the desired OS in a VirtualBox (or other desktop virtualization) environment, expose whatever hardware interface is being used (USB, Ethernet, or whatever) to the VM.
You can then pause and resume the virtual machine at will.
Solution 3:
At least under an older Windows version (some years ago) the following worked:
I wrote a C program with an endless loop:
while(1) {}
... then I gave that program "realtime priority" in the task manager (there is also an API which can do this).
On a multi-core system I would need to do this multiple times so one loop is running on each core...
Solution 4:
The strongest kernel hang (i.e., no mouse tracking, etc.) is when code goes into an infinite loop in kernel mode with interrupts off.
It's possible to achieve this with a device driver, and even better, you can write the driver so that it starts and stops the hang under your control (assuming the infinite loop is testing the condition you're in control of).
How to write and install this driver would be the topic of another question or three, but that's the approach I'd take.