Merge the W32 patch from Evan and his coworker.

This patch provide a pread replacement for Windows. No visible changes for other operating systems.