Hi,
I am working on a virtual COM port driver using UMDF. I would like to
obtain the file name with which a file object that refers to my device
has been opened. Therefore I have implemented the IQueueCallbackCreate
interface and in the context of
IQueueCallbackCreate::OnCreateFile(...) I use
IWDFFileObject::RetrieveFileName to obtain the filename. The method
indicates success by returning S_OK but the string wszFileName (see
below) remains empty with length 0.
Are there any preconditions for the RetrieveFileName method to work as
expected?
The test application opens the virtual com port as follows:
HANDLE hFile = CreateFile(_T("COM3"), GENERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
The code I use to obtain the file name in the UMDF driver is this:
WCHAR wszFileName[MAX_PATH];
memset(wszFileName, 0, sizeof(wszFileName));
DWORD nFileNameLen = _countof(wszFileName);
HRESULT hr = pWdfFileObject->RetrieveFileName(wszFileName,
&nFileNameLen);
if (FAILED(hr))
{
Trace(TRACE_LEVEL_ERROR, "%!FUNC! failed to get filename, hr=0x%x",
hr);
}
else
{
Trace(TRACE_LEVEL_INFORMATION, "%!FUNC! filename %S, hr=0x%x",
wszFileName,hr);
}
The first method described by the blog entry sets short symbolic links. The
example assumes a device name L"\\Device\\Foo0" and creates the links
"\\??\\Foo\\Ref1" and "\\??\\Foo\\Ref2". I tried to do this similarly and
replaced "Foo" with my device name "TcEL60xx". But then I got the error
0x80070003, which indicates that the system cannot find given the path. What
would be the correct path for an UMDF device and how can I obtain it?
The blog entry describes as second method, that I can create two com port
interfaces with different reference strings. Then I should create two
symbolic links that refer to these com port interface instances,
respectively. However, the UMDF interface does not seem to allow this. In the
blog entry the method IoCreateSymbolicLink is used which has two parameters,
i.e. link name and link target. Within UMDF framework there is the method
IWDFDevice::CreateSymbolicLink which has only one parameter, i.e. the link
name. Therefore I cannot specify the correct link target as suggested by the
blog entry.
I can actually open a com port interface instance with CreateFile. However,
I must specify the full device interface instance name which is
"\\\\?\\root#tcel60xxclass#0000#{86e0d1e0-8089-11d0-9ce4-08003e301f73}\\com3"
How can I create a symbolic link to this com port interface instance using
UMDF?
Regards,
Andre
"Doron Holan [MSFT]" wrote: