### ms-pcq.idl
"""
RPC definitions for the following interfaces:
- PerflibV2 (v1.0): da5a86c5-12c2-4943-ab30-7f74a813d853
This file is auto-generated by midl-to-scapy, do not modify.
"""

import uuid

from scapy.fields import PacketListField, StrFixedLenField
from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRConfStrLenField,
    NDRConfVarPacketListField,
    NDRConfVarStrLenField,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRContextHandle,
    NDRIntField,
    NDRPacketField,
    NDRShortField,
    register_dcerpc_interface,
)


class GUID(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("Data1", 0),
        NDRShortField("Data2", 0),
        NDRShortField("Data3", 0),
        StrFixedLenField("Data4", "", length=8),
    ]


class PerflibV2EnumerateCounterSet_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("szMachine", ""),
        NDRIntField("dwInSize", 0),
    ]


class PerflibV2EnumerateCounterSet_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pdwOutSize", None, size_of="lpData"),
        NDRIntField("pdwRtnSize", 0),
        NDRConfVarPacketListField(
            "lpData",
            [],
            GUID,
            size_is=lambda pkt: pkt.dwInSize,
            length_is=lambda pkt: pkt.pdwOutSize,
        ),
        NDRIntField("status", 0),
    ]


class PerflibV2QueryCounterSetRegistrationInfo_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("szMachine", ""),
        NDRPacketField("CounterSetGuid", GUID(), GUID),
        NDRIntField("RequestCode", 0),
        NDRIntField("RequestLCID", 0),
        NDRIntField("dwInSize", 0),
    ]


class PerflibV2QueryCounterSetRegistrationInfo_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pdwOutSize", None, size_of="lpData"),
        NDRIntField("pdwRtnSize", 0),
        NDRConfVarStrLenField(
            "lpData",
            "",
            size_is=lambda pkt: pkt.dwInSize,
            length_is=lambda pkt: pkt.pdwOutSize,
        ),
        NDRIntField("status", 0),
    ]


class PerflibV2EnumerateCounterSetInstances_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("szMachine", ""),
        NDRPacketField("CounterSetGuid", GUID(), GUID),
        NDRIntField("dwInSize", 0),
    ]


class PerflibV2EnumerateCounterSetInstances_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pdwOutSize", None, size_of="lpData"),
        NDRIntField("pdwRtnSize", 0),
        NDRConfVarStrLenField(
            "lpData",
            "",
            size_is=lambda pkt: pkt.dwInSize,
            length_is=lambda pkt: pkt.pdwOutSize,
        ),
        NDRIntField("status", 0),
    ]


class PerflibV2OpenQueryHandle_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("szMachine", "")]


class PerflibV2OpenQueryHandle_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("phQuery", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class PerflibV2CloseQueryHandle_Request(NDRPacket):
    fields_desc = [NDRPacketField("phQuery", NDRContextHandle(), NDRContextHandle)]


class PerflibV2CloseQueryHandle_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("phQuery", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class PerflibV2QueryCounterInfo_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hQuery", NDRContextHandle(), NDRContextHandle),
        NDRIntField("dwInSize", 0),
    ]


class PerflibV2QueryCounterInfo_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pdwOutSize", None, size_of="lpData"),
        NDRIntField("pdwRtnSize", 0),
        NDRConfVarStrLenField(
            "lpData",
            "",
            size_is=lambda pkt: pkt.dwInSize,
            length_is=lambda pkt: pkt.pdwOutSize,
        ),
        NDRIntField("status", 0),
    ]


class PerflibV2QueryCounterData_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hQuery", NDRContextHandle(), NDRContextHandle),
        NDRIntField("dwInSize", 0),
    ]


class PerflibV2QueryCounterData_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pdwOutSize", None, size_of="lpData"),
        NDRIntField("pdwRtnSize", 0),
        NDRConfVarStrLenField(
            "lpData",
            "",
            size_is=lambda pkt: pkt.dwInSize,
            length_is=lambda pkt: pkt.pdwOutSize,
        ),
        NDRIntField("status", 0),
    ]


class PerflibV2ValidateCounters_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hQuery", NDRContextHandle(), NDRContextHandle),
        NDRIntField("dwInSize", None, size_of="lpData"),
        NDRConfStrLenField("lpData", "", size_is=lambda pkt: pkt.dwInSize),
        NDRIntField("dwAdd", 0),
    ]


class PerflibV2ValidateCounters_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("lpData", "", size_is=lambda pkt: pkt.dwInSize),
        NDRIntField("status", 0),
    ]


PERFLIBV2_OPNUMS = {
    0: DceRpcOp(
        PerflibV2EnumerateCounterSet_Request, PerflibV2EnumerateCounterSet_Response
    ),
    1: DceRpcOp(
        PerflibV2QueryCounterSetRegistrationInfo_Request,
        PerflibV2QueryCounterSetRegistrationInfo_Response,
    ),
    2: DceRpcOp(
        PerflibV2EnumerateCounterSetInstances_Request,
        PerflibV2EnumerateCounterSetInstances_Response,
    ),
    3: DceRpcOp(PerflibV2OpenQueryHandle_Request, PerflibV2OpenQueryHandle_Response),
    4: DceRpcOp(PerflibV2CloseQueryHandle_Request, PerflibV2CloseQueryHandle_Response),
    5: DceRpcOp(PerflibV2QueryCounterInfo_Request, PerflibV2QueryCounterInfo_Response),
    6: DceRpcOp(PerflibV2QueryCounterData_Request, PerflibV2QueryCounterData_Response),
    7: DceRpcOp(PerflibV2ValidateCounters_Request, PerflibV2ValidateCounters_Response),
}
register_dcerpc_interface(
    name="PerflibV2",
    uuid=uuid.UUID("da5a86c5-12c2-4943-ab30-7f74a813d853"),
    version="1.0",
    opnums=PERFLIBV2_OPNUMS,
)
