### ms-mqds.idl
"""
RPC definitions for the following interfaces:
- dscomm (v1.0): 77df7a80-f298-11d0-8358-00a024c480a8
- dscomm2 (v1.0): 708cca10-9569-11d1-b2a5-0060977d8118
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,
    NDRByteField,
    NDRConfFieldListField,
    NDRConfPacketListField,
    NDRConfStrLenField,
    NDRConfStrLenFieldUtf16,
    NDRConfVarPacketListField,
    NDRConfVarStrLenField,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRContextHandle,
    NDRFullPointerField,
    NDRIntField,
    NDRLongField,
    NDRPacketField,
    NDRRecursiveField,
    NDRShortField,
    NDRSignedIntField,
    NDRSignedLongField,
    register_dcerpc_interface,
)


class VARENUM(IntEnum):
    VT_EMPTY = 0
    VT_NULL = 1
    VT_I2 = 2
    VT_I4 = 3
    VT_BOOL = 11
    VT_VARIANT = 12
    VT_I1 = 16
    VT_UI1 = 17
    VT_UI2 = 18
    VT_UI4 = 19
    VT_I8 = 20
    VT_UI8 = 21
    VT_LPWSTR = 31
    VT_BLOB = 65
    VT_CLSID = 72
    VT_VECTOR = 4096


class LARGE_INTEGER(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [NDRSignedLongField("QuadPart", 0)]


class ULARGE_INTEGER(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [NDRLongField("QuadPart", 0)]


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


class BLOB(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cbSize", None, size_of="pBlobData"),
        NDRFullPointerField(
            NDRConfStrLenField("pBlobData", "", size_is=lambda pkt: pkt.cbSize),
            deferred=True,
        ),
    ]


class CAUB(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cElems", None, size_of="pElems"),
        NDRFullPointerField(
            NDRConfStrLenField("pElems", "", size_is=lambda pkt: pkt.cElems),
            deferred=True,
        ),
    ]


class CAUI(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cElems", None, size_of="pElems"),
        NDRFullPointerField(
            NDRConfStrLenFieldUtf16("pElems", "", size_is=lambda pkt: pkt.cElems),
            deferred=True,
        ),
    ]


class CAL(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cElems", None, size_of="pElems"),
        NDRFullPointerField(
            NDRConfFieldListField(
                "pElems",
                [],
                NDRSignedIntField("pElems", 0),
                size_is=lambda pkt: pkt.cElems,
            ),
            deferred=True,
        ),
    ]


class CAUL(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cElems", None, size_of="pElems"),
        NDRFullPointerField(
            NDRConfFieldListField(
                "pElems", [], NDRIntField("pElems", 0), size_is=lambda pkt: pkt.cElems
            ),
            deferred=True,
        ),
    ]


class CAUH(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cElems", None, size_of="pElems"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "pElems", [], ULARGE_INTEGER, size_is=lambda pkt: pkt.cElems
            ),
            deferred=True,
        ),
    ]


class CACLSID(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cElems", None, size_of="pElems"),
        NDRFullPointerField(
            NDRConfPacketListField("pElems", [], GUID, size_is=lambda pkt: pkt.cElems),
            deferred=True,
        ),
    ]


class CALPWSTR(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cElems", None, size_of="pElems"),
        NDRFullPointerField(
            NDRConfFieldListField(
                "pElems",
                [],
                NDRFullPointerField(
                    NDRConfVarStrNullFieldUtf16("pElems", ""), deferred=True
                ),
                size_is=lambda pkt: pkt.cElems,
            ),
            deferred=True,
        ),
    ]


class tag_inner_PROPVARIANT(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRShortField("vt", 0),
        NDRByteField("wReserved1", 0),
        NDRByteField("wReserved2", 0),
        NDRIntField("wReserved3", 0),
        NDRRecursiveField("_varUnion"),
    ]


class S_DSCreateObject_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwObjectType", 0),
        NDRFullPointerField(NDRShortField("pwcsPathName", 0)),
        NDRIntField("dwSDLength", None, size_of="SecurityDescriptor"),
        NDRConfStrLenField(
            "SecurityDescriptor", "", size_is=lambda pkt: pkt.dwSDLength
        ),
        NDRIntField("cp", None, size_of="apVar"),
        NDRConfFieldListField(
            "aProp", [], NDRIntField("", 0), size_is=lambda pkt: pkt.cp
        ),
        NDRConfPacketListField(
            "apVar", [], tag_inner_PROPVARIANT, size_is=lambda pkt: pkt.cp
        ),
        NDRFullPointerField(NDRPacketField("pObjGuid", GUID(), GUID)),
    ]


class S_DSCreateObject_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRPacketField("pObjGuid", GUID(), GUID)),
        NDRIntField("status", 0),
    ]


class S_DSDeleteObject_Request(NDRPacket):
    fields_desc = [NDRIntField("dwObjectType", 0), NDRShortField("pwcsPathName", 0)]


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


class S_DSGetProps_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwObjectType", 0),
        NDRShortField("pwcsPathName", 0),
        NDRIntField("cp", None, size_of="apVar"),
        NDRConfFieldListField(
            "aProp", [], NDRIntField("", 0), size_is=lambda pkt: pkt.cp
        ),
        NDRConfPacketListField(
            "apVar", [], tag_inner_PROPVARIANT, size_is=lambda pkt: pkt.cp
        ),
        NDRPacketField("phServerAuth", NDRContextHandle(), NDRContextHandle),
        NDRIntField("pdwServerSignatureSize", 0),
    ]


class S_DSGetProps_Response(NDRPacket):
    fields_desc = [
        NDRConfPacketListField(
            "apVar", [], tag_inner_PROPVARIANT, size_is=lambda pkt: pkt.cp
        ),
        NDRConfStrLenField(
            "pbServerSignature", "", size_is=lambda pkt: pkt.pdwServerSignatureSize
        ),
        NDRIntField("pdwServerSignatureSize", None, size_of="pbServerSignature"),
        NDRIntField("status", 0),
    ]


class S_DSSetProps_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwObjectType", 0),
        NDRShortField("pwcsPathName", 0),
        NDRIntField("cp", None, size_of="apVar"),
        NDRConfFieldListField(
            "aProp", [], NDRIntField("", 0), size_is=lambda pkt: pkt.cp
        ),
        NDRConfPacketListField(
            "apVar", [], tag_inner_PROPVARIANT, size_is=lambda pkt: pkt.cp
        ),
    ]


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


class S_DSGetObjectSecurity_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwObjectType", 0),
        NDRShortField("pwcsPathName", 0),
        NDRIntField("SecurityInformation", 0),
        NDRIntField("nLength", 0),
        NDRPacketField("phServerAuth", NDRContextHandle(), NDRContextHandle),
        NDRIntField("pdwServerSignatureSize", 0),
    ]


class S_DSGetObjectSecurity_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pSecurityDescriptor", "", size_is=lambda pkt: pkt.nLength),
        NDRIntField("lpnLengthNeeded", 0),
        NDRConfStrLenField(
            "pbServerSignature", "", size_is=lambda pkt: pkt.pdwServerSignatureSize
        ),
        NDRIntField("pdwServerSignatureSize", None, size_of="pbServerSignature"),
        NDRIntField("status", 0),
    ]


class S_DSSetObjectSecurity_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwObjectType", 0),
        NDRShortField("pwcsPathName", 0),
        NDRIntField("SecurityInformation", 0),
        NDRConfStrLenField("pSecurityDescriptor", "", size_is=lambda pkt: pkt.nLength),
        NDRIntField("nLength", None, size_of="pSecurityDescriptor"),
    ]


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


class MQPROPERTYRESTRICTION(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("rel", 0),
        NDRIntField("prop", 0),
        NDRPacketField("prval", tag_inner_PROPVARIANT(), tag_inner_PROPVARIANT),
    ]


class MQRESTRICTION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cRes", None, size_of="paPropRes"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "paPropRes", [], MQPROPERTYRESTRICTION, size_is=lambda pkt: pkt.cRes
            ),
            deferred=True,
        ),
    ]


class MQCOLUMNSET(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cCol", None, size_of="aCol"),
        NDRFullPointerField(
            NDRConfFieldListField(
                "aCol", [], NDRIntField("aCol", 0), size_is=lambda pkt: pkt.cCol
            ),
            deferred=True,
        ),
    ]


class MQSORTKEY(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("propColumn", 0), NDRIntField("dwOrder", 0)]


class MQSORTSET(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cCol", None, size_of="aCol"),
        NDRFullPointerField(
            NDRConfPacketListField("aCol", [], MQSORTKEY, size_is=lambda pkt: pkt.cCol),
            deferred=True,
        ),
    ]


class S_DSLookupBegin_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRShortField("pwcsContext", 0)),
        NDRFullPointerField(
            NDRPacketField("pRestriction", MQRESTRICTION(), MQRESTRICTION)
        ),
        NDRPacketField("pColumns", MQCOLUMNSET(), MQCOLUMNSET),
        NDRFullPointerField(NDRPacketField("pSort", MQSORTSET(), MQSORTSET)),
        NDRPacketField("phServerAuth", NDRContextHandle(), NDRContextHandle),
    ]


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


class S_DSLookupNext_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("Handle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("dwSize", 0),
        NDRPacketField("phServerAuth", NDRContextHandle(), NDRContextHandle),
        NDRIntField("pdwServerSignatureSize", 0),
    ]


class S_DSLookupNext_Response(NDRPacket):
    fields_desc = [
        NDRIntField("dwOutSize", None, size_of="pbBuffer"),
        NDRConfVarPacketListField(
            "pbBuffer",
            [],
            tag_inner_PROPVARIANT,
            size_is=lambda pkt: pkt.dwSize,
            length_is=lambda pkt: pkt.dwOutSize,
        ),
        NDRConfStrLenField(
            "pbServerSignature", "", size_is=lambda pkt: pkt.pdwServerSignatureSize
        ),
        NDRIntField("pdwServerSignatureSize", None, size_of="pbServerSignature"),
        NDRIntField("status", 0),
    ]


class S_DSLookupEnd_Request(NDRPacket):
    fields_desc = [NDRPacketField("phContext", NDRContextHandle(), NDRContextHandle)]


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


class S_DSDeleteObjectGuid_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwObjectType", 0),
        NDRPacketField("pGuid", GUID(), GUID),
    ]


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


class S_DSGetPropsGuid_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwObjectType", 0),
        NDRFullPointerField(NDRPacketField("pGuid", GUID(), GUID)),
        NDRIntField("cp", None, size_of="apVar"),
        NDRConfFieldListField(
            "aProp", [], NDRIntField("", 0), size_is=lambda pkt: pkt.cp
        ),
        NDRConfPacketListField(
            "apVar", [], tag_inner_PROPVARIANT, size_is=lambda pkt: pkt.cp
        ),
        NDRPacketField("phServerAuth", NDRContextHandle(), NDRContextHandle),
        NDRIntField("pdwServerSignatureSize", 0),
    ]


class S_DSGetPropsGuid_Response(NDRPacket):
    fields_desc = [
        NDRConfPacketListField(
            "apVar", [], tag_inner_PROPVARIANT, size_is=lambda pkt: pkt.cp
        ),
        NDRConfStrLenField(
            "pbServerSignature", "", size_is=lambda pkt: pkt.pdwServerSignatureSize
        ),
        NDRIntField("pdwServerSignatureSize", None, size_of="pbServerSignature"),
        NDRIntField("status", 0),
    ]


class S_DSSetPropsGuid_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwObjectType", 0),
        NDRPacketField("pGuid", GUID(), GUID),
        NDRIntField("cp", None, size_of="apVar"),
        NDRConfFieldListField(
            "aProp", [], NDRIntField("", 0), size_is=lambda pkt: pkt.cp
        ),
        NDRConfPacketListField(
            "apVar", [], tag_inner_PROPVARIANT, size_is=lambda pkt: pkt.cp
        ),
    ]


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


class S_DSGetObjectSecurityGuid_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwObjectType", 0),
        NDRPacketField("pGuid", GUID(), GUID),
        NDRIntField("SecurityInformation", 0),
        NDRIntField("nLength", 0),
        NDRPacketField("phServerAuth", NDRContextHandle(), NDRContextHandle),
        NDRIntField("pdwServerSignatureSize", 0),
    ]


class S_DSGetObjectSecurityGuid_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pSecurityDescriptor", "", size_is=lambda pkt: pkt.nLength),
        NDRIntField("lpnLengthNeeded", 0),
        NDRConfStrLenField(
            "pbServerSignature", "", size_is=lambda pkt: pkt.pdwServerSignatureSize
        ),
        NDRIntField("pdwServerSignatureSize", None, size_of="pbServerSignature"),
        NDRIntField("status", 0),
    ]


class S_DSSetObjectSecurityGuid_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwObjectType", 0),
        NDRPacketField("pGuid", GUID(), GUID),
        NDRIntField("SecurityInformation", 0),
        NDRConfStrLenField("pSecurityDescriptor", "", size_is=lambda pkt: pkt.nLength),
        NDRIntField("nLength", None, size_of="pSecurityDescriptor"),
    ]


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


class S_DSQMSetMachineProperties_Request(NDRPacket):
    fields_desc = [
        NDRShortField("pwcsPathName", 0),
        NDRIntField("cp", None, size_of="apVar"),
        NDRConfFieldListField(
            "aProp", [], NDRIntField("", 0), size_is=lambda pkt: pkt.cp
        ),
        NDRConfPacketListField(
            "apVar", [], tag_inner_PROPVARIANT, size_is=lambda pkt: pkt.cp
        ),
        NDRIntField("dwContext", 0),
    ]


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


class S_DSCreateServersCache_Request(NDRPacket):
    fields_desc = [
        NDRIntField("pdwIndex", 0),
        NDRFullPointerField(
            NDRFullPointerField(NDRConfVarStrNullFieldUtf16("lplpSiteServers", ""))
        ),
        NDRPacketField("phServerAuth", NDRContextHandle(), NDRContextHandle),
        NDRIntField("pdwServerSignatureSize", 0),
    ]


class S_DSCreateServersCache_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pdwIndex", 0),
        NDRFullPointerField(
            NDRFullPointerField(NDRConfVarStrNullFieldUtf16("lplpSiteServers", ""))
        ),
        NDRConfStrLenField(
            "pbServerSignature", "", size_is=lambda pkt: pkt.pdwServerSignatureSize
        ),
        NDRIntField("pdwServerSignatureSize", None, size_of="pbServerSignature"),
        NDRIntField("status", 0),
    ]


class S_DSQMSetMachinePropertiesSignProc_Request(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("abChallenge", "", size_is=lambda pkt: pkt.dwCallengeSize),
        NDRIntField("dwCallengeSize", None, size_of="abChallenge"),
        NDRIntField("dwContext", 0),
        NDRConfVarStrLenField(
            "abSignature",
            "",
            size_is=lambda pkt: pkt.dwSignatureMaxSize,
            length_is=lambda pkt: pkt.pdwSignatureSize,
        ),
        NDRIntField("pdwSignatureSize", None, size_of="abSignature"),
        NDRIntField("dwSignatureMaxSize", None, size_of="abSignature"),
    ]


class S_DSQMSetMachinePropertiesSignProc_Response(NDRPacket):
    fields_desc = [
        NDRConfVarStrLenField(
            "abSignature",
            "",
            size_is=lambda pkt: pkt.dwSignatureMaxSize,
            length_is=lambda pkt: pkt.pdwSignatureSize,
        ),
        NDRIntField("pdwSignatureSize", None, size_of="abSignature"),
        NDRIntField("status", 0),
    ]


class S_DSQMGetObjectSecurity_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwObjectType", 0),
        NDRPacketField("pGuid", GUID(), GUID),
        NDRIntField("SecurityInformation", 0),
        NDRIntField("nLength", 0),
        NDRIntField("dwContext", 0),
        NDRPacketField("phServerAuth", NDRContextHandle(), NDRContextHandle),
        NDRIntField("pdwServerSignatureSize", 0),
    ]


class S_DSQMGetObjectSecurity_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pSecurityDescriptor", "", size_is=lambda pkt: pkt.nLength),
        NDRIntField("lpnLengthNeeded", 0),
        NDRConfStrLenField(
            "pbServerSignature", "", size_is=lambda pkt: pkt.pdwServerSignatureSize
        ),
        NDRIntField("pdwServerSignatureSize", None, size_of="pbServerSignature"),
        NDRIntField("status", 0),
    ]


class S_DSQMGetObjectSecurityChallengeResponceProc_Request(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("abChallenge", "", size_is=lambda pkt: pkt.dwCallengeSize),
        NDRIntField("dwCallengeSize", None, size_of="abChallenge"),
        NDRIntField("dwContext", 0),
        NDRConfVarStrLenField(
            "abCallengeResponce",
            "",
            size_is=lambda pkt: pkt.dwCallengeResponceMaxSize,
            length_is=lambda pkt: pkt.pdwCallengeResponceSize,
        ),
        NDRIntField("pdwCallengeResponceSize", None, size_of="abCallengeResponce"),
        NDRIntField("dwCallengeResponceMaxSize", None, size_of="abCallengeResponce"),
    ]


class S_DSQMGetObjectSecurityChallengeResponceProc_Response(NDRPacket):
    fields_desc = [
        NDRConfVarStrLenField(
            "abCallengeResponce",
            "",
            size_is=lambda pkt: pkt.dwCallengeResponceMaxSize,
            length_is=lambda pkt: pkt.pdwCallengeResponceSize,
        ),
        NDRIntField("pdwCallengeResponceSize", None, size_of="abCallengeResponce"),
        NDRIntField("status", 0),
    ]


class S_InitSecCtx_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwContext", 0),
        NDRConfStrLenField("pServerbuff", "", size_is=lambda pkt: pkt.dwServerBuffSize),
        NDRIntField("dwServerBuffSize", None, size_of="pServerbuff"),
        NDRIntField("dwClientBuffMaxSize", 0),
    ]


class S_InitSecCtx_Response(NDRPacket):
    fields_desc = [
        NDRConfVarStrLenField(
            "pClientBuff",
            "",
            size_is=lambda pkt: pkt.dwClientBuffMaxSize,
            length_is=lambda pkt: pkt.pdwClientBuffSize,
        ),
        NDRIntField("pdwClientBuffSize", None, size_of="pClientBuff"),
        NDRIntField("status", 0),
    ]


class S_DSValidateServer_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("pguidEnterpriseId", GUID(), GUID),
        NDRSignedIntField("fSetupMode", 0),
        NDRIntField("dwContext", 0),
        NDRIntField("dwClientBuffMaxSize", None, size_of="pClientBuff"),
        NDRConfVarStrLenField(
            "pClientBuff",
            "",
            size_is=lambda pkt: pkt.dwClientBuffMaxSize,
            length_is=lambda pkt: pkt.dwClientBuffSize,
        ),
        NDRIntField("dwClientBuffSize", None, size_of="pClientBuff"),
    ]


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


class S_DSCloseServerHandle_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("pphServerAuth", NDRContextHandle(), NDRContextHandle)
    ]


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


class S_DSGetServerPort_Request(NDRPacket):
    fields_desc = [NDRIntField("fIP", 0)]


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


DSCOMM_OPNUMS = {
    0: DceRpcOp(S_DSCreateObject_Request, S_DSCreateObject_Response),
    1: DceRpcOp(S_DSDeleteObject_Request, S_DSDeleteObject_Response),
    2: DceRpcOp(S_DSGetProps_Request, S_DSGetProps_Response),
    3: DceRpcOp(S_DSSetProps_Request, S_DSSetProps_Response),
    4: DceRpcOp(S_DSGetObjectSecurity_Request, S_DSGetObjectSecurity_Response),
    5: DceRpcOp(S_DSSetObjectSecurity_Request, S_DSSetObjectSecurity_Response),
    6: DceRpcOp(S_DSLookupBegin_Request, S_DSLookupBegin_Response),
    7: DceRpcOp(S_DSLookupNext_Request, S_DSLookupNext_Response),
    8: DceRpcOp(S_DSLookupEnd_Request, S_DSLookupEnd_Response),
    # 9: Opnum9NotUsedOnWire,
    10: DceRpcOp(S_DSDeleteObjectGuid_Request, S_DSDeleteObjectGuid_Response),
    11: DceRpcOp(S_DSGetPropsGuid_Request, S_DSGetPropsGuid_Response),
    12: DceRpcOp(S_DSSetPropsGuid_Request, S_DSSetPropsGuid_Response),
    13: DceRpcOp(S_DSGetObjectSecurityGuid_Request, S_DSGetObjectSecurityGuid_Response),
    14: DceRpcOp(S_DSSetObjectSecurityGuid_Request, S_DSSetObjectSecurityGuid_Response),
    # 15: Opnum15NotUsedOnWire,
    # 16: Opnum16NotUsedOnWire,
    # 17: Opnum17NotUsedOnWire,
    # 18: Opnum18NotUsedOnWire,
    19: DceRpcOp(
        S_DSQMSetMachineProperties_Request, S_DSQMSetMachineProperties_Response
    ),
    20: DceRpcOp(S_DSCreateServersCache_Request, S_DSCreateServersCache_Response),
    21: DceRpcOp(
        S_DSQMSetMachinePropertiesSignProc_Request,
        S_DSQMSetMachinePropertiesSignProc_Response,
    ),
    22: DceRpcOp(S_DSQMGetObjectSecurity_Request, S_DSQMGetObjectSecurity_Response),
    23: DceRpcOp(
        S_DSQMGetObjectSecurityChallengeResponceProc_Request,
        S_DSQMGetObjectSecurityChallengeResponceProc_Response,
    ),
    24: DceRpcOp(S_InitSecCtx_Request, S_InitSecCtx_Response),
    25: DceRpcOp(S_DSValidateServer_Request, S_DSValidateServer_Response),
    26: DceRpcOp(S_DSCloseServerHandle_Request, S_DSCloseServerHandle_Response),
    # 27: Opnum24NotUsedOnWire,
    # 28: Opnum25NotUsedOnWire,
    # 29: Opnum26NotUsedOnWire,
    30: DceRpcOp(S_DSGetServerPort_Request, S_DSGetServerPort_Response),
}
register_dcerpc_interface(
    name="dscomm",
    uuid=uuid.UUID("77df7a80-f298-11d0-8358-00a024c480a8"),
    version="1.0",
    opnums=DSCOMM_OPNUMS,
)


class S_DSGetComputerSites_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRShortField("pwcsPathName", 0)),
        NDRPacketField("phServerAuth", NDRContextHandle(), NDRContextHandle),
        NDRIntField("pdwServerSignatureSize", 0),
    ]


class S_DSGetComputerSites_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pdwNumberOfSites", None, size_of="ppguidSites"),
        NDRConfVarPacketListField(
            "ppguidSites",
            [],
            GUID,
            size_is=lambda pkt: pkt.pdwNumberOfSites,
            length_is=lambda pkt: pkt.pdwNumberOfSites,
            ptr_pack=True,
        ),
        NDRConfStrLenField(
            "pbServerSignature", "", size_is=lambda pkt: pkt.pdwServerSignatureSize
        ),
        NDRIntField("pdwServerSignatureSize", None, size_of="pbServerSignature"),
        NDRIntField("status", 0),
    ]


class S_DSGetPropsEx_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwObjectType", 0),
        NDRShortField("pwcsPathName", 0),
        NDRIntField("cp", None, size_of="apVar"),
        NDRConfFieldListField(
            "aProp", [], NDRIntField("", 0), size_is=lambda pkt: pkt.cp
        ),
        NDRConfPacketListField(
            "apVar", [], tag_inner_PROPVARIANT, size_is=lambda pkt: pkt.cp
        ),
        NDRPacketField("phServerAuth", NDRContextHandle(), NDRContextHandle),
        NDRIntField("pdwServerSignatureSize", 0),
    ]


class S_DSGetPropsEx_Response(NDRPacket):
    fields_desc = [
        NDRConfPacketListField(
            "apVar", [], tag_inner_PROPVARIANT, size_is=lambda pkt: pkt.cp
        ),
        NDRConfStrLenField(
            "pbServerSignature", "", size_is=lambda pkt: pkt.pdwServerSignatureSize
        ),
        NDRIntField("pdwServerSignatureSize", None, size_of="pbServerSignature"),
        NDRIntField("status", 0),
    ]


class S_DSGetPropsGuidEx_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwObjectType", 0),
        NDRFullPointerField(NDRPacketField("pGuid", GUID(), GUID)),
        NDRIntField("cp", None, size_of="apVar"),
        NDRConfFieldListField(
            "aProp", [], NDRIntField("", 0), size_is=lambda pkt: pkt.cp
        ),
        NDRConfPacketListField(
            "apVar", [], tag_inner_PROPVARIANT, size_is=lambda pkt: pkt.cp
        ),
        NDRPacketField("phServerAuth", NDRContextHandle(), NDRContextHandle),
        NDRIntField("pdwServerSignatureSize", 0),
    ]


class S_DSGetPropsGuidEx_Response(NDRPacket):
    fields_desc = [
        NDRConfPacketListField(
            "apVar", [], tag_inner_PROPVARIANT, size_is=lambda pkt: pkt.cp
        ),
        NDRConfStrLenField(
            "pbServerSignature", "", size_is=lambda pkt: pkt.pdwServerSignatureSize
        ),
        NDRIntField("pdwServerSignatureSize", None, size_of="pbServerSignature"),
        NDRIntField("status", 0),
    ]


class S_DSBeginDeleteNotification_Request(NDRPacket):
    fields_desc = [
        NDRShortField("pwcsPathName", 0),
        NDRPacketField("phServerAuth", NDRContextHandle(), NDRContextHandle),
    ]


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


class S_DSNotifyDelete_Request(NDRPacket):
    fields_desc = [NDRPacketField("Handle", NDRContextHandle(), NDRContextHandle)]


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


class S_DSEndDeleteNotification_Request(NDRPacket):
    fields_desc = [NDRPacketField("pHandle", NDRContextHandle(), NDRContextHandle)]


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


class S_DSIsServerGC_Request(NDRPacket):
    fields_desc = []


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


class S_DSGetGCListInDomain_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRShortField("lpwszComputerName", 0)),
        NDRFullPointerField(NDRShortField("lpwszDomainName", 0)),
        NDRPacketField("phServerAuth", NDRContextHandle(), NDRContextHandle),
        NDRIntField("pdwServerSignatureSize", 0),
    ]


class S_DSGetGCListInDomain_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("lplpwszGCList", "")),
        NDRConfStrLenField(
            "pbServerSignature", "", size_is=lambda pkt: pkt.pdwServerSignatureSize
        ),
        NDRIntField("pdwServerSignatureSize", None, size_of="pbServerSignature"),
        NDRIntField("status", 0),
    ]


DSCOMM2_OPNUMS = {
    0: DceRpcOp(S_DSGetComputerSites_Request, S_DSGetComputerSites_Response),
    1: DceRpcOp(S_DSGetPropsEx_Request, S_DSGetPropsEx_Response),
    2: DceRpcOp(S_DSGetPropsGuidEx_Request, S_DSGetPropsGuidEx_Response),
    3: DceRpcOp(
        S_DSBeginDeleteNotification_Request, S_DSBeginDeleteNotification_Response
    ),
    4: DceRpcOp(S_DSNotifyDelete_Request, S_DSNotifyDelete_Response),
    5: DceRpcOp(S_DSEndDeleteNotification_Request, S_DSEndDeleteNotification_Response),
    6: DceRpcOp(S_DSIsServerGC_Request, S_DSIsServerGC_Response),
    # 7: Opnum7NotUsedOnWire,
    8: DceRpcOp(S_DSGetGCListInDomain_Request, S_DSGetGCListInDomain_Response),
}
register_dcerpc_interface(
    name="dscomm2",
    uuid=uuid.UUID("708cca10-9569-11d1-b2a5-0060977d8118"),
    version="1.0",
    opnums=DSCOMM2_OPNUMS,
)
