Hi all,
I’m trying to use the inverted call model to detect when streaming clients connect/disconnect my VAD. It works fine, i.e. I get notifications
and GetOverlappedResult returns TRUE. But I cannot read the value returned, it is always false.
Pretty much in my VADs onClientConnected(bool) I do:
PBOOL pBool = (PBOOL)MmGetSystemAddressForMdlSafe(m_irpConnection->MdlAddress, NormalPagePriority);
if (pBool == 0)
{
DPF(D_TERSE, (“Could get to address of data”));
m_irpConnection->IoStatus.Information = 0;
m_irpConnection->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
}
else
{
DPF(D_TERSE, (“Setting overlapped return value!”));
*pBool = connected ? TRUE : FALSE;
m_irpConnection->IoStatus.Information = sizeof(BOOL);
m_irpConnection->IoStatus.Status = STATUS_SUCCESS;
}
IoCompleteRequest(m_irpConnection, IO_NO_INCREMENT);
m_irpConnection = 0;
and in my UM client I do:
BOOL connected;
BOOL res = DeviceIoControl(filter->GetHandle(), IOCTL_MY_DEVICE_CONNECTION, NULL, 0, &connected, sizeof(BOOL), NULL, &olDeviceConnection);
but neither the value of connected, or the value of *(PBOOL)olDeviceConnection.Pointer (when doing GetOverlappedResult) reflect the value written in the VAD.
Ideas ?
TIA
/Rob
Robert Bielik skrev 2010-10-26 09:56:
Hi all,
I’m trying to use the inverted call model to detect when streaming clients connect/disconnect my VAD. It works fine, i.e. I get notifications
and GetOverlappedResult returns TRUE. But I cannot read the value returned, it is always false.
Pretty much in my VADs onClientConnected(bool) I do:
PBOOL pBool = (PBOOL)MmGetSystemAddressForMdlSafe(m_irpConnection->MdlAddress, NormalPagePriority);
if (pBool == 0)
{
DPF(D_TERSE, (“Could get to address of data”));
m_irpConnection->IoStatus.Information = 0;
m_irpConnection->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
}
else
{
DPF(D_TERSE, (“Setting overlapped return value!”));
*pBool = connected ? TRUE : FALSE;
m_irpConnection->IoStatus.Information = sizeof(BOOL);
m_irpConnection->IoStatus.Status = STATUS_SUCCESS;
}
IoCompleteRequest(m_irpConnection, IO_NO_INCREMENT);
m_irpConnection = 0;
and in my UM client I do:
BOOL connected;
BOOL res = DeviceIoControl(filter->GetHandle(), IOCTL_MY_DEVICE_CONNECTION, NULL, 0, &connected, sizeof(BOOL), NULL, &olDeviceConnection);
but neither the value of connected, or the value of *(PBOOL)olDeviceConnection.Pointer (when doing GetOverlappedResult) reflect the value written in the VAD.
Ideas ?
TIA
/Rob
Oh, forgot to tell that IOCTL_MY_DEVICE_CONNECTION is METHOD_OUT_DIRECT
/Rob
Robert Bielik wrote:
I’m trying to use the inverted call model to detect when streaming clients connect/disconnect my VAD. It works fine, i.e. I get notifications
and GetOverlappedResult returns TRUE. But I cannot read the value returned, it is always false.
If you are only passing 4 bytes, why wouldn’t you use METHOD_BUFFERED?
That’s a much more efficient mechanism.
Pretty much in my VADs onClientConnected(bool) I do:
…
and in my UM client I do:
BOOL connected;
BOOL res = DeviceIoControl(filter->GetHandle(), IOCTL_MY_DEVICE_CONNECTION, NULL, 0, &connected, sizeof(BOOL), NULL, &olDeviceConnection);
but neither the value of connected, or the value of *(PBOOL)olDeviceConnection.Pointer (when doing GetOverlappedResult) reflect the value written in the VAD.
After GetOverlappedResult, you should see the result in “connection”.
What do you see? Is the value unchanged? Does
lpNumberOfBytesTransferred in GetOverlappedResult return 4, as
expected? Does GOR return an error?
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Tim Roberts skrev 2010-10-26 19:13:
Robert Bielik wrote:
> I’m trying to use the inverted call model to detect when streaming clients connect/disconnect my VAD. It works fine, i.e. I get notifications
> and GetOverlappedResult returns TRUE. But I cannot read the value returned, it is always false.
If you are only passing 4 bytes, why wouldn’t you use METHOD_BUFFERED?
That’s a much more efficient mechanism.
Yes, as I wrote that I use METHOD_OUT_DIRECT, I thought that using METHOD_BUFFERED would be more suitable since the Irp is completed out
of the Irp call context. But then I got a BSOD since I tried to use MdlAddress which is zero (checked it when I got the debug setup running
and it’s what the docs say about when doing buffered I/O)
Yet the inverted call example, which do buffered I/O, makes use of MdlAddress, so I don’t know what’s happening here… ?
After GetOverlappedResult, you should see the result in “connection”.
What do you see? Is the value unchanged? Does
lpNumberOfBytesTransferred in GetOverlappedResult return 4, as
expected? Does GOR return an error?
Yes, value of connected is unchanged (always FALSE) and *lpNumberOfBytesTransferred is == 4, GOR returns TRUE, but GetLastError says
“Overlapped I/O in progress”. Shouldn’t it say ERROR_SUCCESS ??
/Rob
Robert Bielik wrote:
Yes, as I wrote that I use METHOD_OUT_DIRECT, I thought that using METHOD_BUFFERED would be more suitable since the Irp is completed out
of the Irp call context. But then I got a BSOD since I tried to use MdlAddress which is zero (checked it when I got the debug setup running
and it’s what the docs say about when doing buffered I/O)
Yet the inverted call example, which do buffered I/O, makes use of MdlAddress, so I don’t know what’s happening here… ?
For METHOD_BUFFERED, you don’t use the MDL. The kernel address of the
buffer is in Irp->AssociatedIrp.SystemBuffer.
Yes, value of connected is unchanged (always FALSE) and *lpNumberOfBytesTransferred is == 4, GOR returns TRUE, but GetLastError says
“Overlapped I/O in progress”. Shouldn’t it say ERROR_SUCCESS ??
No. GetLastError is meaningless unless the last API returned an
indication that there was an error.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Tim Roberts skrev 2010-10-26 20:04:
For METHOD_BUFFERED, you don’t use the MDL. The kernel address of the
buffer is in Irp->AssociatedIrp.SystemBuffer.
Way ahead of 'ya!
Checking the IC example, I just changed to using AssociatedIrp.SystemBuffer of the pending Irp.
Unfortunately, still no change in the variable. But at least, no BSOD either…
/Rob
“Robert Bielik” wrote in message news:xxxxx@ntdev…
Unfortunately, still no change in the variable. But at least, no BSOD
either…
Did you set Irp->IoStatus.Information to the number of bytes transferred?
-scott
Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com
“Robert Bielik” wrote in message news:xxxxx@ntdev…
Tim Roberts skrev 2010-10-26 20:04:
For METHOD_BUFFERED, you don’t use the MDL. The kernel address of the
buffer is in Irp->AssociatedIrp.SystemBuffer.
Way ahead of 'ya!
Checking the IC example, I just changed to using
AssociatedIrp.SystemBuffer of the pending Irp.
Unfortunately, still no change in the variable. But at least, no BSOD
either…
/Rob
Robert Bielik skrev 2010-10-26 20:22:
Way ahead of 'ya!
Checking the IC example, I just changed to using AssociatedIrp.SystemBuffer of the pending Irp.
Unfortunately, still no change in the variable. But at least, no BSOD either…
Uh oh. It seems the transfer works, but I get a timing issue. Often when changing a tune in spotify, it disconnects/connects to the device
faster than I can act on the disconnect completing the Irp (and issue a new pending Irp) so I only receive the disconnect 
What’s the proper way to deal with this ? Have a list of pending Irps in the device so there’s always one to complete ?
/Rob