### ms-par.idl
"""
RPC definitions for the following interfaces:
- IRemoteWinspool (v1.0): 76F03F96-CDFD-44fc-A22C-64950A001209
This file is auto-generated by midl-to-scapy, do not modify.
"""

from enum import IntEnum
import uuid

from scapy.fields import StrFixedLenField, StrFixedLenFieldUtf16
from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRByteField,
    NDRConfFieldListField,
    NDRConfPacketListField,
    NDRConfStrLenField,
    NDRConfStrLenFieldUtf16,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRContextHandle,
    NDRFieldListField,
    NDRFullPointerField,
    NDRIEEEFloatField,
    NDRInt3264EnumField,
    NDRIntField,
    NDRLongField,
    NDRPacketField,
    NDRShortField,
    NDRSignedInt3264Field,
    NDRSignedIntField,
    NDRSignedLongField,
    NDRSignedShortField,
    NDRUnionField,
    register_dcerpc_interface,
)


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


class SPLCLIENT_INFO_1(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("dwSize", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pMachineName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pUserName", ""), deferred=True
        ),
        NDRIntField("dwBuildNum", 0),
        NDRIntField("dwMajorVersion", 0),
        NDRIntField("dwMinorVersion", 0),
        NDRShortField("wProcessorArchitecture", 0),
    ]


class SPLCLIENT_INFO_2(NDRPacket):
    fields_desc = [NDRSignedInt3264Field("notUsed", 0)]


class SPLCLIENT_INFO_3(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRIntField("cbSize", 0),
        NDRIntField("dwFlags", 0),
        NDRIntField("dwSize", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pMachineName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pUserName", ""), deferred=True
        ),
        NDRIntField("dwBuildNum", 0),
        NDRIntField("dwMajorVersion", 0),
        NDRIntField("dwMinorVersion", 0),
        NDRShortField("wProcessorArchitecture", 0),
        NDRLongField("hSplPrinter", 0),
    ]


class SPLCLIENT_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Level", 0),
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "ClientInfo", SPLCLIENT_INFO_1(), SPLCLIENT_INFO_1
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 1),
                        (lambda _, val: val.tag == 1),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "ClientInfo", SPLCLIENT_INFO_2(), SPLCLIENT_INFO_2
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 2),
                        (lambda _, val: val.tag == 2),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "ClientInfo", SPLCLIENT_INFO_3(), SPLCLIENT_INFO_3
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 3),
                        (lambda _, val: val.tag == 3),
                    ),
                ),
            ],
            StrFixedLenField("ClientInfo", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
    ]


class RpcAsyncOpenPrinter_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pPrinterName", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pDatatype", "")),
        NDRPacketField("pDevModeContainer", DEVMODE_CONTAINER(), DEVMODE_CONTAINER),
        NDRIntField("AccessRequired", 0),
        NDRPacketField("pClientInfo", SPLCLIENT_CONTAINER(), SPLCLIENT_CONTAINER),
    ]


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


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 PRINTER_INFO_STRESS(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPrinterName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pServerName", ""), deferred=True
        ),
        NDRIntField("cJobs", 0),
        NDRIntField("cTotalJobs", 0),
        NDRIntField("cTotalBytes", 0),
        NDRPacketField("stUpTime", SYSTEMTIME(), SYSTEMTIME),
        NDRIntField("MaxcRef", 0),
        NDRIntField("cTotalPagesPrinted", 0),
        NDRIntField("dwGetVersion", 0),
        NDRIntField("fFreeBuild", 0),
        NDRIntField("cSpooling", 0),
        NDRIntField("cMaxSpooling", 0),
        NDRIntField("cRef", 0),
        NDRIntField("cErrorOutOfPaper", 0),
        NDRIntField("cErrorNotReady", 0),
        NDRIntField("cJobError", 0),
        NDRIntField("dwNumberOfProcessors", 0),
        NDRIntField("dwProcessorType", 0),
        NDRIntField("dwHighPartTotalBytes", 0),
        NDRIntField("cChangeID", 0),
        NDRIntField("dwLastError", 0),
        NDRIntField("Status", 0),
        NDRIntField("cEnumerateNetworkPrinters", 0),
        NDRIntField("cAddNetPrinters", 0),
        NDRShortField("wProcessorArchitecture", 0),
        NDRShortField("wProcessorLevel", 0),
        NDRIntField("cRefIC", 0),
        NDRIntField("dwReserved2", 0),
        NDRIntField("dwReserved3", 0),
    ]


class PRINTER_INFO_1(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Flags", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDescription", ""), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", ""), deferred=True),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pComment", ""), deferred=True),
    ]


class DEVMODE(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        StrFixedLenFieldUtf16("dmDeviceName", "", length=32 * 2),
        NDRShortField("dmSpecVersion", 0),
        NDRShortField("dmDriverVersion", 0),
        NDRShortField("dmSize", 0),
        NDRShortField("dmDriverExtra", 0),
        NDRIntField("dmFields", 0),
        NDRSignedShortField("dmOrientation", 0),
        NDRSignedShortField("dmPaperSize", 0),
        NDRSignedShortField("dmPaperLength", 0),
        NDRSignedShortField("dmPaperWidth", 0),
        NDRSignedShortField("dmScale", 0),
        NDRSignedShortField("dmCopies", 0),
        NDRSignedShortField("dmDefaultSource", 0),
        NDRSignedShortField("dmPrintQuality", 0),
        NDRSignedShortField("dmColor", 0),
        NDRSignedShortField("dmDuplex", 0),
        NDRSignedShortField("dmYResolution", 0),
        NDRSignedShortField("dmTTOption", 0),
        NDRSignedShortField("dmCollate", 0),
        StrFixedLenFieldUtf16("dmFormName", "", length=32 * 2),
        NDRShortField("reserved0", 0),
        NDRIntField("reserved1", 0),
        NDRIntField("reserved2", 0),
        NDRIntField("reserved3", 0),
        NDRIntField("dmNup", 0),
        NDRIntField("reserved4", 0),
        NDRIntField("dmICMMethod", 0),
        NDRIntField("dmICMIntent", 0),
        NDRIntField("dmMediaType", 0),
        NDRIntField("dmDitherType", 0),
        NDRIntField("reserved5", 0),
        NDRIntField("reserved6", 0),
        NDRIntField("reserved7", 0),
        NDRIntField("reserved8", 0),
    ]


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


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 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 PRINTER_INFO_2(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pServerName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPrinterName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pShareName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPortName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDriverName", ""), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pComment", ""), deferred=True),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pLocation", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRPacketField("pDevMode", DEVMODE(), DEVMODE), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pSepFile", ""), deferred=True),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPrintProcessor", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDatatype", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pParameters", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRPacketField(
                "pSecurityDescriptor", SECURITY_DESCRIPTOR(), SECURITY_DESCRIPTOR
            ),
            deferred=True,
        ),
        NDRIntField("Attributes", 0),
        NDRIntField("Priority", 0),
        NDRIntField("DefaultPriority", 0),
        NDRIntField("StartTime", 0),
        NDRIntField("UntilTime", 0),
        NDRIntField("Status", 0),
        NDRIntField("cJobs", 0),
        NDRIntField("AveragePPM", 0),
    ]


class PRINTER_INFO_3(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField(
                "pSecurityDescriptor", SECURITY_DESCRIPTOR(), SECURITY_DESCRIPTOR
            ),
            deferred=True,
        )
    ]


class PRINTER_INFO_4(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPrinterName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pServerName", ""), deferred=True
        ),
        NDRIntField("Attributes", 0),
    ]


class PRINTER_INFO_5(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPrinterName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPortName", ""), deferred=True
        ),
        NDRIntField("Attributes", 0),
        NDRIntField("DeviceNotSelectedTimeout", 0),
        NDRIntField("TransmissionRetryTimeout", 0),
    ]


class PRINTER_INFO_6(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("dwStatus", 0)]


class PRINTER_INFO_7(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pszObjectGUID", ""), deferred=True
        ),
        NDRIntField("dwAction", 0),
    ]


class PRINTER_INFO_8(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("pDevMode", DEVMODE(), DEVMODE), deferred=True
        )
    ]


class PRINTER_INFO_9(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("pDevMode", DEVMODE(), DEVMODE), deferred=True
        )
    ]


class PRINTER_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Level", 0),
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "PrinterInfo", PRINTER_INFO_STRESS(), PRINTER_INFO_STRESS
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 0),
                        (lambda _, val: val.tag == 0),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("PrinterInfo", PRINTER_INFO_1(), PRINTER_INFO_1),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 1),
                        (lambda _, val: val.tag == 1),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("PrinterInfo", PRINTER_INFO_2(), PRINTER_INFO_2),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 2),
                        (lambda _, val: val.tag == 2),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("PrinterInfo", PRINTER_INFO_3(), PRINTER_INFO_3),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 3),
                        (lambda _, val: val.tag == 3),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("PrinterInfo", PRINTER_INFO_4(), PRINTER_INFO_4),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 4),
                        (lambda _, val: val.tag == 4),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("PrinterInfo", PRINTER_INFO_5(), PRINTER_INFO_5),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 5),
                        (lambda _, val: val.tag == 5),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("PrinterInfo", PRINTER_INFO_6(), PRINTER_INFO_6),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 6),
                        (lambda _, val: val.tag == 6),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("PrinterInfo", PRINTER_INFO_7(), PRINTER_INFO_7),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 7),
                        (lambda _, val: val.tag == 7),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("PrinterInfo", PRINTER_INFO_8(), PRINTER_INFO_8),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 8),
                        (lambda _, val: val.tag == 8),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("PrinterInfo", PRINTER_INFO_9(), PRINTER_INFO_9),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 9),
                        (lambda _, val: val.tag == 9),
                    ),
                ),
            ],
            StrFixedLenField("PrinterInfo", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
    ]


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


