WriteFile() Win32 call with input buffer size = 512 Fails., when i try to write to the disk that has bytes per sector = 4096.[3 TB disk]. Same WriteFile with input buffer size = 4096 works fine.,
Can any body explain this behavior.
Explanation
This what the call is.,
res &= WriteFile(hFile, m_Footer,sizeof(VHDFooter), &dwNumBytes, NULL);
hFile - Handle of a VHD File.,
m_Footer - VHD File Footer.,
sizeof(VHDFooter) = 512 always .,
dwNumBytes = o/p buffer.,
My Create File looks like this:
hFile = _CreateFile(szImageFile, GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
Problem:
res &= WriteFile(hFile, m_Footer, sizeof(VHDFooter), &dwNumBytes, NULL);
res &= WriteFile(hFile, m_Footer,4096, &dwNumBytes, NULL);
Disk property.,4096 bytes per sector.,
NOTE: For 512 bytes per sector., the first function call works well.,
Thanks,
Sajith