Fix ATTEMPTED_WRITE_TO_READONLY_MEMORY error in Windows 10