### ms-dtyp.idl
"""
RPC definitions for the following interfaces:
- 
This file is auto-generated by midl-to-scapy, do not modify.
"""


import uuid

from scapy.fields import StrFixedLenField
from scapy.layers.dcerpc import (
    NDRPacket,
    NDRByteField,
    NDRConfFieldListField,
    NDRConfVarStrLenField,
    NDRConfVarStrLenFieldUtf16,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRFullPointerField,
    NDRIntField,
    NDRLongField,
    NDRPacketField,
    NDRShortField,
    NDRSignedIntField,
    NDRSignedLongField,
)


class FILETIME(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("dwLowDateTime", 0), NDRIntField("dwHighDateTime", 0)]


class PFILETIME(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("dwLowDateTime", 0), NDRIntField("dwHighDateTime", 0)]


class LPFILETIME(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("dwLowDateTime", 0), NDRIntField("dwHighDateTime", 0)]


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


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


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


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


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


class EVENT_DESCRIPTOR(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRShortField("Id", 0),
        NDRByteField("Version", 0),
        NDRByteField("Channel", 0),
        NDRByteField("Level", 0),
        NDRByteField("Opcode", 0),
        NDRShortField("Task", 0),
        NDRLongField("Keyword", 0),
    ]


class PEVENT_DESCRIPTOR(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRShortField("Id", 0),
        NDRByteField("Version", 0),
        NDRByteField("Channel", 0),
        NDRByteField("Level", 0),
        NDRByteField("Opcode", 0),
        NDRShortField("Task", 0),
        NDRLongField("Keyword", 0),
    ]


class PCEVENT_DESCRIPTOR(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRShortField("Id", 0),
        NDRByteField("Version", 0),
        NDRByteField("Channel", 0),
        NDRByteField("Level", 0),
        NDRByteField("Opcode", 0),
        NDRShortField("Task", 0),
        NDRLongField("Keyword", 0),
    ]


class LUID(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("LowPart", 0), NDRSignedIntField("HighPart", 0)]


class PLUID(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("LowPart", 0), NDRSignedIntField("HighPart", 0)]


class MULTI_SZ(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(NDRShortField("Value", 0), deferred=True),
        NDRIntField("nChar", 0),
    ]


