Exemple #1
0
NTSTATUS
EvtWmiQueryPortName(
    IN  WDFWMIINSTANCE WmiInstance,
    IN  ULONG OutBufferSize,
    IN  PVOID OutBuffer,
    OUT PULONG BufferUsed
    )
{
    WDFDEVICE device;
    WCHAR pRegName[SYMBOLIC_NAME_LENGTH];
    UNICODE_STRING string;
    USHORT nameSize = sizeof(pRegName);
    NTSTATUS status;

    PAGED_CODE();

    device = WdfWmiInstanceGetDevice(WmiInstance);

    status = SerialReadSymName(device, pRegName, &nameSize);
    if (!NT_SUCCESS(status)) {
        return status;
    }

    RtlInitUnicodeString(&string, pRegName);

    return WDF_WMI_BUFFER_APPEND_STRING(OutBuffer,
                                        OutBufferSize,
                                        &string,
                                        BufferUsed);
}
Exemple #2
0
NTSTATUS
EvtWmiQueryPortPerfData(
    IN  WDFWMIINSTANCE WmiInstance,
    IN  ULONG OutBufferSize,
    IN  PVOID OutBuffer,
    OUT PULONG BufferUsed
    )
{
    PSERIAL_DEVICE_EXTENSION pDevExt;

    UNREFERENCED_PARAMETER(OutBufferSize);

    PAGED_CODE();

    pDevExt = SerialGetDeviceExtension (WdfWmiInstanceGetDevice(WmiInstance));

    *BufferUsed = sizeof(SERIAL_WMI_PERF_DATA);

    if (OutBufferSize < *BufferUsed) {
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    *(PSERIAL_WMI_PERF_DATA)OutBuffer = pDevExt->WmiPerfData;

    return STATUS_SUCCESS;
}
Exemple #3
0
NTSTATUS
EvtWmiClass5DataSetInstance(
    WDFWMIINSTANCE WmiInstance,
    ULONG InBufferSize,
    PVOID InBuffer
    )
{
    WDFDEVICE device;
    PWMI_SAMPLE_DEVICE_DATA wmiDeviceData;

    PAGED_CODE();

    //
    // InBufferSize is guaranteed to be at least WmiSampleClass5_SIZE
    // which in this case is EC2_SIZE.
    //
    UNREFERENCED_PARAMETER(InBufferSize);

    device = WdfWmiInstanceGetDevice(WmiInstance);
    wmiDeviceData = GetWmiSampleDeviceData(device);

    //
    // Plain (Embedded) EC2.
    //
    WmiSampSetEc2(wmiDeviceData,
                  InBuffer,
                  EC2_SIZE,
                  0);

    return STATUS_SUCCESS;
}
Exemple #4
0
Fichier : wmi.c Projet : ms-iot/bsp
_Use_decl_annotations_
NTSTATUS
EvtWmiQueryPortPerfData(
    WDFWMIINSTANCE WmiInstance,
    ULONG OutBufferSize,
    PVOID OutBuffer,
    PULONG BufferUsed
    )
{
    PSERIAL_DEVICE_EXTENSION devExt;
    UNREFERENCED_PARAMETER(OutBufferSize);
    NTSTATUS status;

    PAGED_CODE();

    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_WMI, "++EvtWmiQueryPortPerfData()\r\n");

    devExt = SerialGetDeviceExtension(WdfWmiInstanceGetDevice(WmiInstance));

    *BufferUsed = sizeof(SERIAL_WMI_PERF_DATA);

    if (OutBufferSize < *BufferUsed) {

        status = STATUS_INSUFFICIENT_RESOURCES;

    } else {

        *(PSERIAL_WMI_PERF_DATA)OutBuffer = devExt->WmiPerfData;
        status = STATUS_SUCCESS;
    }

    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_WMI, "--EvtWmiQueryPortPerfData()=%Xh\r\n", status);
    return status;
}
Exemple #5
0
NTSTATUS
EvtWmiQueryPortPropData(
    IN  WDFWMIINSTANCE WmiInstance,
    IN  ULONG OutBufferSize,
    IN  PVOID OutBuffer,
    OUT PULONG BufferUsed
    )
{
    PSERIAL_DEVICE_EXTENSION pDevExt;

    UNREFERENCED_PARAMETER(OutBufferSize);

    PAGED_CODE();

    pDevExt = SerialGetDeviceExtension (WdfWmiInstanceGetDevice(WmiInstance));

    *BufferUsed = sizeof(SERIAL_COMMPROP) + sizeof(ULONG);

    if (OutBufferSize < *BufferUsed) {
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    SerialGetProperties(
            pDevExt,
            (PSERIAL_COMMPROP)OutBuffer
            );

    *((PULONG)(((PSERIAL_COMMPROP)OutBuffer)->ProvChar)) = 0;

    return STATUS_SUCCESS;
}
Exemple #6
0
//
// WMI System Call back functions
//
NTSTATUS
NdasPortEvtStdDataSetItem(
    IN  WDFWMIINSTANCE WmiInstance,
    IN  ULONG DataItemId,
    IN  ULONG InBufferSize,
    IN  PVOID InBuffer
    )
/*++

Routine Description:

    This routine is a callback into the driver to set for the contents of
    an instance.

Arguments:

    WmiInstance is the instance being set

    DataItemId has the id of the data item being set

    InBufferSize has the size of the data item passed

    InBuffer has the new values for the data item

Return Value:

    status

--*/
{
    PNDASPORT_FDO_EXTENSION    fdoData;

    PAGED_CODE();

    fdoData = NdasPortFdoGetExtension(WdfWmiInstanceGetDevice(WmiInstance));

    //
    // TODO: Use generated header's #defines for constants and sizes
    // (for the remainder of the file)
    //

    if (DataItemId == 2) 
	{
        if (InBufferSize < sizeof(ULONG)) 
		{
            return STATUS_BUFFER_TOO_SMALL;
        }

        //BusEnumDebugLevel = fdoData->StdToasterBusData.DebugPrintLevel =
        //    *((PULONG)InBuffer);

        return STATUS_SUCCESS;
    }

    //
    // All other fields are read only
    //
    return STATUS_WMI_READ_ONLY;
}
Exemple #7
0
NTSTATUS
EvtWmiClass3DataSetInstance(
    WDFWMIINSTANCE WmiInstance,
    ULONG InBufferSize,
    PVOID InBuffer
    )

/*++

Routine Description:

    ---

Arguments:

    WmiInstance -
    InBufferSize -
    InBuffer -

Return Value:

    NT Status code.

--*/

{
    NTSTATUS status = STATUS_SUCCESS;
    WDFDEVICE device;
    PWMI_SAMPLE_DEVICE_DATA wmiDeviceData;
    ULONG i;
    PEC1 Ec1;

    PAGED_CODE();

    device = WdfWmiInstanceGetDevice(WmiInstance);
    wmiDeviceData = GetWmiSampleDeviceData(device);

    //
    // Fixed array of EC1.
    //
    Ec1 = (PEC1)InBuffer;
    for (i = 0; i < EC1_COUNT; i++) {

        if (InBufferSize >= EC1_SIZE) {

            WmiSampSetEc1(wmiDeviceData, Ec1, EC1_SIZE, i);
            InBufferSize -= EC1_SIZE;
            Ec1++;

        } else {

            status = STATUS_INVALID_PARAMETER_MIX;
            DebugPrint(("[WmiSamp] Status = 0x%08x, EvtWmiClass3DataSetInstance\n", status));
        }
    }
    return status;
}
Exemple #8
0
NTSTATUS
EvtWmiClass5DataQueryInstance(
    WDFWMIINSTANCE WmiInstance,
    ULONG OutBufferSize,
    PVOID OutBuffer,
    PULONG BufferUsed
    )

/*++

Routine Description:

    This is the callback routine for the WMI Query irp on the Instance representing
    the sample class 5. This routine gets the current value for the data members
    of the sample class and copies it to the given output buffer. The sample class5
    contains an embedded class.

Arguments:

    WmiInstance - The handle to the WMI instance object.

    OutBufferSize - The size (in bytes) of the output buffer into which the
        instance data is to be copied.

    OutBuffer - Pointer to the output buffer.

    BufferUsed - Pointer to the location that receives the number of bytes that
        were copied into the output buffer.

Return Value:

    NT Status code.

--*/

{
    WDFDEVICE device;
    PWMI_SAMPLE_DEVICE_DATA wmiDeviceData;

    UNREFERENCED_PARAMETER(OutBufferSize);
    PAGED_CODE();

    device = WdfWmiInstanceGetDevice(WmiInstance);
    wmiDeviceData = GetWmiSampleDeviceData(device);

    //
    // Plain (Embedded) EC2.
    //
    *BufferUsed = WmiSampGetEc2(wmiDeviceData,
                                OutBuffer,
                                0);

    return STATUS_SUCCESS;
}
Exemple #9
0
NTSTATUS
EvtWmiClass1ExecuteMethod(
    WDFWMIINSTANCE WmiInstance,
    ULONG MethodId,
    ULONG InBufferSize,
    ULONG OutBufferSize,
    PVOID Buffer,
    PULONG BufferUsed
    )
{
    NTSTATUS status;
    WDFDEVICE device;
    PWMI_SAMPLE_DEVICE_DATA wmiDeviceData;

    UNREFERENCED_PARAMETER(OutBufferSize);
    PAGED_CODE();

    device = WdfWmiInstanceGetDevice(WmiInstance);
    wmiDeviceData = GetWmiSampleDeviceData(device);

    switch (MethodId) {
    case SetEC1:
        {
            if (InBufferSize >= EC1_SIZE) {

                WmiSampSetEc1(wmiDeviceData,
                              Buffer,
                              EC1_SIZE,
                              0);
                status = STATUS_SUCCESS;

            } else {

                status = STATUS_INVALID_PARAMETER_MIX;
                DebugPrint(("[WmiSamp] Status = 0x%08x, EvtWmiClass1ExecuteMethod\n", status));
            }
        }
        break;

    case DummyMethod:
        status = STATUS_SUCCESS;
        break;

    default:
        status = STATUS_WMI_ITEMID_NOT_FOUND;
        DebugPrint(("[WmiSamp] Status = 0x%08x, EvtWmiClass1ExecuteMethod\n", status));
        break;
    }

    *BufferUsed = 0;
    return status;
}
Exemple #10
0
Fichier : wmi.c Projet : ms-iot/bsp
/*++

Routine Description:

    WMI Call back functions

Arguments:

    WmiInstance
    OutBufferSize
    OutBuffer
    BufferUsed

Return Value:
    Status

--*/
_Use_decl_annotations_
NTSTATUS
EvtWmiQueryPortName(
    WDFWMIINSTANCE WmiInstance,
    ULONG OutBufferSize,
    PVOID OutBuffer,
    PULONG BufferUsed
    )
{
    WDFDEVICE device;
    WCHAR regName[SYMBOLIC_NAME_LENGTH];
    UNICODE_STRING string;
    USHORT nameSize = sizeof(regName);
    NTSTATUS status;

    PAGED_CODE();

    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_WMI, "++EvtWmiQueryPortName()\r\n");

    device = WdfWmiInstanceGetDevice(WmiInstance);

    status = SerialReadSymName(device, regName, &nameSize);

    if (!NT_SUCCESS(status)) {
        TraceEvents(TRACE_LEVEL_ERROR, DBG_WMI,
                    "EvtWmiQueryPortName() SerialReadSymName failed. Err=%Xh\r\n",
                    status);
        goto EndWmiPortname;
    }

    RtlInitUnicodeString(&string, regName);

    status = WDF_WMI_BUFFER_APPEND_STRING(OutBuffer,
                                        OutBufferSize,
                                        &string,
                                        BufferUsed);
    if (!NT_SUCCESS(status)) {
        TraceEvents(TRACE_LEVEL_ERROR, DBG_WMI,
                    "EvtWmiQueryPortName() WMI_BUFFER_APPEND_STRING failed. Err=%Xh\r\n",
                    status);
    }

EndWmiPortname:

    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_WMI, "--EvtWmiQueryPortName()=%Xh\r\n", status);
    return status;
}
Exemple #11
0
NTSTATUS
Bus_EvtStdDataQueryInstance(
    IN  WDFWMIINSTANCE WmiInstance,
    IN  ULONG OutBufferSize,
    IN  PVOID OutBuffer,
    OUT PULONG BufferUsed
    )
