I doubt if it even compiles. You cannot use “Createfile” in the kernel. Nor
can you use SetupDiXxxx. You’re attempting to do user mode “stuff” in the
kernel and you can’t.
The personal opinion of
Gary G. Little
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@hotmail.com
Sent: Sunday, September 13, 2009 4:30 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Driver communication.
This is my code. It won’t work and excuse the variable names.
VOID EvtUsbTargetPipeReadComplete (WDFUSBPIPE Pipe, WDFMEMORY Buffer, size_t
NumBytesTransferred, WDFCONTEXT Context)
{
PUCHAR SwitchState = NULL;
WDFDEVICE WdfDevice;
PDEVICE_CONTEXT pDeviceContext = Context;
UCHAR index;
HANDLE Handle;
IO_STATUS_BLOCK IoStatusBlock;
CHAR pVoidBuffer[24];
size_t uLength;
NTSTATUS NtStatus;
WdfDevice = WdfObjectContextGetObject(pDeviceContext);
SwitchState = WdfMemoryGetBuffer(Buffer, &NumBytesTransferred);
pDeviceContext->CurrentSwitchState = *SwitchState;
DbgPrint (“EvtUsbTargetPipeReadComplete Pipe=40x%08x4 Buffer=40x%08x4
NumBytesTransferred=4%i4 Context=40x%08x4”, Pipe, Buffer,
NumBytesTransferred, Context);
for(index=0; index < NumBytesTransferred; index++)
DbgPrint (“byte[%i]=40x%02x4”, index, *(SwitchState+index));
NtStatus = CreateFile (&Handle, GUNCONKB_DEVICE_ID, GENERIC_WRITE);
if(!NT_SUCCESS(NtStatus))
{
DbgPrint(“CreateFile unfortunately failed.\n”);
return;
}
RtlStringCbPrintfA(pVoidBuffer, sizeof(pVoidBuffer),
“%02x%02x%02x%02x%02x%02x%02x%02x\0”, *(SwitchState), *(SwitchState+1),
*(SwitchState+2), *(SwitchState+3), *(SwitchState+4), *(SwitchState+5),
*(SwitchState+6), *(SwitchState+7));
RtlStringCbLengthA(pVoidBuffer, sizeof(pVoidBuffer), &uLength);
NtStatus = ZwWriteFile (Handle, NULL, NULL, NULL, &IoStatusBlock,
pVoidBuffer, uLength, NULL, NULL);
if(!NT_SUCCESS(NtStatus))
{
DbgPrint(“WriteFile unfortunately failed.\n”);
ZwClose(Handle);
return;
}
ZwClose(Handle);
}
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
__________ Information from ESET Smart Security, version of virus signature
database 4422 (20090913) __________
The message was checked by ESET Smart Security.
http://www.eset.com
__________ Information from ESET Smart Security, version of virus signature
database 4422 (20090913) __________
The message was checked by ESET Smart Security.
http://www.eset.com