### ms-scmp.idl
"""
RPC definitions for the following interfaces:
- IVssSnapshotMgmt (v0.0): FA7DF749-66E7-4986-A27F-E2F04AE53772
- IVssDifferentialSoftwareSnapshotMgmt (v0.0): 214A0F28-B737-4026-B847-4F9E37D79529
- IVssEnumObject (v0.0): AE1C7110-2F60-11d3-8A39-00C04F72D8E3
- IVssEnumMgmtObject (v0.0): 01954E6B-9254-4e6e-808C-C9E05D007696
This file is auto-generated by midl-to-scapy, do not modify.
"""

from enum import IntEnum
import uuid

from scapy.fields import PacketListField, StrFixedLenField
from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRConfStrLenField,
    NDRConfVarPacketListField,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRFullPointerField,
    NDRIntEnumField,
    NDRIntField,
    NDRPacketField,
    NDRShortField,
    NDRSignedIntField,
    NDRSignedLongField,
    NDRUnionField,
    register_com_interface,
)


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


class MInterfacePointer(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["abData"]
    fields_desc = [
        NDRIntField("ulCntData", None, size_of="abData"),
        NDRConfStrLenField(
            "abData", "", size_is=lambda pkt: pkt.ulCntData, conformant_in_struct=True
        ),
    ]


class GetProviderMgmtInterface_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ProviderId", GUID(), GUID),
        NDRPacketField("InterfaceId", GUID(), GUID),
    ]


class GetProviderMgmtInterface_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("ppItf", MInterfacePointer(), MInterfacePointer)
        ),
        NDRIntField("status", 0),
    ]


class QueryVolumesSupportedForSnapshots_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ProviderId", GUID(), GUID),
        NDRSignedIntField("lContext", 0),
    ]


class QueryVolumesSupportedForSnapshots_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("ppEnum", MInterfacePointer(), MInterfacePointer)
        ),
        NDRIntField("status", 0),
    ]


class QuerySnapshotsByVolume_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("pwszVolumeName", ""),
        NDRPacketField("ProviderId", GUID(), GUID),
    ]


class QuerySnapshotsByVolume_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("ppEnum", MInterfacePointer(), MInterfacePointer)
        ),
        NDRIntField("status", 0),
    ]


IVSSSNAPSHOTMGMT_OPNUMS = {
    0: DceRpcOp(GetProviderMgmtInterface_Request, GetProviderMgmtInterface_Response),
    1: DceRpcOp(
        QueryVolumesSupportedForSnapshots_Request,
        QueryVolumesSupportedForSnapshots_Response,
    ),
    2: DceRpcOp(QuerySnapshotsByVolume_Request, QuerySnapshotsByVolume_Response),
}
register_com_interface(
    name="IVssSnapshotMgmt",
    uuid=uuid.UUID("FA7DF749-66E7-4986-A27F-E2F04AE53772"),
    opnums=IVSSSNAPSHOTMGMT_OPNUMS,
)


class AddDiffArea_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("pwszVolumeName", ""),
        NDRConfVarStrNullFieldUtf16("pwszDiffAreaVolumeName", ""),
        NDRSignedLongField("llMaximumDiffSpace", 0),
    ]


class AddDiffArea_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class ChangeDiffAreaMaximumSize_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("pwszVolumeName", ""),
        NDRConfVarStrNullFieldUtf16("pwszDiffAreaVolumeName", ""),
        NDRSignedLongField("llMaximumDiffSpace", 0),
    ]


class ChangeDiffAreaMaximumSize_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class QueryVolumesSupportedForDiffAreas_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("pwszOriginalVolumeName", "")]


class QueryVolumesSupportedForDiffAreas_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("ppEnum", MInterfacePointer(), MInterfacePointer)
        ),
        NDRIntField("status", 0),
    ]


class QueryDiffAreasForVolume_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("pwszVolumeName", "")]


class QueryDiffAreasForVolume_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("ppEnum", MInterfacePointer(), MInterfacePointer)
        ),
        NDRIntField("status", 0),
    ]


class QueryDiffAreasOnVolume_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("pwszVolumeName", "")]


class QueryDiffAreasOnVolume_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("ppEnum", MInterfacePointer(), MInterfacePointer)
        ),
        NDRIntField("status", 0),
    ]


IVSSDIFFERENTIALSOFTWARESNAPSHOTMGMT_OPNUMS = {
    0: DceRpcOp(AddDiffArea_Request, AddDiffArea_Response),
    1: DceRpcOp(ChangeDiffAreaMaximumSize_Request, ChangeDiffAreaMaximumSize_Response),
    2: DceRpcOp(
        QueryVolumesSupportedForDiffAreas_Request,
        QueryVolumesSupportedForDiffAreas_Response,
    ),
    3: DceRpcOp(QueryDiffAreasForVolume_Request, QueryDiffAreasForVolume_Response),
    4: DceRpcOp(QueryDiffAreasOnVolume_Request, QueryDiffAreasOnVolume_Response),
    # 5: Opnum08NotUsedOnWire
}
register_com_interface(
    name="IVssDifferentialSoftwareSnapshotMgmt",
    uuid=uuid.UUID("214A0F28-B737-4026-B847-4F9E37D79529"),
    opnums=IVSSDIFFERENTIALSOFTWARESNAPSHOTMGMT_OPNUMS,
)