class RpcAsyncAddPrinter_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRPacketField("pPrinterContainer", PRINTER_CONTAINER(), PRINTER_CONTAINER),
        NDRPacketField("pDevModeContainer", DEVMODE_CONTAINER(), DEVMODE_CONTAINER),
        NDRPacketField("pSecurityContainer", SECURITY_CONTAINER(), SECURITY_CONTAINER),
        NDRPacketField("pClientInfo", SPLCLIENT_CONTAINER(), SPLCLIENT_CONTAINER),
    ]


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


class JOB_INFO_1(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("JobId", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPrinterName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pMachineName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pUserName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDocument", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDatatype", ""), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pStatus", ""), deferred=True),
        NDRIntField("Status", 0),
        NDRIntField("Priority", 0),
        NDRIntField("Position", 0),
        NDRIntField("TotalPages", 0),
        NDRIntField("PagesPrinted", 0),
        NDRPacketField("Submitted", SYSTEMTIME(), SYSTEMTIME),
    ]


class JOB_INFO_2(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("JobId", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPrinterName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pMachineName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pUserName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDocument", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pNotifyName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDatatype", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPrintProcessor", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pParameters", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDriverName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRPacketField("pDevMode", DEVMODE(), DEVMODE), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pStatus", ""), deferred=True),
        NDRFullPointerField(
            NDRPacketField(
                "pSecurityDescriptor", SECURITY_DESCRIPTOR(), SECURITY_DESCRIPTOR
            ),
            deferred=True,
        ),
        NDRIntField("Status", 0),
        NDRIntField("Priority", 0),
        NDRIntField("Position", 0),
        NDRIntField("StartTime", 0),
        NDRIntField("UntilTime", 0),
        NDRIntField("TotalPages", 0),
        NDRIntField("Size", 0),
        NDRPacketField("Submitted", SYSTEMTIME(), SYSTEMTIME),
        NDRIntField("Time", 0),
        NDRIntField("PagesPrinted", 0),
    ]


class JOB_INFO_3(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("JobId", 0),
        NDRIntField("NextJobId", 0),
        NDRIntField("Reserved", 0),
    ]


class JOB_INFO_4(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("JobId", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPrinterName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pMachineName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pUserName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDocument", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pNotifyName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDatatype", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPrintProcessor", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pParameters", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDriverName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRPacketField("pDevMode", DEVMODE(), DEVMODE), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pStatus", ""), deferred=True),
        NDRFullPointerField(
            NDRPacketField(
                "pSecurityDescriptor", SECURITY_DESCRIPTOR(), SECURITY_DESCRIPTOR
            ),
            deferred=True,
        ),
        NDRIntField("Status", 0),
        NDRIntField("Priority", 0),
        NDRIntField("Position", 0),
        NDRIntField("StartTime", 0),
        NDRIntField("UntilTime", 0),
        NDRIntField("TotalPages", 0),
        NDRIntField("Size", 0),
        NDRPacketField("Submitted", SYSTEMTIME(), SYSTEMTIME),
        NDRIntField("Time", 0),
        NDRIntField("PagesPrinted", 0),
        NDRSignedIntField("SizeHigh", 0),
    ]


class JOB_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Level", 0),
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRPacketField("JobInfo", JOB_INFO_1(), JOB_INFO_1),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 1),
                        (lambda _, val: val.tag == 1),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("JobInfo", JOB_INFO_2(), JOB_INFO_2),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 2),
                        (lambda _, val: val.tag == 2),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("JobInfo", JOB_INFO_3(), JOB_INFO_3),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 3),
                        (lambda _, val: val.tag == 3),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("JobInfo", JOB_INFO_4(), JOB_INFO_4),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 4),
                        (lambda _, val: val.tag == 4),
                    ),
                ),
            ],
            StrFixedLenField("JobInfo", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
    ]


class RpcAsyncSetJob_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("JobId", 0),
        NDRFullPointerField(
            NDRPacketField("pJobContainer", JOB_CONTAINER(), JOB_CONTAINER)
        ),
        NDRIntField("Command", 0),
    ]


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


class RpcAsyncGetJob_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("JobId", 0),
        NDRIntField("Level", 0),
        NDRConfStrLenField("pJob", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pJob"),
    ]


class RpcAsyncGetJob_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pJob", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncEnumJobs_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("FirstJob", 0),
        NDRIntField("NoJobs", 0),
        NDRIntField("Level", 0),
        NDRConfStrLenField("pJob", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pJob"),
    ]


class RpcAsyncEnumJobs_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pJob", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncAddJob_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("Level", 0),
        NDRConfStrLenField("pAddJob", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pAddJob"),
    ]


class RpcAsyncAddJob_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pAddJob", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncScheduleJob_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("JobId", 0),
    ]


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


class RpcAsyncDeletePrinter_Request(NDRPacket):
    fields_desc = [NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle)]


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


class RpcAsyncSetPrinter_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("pPrinterContainer", PRINTER_CONTAINER(), PRINTER_CONTAINER),
        NDRPacketField("pDevModeContainer", DEVMODE_CONTAINER(), DEVMODE_CONTAINER),
        NDRPacketField("pSecurityContainer", SECURITY_CONTAINER(), SECURITY_CONTAINER),
        NDRIntField("Command", 0),
    ]


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


class RpcAsyncGetPrinter_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("Level", 0),
        NDRConfStrLenField("pPrinter", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pPrinter"),
    ]


class RpcAsyncGetPrinter_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pPrinter", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("status", 0),
    ]


class DOC_INFO_1(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pDocName", ""), deferred=True),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pOutputFile", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDatatype", ""), deferred=True
        ),
    ]


class DOC_INFO_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Level", 0),
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRPacketField("DocInfo", DOC_INFO_1(), DOC_INFO_1),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 1),
                        (lambda _, val: val.tag == 1),
                    ),
                )
            ],
            StrFixedLenField("DocInfo", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
    ]


class RpcAsyncStartDocPrinter_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("pDocInfoContainer", DOC_INFO_CONTAINER(), DOC_INFO_CONTAINER),
    ]


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


class RpcAsyncStartPagePrinter_Request(NDRPacket):
    fields_desc = [NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle)]


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


class RpcAsyncWritePrinter_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRConfStrLenField("pBuf", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pBuf"),
    ]


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


class RpcAsyncEndPagePrinter_Request(NDRPacket):
    fields_desc = [NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle)]


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


class RpcAsyncEndDocPrinter_Request(NDRPacket):
    fields_desc = [NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle)]


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


class RpcAsyncAbortPrinter_Request(NDRPacket):
    fields_desc = [NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle)]


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


class RpcAsyncGetPrinterData_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRConfVarStrNullFieldUtf16("pValueName", ""),
        NDRIntField("nSize", 0),
    ]


class RpcAsyncGetPrinterData_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pType", 0),
        NDRConfStrLenField("pData", "", size_is=lambda pkt: pkt.nSize),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncGetPrinterDataEx_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRConfVarStrNullFieldUtf16("pKeyName", ""),
        NDRConfVarStrNullFieldUtf16("pValueName", ""),
        NDRIntField("nSize", 0),
    ]


class RpcAsyncGetPrinterDataEx_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pType", 0),
        NDRConfStrLenField("pData", "", size_is=lambda pkt: pkt.nSize),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncSetPrinterData_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRConfVarStrNullFieldUtf16("pValueName", ""),
        NDRIntField("Type", 0),
        NDRConfStrLenField("pData", "", size_is=lambda pkt: pkt.cbData),
        NDRIntField("cbData", None, size_of="pData"),
    ]


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


class RpcAsyncSetPrinterDataEx_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRConfVarStrNullFieldUtf16("pKeyName", ""),
        NDRConfVarStrNullFieldUtf16("pValueName", ""),
        NDRIntField("Type", 0),
        NDRConfStrLenField("pData", "", size_is=lambda pkt: pkt.cbData),
        NDRIntField("cbData", None, size_of="pData"),
    ]


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


class RpcAsyncClosePrinter_Request(NDRPacket):
    fields_desc = [NDRPacketField("phPrinter", NDRContextHandle(), NDRContextHandle)]


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


class SIZE(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRSignedIntField("cx", 0), NDRSignedIntField("cy", 0)]


class RECTL(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRSignedIntField("left", 0),
        NDRSignedIntField("top", 0),
        NDRSignedIntField("right", 0),
        NDRSignedIntField("bottom", 0),
    ]


class FORM_INFO_1(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Flags", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", ""), deferred=True),
        NDRPacketField("Size", SIZE(), SIZE),
        NDRPacketField("ImageableArea", RECTL(), RECTL),
    ]


class RPC_FORM_INFO_2(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Flags", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", ""), deferred=True),
        NDRPacketField("Size", SIZE(), SIZE),
        NDRPacketField("ImageableArea", RECTL(), RECTL),
        NDRFullPointerField(NDRConfVarStrNullField("pKeyword", ""), deferred=True),
        NDRIntField("StringType", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pMuiDll", ""), deferred=True),
        NDRIntField("dwResourceId", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDisplayName", ""), deferred=True
        ),
        NDRShortField("wLangID", 0),
    ]


class FORM_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Level", 0),
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRPacketField("FormInfo", FORM_INFO_1(), FORM_INFO_1),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 1),
                        (lambda _, val: val.tag == 1),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("FormInfo", RPC_FORM_INFO_2(), RPC_FORM_INFO_2),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 2),
                        (lambda _, val: val.tag == 2),
                    ),
                ),
            ],
            StrFixedLenField("FormInfo", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
    ]


class RpcAsyncAddForm_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("pFormInfoContainer", FORM_CONTAINER(), FORM_CONTAINER),
    ]


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


class RpcAsyncDeleteForm_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRConfVarStrNullFieldUtf16("pFormName", ""),
    ]


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


class RpcAsyncGetForm_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRConfVarStrNullFieldUtf16("pFormName", ""),
        NDRIntField("Level", 0),
        NDRConfStrLenField("pForm", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pForm"),
    ]


class RpcAsyncGetForm_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pForm", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncSetForm_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRConfVarStrNullFieldUtf16("pFormName", ""),
        NDRPacketField("pFormInfoContainer", FORM_CONTAINER(), FORM_CONTAINER),
    ]


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


class RpcAsyncEnumForms_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("Level", 0),
        NDRConfStrLenField("pForm", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pForm"),
    ]


class RpcAsyncEnumForms_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pForm", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncGetPrinterDriver_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pEnvironment", "")),
        NDRIntField("Level", 0),
        NDRConfStrLenField("pDriver", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pDriver"),
        NDRIntField("dwClientMajorVersion", 0),
        NDRIntField("dwClientMinorVersion", 0),
    ]


class RpcAsyncGetPrinterDriver_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pDriver", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pdwServerMaxVersion", 0),
        NDRIntField("pdwServerMinVersion", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncEnumPrinterData_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("dwIndex", 0),
        NDRIntField("cbValueName", 0),
        NDRIntField("cbData", 0),
    ]


class RpcAsyncEnumPrinterData_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenFieldUtf16(
            "pValueName", "", size_is=lambda pkt: (pkt.cbValueName // 2)
        ),
        NDRIntField("pcbValueName", 0),
        NDRIntField("pType", 0),
        NDRConfStrLenField("pData", "", size_is=lambda pkt: pkt.cbData),
        NDRIntField("pcbData", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncEnumPrinterDataEx_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRConfVarStrNullFieldUtf16("pKeyName", ""),
        NDRIntField("cbEnumValues", 0),
    ]


class RpcAsyncEnumPrinterDataEx_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pEnumValues", "", size_is=lambda pkt: pkt.cbEnumValues),
        NDRIntField("pcbEnumValues", 0),
        NDRIntField("pnEnumValues", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncEnumPrinterKey_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRConfVarStrNullFieldUtf16("pKeyName", ""),
        NDRIntField("cbSubkey", 0),
    ]


class RpcAsyncEnumPrinterKey_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenFieldUtf16("pSubkey", "", size_is=lambda pkt: (pkt.cbSubkey // 2)),
        NDRIntField("pcbSubkey", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncDeletePrinterData_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRConfVarStrNullFieldUtf16("pValueName", ""),
    ]


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


class RpcAsyncDeletePrinterDataEx_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRConfVarStrNullFieldUtf16("pKeyName", ""),
        NDRConfVarStrNullFieldUtf16("pValueName", ""),
    ]


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


class RpcAsyncDeletePrinterKey_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRConfVarStrNullFieldUtf16("pKeyName", ""),
    ]


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


class RpcAsyncXcvData_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hXcv", NDRContextHandle(), NDRContextHandle),
        NDRConfVarStrNullFieldUtf16("pszDataName", ""),
        NDRConfStrLenField("pInputData", "", size_is=lambda pkt: pkt.cbInputData),
        NDRIntField("cbInputData", None, size_of="pInputData"),
        NDRIntField("cbOutputData", 0),
        NDRIntField("pdwStatus", 0),
    ]


class RpcAsyncXcvData_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pOutputData", "", size_is=lambda pkt: pkt.cbOutputData),
        NDRIntField("pcbOutputNeeded", 0),
        NDRIntField("pdwStatus", 0),
        NDRIntField("status", 0),
    ]


class BIDI_TYPE(IntEnum):
    BIDI_NULL = 0
    BIDI_INT = 1
    BIDI_FLOAT = 2
    BIDI_BOOL = 3
    BIDI_STRING = 4
    BIDI_TEXT = 5
    BIDI_ENUM = 6
    BIDI_BLOB = 7


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


class RPC_BIDI_DATA(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("dwBidiType", 0),
        NDRUnionField(
            [
                (
                    NDRSignedIntField("u", 0),
                    (
                        (
                            lambda pkt: getattr(pkt, "dwBidiType", None)
                            in [BIDI_TYPE.BIDI_NULL, BIDI_TYPE.BIDI_BOOL]
                        ),
                        (
                            lambda _, val: val.tag
                            in [BIDI_TYPE.BIDI_NULL, BIDI_TYPE.BIDI_BOOL]
                        ),
                    ),
                ),
                (
                    NDRSignedIntField("u", 0),
                    (
                        (
                            lambda pkt: getattr(pkt, "dwBidiType", None)
                            == BIDI_TYPE.BIDI_INT
                        ),
                        (lambda _, val: val.tag == BIDI_TYPE.BIDI_INT),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRConfVarStrNullFieldUtf16("u", ""), deferred=True
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "dwBidiType", None)
                            in [
                                BIDI_TYPE.BIDI_STRING,
                                BIDI_TYPE.BIDI_TEXT,
                                BIDI_TYPE.BIDI_ENUM,
                            ]
                        ),
                        (
                            lambda _, val: val.tag
                            in [
                                BIDI_TYPE.BIDI_STRING,
                                BIDI_TYPE.BIDI_TEXT,
                                BIDI_TYPE.BIDI_ENUM,
                            ]
                        ),
                    ),
                ),
                (
                    NDRIEEEFloatField("u", 0),
                    (
                        (
                            lambda pkt: getattr(pkt, "dwBidiType", None)
                            == BIDI_TYPE.BIDI_FLOAT
                        ),
                        (lambda _, val: val.tag == BIDI_TYPE.BIDI_FLOAT),
                    ),
                ),
                (
                    NDRPacketField("u", RPC_BINARY_CONTAINER(), RPC_BINARY_CONTAINER),
                    (
                        (
                            lambda pkt: getattr(pkt, "dwBidiType", None)
                            == BIDI_TYPE.BIDI_BLOB
                        ),
                        (lambda _, val: val.tag == BIDI_TYPE.BIDI_BLOB),
                    ),
                ),
            ],
            StrFixedLenField("u", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
    ]


class RPC_BIDI_REQUEST_DATA(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("dwReqNumber", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pSchema", ""), deferred=True),
        NDRPacketField("data", RPC_BIDI_DATA(), RPC_BIDI_DATA),
    ]


class RPC_BIDI_REQUEST_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["aData"]
    fields_desc = [
        NDRIntField("Version", 0),
        NDRIntField("Flags", 0),
        NDRIntField("Count", None, size_of="aData"),
        NDRConfPacketListField(
            "aData",
            [],
            RPC_BIDI_REQUEST_DATA,
            size_is=lambda pkt: pkt.Count,
            conformant_in_struct=True,
        ),
    ]


class RPC_BIDI_RESPONSE_DATA(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("dwResult", 0),
        NDRIntField("dwReqNumber", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pSchema", ""), deferred=True),
        NDRPacketField("data", RPC_BIDI_DATA(), RPC_BIDI_DATA),
    ]


class RPC_BIDI_RESPONSE_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["aData"]
    fields_desc = [
        NDRIntField("Version", 0),
        NDRIntField("Flags", 0),
        NDRIntField("Count", None, size_of="aData"),
        NDRConfPacketListField(
            "aData",
            [],
            RPC_BIDI_RESPONSE_DATA,
            size_is=lambda pkt: pkt.Count,
            conformant_in_struct=True,
        ),
    ]


class RpcAsyncSendRecvBidiData_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pAction", "")),
        NDRPacketField(
            "pReqData", RPC_BIDI_REQUEST_CONTAINER(), RPC_BIDI_REQUEST_CONTAINER
        ),
    ]


class RpcAsyncSendRecvBidiData_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField(
                "ppRespData", RPC_BIDI_RESPONSE_CONTAINER(), RPC_BIDI_RESPONSE_CONTAINER
            )
        ),
        NDRIntField("status", 0),
    ]


class RpcAsyncCreatePrinterIC_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("pDevModeContainer", DEVMODE_CONTAINER(), DEVMODE_CONTAINER),
    ]


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


class RpcAsyncPlayGdiScriptOnPrinterIC_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinterIC", NDRContextHandle(), NDRContextHandle),
        NDRConfStrLenField("pIn", "", size_is=lambda pkt: pkt.cIn),
        NDRIntField("cIn", None, size_of="pIn"),
        NDRIntField("cOut", 0),
        NDRIntField("ul", 0),
    ]


class RpcAsyncPlayGdiScriptOnPrinterIC_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pOut", "", size_is=lambda pkt: pkt.cOut),
        NDRIntField("status", 0),
    ]


class RpcAsyncDeletePrinterIC_Request(NDRPacket):
    fields_desc = [NDRPacketField("phPrinterIC", NDRContextHandle(), NDRContextHandle)]


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


class RpcAsyncEnumPrinters_Request(NDRPacket):
    fields_desc = [
        NDRIntField("Flags", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Name", "")),
        NDRIntField("Level", 0),
        NDRConfStrLenField("pPrinterEnum", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pPrinterEnum"),
    ]


class RpcAsyncEnumPrinters_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pPrinterEnum", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


class DRIVER_INFO_1(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", ""), deferred=True)
    ]


class DRIVER_INFO_2(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cVersion", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", ""), deferred=True),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pEnvironment", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDriverPath", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDataFile", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pConfigFile", ""), deferred=True
        ),
    ]


class RPC_DRIVER_INFO_3(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cVersion", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", ""), deferred=True),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pEnvironment", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDriverPath", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDataFile", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pConfigFile", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pHelpFile", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pMonitorName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDefaultDataType", ""), deferred=True
        ),
        NDRIntField("cchDependentFiles", None, size_of="pDependentFiles"),
        NDRFullPointerField(
            NDRConfStrLenFieldUtf16(
                "pDependentFiles", "", size_is=lambda pkt: pkt.cchDependentFiles
            ),
            deferred=True,
        ),
    ]


class RPC_DRIVER_INFO_4(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cVersion", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", ""), deferred=True),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pEnvironment", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDriverPath", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDataFile", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pConfigFile", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pHelpFile", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pMonitorName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDefaultDataType", ""), deferred=True
        ),
        NDRIntField("cchDependentFiles", None, size_of="pDependentFiles"),
        NDRFullPointerField(
            NDRConfStrLenFieldUtf16(
                "pDependentFiles", "", size_is=lambda pkt: pkt.cchDependentFiles
            ),
            deferred=True,
        ),
        NDRIntField("cchPreviousNames", None, size_of="pszzPreviousNames"),
        NDRFullPointerField(
            NDRConfStrLenFieldUtf16(
                "pszzPreviousNames", "", size_is=lambda pkt: pkt.cchPreviousNames
            ),
            deferred=True,
        ),
    ]


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


class RPC_DRIVER_INFO_6(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRIntField("cVersion", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", ""), deferred=True),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pEnvironment", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDriverPath", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDataFile", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pConfigFile", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pHelpFile", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pMonitorName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDefaultDataType", ""), deferred=True
        ),
        NDRIntField("cchDependentFiles", None, size_of="pDependentFiles"),
        NDRFullPointerField(
            NDRConfStrLenFieldUtf16(
                "pDependentFiles", "", size_is=lambda pkt: pkt.cchDependentFiles
            ),
            deferred=True,
        ),
        NDRIntField("cchPreviousNames", None, size_of="pszzPreviousNames"),
        NDRFullPointerField(
            NDRConfStrLenFieldUtf16(
                "pszzPreviousNames", "", size_is=lambda pkt: pkt.cchPreviousNames
            ),
            deferred=True,
        ),
        NDRPacketField("ftDriverDate", FILETIME(), FILETIME),
        NDRLongField("dwlDriverVersion", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pMfgName", ""), deferred=True),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pOEMUrl", ""), deferred=True),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pHardwareID", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pProvider", ""), deferred=True
        ),
    ]


class RPC_DRIVER_INFO_8(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRIntField("cVersion", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", ""), deferred=True),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pEnvironment", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDriverPath", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDataFile", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pConfigFile", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pHelpFile", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pMonitorName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDefaultDataType", ""), deferred=True
        ),
        NDRIntField("cchDependentFiles", None, size_of="pDependentFiles"),
        NDRFullPointerField(
            NDRConfStrLenFieldUtf16(
                "pDependentFiles", "", size_is=lambda pkt: pkt.cchDependentFiles
            ),
            deferred=True,
        ),
        NDRIntField("cchPreviousNames", None, size_of="pszzPreviousNames"),
        NDRFullPointerField(
            NDRConfStrLenFieldUtf16(
                "pszzPreviousNames", "", size_is=lambda pkt: pkt.cchPreviousNames
            ),
            deferred=True,
        ),
        NDRPacketField("ftDriverDate", FILETIME(), FILETIME),
        NDRLongField("dwlDriverVersion", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pMfgName", ""), deferred=True),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pOEMUrl", ""), deferred=True),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pHardwareID", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pProvider", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPrintProcessor", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pVendorSetup", ""), deferred=True
        ),
        NDRIntField("cchColorProfiles", None, size_of="pszzColorProfiles"),
        NDRFullPointerField(
            NDRConfStrLenFieldUtf16(
                "pszzColorProfiles", "", size_is=lambda pkt: pkt.cchColorProfiles
            ),
            deferred=True,
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pInfPath", ""), deferred=True),
        NDRIntField("dwPrinterDriverAttributes", 0),
        NDRIntField("cchCoreDependencies", None, size_of="pszzCoreDriverDependencies"),
        NDRFullPointerField(
            NDRConfStrLenFieldUtf16(
                "pszzCoreDriverDependencies",
                "",
                size_is=lambda pkt: pkt.cchCoreDependencies,
            ),
            deferred=True,
        ),
        NDRPacketField("ftMinInboxDriverVerDate", FILETIME(), FILETIME),
        NDRLongField("dwlMinInboxDriverVerVersion", 0),
    ]


class DRIVER_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Level", 0),
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRPacketField("DriverInfo", DRIVER_INFO_1(), DRIVER_INFO_1),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 1),
                        (lambda _, val: val.tag == 1),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("DriverInfo", DRIVER_INFO_2(), DRIVER_INFO_2),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 2),
                        (lambda _, val: val.tag == 2),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "DriverInfo", RPC_DRIVER_INFO_3(), RPC_DRIVER_INFO_3
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 3),
                        (lambda _, val: val.tag == 3),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "DriverInfo", RPC_DRIVER_INFO_4(), RPC_DRIVER_INFO_4
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 4),
                        (lambda _, val: val.tag == 4),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "DriverInfo", RPC_DRIVER_INFO_6(), RPC_DRIVER_INFO_6
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 6),
                        (lambda _, val: val.tag == 6),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "DriverInfo", RPC_DRIVER_INFO_8(), RPC_DRIVER_INFO_8
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 8),
                        (lambda _, val: val.tag == 8),
                    ),
                ),
            ],
            StrFixedLenField("DriverInfo", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
    ]


class RpcAsyncAddPrinterDriver_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRPacketField("pDriverContainer", DRIVER_CONTAINER(), DRIVER_CONTAINER),
        NDRIntField("dwFileCopyFlags", 0),
    ]


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


class RpcAsyncEnumPrinterDrivers_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pEnvironment", "")),
        NDRIntField("Level", 0),
        NDRConfStrLenField("pDrivers", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pDrivers"),
    ]


class RpcAsyncEnumPrinterDrivers_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pDrivers", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncGetPrinterDriverDirectory_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pEnvironment", "")),
        NDRIntField("Level", 0),
        NDRConfStrLenField("pDriverDirectory", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pDriverDirectory"),
    ]


class RpcAsyncGetPrinterDriverDirectory_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pDriverDirectory", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncDeletePrinterDriver_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRConfVarStrNullFieldUtf16("pEnvironment", ""),
        NDRConfVarStrNullFieldUtf16("pDriverName", ""),
    ]


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


class RpcAsyncDeletePrinterDriverEx_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRConfVarStrNullFieldUtf16("pEnvironment", ""),
        NDRConfVarStrNullFieldUtf16("pDriverName", ""),
        NDRIntField("dwDeleteFlag", 0),
        NDRIntField("dwVersionNum", 0),
    ]


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


class RpcAsyncAddPrintProcessor_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRConfVarStrNullFieldUtf16("pEnvironment", ""),
        NDRConfVarStrNullFieldUtf16("pPathName", ""),
        NDRConfVarStrNullFieldUtf16("pPrintProcessorName", ""),
    ]


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


class RpcAsyncEnumPrintProcessors_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pEnvironment", "")),
        NDRIntField("Level", 0),
        NDRConfStrLenField("pPrintProcessorInfo", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pPrintProcessorInfo"),
    ]


class RpcAsyncEnumPrintProcessors_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pPrintProcessorInfo", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncGetPrintProcessorDirectory_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pEnvironment", "")),
        NDRIntField("Level", 0),
        NDRConfStrLenField(
            "pPrintProcessorDirectory", "", size_is=lambda pkt: pkt.cbBuf
        ),
        NDRIntField("cbBuf", None, size_of="pPrintProcessorDirectory"),
    ]


class RpcAsyncGetPrintProcessorDirectory_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField(
            "pPrintProcessorDirectory", "", size_is=lambda pkt: pkt.cbBuf
        ),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncEnumPorts_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRIntField("Level", 0),
        NDRConfStrLenField("pPort", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pPort"),
    ]


class RpcAsyncEnumPorts_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pPort", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncEnumMonitors_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRIntField("Level", 0),
        NDRConfStrLenField("pMonitor", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pMonitor"),
    ]


class RpcAsyncEnumMonitors_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pMonitor", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


class PORT_INFO_1(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pPortName", ""), deferred=True)
    ]


