Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

Can I transfer a data which length more than 0xFFFF to SD Card by sending SCSI command?

ohnotme29ohnotme29 Member Posts: 1

Hello, I am using C#, with Dllimport I can send SCSI WRITE10 & READ10. But I run and record H2Test behavior in Bushound. The log looks like this
43 CMD 2a 00 00 02 e0 20 00 00 80 00 WRITE 1984.1.0
43 CMD 2a 00 00 02 e0 a0 00 00 80 00 WRITE 1985.1.0
43 CMD 2a 00 00 02 e1 20 00 00 80 00 WRITE 1986.1.0
43 CMD 2a 00 00 02 e1 a0 00 00 80 00 WRITE 1987.1.0
43 CMD 2a 00 00 02 e2 20 00 00 80 00 WRITE 1988.1.0
43 CMD 2a 00 00 02 e2 a0 00 00 80 00 WRITE 1989.1.0
43 CMD 2a 00 00 02 e3 20 00 00 80 00 WRITE 1990.1.0
43 CMD 2a 00 00 02 e3 a0 00 00 80 00 WRITE 1991.1.0
43 CMD 2a 00 00 02 e4 20 00 00 80 00 WRITE 1992.1.0
43 CMD 2a 00 00 02 e4 a0 00 00 80 00 WRITE 1993.1.0
43 CMD 2a 00 00 02 e5 20 00 00 80 00 WRITE 1994.1.0
43 CMD 2a 00 00 02 e5 a0 00 00 80 00 WRITE 1995.1.0
43 CMD 2a 00 00 02 e6 20 00 00 80 00 WRITE 1996.1.0
43 CMD 2a 00 00 02 e6 a0 00 00 80 00 WRITE 1997.1.0
43 CMD 2a 00 00 02 e7 20 00 00 80 00 WRITE 1998.1.0
43 CMD 2a 00 00 02 e7 a0 00 00 80 00 WRITE 1999.1.0
43 OUT f3 5d de d4 dc c8 8e 6e fe fd ef 0f 8a 35 c9 7e a2 7f a3 9e c8 77 70 94 c5 23 4a 97 98 64 29 e9 .].....n.....5.......wp..#J..d). 1984.2.0
03 d9 b2 01 72 45 c9 52 54 4b f7 99 8e 95 bb e5 16 03 fa 74 47 b9 42 94 74 c2 ca 02 ce 38 29 6e ....rE.RTK.........tG.B.t....8)n 1984.2.32
6d 74 f0 68 b0 23 70 ac 13 f7 fb 8b 5c a7 fe eb 49 1e 9e 36 be b3 13 d2 81 36 fe 4a 2a 8b 3a 0f mt.h.#p........I..6.....6.J*.:. 1984.2.64 ~~~~many many data
The log looks like many separated SCSI WRITE10 (from LBA:0x0002E020~0x0002E0A0 LBA:0x0002E0A0~0x0002E120...etc) operation. But It's actually a single multi-write operation in SD card(LBA:0x0002E020~0x0002E7A0). How can I send my SCSI command like the log does? Thank you!

Here are my codes:
private Boolean SendCMD(byte OPCode, ref byte[] buf, long len, long addr, ref int errorCode)
{
bool result = false;
SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER sptwb = null;
sptwb = new SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER((UInt32)(len * 512));
sptwb.sptd.Cdb[1] = 0x00;
sptwb.sptd.Cdb[2] = (byte)((addr >> 24) & 0xFF);
sptwb.sptd.Cdb[3] = (byte)((addr >> 16) & 0xFF);
sptwb.sptd.Cdb[4] = (byte)((addr >> 8) & 0xFF);
sptwb.sptd.Cdb[5] = (byte)((addr) & 0xFF);
sptwb.sptd.Cdb[6] = 0x01;
sptwb.sptd.Cdb[7] = (byte)((len >> 8) & 0xFF);
sptwb.sptd.Cdb[8] = (byte)((len) & 0xFF);
sptwb.sptd.Cdb[9] = 0x00;
sptwb.sptd.DataIn = SCSI_IOCTL_DATA_OUT;
Marshal.Copy(buf, 0, ptrBuf, (int)(len * 512));
sptwb.sptd.CdbLength = 10;
sptwb.sptd.Cdb[0] = OPCode;
sptwb.sptd.DataBuffer = ptrBuf;

int outByte = 0;
int inputSize = Marshal.SizeOf(typeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER));
IntPtr input = Marshal.AllocHGlobal(inputSize);
Marshal.StructureToPtr(sptwb, input, true);
//result = DeviceIoControl(m_hDrive, 0x4D014, input, inputSize, input, inputSize, ref outByte, System.IntPtr.Zero);
result = DeviceIoControl(m_hDrive, (int)IOCTL_SCSI_PASS_THROUGH_DIRECT, input, inputSize, input, inputSize, ref outByte, System.IntPtr.Zero);
return result;
}

Comments

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 12,982
    via Email
    ohnotme29 wrote:
    > Hello, I am using C#, with Dllimport I can send SCSI WRITE10 & READ10. But I run and record H2Test behavior in Bushound.
    > ...
    > The log looks like many separated SCSI WRITE10 (from LBA:0x0002E020~0x0002E0A0 LBA:0x0002E0A0~0x0002E120...etc) operation. But It's actually a single multi-write operation in SD card(LBA:0x0002E020~0x0002E7A0). How can I send my SCSI command like the log does?

    Is that the log output produced from the request in your code? If so,
    then what's the problem?  The port driver is free to chop a large I/O
    request into smaller SCSI commands, if it helps do scheduling or timing
    management.  USB does the same thing.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Developing Minifilters 29 July 2019 OSR Seminar Space
Writing WDF Drivers 23 Sept 2019 OSR Seminar Space
Kernel Debugging 21 Oct 2019 OSR Seminar Space
Internals & Software Drivers 18 Nov 2019 Dulles, VA