Hard Lessons Learned: Windows RtlZeroMemory

Zero Memory

Make it faster by picking larger register (same optimization can be done to copy memory).

In early Windows, they picked the BIGGEST register (floating point)

Speed Up Interrupt Handling

Gary's Sad Story

It turns out Dave Cutler tried to optimize interrupt handling to not save fp registers. Both RtlZeroMemory and RtlCopyMemory didnt copy the fp registers. When the filesystem calls RtlZeroMemory, if an interrupt occurs and the device calls CopyMemory, this has side effects when control is returned to the process.

Moral of the Story