class PORT_INFO_2(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPortName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pMonitorName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDescription", ""), deferred=True
        ),
        NDRIntField("fPortType", 0),
        NDRIntField("Reserved", 0),
    ]


class PORT_INFO_3(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("dwStatus", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pszStatus", ""), deferred=True
        ),
        NDRIntField("dwSeverity", 0),
    ]


class PORT_INFO_FF(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPortName", ""), deferred=True
        ),
        NDRIntField("cbMonitorData", 0),
        NDRFullPointerField(NDRByteField("pMonitorData", 0), deferred=True),
    ]


class PORT_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Level", 0),
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRPacketField("PortInfo", PORT_INFO_1(), PORT_INFO_1),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: (16777215 & getattr(pkt, "Level", None)) == 1),
                        (lambda _, val: val.tag == 1),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("PortInfo", PORT_INFO_2(), PORT_INFO_2),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: (16777215 & getattr(pkt, "Level", None)) == 2),
                        (lambda _, val: val.tag == 2),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("PortInfo", PORT_INFO_3(), PORT_INFO_3),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: (16777215 & getattr(pkt, "Level", None)) == 3),
                        (lambda _, val: val.tag == 3),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("PortInfo", PORT_INFO_FF(), PORT_INFO_FF),
                        deferred=True,
                    ),
                    (
                        (
                            lambda pkt: (16777215 & getattr(pkt, "Level", None))
                            == 16777215
                        ),
                        (lambda _, val: val.tag == 16777215),
                    ),
                ),
            ],
            StrFixedLenField("PortInfo", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
    ]


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


class RpcAsyncAddPort_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRPacketField("pPortContainer", PORT_CONTAINER(), PORT_CONTAINER),
        NDRPacketField("pPortVarContainer", PORT_VAR_CONTAINER(), PORT_VAR_CONTAINER),
        NDRConfVarStrNullFieldUtf16("pMonitorName", ""),
    ]


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


class RpcAsyncSetPort_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pPortName", "")),
        NDRPacketField("pPortContainer", PORT_CONTAINER(), PORT_CONTAINER),
    ]


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


class MONITOR_INFO_1(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", ""), deferred=True)
    ]


class MONITOR_INFO_2(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", ""), deferred=True),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pEnvironment", ""), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pDLLName", ""), deferred=True),
    ]


class MONITOR_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Level", 0),
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRPacketField("MonitorInfo", MONITOR_INFO_1(), MONITOR_INFO_1),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 1),
                        (lambda _, val: val.tag == 1),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("MonitorInfo", MONITOR_INFO_2(), MONITOR_INFO_2),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 2),
                        (lambda _, val: val.tag == 2),
                    ),
                ),
            ],
            StrFixedLenField("MonitorInfo", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
    ]


class RpcAsyncAddMonitor_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Name", "")),
        NDRPacketField("pMonitorContainer", MONITOR_CONTAINER(), MONITOR_CONTAINER),
    ]


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


class RpcAsyncDeleteMonitor_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Name", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pEnvironment", "")),
        NDRConfVarStrNullFieldUtf16("pMonitorName", ""),
    ]


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


class RpcAsyncDeletePrintProcessor_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Name", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pEnvironment", "")),
        NDRConfVarStrNullFieldUtf16("pPrintProcessorName", ""),
    ]


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


class RpcAsyncEnumPrintProcessorDatatypes_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pPrintProcessorName", "")),
        NDRIntField("Level", 0),
        NDRConfStrLenField("pDatatypes", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pDatatypes"),
    ]


class RpcAsyncEnumPrintProcessorDatatypes_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pDatatypes", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncAddPerMachineConnection_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pServer", "")),
        NDRConfVarStrNullFieldUtf16("pPrinterName", ""),
        NDRConfVarStrNullFieldUtf16("pPrintServer", ""),
        NDRConfVarStrNullFieldUtf16("pProvider", ""),
    ]


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


class RpcAsyncDeletePerMachineConnection_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pServer", "")),
        NDRConfVarStrNullFieldUtf16("pPrinterName", ""),
    ]


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


class RpcAsyncEnumPerMachineConnections_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pServer", "")),
        NDRConfStrLenField("pPrinterEnum", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("cbBuf", None, size_of="pPrinterEnum"),
    ]


class RpcAsyncEnumPerMachineConnections_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pPrinterEnum", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


class EPrintPropertyType(IntEnum):
    kPropertyTypeString = 1
    kPropertyTypeInt32 = 2
    kPropertyTypeInt64 = 3
    kPropertyTypeByte = 4
    kPropertyTypeTime = 5
    kPropertyTypeDevMode = 6
    kPropertyTypeSD = 7
    kPropertyTypeNotificationReply = 8
    kPropertyTypeNotificationOptions = 9


class SYSTEMTIME_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cbBuf", 0),
        NDRFullPointerField(
            NDRPacketField("pSystemTime", SYSTEMTIME(), SYSTEMTIME), deferred=True
        ),
    ]


class STRING_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cbBuf", None, size_of="pszString", adjust=lambda _, x: (x * 2)),
        NDRFullPointerField(
            NDRConfStrLenFieldUtf16(
                "pszString", "", size_is=lambda pkt: (pkt.cbBuf // 2)
            ),
            deferred=True,
        ),
    ]


class RPC_V2_NOTIFY_INFO_DATA(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRShortField("Type", 0),
        NDRShortField("Field", 0),
        NDRIntField("Reserved", 0),
        NDRIntField("Id", 0),
        NDRUnionField(
            [
                (
                    NDRPacketField("Data", STRING_CONTAINER(), STRING_CONTAINER),
                    (
                        (
                            lambda pkt: (getattr(pkt, "Reserved", None) & 65535)
                            == DWORD.TABLE_STRING
                        ),
                        (lambda _, val: val.tag == DWORD.TABLE_STRING),
                    ),
                ),
                (
                    NDRFieldListField(
                        "Data", [], NDRIntField("", 0), length_is=lambda _: 2
                    ),
                    (
                        (
                            lambda pkt: (getattr(pkt, "Reserved", None) & 65535)
                            == DWORD.TABLE_DWORD
                        ),
                        (lambda _, val: val.tag == DWORD.TABLE_DWORD),
                    ),
                ),
                (
                    NDRPacketField(
                        "Data", SYSTEMTIME_CONTAINER(), SYSTEMTIME_CONTAINER
                    ),
                    (
                        (
                            lambda pkt: (getattr(pkt, "Reserved", None) & 65535)
                            == DWORD.TABLE_TIME
                        ),
                        (lambda _, val: val.tag == DWORD.TABLE_TIME),
                    ),
                ),
                (
                    NDRPacketField("Data", DEVMODE_CONTAINER(), DEVMODE_CONTAINER),
                    (
                        (
                            lambda pkt: (getattr(pkt, "Reserved", None) & 65535)
                            == DWORD.TABLE_DEVMODE
                        ),
                        (lambda _, val: val.tag == DWORD.TABLE_DEVMODE),
                    ),
                ),
                (
                    NDRPacketField("Data", SECURITY_CONTAINER(), SECURITY_CONTAINER),
                    (
                        (
                            lambda pkt: (getattr(pkt, "Reserved", None) & 65535)
                            == DWORD.TABLE_SECURITYDESCRIPTOR
                        ),
                        (lambda _, val: val.tag == DWORD.TABLE_SECURITYDESCRIPTOR),
                    ),
                ),
            ],
            StrFixedLenField("Data", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
    ]


class RPC_V2_NOTIFY_INFO(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["aData"]
    fields_desc = [
        NDRIntField("Version", 0),
        NDRIntField("Flags", 0),
        NDRIntField("Count", None, size_of="aData"),
        NDRConfPacketListField(
            "aData",
            [],
            RPC_V2_NOTIFY_INFO_DATA,
            size_is=lambda pkt: pkt.Count,
            conformant_in_struct=True,
        ),
    ]


class NOTIFY_REPLY_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("pInfo", RPC_V2_NOTIFY_INFO(), RPC_V2_NOTIFY_INFO),
            deferred=True,
        )
    ]


class RPC_V2_NOTIFY_OPTIONS_TYPE(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRShortField("Type", 0),
        NDRShortField("Reserved0", 0),
        NDRIntField("Reserved1", 0),
        NDRIntField("Reserved2", 0),
        NDRIntField("Count", None, size_of="pFields"),
        NDRFullPointerField(
            NDRConfStrLenFieldUtf16("pFields", "", size_is=lambda pkt: pkt.Count),
            deferred=True,
        ),
    ]


class RPC_V2_NOTIFY_OPTIONS(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Version", 0),
        NDRIntField("Reserved", 0),
        NDRIntField("Count", None, size_of="pTypes"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "pTypes", [], RPC_V2_NOTIFY_OPTIONS_TYPE, size_is=lambda pkt: pkt.Count
            ),
            deferred=True,
        ),
    ]


class NOTIFY_OPTIONS_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("pOptions", RPC_V2_NOTIFY_OPTIONS(), RPC_V2_NOTIFY_OPTIONS),
            deferred=True,
        )
    ]


