none
IOCTL_IDE_PASS_THROUGH RRS feed

  • Question

  • Hi,

    Would anyone know why

    HANDLE handle;

    UCHAR buffer[sizeof(ATA_PASS_THROUGH)-1 + 512];

    memset(&buffer,0,sizeof(ATA_PASS_THROUGH)-1 + 512);

    ATA_PASS_THROUGH *buf = reinterpret_cast<ATA_PASS_THROUGH*>(&buffer);

    DWORD num_out;

    const unsigned char magic = 0xcf;

    buf->IdeReg.bFeaturesReg = 0;

    buf->IdeReg.bSectorCountReg= 0x01;

    buf->IdeReg.bSectorNumberReg= 0x01;

    buf->IdeReg.bDriveHeadReg = 0xE0;

    buf->IdeReg.bCommandReg = 0x20;

    buf->DataBufferSize = 512;

    //buf->DataBuffer[0] = magic;



    int ioControlCode = IOCTL_IDE_PASS_THROUGH;

    handle= CreateFile(L"\\\\.\\PhysicalDrive0",GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL);







    printf("\n Error = %d", GetLastError());



    DWORD bytescopied = 0;



    if(handle)



    {



    if( DeviceIoControl(



    handle,



    ioControlCode,



    buffer,



    sizeof(ATA_PASS_THROUGH)-1 + 512 ,



    buffer,



    sizeof(ATA_PASS_THROUGH)-1 + 512 ,



    &bytescopied,



    NULL //not an overlapped operation



    ) )

    {









    printf("\n status is %d",buf->IdeReg.bCommandReg);



    printf("\n Error = %d", GetLastError());

    PrintDataBuffer(buf->DataBuffer, 512);

    }











    }

    CloseHandle(handle);

    Does not give any error and does not do a read on WIn 7?

    Are there any paramters I am missing. The struct is
    typedef struct {
    IDEREGS IdeReg;
    ULONG DataBufferSize;
    UCHAR DataBuffer[1];
    } ATA_PASS_THROUGH;


    Thanks,

    SS

    Wednesday, November 27, 2013 8:31 PM