The ‘name’ in
WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(
&openParams,
“\\?\root#sample#0000#{cdc35b6e-0be4-4936-bf5f-5537380a7c1a}”,
STANDARD_RIGHTS_ALL);
Seems to be incorrect. This macro takes a pointer to a UNICODE_STRING
(PUNICODE_STRING) structure, not a wide character string.
Try something more like this:
DECLARE_CONST_UNICODE_STRING(targetDeviceName,
L"\\?\root#sample#0000#{cdc35b6e-0be4-4936-bf5f-5537380a7c1a}");
…
WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(&openParams,
&targetDeviceName, STANDARD_RIGHTS_ALL);
That will probably work much better. You are passing PCSTR (char*) pointer
to the macro when it is expecting a PUNICODE_STRING. Don’t forget that all
of this is WCHAR and that a L"" prefix is needed on the constant string
value to make it a WCHAR string.
Out of curiosity, does the compiler complain about this line of code? The
WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME is a FORCEINLINE function with
TargetDeviceName declared as PUNICODE_STRING. A const char * is definitely
not the same type as a struct _UNICODE_STRING* and thus the compiler should
have warned that the pointer types don’t match.
Good Luck,
Dave Cattley
Consulting Engineer
Systems Software Development
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@hotmail.com
Sent: Tuesday, September 23, 2008 2:35 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Opening a remote IO target
Hi doron, thank you for the fast respond. I did not use any unicode or ansi
string object for my string. Apology if my coding style is not very good. My
driver code:
NTSTATUS
FmForwardEchoIOTarget(
IN WDFREQUEST Request,
IN WDFDEVICE device
){
WDFIOTARGET ioTarget;
WDF_IO_TARGET_OPEN_PARAMS openParams;
NTSTATUS status = STATUS_SUCCESS;
WDF_REQUEST_SEND_OPTIONS sendOption;
PAGED_CODE();
status = WdfIoTargetCreate(
device,
WDF_NO_OBJECT_ATTRIBUTES,
&ioTarget );
if (!NT_SUCCESS(status)) {
KdPrint((“IO Target create failed\n”));
return status;
}
WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(
&openParams,
“\\?\root#sample#0000#{cdc35b6e-0be4-4936-bf5f-5537380a7c1a}”,
STANDARD_RIGHTS_ALL);
status = WdfIoTargetOpen(
ioTarget,
&openParams);
if (!NT_SUCCESS(status)) {
KdPrint((“IO Target open failed\n”));
}
WdfObjectDelete(ioTarget);
return status;
}
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