Aric Stewart : hidclass.sys: When processing reads fill all the buffers.
Alexandre Julliard
julliard at winehq.org
Thu Jan 26 14:53:15 CST 2017
Module: wine
Branch: master
Commit: 68ecd3b76a7f3ef901cf2b648d25773b8ab9db91
URL: http://source.winehq.org/git/wine.git/?a=commit;h=68ecd3b76a7f3ef901cf2b648d25773b8ab9db91
Author: Aric Stewart <aric at codeweavers.com>
Date: Thu Jan 26 08:59:22 2017 -0600
hidclass.sys: When processing reads fill all the buffers.
Signed-off-by: Aric Stewart <aric at codeweavers.com>
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/hidclass.sys/buffer.c | 36 +++++++++++++++++++++++++++++++++++-
dlls/hidclass.sys/device.c | 2 +-
dlls/hidclass.sys/hid.h | 3 ++-
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/dlls/hidclass.sys/buffer.c b/dlls/hidclass.sys/buffer.c
index 0b29f97..731f1e0 100644
--- a/dlls/hidclass.sys/buffer.c
+++ b/dlls/hidclass.sys/buffer.c
@@ -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;
diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c
index fe79212..ff9655e 100644
--- a/dlls/hidclass.sys/device.c
+++ b/dlls/hidclass.sys/device.c
@@ -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)
{
diff --git a/dlls/hidclass.sys/hid.h b/dlls/hidclass.sys/hid.h
index adc547c..1829319 100644
--- a/dlls/hidclass.sys/hid.h
+++ b/dlls/hidclass.sys/hid.h
@@ -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;
More information about the wine-cvs
mailing list