/*++

Routine Description:

    This routine is a callback into the driver to set for the contents of
    a wmi instance

Arguments:

    WmiInstance is the instance being set

    OutBufferSize on has the maximum size available to write the data
        block.

    OutBuffer on return is filled with the returned data block

    BufferUsed pointer containing how many bytes are required (upon failure) or
        how many bytes were used (upon success)

Return Value:

    status

--*/
{
    PFDO_DEVICE_DATA fdoData;

    UNREFERENCED_PARAMETER(OutBufferSize);

    PAGED_CODE();

    fdoData = FdoGetData(WdfWmiInstanceGetDevice(WmiInstance));

    *BufferUsed = sizeof (TOASTER_BUS_WMI_STD_DATA);
    * (PTOASTER_BUS_WMI_STD_DATA) OutBuffer = fdoData->StdToasterBusData;

    return STATUS_SUCCESS;
}
Exemple #12
0
NTSTATUS
Bus_EvtStdDataSetInstance(
    IN  WDFWMIINSTANCE WmiInstance,
    IN  ULONG InBufferSize,
    IN  PVOID InBuffer
    )
/*++

Routine Description:

    This routine is a callback into the driver to set for the contents of
    an instance.

Arguments:

    WmiInstance is the instance being set

    BufferSize has the size of the data block passed

    Buffer has the new values for the data block

Return Value:

    status

--*/
{
    PFDO_DEVICE_DATA   fdoData;

    UNREFERENCED_PARAMETER(InBufferSize);

    PAGED_CODE();

    fdoData = FdoGetData(WdfWmiInstanceGetDevice(WmiInstance));

    //
    // We will update only writable elements.
    //
    BusEnumDebugLevel = fdoData->StdToasterBusData.DebugPrintLevel =
        ((PTOASTER_BUS_WMI_STD_DATA)InBuffer)->DebugPrintLevel;

    return STATUS_SUCCESS;
}
Exemple #13
0
NTSTATUS
NdasPortEvtStdDataSetInstance(
    IN  WDFWMIINSTANCE WmiInstance,
    IN  ULONG InBufferSize,
    IN  PVOID InBuffer
    )
