### ms-ioi.idl
"""
RPC definitions for the following interfaces:
- IManagedObject (v0.0): C3FCC19E-A970-11d2-8B5A-00A0C9B7C9C4
- IRemoteDispatch (v0.0): 6619a740-8154-43be-a186-0319578e02db
- IServicedComponentInfo (v0.0): 8165B19E-8D3A-4d0b-80C8-97DE310DB583
This file is auto-generated by midl-to-scapy, do not modify.
"""

from enum import IntEnum
import uuid


from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRConfPacketListField,
    NDRConfStrLenField,
    NDRConfStrLenFieldUtf16,
    NDRFullPointerField,
    NDRIntField,
    NDRPacketField,
    NDRRecursiveField,
    NDRRefEmbPointerField,
    NDRShortField,
    NDRSignedIntField,
    NDRSignedLongField,
    register_com_interface,
)


class FLAGGED_WORD_BLOB(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["asData"]
    fields_desc = [
        NDRIntField("cBytes", 0),
        NDRIntField("clSize", None, size_of="asData"),
        NDRConfStrLenFieldUtf16(
            "asData", "", size_is=lambda pkt: pkt.clSize, conformant_in_struct=True
        ),
    ]


class GetSerializedBuffer_Request(NDRPacket):
    fields_desc = []


class GetSerializedBuffer_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("pBSTR", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)
        ),
        NDRIntField("status", 0),
    ]


class GetObjectIdentity_Request(NDRPacket):
    fields_desc = []


class GetObjectIdentity_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("pBSTRGUID", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)
        ),
        NDRSignedIntField("AppDomainID", 0),
        NDRSignedIntField("pCCW", 0),
        NDRIntField("status", 0),
    ]


IMANAGEDOBJECT_OPNUMS = {
    0: DceRpcOp(GetSerializedBuffer_Request, GetSerializedBuffer_Response),
    1: DceRpcOp(GetObjectIdentity_Request, GetObjectIdentity_Response),
}
register_com_interface(
    name="IManagedObject",
    uuid=uuid.UUID("C3FCC19E-A970-11d2-8B5A-00A0C9B7C9C4"),
    opnums=IMANAGEDOBJECT_OPNUMS,
)


class RemoteDispatchAutoDone_Request(NDRPacket):
    fields_desc = [NDRPacketField("s", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)]


class RemoteDispatchAutoDone_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("pRetVal", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)
        ),
        NDRIntField("status", 0),
    ]


class RemoteDispatchNotAutoDone_Request(NDRPacket):
    fields_desc = [NDRPacketField("s", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)]


class RemoteDispatchNotAutoDone_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("pRetVal", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)
        ),
        NDRIntField("status", 0),
    ]


IREMOTEDISPATCH_OPNUMS = {
    0: DceRpcOp(RemoteDispatchAutoDone_Request, RemoteDispatchAutoDone_Response),
    1: DceRpcOp(RemoteDispatchNotAutoDone_Request, RemoteDispatchNotAutoDone_Response),
}
register_com_interface(
    name="IRemoteDispatch",
    uuid=uuid.UUID("6619a740-8154-43be-a186-0319578e02db"),
    opnums=IREMOTEDISPATCH_OPNUMS,
)


class VARENUM(IntEnum):
    VT_EMPTY = 0
    VT_NULL = 1
    VT_I2 = 2
    VT_I4 = 3
    VT_R4 = 4
    VT_R8 = 5
    VT_CY = 6
    VT_DATE = 7
    VT_BSTR = 8
    VT_DISPATCH = 9
    VT_ERROR = 10
    VT_BOOL = 11
    VT_VARIANT = 12
    VT_UNKNOWN = 13
    VT_DECIMAL = 14
    VT_I1 = 16
    VT_UI1 = 17
    VT_UI2 = 18
    VT_UI4 = 19
    VT_I8 = 20
    VT_UI8 = 21
    VT_INT = 22
    VT_UINT = 23
    VT_VOID = 24
    VT_HRESULT = 25
    VT_PTR = 26
    VT_SAFEARRAY = 27
    VT_CARRAY = 28
    VT_USERDEFINED = 29
    VT_LPSTR = 30
    VT_LPWSTR = 31
    VT_RECORD = 36
    VT_INT_PTR = 37
    VT_UINT_PTR = 38
    VT_ARRAY = 8192
    VT_BYREF = 16384


class SF_TYPE(IntEnum):
    SF_ERROR = VARENUM.VT_ERROR
    SF_I1 = VARENUM.VT_I1
    SF_I2 = VARENUM.VT_I2
    SF_I4 = VARENUM.VT_I4
    SF_I8 = VARENUM.VT_I8
    SF_BSTR = VARENUM.VT_BSTR
    SF_UNKNOWN = VARENUM.VT_UNKNOWN
    SF_DISPATCH = VARENUM.VT_DISPATCH
    SF_VARIANT = VARENUM.VT_VARIANT
    SF_RECORD = VARENUM.VT_RECORD
    SF_HAVEIID = VARENUM.VT_UNKNOWN | 32768


class SAFEARR_BSTR(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Size", None, size_of="aBstr"),
        NDRRefEmbPointerField(
            NDRConfPacketListField(
                "aBstr", [], FLAGGED_WORD_BLOB, size_is=lambda pkt: pkt.Size
            ),
            deferred=True,
        ),
    ]


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 SAFEARR_UNKNOWN(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Size", None, size_of="apUnknown"),
        NDRRefEmbPointerField(
            NDRConfPacketListField(
                "apUnknown", [], MInterfacePointer, size_is=lambda pkt: pkt.Size
            ),
            deferred=True,
        ),
    ]


class SAFEARR_DISPATCH(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Size", None, size_of="apDispatch"),
        NDRRefEmbPointerField(
            NDRConfPacketListField(
                "apDispatch", [], MInterfacePointer, size_is=lambda pkt: pkt.Size
            ),
            deferred=True,
        ),
    ]


class CURRENCY(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [NDRSignedLongField("int64", 0)]


class SAFEARRAYBOUND(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("cElements", 0), NDRSignedIntField("lLbound", 0)]


class SAFEARRAY(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["rgsabound"]
    fields_desc = [
        NDRShortField("cDims", None, size_of="rgsabound"),
        NDRShortField("fFeatures", 0),
        NDRIntField("cbElements", 0),
        NDRIntField("cLocks", 0),
        NDRRecursiveField("uArrayStructs"),
        NDRConfPacketListField(
            "rgsabound",
            [],
            SAFEARRAYBOUND,
            size_is=lambda pkt: pkt.cDims,
            conformant_in_struct=True,
        ),
    ]


class GetComponentInfo_Request(NDRPacket):
    fields_desc = [NDRSignedIntField("infoMask", 0)]


class GetComponentInfo_Response(NDRPacket):
    fields_desc = [
        NDRSignedIntField("infoMask", 0),
        NDRFullPointerField(NDRPacketField("infoArray", SAFEARRAY(), SAFEARRAY)),
        NDRIntField("status", 0),
    ]


ISERVICEDCOMPONENTINFO_OPNUMS = {
    0: DceRpcOp(GetComponentInfo_Request, GetComponentInfo_Response)
}
register_com_interface(
    name="IServicedComponentInfo",
    uuid=uuid.UUID("8165B19E-8D3A-4d0b-80C8-97DE310DB583"),
    opnums=ISERVICEDCOMPONENTINFO_OPNUMS,
)
