Skip to content

Commit

Permalink
Correct completion code
Browse files Browse the repository at this point in the history
vJoyGetPositionData() succeeds only if data copied to output buffer successfully
Completion code for handler for IOCTL_HID_READ_REPORT is now STATUS_UNSUCCESSFUL if function vJoyGetPositionData() fails.
  • Loading branch information
shauleiz committed Mar 9, 2017
1 parent fa94cbb commit 6052a9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions driver/sys/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,8 @@ Return Value:
} else
{
// Copy the data stored in the Device Context into the the output buffer
vJoyGetPositionData(HidReport,pDevContext,id, bytesReturned);
if (vJoyGetPositionData(HidReport, pDevContext, id, bytesReturned) != STATUS_SUCCESS)
status = STATUS_UNSUCCESSFUL;
}

WdfRequestCompleteWithInformation(request, status, bytesReturned);
Expand Down Expand Up @@ -787,10 +788,12 @@ Routine Description
Return Value:
None.
STATUS_SUCCESS if succeeded.
STATUS_TIMEOUT if failed because could not acquire lock
STATUS_ACCESS_VIOLATION if bad pointer
--*/
VOID
NTSTATUS
vJoyGetPositionData(
OUT HID_INPUT_REPORT_V2 *HidReport,
IN DEVICE_EXTENSION *pDevContext,
Expand All @@ -810,7 +813,7 @@ vJoyGetPositionData(
i = id-1;

if (!pDevContext->positions[i])
return;
return STATUS_ACCESS_VIOLATION;


if (STATUS_SUCCESS == WdfWaitLockAcquire(pDevContext->positionLock, &timeout))
Expand Down Expand Up @@ -839,7 +842,11 @@ vJoyGetPositionData(
};
// DEBUGGING HidReport->InputReport.FFBVal = 0xFF; // FFB Value
WdfWaitLockRelease(pDevContext->positionLock);

return STATUS_SUCCESS;
};

return STATUS_TIMEOUT;
}


Expand Down
2 changes: 1 addition & 1 deletion driver/sys/vjoy.h
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,7 @@ vJoyCompleteReadReport(
UCHAR id
);

VOID
NTSTATUS
vJoyGetPositionData(
IN HID_INPUT_REPORT_V2 *HidReport,
IN DEVICE_EXTENSION *pDevContext,
Expand Down

0 comments on commit 6052a9d

Please sign in to comment.