Skip to content

Commit

Permalink
1. Correct SAL issues in DMF_ThreadedBufferQueue. (#155)
Browse files Browse the repository at this point in the history
2. Correct issue in DMF_VirtualHidMini that causes legacy devices with no report id to fail in User-mode (but not Kernel -mode).
3. Add DMF_UdeClient Module to make it easier to create virtual USB devices.
4. Correct report id issue in VirtualHidAmbientColorSensor.
5. Correct issues in DMF_HingeAngle and DMF_SimpleOrientation Modules.
6. Add new Method to DMF_AcpiTarget.
  • Loading branch information
samtertzakian authored Feb 26, 2021
1 parent 8825488 commit 225c72d
Show file tree
Hide file tree
Showing 15 changed files with 2,933 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Dmf/DmfVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// built using DMF.
//

// DMF Release: v1.1.82
// DMF Release: v1.1.83
//

// eof: DmfVersion.h
Expand Down
1 change: 1 addition & 0 deletions Dmf/Modules.Library/DmfModules.Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ extern "C"
#include "Dmf_Doorbell.h"
#include "Dmf_VirtualEyeGaze.h"
#include "Dmf_EyeGazeIoctl.h"
#include "Dmf_UdeClient.h"

#if defined(DMF_WDF_DRIVER)
#include "Dmf_Wmi.h"
Expand Down
211 changes: 208 additions & 3 deletions Dmf/Modules.Library/Dmf_AcpiTarget.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,18 @@ Return Value:
*ReturnBuffer = outputBuffer;
outputBuffer = NULL;
}
if (ARGUMENT_PRESENT(ReturnBufferSize) != FALSE)
if (ARGUMENT_PRESENT(ReturnBufferSize))
{
*ReturnBufferSize = (ULONG)sizeReturned;
}
}
else
{
*ReturnBuffer = NULL;
if (ARGUMENT_PRESENT(ReturnBufferSize) != FALSE)
if (ARGUMENT_PRESENT(ReturnBuffer))
{
*ReturnBuffer = NULL;
}
if (ARGUMENT_PRESENT(ReturnBufferSize))
{
*ReturnBufferSize = 0;
}
Expand All @@ -432,6 +435,95 @@ Return Value:
return ntStatus;
}

_Must_inspect_result_
__drv_requiresIRQL(PASSIVE_LEVEL)
NTSTATUS
AcpiTarget_EvaluateMethodReturningUlong(
_In_ DMFMODULE DmfModule,
_In_ ULONG MethodNameAsUlong,
_In_ WDF_MEMORY_DESCRIPTOR *InputMemoryDescriptor,
_Out_ ULONG* ReturnValue
)
/*
Routine Description:
This function sends an IRP to ACPI to evaluate a method. The method is
expected to return only a single UONG value.
ACPI must be in the device stack (either as a bus or filter driver).
Arguments:
DmfModule - This Module's Module handle.
MethodNameAsUlong - Supplies a packed string identifying the method.
InputMemoryDescriptor - Memory discriptor for input buffer.
ReturnValue - Returns the ULONG value which is returned from the method.
Return Value:
NTSTATUS
--*/
{
NTSTATUS ntStatus;
ACPI_EVAL_OUTPUT_BUFFER_V1 outputBuffer;
WDF_MEMORY_DESCRIPTOR outputMemoryDescriptor;
WDFDEVICE device;
WDFIOTARGET ioTarget;

PAGED_CODE();

FuncEntry(DMF_TRACE);

RtlZeroMemory(&outputBuffer,
sizeof(outputBuffer));

WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&outputMemoryDescriptor,
&outputBuffer,
(ULONG)sizeof(outputBuffer));

device = DMF_ParentDeviceGet(DmfModule);
ioTarget = WdfDeviceGetIoTarget(device);
ntStatus = WdfIoTargetSendIoctlSynchronously(ioTarget,
NULL,
IOCTL_ACPI_EVAL_METHOD_V1,
InputMemoryDescriptor,
&outputMemoryDescriptor,
NULL,
NULL);
if (!NT_SUCCESS(ntStatus))
{
TraceEvents(TRACE_LEVEL_ERROR, DMF_TRACE, "IOCTL_ACPI_EVAL_METHOD_V1 for method 0x%x fails: ntStatus=%!STATUS!",
MethodNameAsUlong,
ntStatus);
}
else if (outputBuffer.Signature != ACPI_EVAL_OUTPUT_BUFFER_SIGNATURE_V1)
{
ntStatus = STATUS_ACPI_INVALID_DATA;
TraceEvents(TRACE_LEVEL_ERROR, DMF_TRACE, "ACPI_EVAL_OUTPUT_BUFFER signature is incorrect");
}
else if (outputBuffer.Count < 1)
{
ntStatus = STATUS_ACPI_INVALID_DATA;
TraceEvents(TRACE_LEVEL_ERROR, DMF_TRACE, "Method 0x%x didn't return anything", MethodNameAsUlong);
}
else if (outputBuffer.Argument[0].Type != ACPI_METHOD_ARGUMENT_INTEGER)
{
ntStatus = STATUS_ACPI_INVALID_DATA;
TraceEvents(TRACE_LEVEL_ERROR, DMF_TRACE, "Method 0x%x returned an unexpected argument of type %d",
MethodNameAsUlong,
outputBuffer.Argument[0].Type);
}
else
{
*ReturnValue = outputBuffer.Argument[0].Argument;
}

FuncExit(DMF_TRACE, "ntStatus=%!STATUS!", ntStatus);

return ntStatus;
}

__drv_requiresIRQL(PASSIVE_LEVEL)
NTSTATUS
AcpiTarget_IsDsmFunctionSupported(
Expand Down Expand Up @@ -869,6 +961,119 @@ Return Value:
return ntStatus;
}

