Figured out why lstat() was randomly failing on 32 bit mingw builds - the NT kernel expects an 8 byte alignment for kernel structures.