class RpcPrintPropertyValue(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRInt3264EnumField("ePropertyType", 0, EPrintPropertyType),
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRConfVarStrNullFieldUtf16("value", ""), deferred=True
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "ePropertyType", None)
                            == EPrintPropertyType.kPropertyTypeString
                        ),
                        (
                            lambda _, val: val.tag
                            == EPrintPropertyType.kPropertyTypeString
                        ),
                    ),
                ),
                (
                    NDRSignedIntField("value", 0),
                    (
                        (
                            lambda pkt: getattr(pkt, "ePropertyType", None)
                            == EPrintPropertyType.kPropertyTypeInt32
                        ),
                        (
                            lambda _, val: val.tag
                            == EPrintPropertyType.kPropertyTypeInt32
                        ),
                    ),
                ),
                (
                    NDRSignedLongField("value", 0),
                    (
                        (
                            lambda pkt: getattr(pkt, "ePropertyType", None)
                            == EPrintPropertyType.kPropertyTypeInt64
                        ),
                        (
                            lambda _, val: val.tag
                            == EPrintPropertyType.kPropertyTypeInt64
                        ),
                    ),
                ),
                (
                    NDRByteField("value", 0),
                    (
                        (
                            lambda pkt: getattr(pkt, "ePropertyType", None)
                            == EPrintPropertyType.kPropertyTypeByte
                        ),
                        (
                            lambda _, val: val.tag
                            == EPrintPropertyType.kPropertyTypeByte
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "value", SYSTEMTIME_CONTAINER(), SYSTEMTIME_CONTAINER
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "ePropertyType", None)
                            == EPrintPropertyType.kPropertyTypeTime
                        ),
                        (
                            lambda _, val: val.tag
                            == EPrintPropertyType.kPropertyTypeTime
                        ),
                    ),
                ),
                (
                    NDRPacketField("value", DEVMODE_CONTAINER(), DEVMODE_CONTAINER),
                    (
                        (
                            lambda pkt: getattr(pkt, "ePropertyType", None)
                            == EPrintPropertyType.kPropertyTypeDevMode
                        ),
                        (
                            lambda _, val: val.tag
                            == EPrintPropertyType.kPropertyTypeDevMode
                        ),
                    ),
                ),
                (
                    NDRPacketField("value", SECURITY_CONTAINER(), SECURITY_CONTAINER),
                    (
                        (
                            lambda pkt: getattr(pkt, "ePropertyType", None)
                            == EPrintPropertyType.kPropertyTypeSD
                        ),
                        (lambda _, val: val.tag == EPrintPropertyType.kPropertyTypeSD),
                    ),
                ),
                (
                    NDRPacketField(
                        "value", NOTIFY_REPLY_CONTAINER(), NOTIFY_REPLY_CONTAINER
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "ePropertyType", None)
                            == EPrintPropertyType.kPropertyTypeNotificationReply
                        ),
                        (
                            lambda _, val: val.tag
                            == EPrintPropertyType.kPropertyTypeNotificationReply
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "value", NOTIFY_OPTIONS_CONTAINER(), NOTIFY_OPTIONS_CONTAINER
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "ePropertyType", None)
                            == EPrintPropertyType.kPropertyTypeNotificationOptions
                        ),
                        (
                            lambda _, val: val.tag
                            == EPrintPropertyType.kPropertyTypeNotificationOptions
                        ),
                    ),
                ),
            ],
            StrFixedLenField("value", "", length=0),
            align=(2, 8),
            switch_fmt=("H", "I"),
        ),
    ]


class RpcPrintNamedProperty(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("propertyName", ""), deferred=True
        ),
        NDRPacketField("propertyValue", RpcPrintPropertyValue(), RpcPrintPropertyValue),
    ]


class RpcPrintPropertiesCollection(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("numberOfProperties", None, size_of="propertiesCollection"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "propertiesCollection",
                [],
                RpcPrintNamedProperty,
                size_is=lambda pkt: pkt.numberOfProperties,
            ),
            deferred=True,
        ),
    ]


class RpcSyncRegisterForRemoteNotifications_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRPacketField(
            "pNotifyFilter",
            RpcPrintPropertiesCollection(),
            RpcPrintPropertiesCollection,
        ),
    ]


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


class RpcSyncUnRegisterForRemoteNotifications_Request(NDRPacket):
    fields_desc = [NDRPacketField("phRpcHandle", NDRContextHandle(), NDRContextHandle)]


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


class RpcSyncRefreshRemoteNotifications_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hRpcHandle", NDRContextHandle(), NDRContextHandle),
        NDRPacketField(
            "pNotifyFilter",
            RpcPrintPropertiesCollection(),
            RpcPrintPropertiesCollection,
        ),
    ]


class RpcSyncRefreshRemoteNotifications_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField(
                "ppNotifyData",
                RpcPrintPropertiesCollection(),
                RpcPrintPropertiesCollection,
            )
        ),
        NDRIntField("status", 0),
    ]


class RpcAsyncGetRemoteNotifications_Request(NDRPacket):
    fields_desc = [NDRPacketField("hRpcHandle", NDRContextHandle(), NDRContextHandle)]


class RpcAsyncGetRemoteNotifications_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField(
                "ppNotifyData",
                RpcPrintPropertiesCollection(),
                RpcPrintPropertiesCollection,
            )
        ),
        NDRIntField("status", 0),
    ]


class RpcAsyncInstallPrinterDriverFromPackage_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pszServer", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pszInfPath", "")),
        NDRConfVarStrNullFieldUtf16("pszDriverName", ""),
        NDRConfVarStrNullFieldUtf16("pszEnvironment", ""),
        NDRIntField("dwFlags", 0),
    ]


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


class RpcAsyncUploadPrinterDriverPackage_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pszServer", "")),
        NDRConfVarStrNullFieldUtf16("pszInfPath", ""),
        NDRConfVarStrNullFieldUtf16("pszEnvironment", ""),
        NDRIntField("dwFlags", 0),
        NDRConfStrLenFieldUtf16(
            "pszDestInfPath", "", size_is=lambda pkt: pkt.pcchDestInfPath
        ),
        NDRIntField("pcchDestInfPath", None, size_of="pszDestInfPath"),
    ]


class RpcAsyncUploadPrinterDriverPackage_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenFieldUtf16(
            "pszDestInfPath", "", size_is=lambda pkt: pkt.pcchDestInfPath
        ),
        NDRIntField("pcchDestInfPath", None, size_of="pszDestInfPath"),
        NDRIntField("status", 0),
    ]


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


class CORE_PRINTER_DRIVER(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRPacketField("CoreDriverGUID", GUID(), GUID),
        NDRPacketField("ftDriverDate", FILETIME(), FILETIME),
        NDRLongField("dwlDriverVersion", 0),
        StrFixedLenFieldUtf16("szPackageID", "", length=260 * 2),
    ]


class RpcAsyncGetCorePrinterDrivers_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pszServer", "")),
        NDRConfVarStrNullFieldUtf16("pszEnvironment", ""),
        NDRIntField("cchCoreDrivers", None, size_of="pszzCoreDriverDependencies"),
        NDRConfStrLenFieldUtf16(
            "pszzCoreDriverDependencies", "", size_is=lambda pkt: pkt.cchCoreDrivers
        ),
        NDRIntField("cCorePrinterDrivers", 0),
    ]


class RpcAsyncGetCorePrinterDrivers_Response(NDRPacket):
    fields_desc = [
        NDRConfPacketListField(
            "pCorePrinterDrivers",
            [],
            CORE_PRINTER_DRIVER,
            size_is=lambda pkt: pkt.cCorePrinterDrivers,
        ),
        NDRIntField("status", 0),
    ]


class RpcAsyncCorePrinterDriverInstalled_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pszServer", "")),
        NDRConfVarStrNullFieldUtf16("pszEnvironment", ""),
        NDRPacketField("CoreDriverGUID", GUID(), GUID),
        NDRPacketField("ftDriverDate", FILETIME(), FILETIME),
        NDRLongField("dwlDriverVersion", 0),
    ]


class RpcAsyncCorePrinterDriverInstalled_Response(NDRPacket):
    fields_desc = [NDRSignedIntField("pbDriverInstalled", 0), NDRIntField("status", 0)]


class RpcAsyncGetPrinterDriverPackagePath_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pszServer", "")),
        NDRConfVarStrNullFieldUtf16("pszEnvironment", ""),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pszLanguage", "")),
        NDRConfVarStrNullFieldUtf16("pszPackageID", ""),
        NDRConfStrLenFieldUtf16(
            "pszDriverPackageCab", "", size_is=lambda pkt: pkt.cchDriverPackageCab
        ),
        NDRIntField("cchDriverPackageCab", None, size_of="pszDriverPackageCab"),
    ]


class RpcAsyncGetPrinterDriverPackagePath_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenFieldUtf16(
            "pszDriverPackageCab", "", size_is=lambda pkt: pkt.cchDriverPackageCab
        ),
        NDRIntField("pcchRequiredSize", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncDeletePrinterDriverPackage_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pszServer", "")),
        NDRConfVarStrNullFieldUtf16("pszInfPath", ""),
        NDRConfVarStrNullFieldUtf16("pszEnvironment", ""),
    ]


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


class RpcAsyncReadPrinter_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("cbBuf", 0),
    ]


class RpcAsyncReadPrinter_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pBuf", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcNoBytesRead", 0),
        NDRIntField("status", 0),
    ]


class RpcAsyncResetPrinter_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pDatatype", "")),
        NDRPacketField("pDevModeContainer", DEVMODE_CONTAINER(), DEVMODE_CONTAINER),
    ]


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


