mirror of
https://github.com/nefarius/ViGEmBus.git
synced 2025-08-10 00:52:17 +00:00
Removed misused locking mechanisms
This commit is contained in:
10
Context.h
10
Context.h
@@ -106,21 +106,11 @@ typedef struct _PDO_DEVICE_DATA
|
||||
//
|
||||
WDFQUEUE PendingUsbInRequests;
|
||||
|
||||
//
|
||||
// Lock for queue for incoming data interrupt transfer
|
||||
//
|
||||
WDFSPINLOCK PendingUsbInRequestsLock;
|
||||
|
||||
//
|
||||
// Queue for inverted calls
|
||||
//
|
||||
WDFQUEUE PendingNotificationRequests;
|
||||
|
||||
//
|
||||
// Lock for queue for inverted calls
|
||||
//
|
||||
WDFSPINLOCK PendingNotificationRequestsLock;
|
||||
|
||||
} PDO_DEVICE_DATA, *PPDO_DEVICE_DATA;
|
||||
|
||||
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(PDO_DEVICE_DATA, PdoGetData)
|
||||
|
||||
8
Ds4.c
8
Ds4.c
@@ -351,13 +351,10 @@ VOID Ds4_PendingUsbRequestsTimerFunc(
|
||||
ds4Data = Ds4GetData(hChild);
|
||||
|
||||
// Get pending USB request
|
||||
WdfSpinLockAcquire(pdoData->PendingUsbInRequestsLock);
|
||||
status = WdfIoQueueRetrieveNextRequest(pdoData->PendingUsbInRequests, &usbRequest);
|
||||
|
||||
if (NT_SUCCESS(status))
|
||||
{
|
||||
// KdPrint((DRIVERNAME "Ds4_PendingUsbRequestsTimerFunc: pending IRP found\n"));
|
||||
|
||||
// Get pending IRP
|
||||
pendingIrp = WdfRequestWdmGetIrp(usbRequest);
|
||||
irpStack = IoGetCurrentIrpStackLocation(pendingIrp);
|
||||
@@ -371,12 +368,11 @@ VOID Ds4_PendingUsbRequestsTimerFunc(
|
||||
urb->UrbBulkOrInterruptTransfer.TransferBufferLength = DS4_REPORT_SIZE;
|
||||
|
||||
// Copy cached report to transfer buffer
|
||||
RtlCopyBytes(Buffer, ds4Data->Report, DS4_REPORT_SIZE);
|
||||
if (Buffer)
|
||||
RtlCopyBytes(Buffer, ds4Data->Report, DS4_REPORT_SIZE);
|
||||
|
||||
// Complete pending request
|
||||
WdfRequestComplete(usbRequest, status);
|
||||
}
|
||||
|
||||
WdfSpinLockRelease(pdoData->PendingUsbInRequestsLock);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,13,2,0
|
||||
PRODUCTVERSION 1,13,2,0
|
||||
FILEVERSION 1,13,8,0
|
||||
PRODUCTVERSION 1,13,8,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -69,12 +69,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Benjamin H<>glinger-Stelzer"
|
||||
VALUE "FileDescription", "Virtual Gamepad Emulation Bus Driver"
|
||||
VALUE "FileVersion", "1.13.2.0"
|
||||
VALUE "FileVersion", "1.13.8.0"
|
||||
VALUE "InternalName", "Virtual Gamepad Emulation Bus Driver"
|
||||
VALUE "LegalCopyright", "Copyright (C) Benjamin H<>glinger-Stelzer 2016"
|
||||
VALUE "OriginalFilename", "vigembus.sys"
|
||||
VALUE "ProductName", "Virtual Gamepad Emulation Bus Driver"
|
||||
VALUE "ProductVersion", "1.13.2.0"
|
||||
VALUE "ProductVersion", "1.13.8.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -182,7 +182,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<Inf>
|
||||
<TimeStamp>1.13.2.0</TimeStamp>
|
||||
<TimeStamp>1.13.8.0</TimeStamp>
|
||||
</Inf>
|
||||
<Link>
|
||||
<AdditionalDependencies>$(DDK_LIB_PATH)ntstrsafe.lib;$(DDK_LIB_PATH)wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
@@ -190,7 +190,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<Inf>
|
||||
<TimeStamp>1.13.2.0</TimeStamp>
|
||||
<TimeStamp>1.13.8.0</TimeStamp>
|
||||
</Inf>
|
||||
<Link>
|
||||
<AdditionalDependencies>$(DDK_LIB_PATH)ntstrsafe.lib;$(DDK_LIB_PATH)wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
@@ -198,7 +198,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Inf>
|
||||
<TimeStamp>1.13.2.0</TimeStamp>
|
||||
<TimeStamp>1.13.8.0</TimeStamp>
|
||||
</Inf>
|
||||
<Link>
|
||||
<AdditionalDependencies>$(DDK_LIB_PATH)ntstrsafe.lib;$(DDK_LIB_PATH)wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
@@ -206,7 +206,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Inf>
|
||||
<TimeStamp>1.13.2.0</TimeStamp>
|
||||
<TimeStamp>1.13.8.0</TimeStamp>
|
||||
</Inf>
|
||||
<Link>
|
||||
<AdditionalDependencies>$(DDK_LIB_PATH)ntstrsafe.lib;$(DDK_LIB_PATH)wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
@@ -214,7 +214,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
|
||||
<Inf>
|
||||
<TimeStamp>1.13.2.0</TimeStamp>
|
||||
<TimeStamp>1.13.8.0</TimeStamp>
|
||||
</Inf>
|
||||
<Link>
|
||||
<AdditionalDependencies>$(DDK_LIB_PATH)ntstrsafe.lib;$(DDK_LIB_PATH)wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
@@ -222,7 +222,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
|
||||
<Inf>
|
||||
<TimeStamp>1.13.2.0</TimeStamp>
|
||||
<TimeStamp>1.13.8.0</TimeStamp>
|
||||
</Inf>
|
||||
<Link>
|
||||
<AdditionalDependencies>$(DDK_LIB_PATH)ntstrsafe.lib;$(DDK_LIB_PATH)wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
@@ -230,7 +230,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Inf>
|
||||
<TimeStamp>1.13.2.0</TimeStamp>
|
||||
<TimeStamp>1.13.8.0</TimeStamp>
|
||||
</Inf>
|
||||
<Link>
|
||||
<AdditionalDependencies>$(DDK_LIB_PATH)ntstrsafe.lib;$(DDK_LIB_PATH)wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
@@ -238,7 +238,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Inf>
|
||||
<TimeStamp>1.13.2.0</TimeStamp>
|
||||
<TimeStamp>1.13.8.0</TimeStamp>
|
||||
</Inf>
|
||||
<Link>
|
||||
<AdditionalDependencies>$(DDK_LIB_PATH)ntstrsafe.lib;$(DDK_LIB_PATH)wdmsec.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
|
||||
27
busenum.c
27
busenum.c
@@ -361,9 +361,7 @@ NTSTATUS Bus_QueueNotification(WDFDEVICE Device, ULONG SerialNo, WDFREQUEST Requ
|
||||
|
||||
if (xusbData == NULL) break;
|
||||
|
||||
WdfSpinLockAcquire(pdoData->PendingNotificationRequestsLock);
|
||||
status = WdfRequestForwardToIoQueue(Request, pdoData->PendingNotificationRequests);
|
||||
WdfSpinLockRelease(pdoData->PendingNotificationRequestsLock);
|
||||
|
||||
break;
|
||||
case DualShock4Wired:
|
||||
@@ -372,9 +370,7 @@ NTSTATUS Bus_QueueNotification(WDFDEVICE Device, ULONG SerialNo, WDFREQUEST Requ
|
||||
|
||||
if (ds4Data == NULL) break;
|
||||
|
||||
WdfSpinLockAcquire(pdoData->PendingNotificationRequestsLock);
|
||||
status = WdfRequestForwardToIoQueue(Request, pdoData->PendingNotificationRequests);
|
||||
WdfSpinLockRelease(pdoData->PendingNotificationRequestsLock);
|
||||
|
||||
break;
|
||||
default:
|
||||
@@ -496,13 +492,11 @@ NTSTATUS Bus_SubmitReport(WDFDEVICE Device, ULONG SerialNo, PVOID Report, BOOLEA
|
||||
|
||||
KdPrint((DRIVERNAME "Bus_SubmitReport: received new report\n"));
|
||||
|
||||
WdfSpinLockAcquire(pdoData->PendingUsbInRequestsLock);
|
||||
|
||||
// Get pending USB request
|
||||
switch (pdoData->TargetType)
|
||||
{
|
||||
case Xbox360Wired:
|
||||
|
||||
|
||||
status = WdfIoQueueRetrieveNextRequest(pdoData->PendingUsbInRequests, &usbRequest);
|
||||
|
||||
break;
|
||||
@@ -530,7 +524,7 @@ NTSTATUS Bus_SubmitReport(WDFDEVICE Device, ULONG SerialNo, PVOID Report, BOOLEA
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
KdPrint((DRIVERNAME "WdfMemoryCreate failed with status 0x%X\n", status));
|
||||
goto releaseAndExit;
|
||||
goto endSubmitReport;
|
||||
}
|
||||
|
||||
// Copy interrupt buffer to memory object
|
||||
@@ -538,7 +532,7 @@ NTSTATUS Bus_SubmitReport(WDFDEVICE Device, ULONG SerialNo, PVOID Report, BOOLEA
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
KdPrint((DRIVERNAME "WdfMemoryCopyFromBuffer failed with status 0x%X\n", status));
|
||||
goto releaseAndExit;
|
||||
goto endSubmitReport;
|
||||
}
|
||||
|
||||
// Add memory object to collection
|
||||
@@ -546,7 +540,7 @@ NTSTATUS Bus_SubmitReport(WDFDEVICE Device, ULONG SerialNo, PVOID Report, BOOLEA
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
KdPrint((DRIVERNAME "WdfCollectionAdd failed with status 0x%X\n", status));
|
||||
goto releaseAndExit;
|
||||
goto endSubmitReport;
|
||||
}
|
||||
|
||||
// Check if all packets have been received
|
||||
@@ -559,7 +553,7 @@ NTSTATUS Bus_SubmitReport(WDFDEVICE Device, ULONG SerialNo, PVOID Report, BOOLEA
|
||||
WdfTimerStart(xgip->XboxgipSysInitTimer, XGIP_SYS_INIT_PERIOD);
|
||||
}
|
||||
|
||||
goto releaseAndExit;
|
||||
goto endSubmitReport;
|
||||
}
|
||||
|
||||
status = WdfIoQueueRetrieveNextRequest(XgipGetData(hChild)->PendingUsbInRequests, &usbRequest);
|
||||
@@ -568,11 +562,11 @@ NTSTATUS Bus_SubmitReport(WDFDEVICE Device, ULONG SerialNo, PVOID Report, BOOLEA
|
||||
default:
|
||||
|
||||
status = STATUS_NOT_SUPPORTED;
|
||||
goto releaseAndExit;
|
||||
goto endSubmitReport;
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(status))
|
||||
goto releaseAndExit;
|
||||
goto endSubmitReport;
|
||||
|
||||
KdPrint((DRIVERNAME "Bus_SubmitReport: pending IRP found\n"));
|
||||
|
||||
@@ -604,7 +598,9 @@ NTSTATUS Bus_SubmitReport(WDFDEVICE Device, ULONG SerialNo, PVOID Report, BOOLEA
|
||||
/* Copy report to cache and transfer buffer
|
||||
* Skip first byte as it contains the never changing report id */
|
||||
RtlCopyBytes(Ds4GetData(hChild)->Report + 1, &((PDS4_SUBMIT_REPORT)Report)->Report, sizeof(DS4_REPORT));
|
||||
RtlCopyBytes(Buffer, Ds4GetData(hChild)->Report, DS4_REPORT_SIZE);
|
||||
|
||||
if (Buffer)
|
||||
RtlCopyBytes(Buffer, Ds4GetData(hChild)->Report, DS4_REPORT_SIZE);
|
||||
|
||||
break;
|
||||
case XboxOneWired:
|
||||
@@ -634,8 +630,7 @@ NTSTATUS Bus_SubmitReport(WDFDEVICE Device, ULONG SerialNo, PVOID Report, BOOLEA
|
||||
// Complete pending request
|
||||
WdfRequestComplete(usbRequest, status);
|
||||
|
||||
releaseAndExit:
|
||||
WdfSpinLockRelease(pdoData->PendingUsbInRequestsLock);
|
||||
endSubmitReport:
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
16
buspdo.c
16
buspdo.c
@@ -367,14 +367,6 @@ NTSTATUS Bus_CreatePdo(
|
||||
KdPrint((DRIVERNAME "WdfIoQueueCreate (PendingUsbInRequests) failed 0x%x\n", status));
|
||||
goto endCreatePdo;
|
||||
}
|
||||
|
||||
// Create lock for queue
|
||||
status = WdfSpinLockCreate(&attributes, &pdoData->PendingUsbInRequestsLock);
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
KdPrint((DRIVERNAME "WdfSpinLockCreate (PendingUsbInRequestsLock) failed 0x%x\n", status));
|
||||
goto endCreatePdo;
|
||||
}
|
||||
|
||||
// Create and assign queue for user-land notification requests
|
||||
WDF_IO_QUEUE_CONFIG_INIT(¬ificationsQueueConfig, WdfIoQueueDispatchManual);
|
||||
@@ -386,14 +378,6 @@ NTSTATUS Bus_CreatePdo(
|
||||
goto endCreatePdo;
|
||||
}
|
||||
|
||||
// Create lock for queue
|
||||
status = WdfSpinLockCreate(&attributes, &pdoData->PendingNotificationRequestsLock);
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
KdPrint((DRIVERNAME "WdfSpinLockCreate (PendingNotificationRequestsLock) failed 0x%x\n", status));
|
||||
goto endCreatePdo;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Default I/O queue setup
|
||||
|
||||
5
usbpdo.c
5
usbpdo.c
@@ -507,9 +507,7 @@ NTSTATUS UsbPdo_BulkOrInterruptTransfer(PURB urb, WDFDEVICE Device, WDFREQUEST R
|
||||
/* This request is sent periodically and relies on data the "feeder"
|
||||
* has to supply, so we queue this request and return with STATUS_PENDING.
|
||||
* The request gets completed as soon as the "feeder" sent an update. */
|
||||
WdfSpinLockAcquire(pdoData->PendingUsbInRequestsLock);
|
||||
status = WdfRequestForwardToIoQueue(Request, pdoData->PendingUsbInRequests);
|
||||
WdfSpinLockRelease(pdoData->PendingUsbInRequestsLock);
|
||||
|
||||
return (NT_SUCCESS(status)) ? STATUS_PENDING : status;
|
||||
}
|
||||
@@ -567,7 +565,6 @@ NTSTATUS UsbPdo_BulkOrInterruptTransfer(PURB urb, WDFDEVICE Device, WDFREQUEST R
|
||||
}
|
||||
|
||||
// Notify user-mode process that new data is available
|
||||
WdfSpinLockAcquire(pdoData->PendingNotificationRequestsLock);
|
||||
status = WdfIoQueueRetrieveNextRequest(pdoData->PendingNotificationRequests, ¬ifyRequest);
|
||||
|
||||
if (NT_SUCCESS(status))
|
||||
@@ -593,8 +590,6 @@ NTSTATUS UsbPdo_BulkOrInterruptTransfer(PURB urb, WDFDEVICE Device, WDFREQUEST R
|
||||
}
|
||||
}
|
||||
|
||||
WdfSpinLockRelease(pdoData->PendingNotificationRequestsLock);
|
||||
|
||||
break;
|
||||
}
|
||||
case DualShock4Wired:
|
||||
|
||||
Reference in New Issue
Block a user