Well, it appears the hard drive is in teh early stages of failure. When I run the following code, it does great up to about 512MB, then it slows to a crawl and pauses after every 3-8 writes.
Code:
#include <windows.h>
#include <stdio.h>
BYTE Info[65536];
int main(){
DWORD BytesWritten = 1;
for(int x = 0;x<65536;x++) Info[x] = 0;
DWORD Sector = 0;
DWORD SectorsWritten = 0;
DWORD BytesRead = 512;
DWORD ByteCount = 0;
DWORD Start = 0;
HANDLE hFileTemp = CreateFile("C:\\temp.temp" , GENERIC_WRITE , 0 , NULL , CREATE_ALWAYS , FILE_FLAG_DELETE_ON_CLOSE , NULL);
while(BytesWritten){
Start = GetTickCount();
WriteFile(hFileTemp , (LPVOID)Info , 65536 , &BytesWritten , NULL);
Sector += BytesWritten / 1024;
printf("%d\n" , Sector); // actually reports kilobytes written so far
if(GetTickCount() - Start > 55){
printf("Pausing...(%d ms)\n" , GetTickCount() - Start );
Sleep(1000);
}
}
CloseHandle(hFileTemp);
Sector = 0;
return 0;
HANDLE hFile = CreateFile("\\\\.\\C:" , GENERIC_READ , FILE_SHARE_READ , NULL , OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL);
HANDLE hFileOut = CreateFile("D:\\HardDrive.bin" , GENERIC_WRITE , FILE_SHARE_WRITE , NULL , CREATE_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL);
BytesRead = 1;
while(BytesRead){
ReadFile(hFile , (LPVOID)Info , 512 , &BytesRead , NULL);
if(BytesRead){
ByteCount = 0;
for(int x = 0;x<512;x++) ByteCount += Info[x];
if(ByteCount){
SectorsWritten++;
printf("Sectors - %d\n" , SectorsWritten);
//WriteFile(hFileOut , (LPVOID)&Sector , sizeof(DWORD) , &ByteCount , NULL);
//WriteFile(hFileOut , (LPVOID)Info , 512 , &ByteCount , NULL);
}
}
Sector++;
}
CloseHandle(hFileOut);
CloseHandle(hFile);
return 0;
}