class RPC_EPrintPropertyType(IntEnum):
    kRpcPropertyTypeString = 1
    kRpcPropertyTypeInt32 = 2
    kRpcPropertyTypeInt64 = 3
    kRpcPropertyTypeByte = 4
    kRpcPropertyTypeBuffer = 5


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


class RPC_PrintPropertyValue(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRInt3264EnumField("ePropertyType", 0, RPC_EPrintPropertyType),
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRConfVarStrNullFieldUtf16("value", ""), deferred=True
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "ePropertyType", None)
                            == RPC_EPrintPropertyType.kRpcPropertyTypeString
                        ),
                        (
                            lambda _, val: val.tag
                            == RPC_EPrintPropertyType.kRpcPropertyTypeString
                        ),
                    ),
                ),
                (
                    NDRSignedIntField("value", 0),
                    (
                        (
                            lambda pkt: getattr(pkt, "ePropertyType", None)
                            == RPC_EPrintPropertyType.kRpcPropertyTypeInt32
                        ),
                        (
                            lambda _, val: val.tag
                            == RPC_EPrintPropertyType.kRpcPropertyTypeInt32
                        ),
                    ),
                ),
                (
                    NDRSignedLongField("value", 0),
                    (
                        (
                            lambda pkt: getattr(pkt, "ePropertyType", None)
                            == RPC_EPrintPropertyType.kRpcPropertyTypeInt64
                        ),
                        (
                            lambda _, val: val.tag
                            == RPC_EPrintPropertyType.kRpcPropertyTypeInt64
                        ),
                    ),
                ),
                (
                    NDRByteField("value", 0),
                    (
                        (
                            lambda pkt: getattr(pkt, "ePropertyType", None)
                            == RPC_EPrintPropertyType.kRpcPropertyTypeByte
                        ),
                        (
                            lambda _, val: val.tag
                            == RPC_EPrintPropertyType.kRpcPropertyTypeByte
                        ),
                    ),
                ),
                (
                    NDRPacketField("value", propertyBlob_sub4(), propertyBlob_sub4),
                    (
                        (
                            lambda pkt: getattr(pkt, "ePropertyType", None)
                            == RPC_EPrintPropertyType.kRpcPropertyTypeBuffer
                        ),
                        (
                            lambda _, val: val.tag
                            == RPC_EPrintPropertyType.kRpcPropertyTypeBuffer
                        ),
                    ),
                ),
            ],
            StrFixedLenField("value", "", length=0),
            align=(2, 8),
            switch_fmt=("H", "I"),
        ),
    ]


class RpcAsyncGetJobNamedPropertyValue_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("JobId", 0),
        NDRConfVarStrNullFieldUtf16("pszName", ""),
    ]


class RpcAsyncGetJobNamedPropertyValue_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pValue", RPC_PrintPropertyValue(), RPC_PrintPropertyValue),
        NDRIntField("status", 0),
    ]


class RPC_PrintNamedProperty(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("propertyName", ""), deferred=True
        ),
        NDRPacketField(
            "propertyValue", RPC_PrintPropertyValue(), RPC_PrintPropertyValue
        ),
    ]


class RpcAsyncSetJobNamedProperty_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("JobId", 0),
        NDRPacketField("pProperty", RPC_PrintNamedProperty(), RPC_PrintNamedProperty),
    ]


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


class RpcAsyncDeleteJobNamedProperty_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("JobId", 0),
        NDRConfVarStrNullFieldUtf16("pszName", ""),
    ]


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


class RpcAsyncEnumJobNamedProperties_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("JobId", 0),
    ]


class RpcAsyncEnumJobNamedProperties_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pcProperties", None, size_of="ppProperties"),
        NDRConfPacketListField(
            "ppProperties",
            [],
            RPC_PrintNamedProperty,
            size_is=lambda pkt: pkt.pcProperties,
            ptr_pack=True,
        ),
        NDRIntField("status", 0),
    ]


class EBranchOfficeJobEventType(IntEnum):
    kInvalidJobState = 0
    kLogJobPrinted = 1
    kLogJobRendered = 2
    kLogJobError = 3
    kLogJobPipelineError = 4
    kLogOfflineFileFull = 5


class RPC_BranchOfficeJobDataPrinted(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRIntField("Status", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDocumentName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pUserName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pMachineName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPrinterName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPortName", ""), deferred=True
        ),
        NDRSignedLongField("Size", 0),
        NDRIntField("TotalPages", 0),
    ]


class RPC_BranchOfficeJobDataRendered(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRSignedLongField("Size", 0),
        NDRIntField("ICMMethod", 0),
        NDRSignedShortField("Color", 0),
        NDRSignedShortField("PrintQuality", 0),
        NDRSignedShortField("YResolution", 0),
        NDRSignedShortField("Copies", 0),
        NDRSignedShortField("TTOption", 0),
    ]


class RPC_BranchOfficeJobDataError(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRIntField("LastError", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDocumentName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pUserName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPrinterName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDataType", ""), deferred=True
        ),
        NDRSignedLongField("TotalSize", 0),
        NDRSignedLongField("PrintedSize", 0),
        NDRIntField("TotalPages", 0),
        NDRIntField("PrintedPages", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pMachineName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pJobError", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pErrorDescription", ""), deferred=True
        ),
    ]


class RPC_BranchOfficeJobDataPipelineFailed(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDocumentName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPrinterName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pExtraErrorInfo", ""), deferred=True
        ),
    ]


class RPC_BranchOfficeLogOfflineFileFull(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pMachineName", ""), deferred=True
        )
    ]


class RPC_BranchOfficeJobData(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRInt3264EnumField("eEventType", 0, EBranchOfficeJobEventType),
        NDRIntField("JobId", 0),
        NDRUnionField(
            [
                (
                    NDRPacketField(
                        "JobInfo",
                        RPC_BranchOfficeJobDataPrinted(),
                        RPC_BranchOfficeJobDataPrinted,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "eEventType", None)
                            == EBranchOfficeJobEventType.kLogJobPrinted
                        ),
                        (
                            lambda _, val: val.tag
                            == EBranchOfficeJobEventType.kLogJobPrinted
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "JobInfo",
                        RPC_BranchOfficeJobDataRendered(),
                        RPC_BranchOfficeJobDataRendered,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "eEventType", None)
                            == EBranchOfficeJobEventType.kLogJobRendered
                        ),
                        (
                            lambda _, val: val.tag
                            == EBranchOfficeJobEventType.kLogJobRendered
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "JobInfo",
                        RPC_BranchOfficeJobDataError(),
                        RPC_BranchOfficeJobDataError,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "eEventType", None)
                            == EBranchOfficeJobEventType.kLogJobError
                        ),
                        (
                            lambda _, val: val.tag
                            == EBranchOfficeJobEventType.kLogJobError
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "JobInfo",
                        RPC_BranchOfficeJobDataPipelineFailed(),
                        RPC_BranchOfficeJobDataPipelineFailed,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "eEventType", None)
                            == EBranchOfficeJobEventType.kLogJobPipelineError
                        ),
                        (
                            lambda _, val: val.tag
                            == EBranchOfficeJobEventType.kLogJobPipelineError
                        ),
                    ),
                ),
                (
                    NDRPacketField(
                        "JobInfo",
                        RPC_BranchOfficeLogOfflineFileFull(),
                        RPC_BranchOfficeLogOfflineFileFull,
                    ),
                    (
                        (
                            lambda pkt: getattr(pkt, "eEventType", None)
                            == EBranchOfficeJobEventType.kLogOfflineFileFull
                        ),
                        (
                            lambda _, val: val.tag
                            == EBranchOfficeJobEventType.kLogOfflineFileFull
                        ),
                    ),
                ),
            ],
            StrFixedLenField("JobInfo", "", length=0),
            align=(2, 8),
            switch_fmt=("H", "I"),
        ),
    ]


class RPC_BranchOfficeJobDataContainer(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["JobData"]
    fields_desc = [
        NDRIntField("cJobDataEntries", None, size_of="JobData"),
        NDRConfPacketListField(
            "JobData",
            [],
            RPC_BranchOfficeJobData,
            size_is=lambda pkt: pkt.cJobDataEntries,
            conformant_in_struct=True,
        ),
    ]


class RpcAsyncLogJobInfoForBranchOffice_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRPacketField(
            "pBranchOfficeJobDataContainer",
            RPC_BranchOfficeJobDataContainer(),
            RPC_BranchOfficeJobDataContainer,
        ),
    ]


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


