i want read particular sector(mbr sector) of disk using ata commands in vc++. new vc++ facing problem when sending command disk using deviceiocontrol. providing code using read out sector using command read sector(s)(0x20).
bool status = false; pata_pass_through_ex patadata; dword datasize = sizeof(ata_pass_through_ex) + 512; byte buffer[sizeof(ata_pass_through_ex) + 512]; dword bytescopied = 0; patadata = (ata_pass_through_ex*)buffer; zeromemory(patadata,datasize); // clears buffer patadata->length = sizeof(ata_pass_through_ex); patadata->databufferoffset = sizeof(ata_pass_through_ex); patadata->datatransferlength = 512; patadata->timeoutvalue = 2; patadata->currenttaskfile[1] = 0x01; patadata->currenttaskfile[2] = 0x00; patadata->currenttaskfile[3] = 0x00; patadata->currenttaskfile[4] = 0x00; patadata->ataflags =ata_flags_data_in; patadata->currenttaskfile[6] = 0x20; // command read sector(s)(0x20) /* sends command device, **hdevice** device handle*/ status = deviceiocontrol(hdevice, ioctl_ata_pass_through, patadata, datasize,buffer, datasize, &bytescopied, null );
i can't undersatnd what's wrong in code , missing here, not working. missing here ? if there problem parametres of pata_pass_through_ex structure tell how read first sector(mbr).
thanks guys. got solution. not assigning device handle in currenttaskfile.
patadata->currenttaskfile[5] = (uchar)hdevice;
but identify_device(ech) command sending succesfully without this. don't know it's right or wrong working.
Comments
Post a Comment