Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

Is anyone could demo how to to EXECUTE_DEVICE_DIAGNOSTIC and READ_VERIFY_SECTOR in VC6++?

Vincent
Posted
Comments
Matthew Faithfull 12-Mar-13 5:20am    
You'll need to give more details of what you're trying to do for people to be able to help. EXECUTE_DEVICE_DIAGNOSTIC is not a keyword in any language I'm familiar with. Are you trying to write a SATA driver or something?
Vincentchien 12-Mar-13 21:29pm    
Hello Matthew,

I'm writing a HDD test utility in Windows XP platform, EXECUTE_DEVICE_DIAGNOSTIC and READ_VERIFY_SECTOR are ATA command.

WORD inputBuffer[6];

inputBuffer[0]=0; //reserved
inputBuffer[1]=6*2; // size of this buffer
inputBuffer[2]=0;
inputBuffer[3]=0
inputBuffer[4]=0
inputBuffer[5]=0x90; ATA command, 90h means EXECUTE_DEVICE_DIAGNOSTIC

hDevice=CreateFile("\\\\.\\PHYSICALDRIVE0,...);

bRet=DeviceIoControl(hDevice,EXECUTE_DEVICE_DIAGNOSTIC,inoutBuffer...)

CloseHandle(hDevice);

The bRet always fail, and GetLastError() equal to 87, its means incorrect parameters, please help, or have any sample code for that.
Matthew Faithfull 13-Mar-13 7:42am    
OK that sounds reasonable. I can't help you directly with the issue. The only relevant document I could find is at http://www.technick.net/pagefiles/serialata10a.pdf and the server seems to be too slow to deliver it completely. However I suggest that you edit your original question to include this additional information about what you're doing and the error you recieve and also delete your 'solution' as this already being 'solved' might discourage useful people from looking at your question. Other than that I can only advise that you check for any permissions or privilleges needed to do what your trying to do, make sure you have the correct definition for EXECUTE_DEVICE_DIAGNOSTIC and post the full parameters you're passing to CreateFile and DeviceIoControl as it appears you have a parameter error.
I think there's a very good chance you'll get this solved.

1 solution

Hello Matthew,

I'm writing a HDD test utility in Windows XP platform, EXECUTE_DEVICE_DIAGNOSTIC and READ_VERIFY_SECTOR are ATA command.

WORD inputBuffer[6];

inputBuffer[0]=0; //reserved
inputBuffer[1]=6*2; // size of this buffer
inputBuffer[2]=0;
inputBuffer[3]=0
inputBuffer[4]=0
inputBuffer[5]=0x90; ATA command, 90h means EXECUTE_DEVICE_DIAGNOSTIC

hDevice=CreateFile("\\\\.\\PHYSICALDRIVE0,...);

bRet=DeviceIoControl(hDevice,EXECUTE_DEVICE_DIAGNOSTIC,inoutBuffer...)

CloseHandle(hDevice);

The bRet always fail, and GetLastError() equal to 87, its means incorrect parameters, please help, or have any sample code for that.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900