Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GetQueuedCompletionStatus returns ERROR_INSUFFICIENT_BUFFER

46 views
Skip to first unread message

Yaroslav Naglya

unread,
May 12, 2009, 11:49:38 AM5/12/09
to
Hi, All!

I use sample Scanner Minifilter Sample
(http://msdn.microsoft.com/en-us/library/dd163282.aspx) from DDK.
It's works well, but when I modify code for using variable sized message
(http://aonprog.wordpress.com/2009/02/23/file-minifilter-part4-sending-huge-
data-from-kernel-to-user-mode-efficiently-using-variable-sized-structures/),
I have a trouble:
The call GetQueuedCompletionStatus in User mode returns
ERROR_INSUFFICIENT_BUFFER and
in Kernel mode FltSendMessage returns STATUS_PORT_DISCONNECTED.

What is a problem?

Best regards,
Yaroslav Naglya

Tim Roberts

unread,
May 13, 2009, 1:54:37 AM5/13/09
to

Well, is the buffer large enough for the structure?
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

Yaroslav Naglya

unread,
May 13, 2009, 6:26:31 AM5/13/09
to
> Well, is the buffer large enough for the structure?
Function call GetQueuedCompletionStatus doesn't requre to allocate any
buffer.


"Tim Roberts" <ti...@probo.com> wrote in message
news:g4ok05dk15pcmsihl...@4ax.com...

Jakob Bohm

unread,
May 13, 2009, 8:38:00 AM5/13/09
to
Yaroslav Naglya wrote:
>> Well, is the buffer large enough for the structure?
> Function call GetQueuedCompletionStatus doesn't requre to allocate any
> buffer.
>

So I guess GetQueuedCompletionStatus succeeds and returns the completion
status of your queued operation, which would then happen to be a failure
with an error code of ERROR_INSUFFICIENT_BUFFER.

So is the buffer in your original queued/overlapped request large enough?

(See the 3rd paragraph under "Return Values" in the description of
GetQueuedCompletionStatus() on MSDN).

--
Jakob Bøhm, M.Sc.Eng. * j...@danware.dk * direct tel:+45-45-90-25-33
Netop Solutions A/S * Bregnerodvej 127 * DK-3460 Birkerod * DENMARK
http://www.netop.com * tel:+45-45-90-25-25 * fax:+45-45-90-25-26
Information in this mail is hasty, not binding and may not be right.
Information in this posting may not be the official position of Netop
Solutions A/S, only the personal opinions of the author.

Yaroslav Naglya

unread,
May 13, 2009, 11:43:44 AM5/13/09
to
Yes, GetQueuedCompletionStatus fill NumberOfBytes and other OUT-parameters,
but return 0.

When I use stack allocation in diver:
#define SCANNER_READ_BUFFER_SIZE 1024

typedef struct _SCANNER_NOTIFICATION
{
ULONG BytesToScan;
ULONG Reserved; // for quad-word alignement of the Contents structure
UCHAR Contents[SCANNER_READ_BUFFER_SIZE];
} SCANNER_NOTIFICATION, *PSCANNER_NOTIFICATION;


SCANNER_NOTIFICATION notification;
ULONG length = sizeof(notification);

status = FltSendMessage( ScannerData.Filter, &ScannerData.ClientPort,
&notification, length,
NULL, NULL, NULL );

length = 1032 bytes. All works well.

BUT when I allocate buffer with same size:

#define SCANNER_READ_BUFFER_SIZE 1

typedef struct _SCANNER_NOTIFICATION
{
ULONG BytesToScan;
ULONG Reserved; // for quad-word alignement of the Contents structure
UCHAR Contents[SCANNER_READ_BUFFER_SIZE];
} SCANNER_NOTIFICATION, *PSCANNER_NOTIFICATION;

PSCANNER_NOTIFICATION pNotification = NULL;
ULONG ulBufferSize = 1024;
ULONG length = FIELD_OFFSET(SCANNER_NOTIFICATION, Contents[ulBufferSize]);

pNotification = ExAllocatePoolWithTag( NonPagedPool, length, 'info' );

status = FltSendMessage( ScannerData.Filter, &ScannerData.ClientPort,
pNotification, length,
NULL, NULL, NULL );

length = 1032. but it doesn't work
:(


"Jakob Bohm" <j...@danware.dk> wrote in message
news:OBoEoe80...@TK2MSFTNGP05.phx.gbl...


Yaroslav Naglya wrote:
>> Well, is the buffer large enough for the structure?
> Function call GetQueuedCompletionStatus doesn't requre to allocate any
> buffer.
>

So I guess GetQueuedCompletionStatus succeeds and returns the completion
status of your queued operation, which would then happen to be a failure
with an error code of ERROR_INSUFFICIENT_BUFFER.

So is the buffer in your original queued/overlapped request large enough?

(See the 3rd paragraph under "Return Values" in the description of
GetQueuedCompletionStatus() on MSDN).

--
Jakob B�hm, M.Sc.Eng. * j...@danware.dk * direct tel:+45-45-90-25-33

DarkMatter

unread,
Jul 2, 2009, 6:59:50 AM7/2/09
to
Hi yaroslav,

You need to allocate similar structure in your user mode application
from where you are retrieving this structure.

> Jakob Bøhm, M.Sc.Eng. * j...@danware.dk * direct tel:+45-45-90-25-33
> Netop Solutions A/S * Bregnerodvej 127 * DK-3460 Birkerod * DENMARKhttp://www.netop.com* tel:+45-45-90-25-25 * fax:+45-45-90-25-26

0 new messages