class VSS_OBJECT_TYPE(IntEnum):
    VSS_OBJECT_UNKNOWN = 0
    VSS_OBJECT_NONE = 1
    VSS_OBJECT_SNAPSHOT_SET = 2
    VSS_OBJECT_SNAPSHOT = 3
    VSS_OBJECT_PROVIDER = 4
    VSS_OBJECT_TYPE_COUNT = 5


class VSS_SNAPSHOT_STATE(IntEnum):
    VSS_SS_UNKNOWN = 0
    VSS_SS_CREATED = 12


class VSS_SNAPSHOT_PROP(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRPacketField("m_SnapshotId", GUID(), GUID),
        NDRPacketField("m_SnapshotSetId", GUID(), GUID),
        NDRSignedIntField("m_lSnapshotsCount", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("m_pwszSnapshotDeviceObject", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("m_pwszOriginalVolumeName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("m_pwszOriginatingMachine", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("m_pwszServiceMachine", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("m_pwszExposedName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("m_pwszExposedPath", ""), deferred=True
        ),
        NDRPacketField("m_ProviderId", GUID(), GUID),
        NDRSignedIntField("m_lSnapshotAttributes", 0),
        NDRSignedLongField("m_tsCreationTimestamp", 0),
        NDRIntEnumField("m_eStatus", 0, VSS_SNAPSHOT_STATE),
    ]


class VSS_PROVIDER_TYPE(IntEnum):
    VSS_PROV_UNKNOWN = 0


class VSS_PROVIDER_PROP(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField("m_ProviderId", GUID(), GUID),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("m_pwszProviderName", ""), deferred=True
        ),
        NDRIntEnumField("m_eProviderType", 0, VSS_PROVIDER_TYPE),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("m_pwszProviderVersion", ""), deferred=True
        ),
        NDRPacketField("m_ProviderVersionId", GUID(), GUID),
        NDRPacketField("m_ClassId", GUID(), GUID),
    ]


class VSS_OBJECT_PROP(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRIntEnumField("Type", 0, VSS_OBJECT_TYPE),
        NDRUnionField(
            [
                (
                    NDRPacketField("Obj", VSS_SNAPSHOT_PROP(), VSS_SNAPSHOT_PROP),
                    (
                        (
                            lambda pkt: getattr(pkt, "Type", None)
                            == VSS_OBJECT_TYPE.VSS_OBJECT_SNAPSHOT
                        ),
                        (lambda _, val: val.tag == VSS_OBJECT_TYPE.VSS_OBJECT_SNAPSHOT),
                    ),
                ),
                (
                    NDRPacketField("Obj", VSS_PROVIDER_PROP(), VSS_PROVIDER_PROP),
                    (
                        (
                            lambda pkt: getattr(pkt, "Type", None)
                            == VSS_OBJECT_TYPE.VSS_OBJECT_PROVIDER
                        ),
                        (lambda _, val: val.tag == VSS_OBJECT_TYPE.VSS_OBJECT_PROVIDER),
                    ),
                ),
            ],
            StrFixedLenField("Obj", "", length=0),
            align=(4, 8),
            switch_fmt=("I", "I"),
        ),
    ]


class Next_Request(NDRPacket):
    fields_desc = [NDRIntField("celt", 0)]


class Next_Response(NDRPacket):
    fields_desc = [
        NDRConfVarPacketListField(
            "rgelt",
            [],
            VSS_OBJECT_PROP,
            size_is=lambda pkt: pkt.celt,
            length_is=lambda pkt: pkt.pceltFetched,
        ),
        NDRIntField("pceltFetched", None, size_of="rgelt"),
        NDRIntField("status", 0),
    ]


class Skip_Request(NDRPacket):
    fields_desc = [NDRIntField("celt", 0)]


class Skip_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class Reset_Request(NDRPacket):
    fields_desc = []


class Reset_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class Clone_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("ppenum", MInterfacePointer(), MInterfacePointer)
        )
    ]


class Clone_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("ppenum", MInterfacePointer(), MInterfacePointer)
        ),
        NDRIntField("status", 0),
    ]


IVSSENUMOBJECT_OPNUMS = {
    0: DceRpcOp(Next_Request, Next_Response),
    1: DceRpcOp(Skip_Request, Skip_Response),
    2: DceRpcOp(Reset_Request, Reset_Response),
    3: DceRpcOp(Clone_Request, Clone_Response),
}
register_com_interface(
    name="IVssEnumObject",
    uuid=uuid.UUID("AE1C7110-2F60-11d3-8A39-00C04F72D8E3"),
    opnums=IVSSENUMOBJECT_OPNUMS,
)