IREMOTEWINSPOOL_OPNUMS = {
    0: DceRpcOp(RpcAsyncOpenPrinter_Request, RpcAsyncOpenPrinter_Response),
    1: DceRpcOp(RpcAsyncAddPrinter_Request, RpcAsyncAddPrinter_Response),
    2: DceRpcOp(RpcAsyncSetJob_Request, RpcAsyncSetJob_Response),
    3: DceRpcOp(RpcAsyncGetJob_Request, RpcAsyncGetJob_Response),
    4: DceRpcOp(RpcAsyncEnumJobs_Request, RpcAsyncEnumJobs_Response),
    5: DceRpcOp(RpcAsyncAddJob_Request, RpcAsyncAddJob_Response),
    6: DceRpcOp(RpcAsyncScheduleJob_Request, RpcAsyncScheduleJob_Response),
    7: DceRpcOp(RpcAsyncDeletePrinter_Request, RpcAsyncDeletePrinter_Response),
    8: DceRpcOp(RpcAsyncSetPrinter_Request, RpcAsyncSetPrinter_Response),
    9: DceRpcOp(RpcAsyncGetPrinter_Request, RpcAsyncGetPrinter_Response),
    10: DceRpcOp(RpcAsyncStartDocPrinter_Request, RpcAsyncStartDocPrinter_Response),
    11: DceRpcOp(RpcAsyncStartPagePrinter_Request, RpcAsyncStartPagePrinter_Response),
    12: DceRpcOp(RpcAsyncWritePrinter_Request, RpcAsyncWritePrinter_Response),
    13: DceRpcOp(RpcAsyncEndPagePrinter_Request, RpcAsyncEndPagePrinter_Response),
    14: DceRpcOp(RpcAsyncEndDocPrinter_Request, RpcAsyncEndDocPrinter_Response),
    15: DceRpcOp(RpcAsyncAbortPrinter_Request, RpcAsyncAbortPrinter_Response),
    16: DceRpcOp(RpcAsyncGetPrinterData_Request, RpcAsyncGetPrinterData_Response),
    17: DceRpcOp(RpcAsyncGetPrinterDataEx_Request, RpcAsyncGetPrinterDataEx_Response),
    18: DceRpcOp(RpcAsyncSetPrinterData_Request, RpcAsyncSetPrinterData_Response),
    19: DceRpcOp(RpcAsyncSetPrinterDataEx_Request, RpcAsyncSetPrinterDataEx_Response),
    20: DceRpcOp(RpcAsyncClosePrinter_Request, RpcAsyncClosePrinter_Response),
    21: DceRpcOp(RpcAsyncAddForm_Request, RpcAsyncAddForm_Response),
    22: DceRpcOp(RpcAsyncDeleteForm_Request, RpcAsyncDeleteForm_Response),
    23: DceRpcOp(RpcAsyncGetForm_Request, RpcAsyncGetForm_Response),
    24: DceRpcOp(RpcAsyncSetForm_Request, RpcAsyncSetForm_Response),
    25: DceRpcOp(RpcAsyncEnumForms_Request, RpcAsyncEnumForms_Response),
    26: DceRpcOp(RpcAsyncGetPrinterDriver_Request, RpcAsyncGetPrinterDriver_Response),
    27: DceRpcOp(RpcAsyncEnumPrinterData_Request, RpcAsyncEnumPrinterData_Response),
    28: DceRpcOp(RpcAsyncEnumPrinterDataEx_Request, RpcAsyncEnumPrinterDataEx_Response),
    29: DceRpcOp(RpcAsyncEnumPrinterKey_Request, RpcAsyncEnumPrinterKey_Response),
    30: DceRpcOp(RpcAsyncDeletePrinterData_Request, RpcAsyncDeletePrinterData_Response),
    31: DceRpcOp(
        RpcAsyncDeletePrinterDataEx_Request, RpcAsyncDeletePrinterDataEx_Response
    ),
    32: DceRpcOp(RpcAsyncDeletePrinterKey_Request, RpcAsyncDeletePrinterKey_Response),
    33: DceRpcOp(RpcAsyncXcvData_Request, RpcAsyncXcvData_Response),
    34: DceRpcOp(RpcAsyncSendRecvBidiData_Request, RpcAsyncSendRecvBidiData_Response),
    35: DceRpcOp(RpcAsyncCreatePrinterIC_Request, RpcAsyncCreatePrinterIC_Response),
    36: DceRpcOp(
        RpcAsyncPlayGdiScriptOnPrinterIC_Request,
        RpcAsyncPlayGdiScriptOnPrinterIC_Response,
    ),
    37: DceRpcOp(RpcAsyncDeletePrinterIC_Request, RpcAsyncDeletePrinterIC_Response),
    38: DceRpcOp(RpcAsyncEnumPrinters_Request, RpcAsyncEnumPrinters_Response),
    39: DceRpcOp(RpcAsyncAddPrinterDriver_Request, RpcAsyncAddPrinterDriver_Response),
    40: DceRpcOp(
        RpcAsyncEnumPrinterDrivers_Request, RpcAsyncEnumPrinterDrivers_Response
    ),
    41: DceRpcOp(
        RpcAsyncGetPrinterDriverDirectory_Request,
        RpcAsyncGetPrinterDriverDirectory_Response,
    ),
    42: DceRpcOp(
        RpcAsyncDeletePrinterDriver_Request, RpcAsyncDeletePrinterDriver_Response
    ),
    43: DceRpcOp(
        RpcAsyncDeletePrinterDriverEx_Request, RpcAsyncDeletePrinterDriverEx_Response
    ),
    44: DceRpcOp(RpcAsyncAddPrintProcessor_Request, RpcAsyncAddPrintProcessor_Response),
    45: DceRpcOp(
        RpcAsyncEnumPrintProcessors_Request, RpcAsyncEnumPrintProcessors_Response
    ),
    46: DceRpcOp(
        RpcAsyncGetPrintProcessorDirectory_Request,
        RpcAsyncGetPrintProcessorDirectory_Response,
    ),
    47: DceRpcOp(RpcAsyncEnumPorts_Request, RpcAsyncEnumPorts_Response),
    48: DceRpcOp(RpcAsyncEnumMonitors_Request, RpcAsyncEnumMonitors_Response),
    49: DceRpcOp(RpcAsyncAddPort_Request, RpcAsyncAddPort_Response),
    50: DceRpcOp(RpcAsyncSetPort_Request, RpcAsyncSetPort_Response),
    51: DceRpcOp(RpcAsyncAddMonitor_Request, RpcAsyncAddMonitor_Response),
    52: DceRpcOp(RpcAsyncDeleteMonitor_Request, RpcAsyncDeleteMonitor_Response),
    53: DceRpcOp(
        RpcAsyncDeletePrintProcessor_Request, RpcAsyncDeletePrintProcessor_Response
    ),
    54: DceRpcOp(
        RpcAsyncEnumPrintProcessorDatatypes_Request,
        RpcAsyncEnumPrintProcessorDatatypes_Response,
    ),
    55: DceRpcOp(
        RpcAsyncAddPerMachineConnection_Request,
        RpcAsyncAddPerMachineConnection_Response,
    ),
    56: DceRpcOp(
        RpcAsyncDeletePerMachineConnection_Request,
        RpcAsyncDeletePerMachineConnection_Response,
    ),
    57: DceRpcOp(
        RpcAsyncEnumPerMachineConnections_Request,
        RpcAsyncEnumPerMachineConnections_Response,
    ),
    58: DceRpcOp(
        RpcSyncRegisterForRemoteNotifications_Request,
        RpcSyncRegisterForRemoteNotifications_Response,
    ),
    59: DceRpcOp(
        RpcSyncUnRegisterForRemoteNotifications_Request,
        RpcSyncUnRegisterForRemoteNotifications_Response,
    ),
    60: DceRpcOp(
        RpcSyncRefreshRemoteNotifications_Request,
        RpcSyncRefreshRemoteNotifications_Response,
    ),
    61: DceRpcOp(
        RpcAsyncGetRemoteNotifications_Request, RpcAsyncGetRemoteNotifications_Response
    ),
    62: DceRpcOp(
        RpcAsyncInstallPrinterDriverFromPackage_Request,
        RpcAsyncInstallPrinterDriverFromPackage_Response,
    ),
    63: DceRpcOp(
        RpcAsyncUploadPrinterDriverPackage_Request,
        RpcAsyncUploadPrinterDriverPackage_Response,
    ),
    64: DceRpcOp(
        RpcAsyncGetCorePrinterDrivers_Request, RpcAsyncGetCorePrinterDrivers_Response
    ),
    65: DceRpcOp(
        RpcAsyncCorePrinterDriverInstalled_Request,
        RpcAsyncCorePrinterDriverInstalled_Response,
    ),
    66: DceRpcOp(
        RpcAsyncGetPrinterDriverPackagePath_Request,
        RpcAsyncGetPrinterDriverPackagePath_Response,
    ),
    67: DceRpcOp(
        RpcAsyncDeletePrinterDriverPackage_Request,
        RpcAsyncDeletePrinterDriverPackage_Response,
    ),
    68: DceRpcOp(RpcAsyncReadPrinter_Request, RpcAsyncReadPrinter_Response),
    69: DceRpcOp(RpcAsyncResetPrinter_Request, RpcAsyncResetPrinter_Response),
    70: DceRpcOp(
        RpcAsyncGetJobNamedPropertyValue_Request,
        RpcAsyncGetJobNamedPropertyValue_Response,
    ),
    71: DceRpcOp(
        RpcAsyncSetJobNamedProperty_Request, RpcAsyncSetJobNamedProperty_Response
    ),
    72: DceRpcOp(
        RpcAsyncDeleteJobNamedProperty_Request, RpcAsyncDeleteJobNamedProperty_Response
    ),
    73: DceRpcOp(
        RpcAsyncEnumJobNamedProperties_Request, RpcAsyncEnumJobNamedProperties_Response
    ),
    74: DceRpcOp(
        RpcAsyncLogJobInfoForBranchOffice_Request,
        RpcAsyncLogJobInfoForBranchOffice_Response,
    ),
}
register_dcerpc_interface(
    name="IRemoteWinspool",
    uuid=uuid.UUID("76F03F96-CDFD-44fc-A22C-64950A001209"),
    version="1.0",
    opnums=IREMOTEWINSPOOL_OPNUMS,
)