_Must_inspect_result_
__drv_requiresIRQL(PASSIVE_LEVEL)
NTSTATUS
DMF_AcpiTarget_EvaluateMethodReturningUlong(
_In_ DMFMODULE DmfModule,
_In_ ULONG MethodNameAsUlong,
_Out_ ULONG* ReturnValue
)
/*
Routine Description:
This function sends an IRP to ACPI to evaluate a method. The method is
expected to take no input and return only a single UONG value.
ACPI must be in the device stack (either as a bus or filter driver).
Arguments:
DmfModule - This Module's Module handle.
MethodNameAsUlong - Supplies a packed string identifying the method.
ReturnValue - Returns the ULONG value which is returned from the method.
Return Value:
NTSTATUS
--*/
{
NTSTATUS ntStatus;
ACPI_EVAL_INPUT_BUFFER_V1 inputBuffer;
WDF_MEMORY_DESCRIPTOR inputMemoryDescriptor;

PAGED_CODE();

FuncEntry(DMF_TRACE);

RtlZeroMemory(&inputBuffer,
sizeof(inputBuffer));
inputBuffer.Signature = ACPI_EVAL_INPUT_BUFFER_SIGNATURE_V1;
inputBuffer.MethodNameAsUlong = MethodNameAsUlong;

WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&inputMemoryDescriptor,
&inputBuffer,
(ULONG)sizeof(inputBuffer));

ntStatus = AcpiTarget_EvaluateMethodReturningUlong(DmfModule,
MethodNameAsUlong,
&inputMemoryDescriptor,
ReturnValue);

FuncExit(DMF_TRACE, "ntStatus=%!STATUS!", ntStatus);

return ntStatus;
}

_Must_inspect_result_
__drv_requiresIRQL(PASSIVE_LEVEL)
NTSTATUS
DMF_AcpiTarget_EvaluateMethodWithUlongReturningUlong(
_In_ DMFMODULE DmfModule,
_In_ ULONG MethodNameAsUlong,
_In_ ULONG MethodArgument,
_Out_ ULONG* ReturnValue
)
/*
Routine Description:
This function sends an IRP to ACPI to evaluate a method. The method is
expected to take one ULONG input and return only a single UONG value.
ACPI must be in the device stack (either as a bus or filter driver).
Arguments:
DmfModule - This Module's Module handle.
MethodNameAsUlong - Supplies a packed string identifying the method.
MethodArgument - The single ULONG input value.
ReturnValue - Returns the ULONG value which is returned from the method.
Return Value:
NTSTATUS
--*/
{
NTSTATUS ntStatus;
ACPI_EVAL_INPUT_BUFFER_SIMPLE_INTEGER_V1 inputBuffer;
WDF_MEMORY_DESCRIPTOR inputMemoryDescriptor;

PAGED_CODE();

FuncEntry(DMF_TRACE);

RtlZeroMemory(&inputBuffer,
sizeof(inputBuffer));
inputBuffer.Signature = ACPI_EVAL_INPUT_BUFFER_SIMPLE_INTEGER_SIGNATURE_V1;
inputBuffer.MethodNameAsUlong = MethodNameAsUlong;
inputBuffer.IntegerArgument = MethodArgument;

WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&inputMemoryDescriptor,
&inputBuffer,
(ULONG)sizeof(inputBuffer));

ntStatus = AcpiTarget_EvaluateMethodReturningUlong(DmfModule,
MethodNameAsUlong,
&inputMemoryDescriptor,
ReturnValue);

FuncExit(DMF_TRACE, "ntStatus=%!STATUS!", ntStatus);

return ntStatus;
}

_IRQL_requires_max_(PASSIVE_LEVEL)
NTSTATUS
DMF_AcpiTarget_InvokeDsm(
Expand Down
19 changes: 19 additions & 0 deletions Dmf/Modules.Library/Dmf_AcpiTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,25 @@ DMF_AcpiTarget_EvaluateMethod(
_In_ ULONG Tag
);

_Must_inspect_result_
__drv_requiresIRQL(PASSIVE_LEVEL)
NTSTATUS
DMF_AcpiTarget_EvaluateMethodReturningUlong(
_In_ DMFMODULE DmfModule,
_In_ ULONG MethodNameAsUlong,
_Out_ ULONG* ReturnValue
);

_Must_inspect_result_
__drv_requiresIRQL(PASSIVE_LEVEL)
NTSTATUS
DMF_AcpiTarget_EvaluateMethodWithUlongReturningUlong(
_In_ DMFMODULE DmfModule,
_In_ ULONG MethodNameAsUlong,
_In_ ULONG MethodArgument,
_Out_ ULONG* ReturnValue
);

_IRQL_requires_max_(PASSIVE_LEVEL)
NTSTATUS
DMF_AcpiTarget_InvokeDsm(
Expand Down
6 changes: 6 additions & 0 deletions Dmf/Modules.Library/Dmf_HingeAngle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,12 @@ Return Value:
goto Exit;
}

moduleContext->hingeAngleDevice->thisModuleHandle = DmfModule;
if (moduleConfig->DeviceId == NULL)
{
moduleConfig->DeviceId = L"";
}

moduleContext->hingeAngleDevice->thisModuleHandle = DmfModule;
moduleContext->hingeAngleDevice->DeviceIdToFind = to_hstring(moduleConfig->DeviceId);
moduleContext->hingeAngleDevice->EvtHingeAngleReadingChangeCallback = moduleConfig->EvtHingeAngleReadingChangeCallback;
Expand Down
Loading

0 comments on commit 225c72d

Please sign in to comment.