ken-yossy / nvmetool-win

Communicate with NVMe SSD using Windows' inbox device driver
Other
83 stars 48 forks source link

Compiler error #19

Closed KerickHuang closed 3 years ago

KerickHuang commented 3 years ago

VS2019 build this project can't find PDEVICE_INTERNAL_STATUS_DATA struct in #include @NVMeGetTelemetry.c

ken-yossy commented 3 years ago

Hi,

Thank you for your information. But it can be built without errors in my environment. Would you please check that Windows Driver Kit is installed in your environment (10.0.19030.1000 in my environment)?

screenshot-of-vs2019

Kind regards, Ken

KerickHuang commented 3 years ago

You got it thank you, it's solved and I can build project pass now.

I am a beginner, want to write and read LBA to SSD on Windows

Can this tool do it?

Command line argument how to set? set 2 C:\ but it not find dev following [image: image.png]

ken-yossy @.***> 於 2021年8月21日 週六 下午2:01寫道:

Hi,

Thank you for your information. But it can be built without errors in my environment. Would you please check that Windows Driver Kit is installed in your environment (10.0.19030.1000 in my environment)?

[image: screenshot-of-vs2019] https://user-images.githubusercontent.com/52020141/130311735-5d523eb5-eb16-446e-a947-b08c5d608c19.png

Kind regards, Ken

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ken-yossy/nvmetool-win/issues/19#issuecomment-903065537, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATVNJFKB27SRTBZ6TJCWOZDT546L7ANCNFSM5CRNJ5CA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

ken-yossy commented 3 years ago

Hi,

You got it thank you, it's solved and I can build project pass now.

I'm glad to hear that!

I am a beginner, want to write and read LBA to SSD on Windows Can this tool do it?

No, currently starting LBA and number of sectors are fixed, starting LBA is 0 and number of sectors is 1 (hard coded).

Command line argument how to set?

It does not have any command line arguments related to the drive's action, such as starting LBA, number of sectors, and the data source / destination. It only takes the physical drive number of the target NVMe drive.

The starting LBA and number of sectors to be read or written are specified in NVMeSCSIPassThrough.c The below is for read operation.

int iReadViaSCSIPassThrough(HANDLE _hDevice)
{
(snip)

    if ( srbType )
    {
        ZeroMemory(&sptwb_ex, sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS_EX));
(snip)
        sptwb_ex.spt.DataInTransferLength = 512;
(snip)
        sptwb_ex.spt.Cdb[0] = SCSIOP_READ;
        sptwb_ex.spt.Cdb[5] = 0; // Starting LBA
        sptwb_ex.spt.Cdb[8] = 1; // TRANSFER LENGTH
(snip)
    }
    else
    {
        ZeroMemory(&sptwb, sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS));
(snip)
        sptwb.spt.DataTransferLength = 512;
(snip)
        sptwb.spt.Cdb[0] = SCSIOP_READ;
        sptwb.spt.Cdb[5] = 0; // Starting LBA
        sptwb.spt.Cdb[8] = 1; // TRANSFER LENGTH

(snip)
    }
    return iResult;
}

Number of bytes to be read (multiple of sector size) is set to sptwb_ex.spt.DataInTransferLength and sptwb.spt.DataTransferLength.

Also, Number of sectors to be read is set to sptwb_ex.spt.Cdb[8] and sptwb.spt.Cdb[8].

Starting LBA to be read is set to sptwb_ex.spt.Cdb[5] and `sptwb.spt.Cdb[5]'.

Note that structure SCSI_PASS_THROUGH_WITH_BUFFERS and SCSI_PASS_THROUGH_WITH_BUFFERS_EX have buffer read data goes to inside them. If you want to read more than one sector or to use a drive of non-512 byte sector (ex. 4kB sector), you need to adjust these parameters and buffer.

You can modify this tool on your own, to accept arbitrary starting LBA and number of sectors, and files that read data goes to / write data exists.

CDB (Command Data Block) is a data format specified in SCSI Block Commands (SBC). If you need further information about CDB, you should check the specification.

I hope it help you.

Thank you, Ken

KerickHuang commented 3 years ago

Hi Ken,

Thank you for your advice.

Hi,

You got it thank you, it's solved and I can build project pass now.

I'm glad to hear that!

I am a beginner, want to write and read LBA to SSD on Windows Can this tool do it?

No, currently starting LBA and number of sectors are fixed, starting LBA is 0 and number of sectors is 1 (hard coded).

Command line argument how to set?

It does not have any command line arguments related to the drive's action, such as starting LBA, number of sectors, and the data source / destination. It only takes the physical drive number of the target NVMe drive.

The starting LBA and number of sectors to be read or written are specified in NVMeSCSIPassThrough.c The below is for read operation.

int iReadViaSCSIPassThrough(HANDLE _hDevice)
{
(snip)

    if ( srbType )
    {
        ZeroMemory(&sptwb_ex, sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS_EX));
(snip)
        sptwb_ex.spt.DataInTransferLength = 512;
(snip)
        sptwb_ex.spt.Cdb[0] = SCSIOP_READ;
        sptwb_ex.spt.Cdb[5] = 0; // Starting LBA
        sptwb_ex.spt.Cdb[8] = 1; // TRANSFER LENGTH
(snip)
    }
    else
    {
        ZeroMemory(&sptwb, sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS));
(snip)
        sptwb.spt.DataTransferLength = 512;
(snip)
        sptwb.spt.Cdb[0] = SCSIOP_READ;
        sptwb.spt.Cdb[5] = 0; // Starting LBA
        sptwb.spt.Cdb[8] = 1; // TRANSFER LENGTH

(snip)
    }
    return iResult;
}

Number of bytes to be read (multiple of sector size) is set to sptwb_ex.spt.DataInTransferLength and sptwb.spt.DataTransferLength.

Also, Number of sectors to be read is set to sptwb_ex.spt.Cdb[8] and sptwb.spt.Cdb[8].

Starting LBA to be read is set to sptwb_ex.spt.Cdb[5] and `sptwb.spt.Cdb[5]'.

Note that structure SCSI_PASS_THROUGH_WITH_BUFFERS and SCSI_PASS_THROUGH_WITH_BUFFERS_EX have buffer read data goes to inside them. If you want to read more than one sector or to use a drive of non-512 byte sector (ex. 4kB sector), you need to adjust these parameters and buffer.

You can modify this tool on your own, to accept arbitrary starting LBA and number of sectors, and files that read data goes to / write data exists.

CDB (Command Data Block) is a data format specified in SCSI Block Commands (SBC). If you need further information about CDB, you should check the specification.

I hope it help you.

Thank you, Ken

ken-yossy commented 3 years ago

I think the original problem (the title of this issue) has been resolved. I close this ticket.

Thank you, Ken