class RPC_UNICODE_STRING(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRShortField("Length", None, size_of="Buffer", adjust=lambda _, x: (x * 2)),
        NDRShortField(
            "MaximumLength", None, size_of="Buffer", adjust=lambda _, x: (x * 2)
        ),
        NDRFullPointerField(
            NDRConfVarStrLenFieldUtf16(
                "Buffer",
                "",
                size_is=lambda pkt: (pkt.MaximumLength // 2),
                length_is=lambda pkt: (pkt.Length // 2),
            ),
            deferred=True,
        ),
    ]


class PRPC_UNICODE_STRING(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRShortField("Length", None, size_of="Buffer", adjust=lambda _, x: (x * 2)),
        NDRShortField(
            "MaximumLength", None, size_of="Buffer", adjust=lambda _, x: (x * 2)
        ),
        NDRFullPointerField(
            NDRConfVarStrLenFieldUtf16(
                "Buffer",
                "",
                size_is=lambda pkt: (pkt.MaximumLength // 2),
                length_is=lambda pkt: (pkt.Length // 2),
            ),
            deferred=True,
        ),
    ]


class SERVER_INFO_100(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("sv100_platform_id", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("sv100_name", ""), deferred=True
        ),
    ]


class PSERVER_INFO_100(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("sv100_platform_id", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("sv100_name", ""), deferred=True
        ),
    ]


class LPSERVER_INFO_100(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("sv100_platform_id", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("sv100_name", ""), deferred=True
        ),
    ]


class SERVER_INFO_101(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("sv101_platform_id", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("sv101_name", ""), deferred=True
        ),
        NDRIntField("sv101_version_major", 0),
        NDRIntField("sv101_version_minor", 0),
        NDRIntField("sv101_version_type", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("sv101_comment", ""), deferred=True
        ),
    ]


class PSERVER_INFO_101(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("sv101_platform_id", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("sv101_name", ""), deferred=True
        ),
        NDRIntField("sv101_version_major", 0),
        NDRIntField("sv101_version_minor", 0),
        NDRIntField("sv101_version_type", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("sv101_comment", ""), deferred=True
        ),
    ]


class LPSERVER_INFO_101(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("sv101_platform_id", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("sv101_name", ""), deferred=True
        ),
        NDRIntField("sv101_version_major", 0),
        NDRIntField("sv101_version_minor", 0),
        NDRIntField("sv101_version_type", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("sv101_comment", ""), deferred=True
        ),
    ]


class SYSTEMTIME(NDRPacket):
    ALIGNMENT = (2, 2)
    fields_desc = [
        NDRShortField("wYear", 0),
        NDRShortField("wMonth", 0),
        NDRShortField("wDayOfWeek", 0),
        NDRShortField("wDay", 0),
        NDRShortField("wHour", 0),
        NDRShortField("wMinute", 0),
        NDRShortField("wSecond", 0),
        NDRShortField("wMilliseconds", 0),
    ]


class PSYSTEMTIME(NDRPacket):
    ALIGNMENT = (2, 2)
    fields_desc = [
        NDRShortField("wYear", 0),
        NDRShortField("wMonth", 0),
        NDRShortField("wDayOfWeek", 0),
        NDRShortField("wDay", 0),
        NDRShortField("wHour", 0),
        NDRShortField("wMinute", 0),
        NDRShortField("wSecond", 0),
        NDRShortField("wMilliseconds", 0),
    ]


class UINT128(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [NDRLongField("lower", 0), NDRLongField("upper", 0)]


class PUINT128(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [NDRLongField("lower", 0), NDRLongField("upper", 0)]


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


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


class RPC_SID_IDENTIFIER_AUTHORITY(NDRPacket):
    fields_desc = [StrFixedLenField("Value", "", length=6)]


class OBJECT_TYPE_LIST(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRShortField("Level", 0),
        NDRIntField("Remaining", 0),
        NDRFullPointerField(NDRPacketField("ObjectType", GUID(), GUID), deferred=True),
    ]


class POBJECT_TYPE_LIST(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRShortField("Level", 0),
        NDRIntField("Remaining", 0),
        NDRFullPointerField(NDRPacketField("ObjectType", GUID(), GUID), deferred=True),
    ]


class ACE_HEADER(NDRPacket):
    ALIGNMENT = (2, 2)
    fields_desc = [
        NDRByteField("AceType", 0),
        NDRByteField("AceFlags", 0),
        NDRShortField("AceSize", 0),
    ]


class PACE_HEADER(NDRPacket):
    ALIGNMENT = (2, 2)
    fields_desc = [
        NDRByteField("AceType", 0),
        NDRByteField("AceFlags", 0),
        NDRShortField("AceSize", 0),
    ]


class SYSTEM_MANDATORY_LABEL_ACE(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRPacketField("Header", ACE_HEADER(), ACE_HEADER),
        NDRIntField("Mask", 0),
        NDRIntField("SidStart", 0),
    ]


class PSYSTEM_MANDATORY_LABEL_ACE(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRPacketField("Header", ACE_HEADER(), ACE_HEADER),
        NDRIntField("Mask", 0),
        NDRIntField("SidStart", 0),
    ]


class TOKEN_MANDATORY_POLICY(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("Policy", 0)]


class PTOKEN_MANDATORY_POLICY(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("Policy", 0)]


class MANDATORY_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("AllowedAccess", 0),
        NDRByteField("WriteAllowed", 0),
        NDRByteField("ReadAllowed", 0),
        NDRByteField("ExecuteAllowed", 0),
        NDRPacketField(
            "MandatoryPolicy", TOKEN_MANDATORY_POLICY(), TOKEN_MANDATORY_POLICY
        ),
    ]


class PMANDATORY_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("AllowedAccess", 0),
        NDRByteField("WriteAllowed", 0),
        NDRByteField("ReadAllowed", 0),
        NDRByteField("ExecuteAllowed", 0),
        NDRPacketField(
            "MandatoryPolicy", TOKEN_MANDATORY_POLICY(), TOKEN_MANDATORY_POLICY
        ),
    ]


class RPC_SID(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["SubAuthority"]
    fields_desc = [
        NDRByteField("Revision", 0),
        NDRByteField("SubAuthorityCount", None, size_of="SubAuthority"),
        NDRPacketField(
            "IdentifierAuthority",
            RPC_SID_IDENTIFIER_AUTHORITY(),
            RPC_SID_IDENTIFIER_AUTHORITY,
        ),
        NDRConfFieldListField(
            "SubAuthority",
            [],
            NDRIntField("", 0),
            size_is=lambda pkt: pkt.SubAuthorityCount,
            conformant_in_struct=True,
        ),
    ]


class PRPC_SID(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["SubAuthority"]
    fields_desc = [
        NDRByteField("Revision", 0),
        NDRByteField("SubAuthorityCount", None, size_of="SubAuthority"),
        NDRPacketField(
            "IdentifierAuthority",
            RPC_SID_IDENTIFIER_AUTHORITY(),
            RPC_SID_IDENTIFIER_AUTHORITY,
        ),
        NDRConfFieldListField(
            "SubAuthority",
            [],
            NDRIntField("", 0),
            size_is=lambda pkt: pkt.SubAuthorityCount,
            conformant_in_struct=True,
        ),
    ]


class PSID(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["SubAuthority"]
    fields_desc = [
        NDRByteField("Revision", 0),
        NDRByteField("SubAuthorityCount", None, size_of="SubAuthority"),
        NDRPacketField(
            "IdentifierAuthority",
            RPC_SID_IDENTIFIER_AUTHORITY(),
            RPC_SID_IDENTIFIER_AUTHORITY,
        ),
        NDRConfFieldListField(
            "SubAuthority",
            [],
            NDRIntField("", 0),
            size_is=lambda pkt: pkt.SubAuthorityCount,
            conformant_in_struct=True,
        ),
    ]


class ACL(NDRPacket):
    ALIGNMENT = (2, 2)
    fields_desc = [
        NDRByteField("AclRevision", 0),
        NDRByteField("Sbz1", 0),
        NDRShortField("AclSize", 0),
        NDRShortField("AceCount", 0),
        NDRShortField("Sbz2", 0),
    ]


class PACL(NDRPacket):
    ALIGNMENT = (2, 2)
    fields_desc = [
        NDRByteField("AclRevision", 0),
        NDRByteField("Sbz1", 0),
        NDRShortField("AclSize", 0),
        NDRShortField("AceCount", 0),
        NDRShortField("Sbz2", 0),
    ]


class SECURITY_DESCRIPTOR(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRByteField("Revision", 0),
        NDRByteField("Sbz1", 0),
        NDRShortField("Control", 0),
        NDRFullPointerField(NDRPacketField("Owner", PSID(), PSID), deferred=True),
        NDRFullPointerField(NDRPacketField("Group", PSID(), PSID), deferred=True),
        NDRFullPointerField(NDRPacketField("Sacl", PACL(), PACL), deferred=True),
        NDRFullPointerField(NDRPacketField("Dacl", PACL(), PACL), deferred=True),
    ]


class PSECURITY_DESCRIPTOR(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRByteField("Revision", 0),
        NDRByteField("Sbz1", 0),
        NDRShortField("Control", 0),
        NDRFullPointerField(NDRPacketField("Owner", PSID(), PSID), deferred=True),
        NDRFullPointerField(NDRPacketField("Group", PSID(), PSID), deferred=True),
        NDRFullPointerField(NDRPacketField("Sacl", PACL(), PACL), deferred=True),
        NDRFullPointerField(NDRPacketField("Dacl", PACL(), PACL), deferred=True),
    ]