/*++

Routine Description:

    This routine is a callback into the driver to set for the contents of
    an instance.

Arguments:

    WmiInstance is the instance being set

    BufferSize has the size of the data block passed

    Buffer has the new values for the data block

Return Value:

    status

--*/
{
    PNDASPORT_FDO_EXTENSION   fdoData;

    UNREFERENCED_PARAMETER(InBufferSize);

    PAGED_CODE();

    fdoData = NdasPortFdoGetExtension(WdfWmiInstanceGetDevice(WmiInstance));

    //
    // We will update only writable elements.
    //
    fdoData->FdoWmiStdData.DebugPrintLevel =
        ((PNDASPORT_WMI_STD_DATA)InBuffer)->DebugPrintLevel;

    return STATUS_SUCCESS;
}
Exemple #14
0
NTSTATUS
EvtWmiInstanceSetItem(
    IN  WDFWMIINSTANCE WmiInstance,
    IN  ULONG DataItemId,
    IN  ULONG InBufferSize,
    IN  PVOID InBuffer
    )
{
    NTSTATUS status;
    FireflyDeviceInformation* pInfo;

    PAGED_CODE();

    pInfo = InstanceGetInfo(WmiInstance);

    if (DataItemId == 1) {
        if (InBufferSize < FireflyDeviceInformation_TailLit_SIZE) {
            return STATUS_BUFFER_TOO_SMALL;
        }

        pInfo->TailLit = (*(PBOOLEAN) InBuffer) ? TRUE : FALSE;

        //
        // Tell the HID device about the new tail light state
        //
        status = FireflySetFeature(
            WdfObjectGet_DEVICE_CONTEXT(WdfWmiInstanceGetDevice(WmiInstance)),
            TAILLIGHT_PAGE,
            TAILLIGHT_FEATURE,
            pInfo->TailLit
            );

        return status;
    }
    else {
        return STATUS_INVALID_DEVICE_REQUEST;
    }
}
Exemple #15
0
NTSTATUS
EvtWmiInstanceSetInstance(
    IN  WDFWMIINSTANCE WmiInstance,
    IN  ULONG InBufferSize,
    IN  PVOID InBuffer
    )
{
    FireflyDeviceInformation* pInfo;
    ULONG length;
    NTSTATUS status;

    PAGED_CODE();

    UNREFERENCED_PARAMETER(InBufferSize);

    pInfo = InstanceGetInfo(WmiInstance);

    //
    // Our mininum buffer size has been checked by the Framework
    // and failed automatically if too small.
    //
    length = sizeof(*pInfo);

    RtlMoveMemory(pInfo, InBuffer, length);

    //
    // Tell the HID device about the new tail light state
    //
    status = FireflySetFeature(
        WdfObjectGet_DEVICE_CONTEXT(WdfWmiInstanceGetDevice(WmiInstance)),
        TAILLIGHT_PAGE,
        TAILLIGHT_FEATURE,
        pInfo->TailLit
        );

    return status;
}
Exemple #16
0
Fichier : wmi.c Projet : ms-iot/bsp
_Use_decl_annotations_
NTSTATUS
EvtWmiQueryPortPropData(
    WDFWMIINSTANCE WmiInstance,
    ULONG OutBufferSize,
    PVOID OutBuffer,
    PULONG BufferUsed
    )
{
    PSERIAL_DEVICE_EXTENSION devExt;
    NTSTATUS status;
    UNREFERENCED_PARAMETER(OutBufferSize);

    PAGED_CODE();

    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_WMI, "++EvtWmiQueryPortPerfData()\r\n");

    devExt = SerialGetDeviceExtension(WdfWmiInstanceGetDevice(WmiInstance));

    *BufferUsed = sizeof(SERIAL_COMMPROP) + sizeof(ULONG);

    if (OutBufferSize < *BufferUsed) {

        status = STATUS_INSUFFICIENT_RESOURCES;

    } else {

        SerialGetProperties(devExt,
                            (PSERIAL_COMMPROP)OutBuffer);

        *((PULONG)(((PSERIAL_COMMPROP)OutBuffer)->ProvChar)) = 0;
        status = STATUS_SUCCESS;
    }

    TraceEvents(TRACE_LEVEL_INFORMATION, DBG_WMI, "--EvtWmiQueryPortPerfData()=%Xh\r\n", status);
    return status;
}
Exemple #17
0
NTSTATUS
EvtWmiClass6DataQueryInstance(
    WDFWMIINSTANCE WmiInstance,
    ULONG OutBufferSize,
    PVOID OutBuffer,
    PULONG BufferUsed
    )

