http.sys: Create a skeletal request_queue object for each file opened.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-08-21 23:30:13 -05:00 committed by Alexandre Julliard
parent d3658f262e
commit 2ab696d638

View file

@ -26,21 +26,67 @@
#include "winioctl.h"
#include "ddk/wdm.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h"
static HANDLE directory_obj;
static DEVICE_OBJECT *device_obj;
WINE_DEFAULT_DEBUG_CHANNEL(http);
#define DECLARE_CRITICAL_SECTION(cs) \
static CRITICAL_SECTION cs; \
static CRITICAL_SECTION_DEBUG cs##_debug = \
{ 0, 0, &cs, { &cs##_debug.ProcessLocksList, &cs##_debug.ProcessLocksList }, \
0, 0, { (DWORD_PTR)(__FILE__ ": " # cs) }}; \
static CRITICAL_SECTION cs = { &cs##_debug, -1, 0, 0, 0, 0 };
DECLARE_CRITICAL_SECTION(http_cs);
struct request_queue
{
struct list entry;
};
static struct list request_queues = LIST_INIT(request_queues);
static NTSTATUS WINAPI dispatch_create(DEVICE_OBJECT *device, IRP *irp)
{
IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp);
struct request_queue *queue;
if (!(queue = heap_alloc_zero(sizeof(*queue))))
return STATUS_NO_MEMORY;
stack->FileObject->FsContext = queue;
EnterCriticalSection(&http_cs);
list_add_head(&request_queues, &queue->entry);
LeaveCriticalSection(&http_cs);
TRACE("Created queue %p.\n", queue);
irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
static void close_queue(struct request_queue *queue)
{
EnterCriticalSection(&http_cs);
list_remove(&queue->entry);
LeaveCriticalSection(&http_cs);
heap_free(queue);
}
static NTSTATUS WINAPI dispatch_close(DEVICE_OBJECT *device, IRP *irp)
{
IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp);
struct request_queue *queue = stack->FileObject->FsContext;
TRACE("Closing queue %p.\n", queue);
close_queue(queue);
irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
@ -48,6 +94,13 @@ static NTSTATUS WINAPI dispatch_close(DEVICE_OBJECT *device, IRP *irp)
static void WINAPI unload(DRIVER_OBJECT *driver)
{
struct request_queue *queue, *queue_next;
LIST_FOR_EACH_ENTRY_SAFE(queue, queue_next, &request_queues, struct request_queue, entry)
{
close_queue(queue);
}
IoDeleteDevice(device_obj);
NtClose(directory_obj);
}