class VSS_MGMT_OBJECT_TYPE(IntEnum):
    VSS_MGMT_OBJECT_UNKNOWN = 0
    VSS_MGMT_OBJECT_VOLUME = 1
    VSS_MGMT_OBJECT_DIFF_VOLUME = 2
    VSS_MGMT_OBJECT_DIFF_AREA = 3


class VSS_VOLUME_PROP(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("m_pwszVolumeName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("m_pwszVolumeDisplayName", ""), deferred=True
        ),
    ]


class VSS_DIFF_VOLUME_PROP(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("m_pwszVolumeName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("m_pwszVolumeDisplayName", ""), deferred=True
        ),
        NDRSignedLongField("m_llVolumeFreeSpace", 0),
        NDRSignedLongField("m_llVolumeTotalSpace", 0),
    ]


class VSS_DIFF_AREA_PROP(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("m_pwszVolumeName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("m_pwszDiffAreaVolumeName", ""), deferred=True
        ),
        NDRSignedLongField("m_llMaximumDiffSpace", 0),
        NDRSignedLongField("m_llAllocatedDiffSpace", 0),
        NDRSignedLongField("m_llUsedDiffSpace", 0),
    ]


class VSS_MGMT_OBJECT_PROP(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRIntEnumField("Type", 0, VSS_MGMT_OBJECT_TYPE),
        NDRUnionField(
            [
                (
                    NDRPacketField("Obj", VSS_VOLUME_PROP(), VSS_VOLUME_PROP),
                    (
                        (
                            lambda pkt: getattr(pkt, "Type", None)
                            == VSS_MGMT_OBJECT_TYPE.VSS_MGMT_OBJECT_VOLUME
                        ),
                        (
                            lambda _, val: val.tag
                            == VSS_MGMT_OBJECT_TYPE.VSS_MGMT_OBJECT_VOLUME
                        ),
                    ),
                ),
                (
                    NDRPacketField("Obj", VSS_DIFF_VOLUME_PROP(), VSS_DIFF_VOLUME_PROP),
                    (
                        (
                            lambda pkt: getattr(pkt, "Type", None)
                            == VSS_MGMT_OBJECT_TYPE.VSS_MGMT_OBJECT_DIFF_VOLUME
                        ),
                        (
                            lambda _, val: val.tag
                            == VSS_MGMT_OBJECT_TYPE.VSS_MGMT_OBJECT_DIFF_VOLUME
                        ),
                    ),
                ),
                (
                    NDRPacketField("Obj", VSS_DIFF_AREA_PROP(), VSS_DIFF_AREA_PROP),
                    (
                        (
                            lambda pkt: getattr(pkt, "Type", None)
                            == VSS_MGMT_OBJECT_TYPE.VSS_MGMT_OBJECT_DIFF_AREA
                        ),
                        (
                            lambda _, val: val.tag
                            == VSS_MGMT_OBJECT_TYPE.VSS_MGMT_OBJECT_DIFF_AREA
                        ),
                    ),
                ),
            ],
            StrFixedLenField("Obj", "", length=0),
            align=(4, 8),
            switch_fmt=("I", "I"),
        ),
    ]


class Next_Request(NDRPacket):
    fields_desc = [NDRIntField("celt", 0)]


class Next_Response(NDRPacket):
    fields_desc = [
        NDRConfVarPacketListField(
            "rgelt",
            [],
            VSS_MGMT_OBJECT_PROP,
            size_is=lambda pkt: pkt.celt,
            length_is=lambda pkt: pkt.pceltFetched,
        ),
        NDRIntField("pceltFetched", None, size_of="rgelt"),
        NDRIntField("status", 0),
    ]


class Skip_Request(NDRPacket):
    fields_desc = [NDRIntField("celt", 0)]


class Skip_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class Reset_Request(NDRPacket):
    fields_desc = []


class Reset_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class Clone_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("ppenum", MInterfacePointer(), MInterfacePointer)
        )
    ]


class Clone_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("ppenum", MInterfacePointer(), MInterfacePointer)
        ),
        NDRIntField("status", 0),
    ]


IVSSENUMMGMTOBJECT_OPNUMS = {
    0: DceRpcOp(Next_Request, Next_Response),
    1: DceRpcOp(Skip_Request, Skip_Response),
    2: DceRpcOp(Reset_Request, Reset_Response),
    3: DceRpcOp(Clone_Request, Clone_Response),
}
register_com_interface(
    name="IVssEnumMgmtObject",
    uuid=uuid.UUID("01954E6B-9254-4e6e-808C-C9E05D007696"),
    opnums=IVSSENUMMGMTOBJECT_OPNUMS,
)