/*++

Routine Description:

    This is the callback routine for the WMI Query irp on the Instance representing
    the sample class 6. This routine gets the current value for the data members
    of the sample class and copies it to the given output buffer. The sample class6
    contains a fixed array of embedded class EC2.

Arguments:

    WmiInstance - The handle to the WMI instance object.

    OutBufferSize - The size (in bytes) of the output buffer into which the
        instance data is to be copied.

    OutBuffer - Pointer to the output buffer.

    BufferUsed - Pointer to the location that receives the number of bytes that
        were copied into the output buffer.

Return Value:

    NT Status code.

--*/

{
    NTSTATUS status;
    WDFDEVICE device;
    PWMI_SAMPLE_DEVICE_DATA wmiDeviceData;
    ULONG sizeNeeded;
    ULONG sizeUsed;
    ULONG i;

    UNREFERENCED_PARAMETER(OutBufferSize);
    PAGED_CODE();

    device = WdfWmiInstanceGetDevice(WmiInstance);
    wmiDeviceData = GetWmiSampleDeviceData(device);

    //
    // Fixed array of EC2.
    //
    sizeNeeded = 0;
    for (i = 0; i < EC2_COUNT; i++) {
        sizeNeeded += ALIGN_UP(wmiDeviceData->Ec2Length[i], PVOID);
    }

    if (OutBufferSize < sizeNeeded) {

        *BufferUsed = 0;
        status = STATUS_BUFFER_TOO_SMALL;

    } else {

        *BufferUsed = 0;
        for (i = 0; i < EC2_COUNT; i++) {

            sizeUsed = WmiSampGetEc2(wmiDeviceData, OutBuffer, i);
            OutBuffer = Add2Ptr(OutBuffer, ALIGN_UP(sizeUsed, PVOID));
            *BufferUsed += sizeUsed;
        }
        status = STATUS_SUCCESS;
    }

    return status;
}
Exemple #18
0
NTSTATUS
EvtWmiClass6DataSetInstance(
    WDFWMIINSTANCE WmiInstance,
    ULONG InBufferSize,
    PVOID InBuffer
    )

