Commit 68ecd3b7 authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

hidclass.sys: When processing reads fill all the buffers.

parent 65089c39
......@@ -127,7 +127,7 @@ NTSTATUS RingBuffer_SetSize(struct ReportRingBuffer *ring, UINT size)
return STATUS_SUCCESS;
}
void RingBuffer_Read(struct ReportRingBuffer *ring, UINT index, void *output, UINT *size)
void RingBuffer_ReadNew(struct ReportRingBuffer *ring, UINT index, void *output, UINT *size)
{
void *ret = NULL;
......@@ -155,6 +155,40 @@ void RingBuffer_Read(struct ReportRingBuffer *ring, UINT index, void *output, UI
}
}
void RingBuffer_Read(struct ReportRingBuffer *ring, UINT index, void *output, UINT *size)
{
int pointer;
void *ret = NULL;
EnterCriticalSection(&ring->lock);
if (index >= ring->pointer_alloc || ring->pointers[index] == POINTER_UNUSED
|| ring->end == ring->start)
{
LeaveCriticalSection(&ring->lock);
*size = 0;
return;
}
pointer = ring->pointers[index];
if (pointer == ring->end)
pointer--;
if (pointer < 0)
pointer = ring->size - 1;
ret = &ring->buffer[pointer * ring->buffer_size];
memcpy(output, ret, ring->buffer_size);
if (pointer == ring->pointers[index])
{
ring->pointers[index]++;
if (ring->pointers[index] == ring->size)
ring->pointers[index] = 0;
}
LeaveCriticalSection(&ring->lock);
*size = ring->buffer_size;
}
UINT RingBuffer_AddPointer(struct ReportRingBuffer *ring)
{
UINT idx;
......
......@@ -663,7 +663,7 @@ NTSTATUS WINAPI HID_Device_read(DEVICE_OBJECT *device, IRP *irp)
ptr = PtrToUlong( irp->Tail.Overlay.OriginalFileObject->FsContext );
irp->IoStatus.Information = 0;
RingBuffer_Read(ext->ring_buffer, ptr, packet, &buffer_size);
RingBuffer_ReadNew(ext->ring_buffer, ptr, packet, &buffer_size);
if (buffer_size)
{
......
......@@ -62,7 +62,8 @@ typedef struct _BASE_DEVICE_EXTENSION {
void RingBuffer_Write(struct ReportRingBuffer *buffer, void *data) DECLSPEC_HIDDEN;
UINT RingBuffer_AddPointer(struct ReportRingBuffer *buffer) DECLSPEC_HIDDEN;
void RingBuffer_RemovePointer(struct ReportRingBuffer *ring, UINT index) DECLSPEC_HIDDEN;
void RingBuffer_Read(struct ReportRingBuffer *buffer, UINT index, void *output, UINT *size) DECLSPEC_HIDDEN;
void RingBuffer_Read(struct ReportRingBuffer *ring, UINT index, void *output, UINT *size) DECLSPEC_HIDDEN;
void RingBuffer_ReadNew(struct ReportRingBuffer *buffer, UINT index, void *output, UINT *size) DECLSPEC_HIDDEN;
UINT RingBuffer_GetBufferSize(struct ReportRingBuffer *buffer) DECLSPEC_HIDDEN;
UINT RingBuffer_GetSize(struct ReportRingBuffer *buffer) DECLSPEC_HIDDEN;
void RingBuffer_Destroy(struct ReportRingBuffer *buffer) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment