Thanks alot for your detailed reply.
Ok , i get your reply but still have few questions.
I send 32 kb data which is large , so you 1-say i shall make it like this :
Deviceiocontrol( …,…,sizof(testcmdmux)+32kb-1,…,…) ?
Or i shall divide it ?
If so , how can i divide this much data ?
I mean data i want to send is 32768 bytes “32kb”.
2-What did you mean by second buffer ?
3- the data i should send are sizeof(my structure)+32kb-1 or
sizeof(mystructure)+ (32kb-1)*sizeof(datatosend->buffer) this one is making
me crazy ?
4-If you are only using the first buffer in DeviceIoControl, these two
methods are identical. If the buffer you are sending is large (like,
bigger than 8k or 12k), then it would make sense to use METHOD_IN_DIRECT
and send the data buffer as the second buffer in DeviceIoControl.
So you mean i shall for sure use method in direct ? Ok , but i need to
understand second buffer ! , do you mean i shall send deviceiocontrol 2
times here ?
Really appreciate any help here
On Feb 3, 2017 5:40 AM, “Tim Roberts” wrote:
> On Feb 2, 2017, at 5:07 AM, mohamed rauof
> wrote:
>
>
> problem is when i send data i do like this :
>
> DeviceIoControl (hDMADevice, ISTART_TEST_SMUX, DataToSend,
> sizeof(TestCmdSMUX), NULL, 0, &bytes, &os))
> where DataToSend is pointer to structure i send , with size
> = sizeof(TestCmdSMUX).
>
>
> But that number is not correct. The data you want to send is much larger
> than TestCmdSMUX. If you send sizeof(TestCmdSMUX), you will get exactly
> one byte of your buffer, because that’s what’s specified in the structure.
>
> You have two alternatives. One is to specify the actual length of the
> data you want to send in the ioctl:
>
> … DataToSend, sizeof(TestCmdSMUX) + bufferLength - 1, …
>
> The other is to split the buffer out of the structure altogether, and send
> the structure as the first buffer, and the buffer as the second buffer.
> That would require changing to METHOD_IN_DIRECT.
>
>
> *DataToSend *is ptr to structure like this :
> typedef struct {
> int Engine; / *< Engine Number /
> unsigned int TestMode; / < Test Mode - Enable TX, Enable loopback */
> unsigned int MinPktSize; / *< Min packet size /
> unsigned int MaxPktSize; / < Max packet size */
> UCHAR buffer[1];
>
> } TestCmdSMUX *DataToSend **
>
>
> UCHAR buffer[1]; –> this is pointer to first element of my data i want
> to send to kernel .
>
>
> It is NOT a pointer. It is the address of the first byte of data.
>
>
>
> so it isn’t working properly , and i don’t know why ! , few questions i
> have here :
> 1 - is WdfRequestRetrieveInputBuffer right to use ? and can i in this way
> use members of pTC structure ?
>
>
> Yes and yes.
>
>
> 2 - what is diffrence between *WdfRequestRetrieveInputBuffer *and Irp->AssociatedIrp.SystemBuffer
> ,when to use them?
>
>
> WdfRequestRetrieveInputBuffer will go fetch the right pointer. If
> Irp->AssociatedIrp.SystemBuffer is the right pointer for the method of
> this ioctl, that’s what it will use.
>
>
> 3 - how can i actually recieve the array data i am passing with
> deviceiocontrol datatosend structure ?
>
>
> The problem is not that you aren’t receiving it. The problem is that you
> are sending it. You need to tell it exactly how much data to send.
>
>
> 4 - what is type of my IOCode in this usecase , Method_In_Direct OR
> MethodBuffered ?
>
>
> If you are only using the first buffer in DeviceIoControl, these two
> methods are identical. If the buffer you are sending is large (like,
> bigger than 8k or 12k), then it would make sense to use METHOD_IN_DIRECT
> and send the data buffer as the second buffer in DeviceIoControl.
>
>
> 5 - suppose i want to address in driver the 3rd element data of array
> passed , how i do that in driver ?
>
>
> If you were actually passing the data, it would be pTC->buffer[2].
> —
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer>
></http:></http:>