/*++

Routine Description:

    This is the callback routine for setting the WMI data provider's instance
    data supplied by a WMI client. This routine copies the data in the input
    buffer and updates the sample class6 data which contains a fixed array of
    embedded class EC2.

Arguments:

    WmiInstance - The handle to the WMI instance object.

    InBufferSize - The size (in bytes) of the input buffer from which the
        instance data is to be copied.

    InBuffer - Pointer to the input buffer.

Return Value:

    NT Status code.

--*/

{
    NTSTATUS status = STATUS_SUCCESS;
    WDFDEVICE device;
    PWMI_SAMPLE_DEVICE_DATA wmiDeviceData;
    ULONG i;
    PEC2 Ec2;

    PAGED_CODE();

    device = WdfWmiInstanceGetDevice(WmiInstance);
    wmiDeviceData = GetWmiSampleDeviceData(device);

    //
    // Fixed array of EC2.
    //
    Ec2 = (PEC2)InBuffer;
    for (i = 0; i < EC2_COUNT; i++) {

        if (InBufferSize >= EC2_SIZE) {

            WmiSampSetEc2(wmiDeviceData, Ec2, EC2_SIZE, i);
            InBufferSize -= EC2_SIZE;
            Ec2++;

        } else {

            status = STATUS_INVALID_PARAMETER_MIX;
            DebugPrint(("[WmiSamp] Status = 0x%08x, EvtWmiClass6DataSetInstance\n", status));
        }
    }
    return status;
}
Exemple #19
0
    OutBuffer on return is filled with the returned data block

    BufferUsed pointer containing how many bytes are required (upon failure) or
        how many bytes were used (upon success)

Return Value:

    status

--*/
{
    PFDO_DEVICE_DATA fdoData;

    UNREFERENCED_PARAMETER(OutBufferSize);

    PAGED_CODE();

    fdoData = FdoGetData(WdfWmiInstanceGetDevice(WmiInstance));

    *BufferUsed = sizeof (fdoData->StdToasterBusData);
    if (OutBufferSize < sizeof(fdoData->StdToasterBusData)) {
        return STATUS_BUFFER_TOO_SMALL;
    }

    * (PTOASTER_BUS_WMI_STD_DATA) OutBuffer = fdoData->StdToasterBusData;

    return STATUS_SUCCESS;
}