### ms-rprn.idl
"""
RPC definitions for the following interfaces:
- winspool (v1.0): 12345678-1234-ABCD-EF00-0123456789AB
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,
    NDRConfPacketListField,
    NDRConfStrLenField,
    NDRConfStrLenFieldUtf16,
    NDRConfVarStrLenField,
    NDRConfVarStrLenFieldUtf16,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRContextHandle,
    NDRFieldListField,
    NDRFullPointerField,
    NDRIEEEFloatField,
    NDRInt3264EnumField,
    NDRInt3264Field,
    NDRIntField,
    NDRLongField,
    NDRPacketField,
    NDRShortField,
    NDRSignedInt3264Field,
    NDRSignedIntField,
    NDRSignedLongField,
    NDRSignedShortField,
    NDRUnionField,
    register_dcerpc_interface,
)


class RpcEnumPrinters_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 RpcEnumPrinters_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pPrinterEnum", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


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 RpcOpenPrinter_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pPrinterName", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pDatatype", "")),
        NDRPacketField("pDevModeContainer", DEVMODE_CONTAINER(), DEVMODE_CONTAINER),
        NDRIntField("AccessRequired", 0),
    ]


class RpcOpenPrinter_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 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
        ),
        NDRInt3264Field("pDevMode", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pStatus", ""), deferred=True),
        NDRInt3264Field("pSecurityDescriptor", 0),
        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
        ),
        NDRInt3264Field("pDevMode", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pStatus", ""), deferred=True),
        NDRInt3264Field("pSecurityDescriptor", 0),
        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 RpcSetJob_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("JobId", 0),
        NDRFullPointerField(
            NDRPacketField("pJobContainer", JOB_CONTAINER(), JOB_CONTAINER)
        ),
        NDRIntField("Command", 0),
    ]


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


class RpcGetJob_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 RpcGetJob_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pJob", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("status", 0),
    ]


class RpcEnumJobs_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 RpcEnumJobs_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pJob", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 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 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
        ),
        NDRInt3264Field("pDevMode", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pSepFile", ""), deferred=True),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pPrintProcessor", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pDatatype", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pParameters", ""), deferred=True
        ),
        NDRInt3264Field("pSecurityDescriptor", 0),
        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):
    fields_desc = [NDRInt3264Field("pSecurityDescriptor", 0)]


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):
    fields_desc = [NDRInt3264Field("pDevMode", 0)]


class PRINTER_INFO_9(NDRPacket):
    fields_desc = [NDRInt3264Field("pDevMode", 0)]


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 RpcAddPrinter_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),
    ]


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


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


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


class RpcSetPrinter_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 RpcSetPrinter_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class RpcGetPrinter_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 RpcGetPrinter_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pPrinter", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 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 RpcAddPrinterDriver_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRPacketField("pDriverContainer", DRIVER_CONTAINER(), DRIVER_CONTAINER),
    ]


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


class RpcEnumPrinterDrivers_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 RpcEnumPrinterDrivers_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pDrivers", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


class RpcGetPrinterDriver_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"),
    ]


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


class RpcGetPrinterDriverDirectory_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 RpcGetPrinterDriverDirectory_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pDriverDirectory", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("status", 0),
    ]


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


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


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


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


class RpcEnumPrintProcessors_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 RpcEnumPrintProcessors_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pPrintProcessorInfo", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


class RpcGetPrintProcessorDirectory_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 RpcGetPrintProcessorDirectory_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField(
            "pPrintProcessorDirectory", "", 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 RpcStartDocPrinter_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("pDocInfoContainer", DOC_INFO_CONTAINER(), DOC_INFO_CONTAINER),
    ]


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


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


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


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


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


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


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


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


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


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


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


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


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


class RpcAddJob_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 RpcAddJob_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pAddJob", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("status", 0),
    ]


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


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


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


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


class RpcSetPrinterData_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 RpcSetPrinterData_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


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


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


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


class RpcClosePrinter_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 RpcAddForm_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("pFormInfoContainer", FORM_CONTAINER(), FORM_CONTAINER),
    ]


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


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


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


class RpcGetForm_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 RpcGetForm_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pForm", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("status", 0),
    ]


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


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


class RpcEnumForms_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 RpcEnumForms_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pForm", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


class RpcEnumPorts_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 RpcEnumPorts_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pPort", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


class RpcEnumMonitors_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 RpcEnumMonitors_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pMonitor", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


class RpcDeletePort_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRInt3264Field("hWnd", 0),
        NDRConfVarStrNullFieldUtf16("pPortName", ""),
    ]


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


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


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


class RpcPlayGdiScriptOnPrinterIC_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 RpcPlayGdiScriptOnPrinterIC_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pOut", "", size_is=lambda pkt: pkt.cOut),
        NDRIntField("status", 0),
    ]


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


class RpcDeletePrinterIC_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("phPrinterIC", NDRContextHandle(), NDRContextHandle),
        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 RpcAddMonitor_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Name", "")),
        NDRPacketField("pMonitorContainer", MONITOR_CONTAINER(), MONITOR_CONTAINER),
    ]


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


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


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


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


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


class RpcEnumPrintProcessorDatatypes_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 RpcEnumPrintProcessorDatatypes_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pDatatypes", "", size_is=lambda pkt: pkt.cbBuf),
        NDRIntField("pcbNeeded", 0),
        NDRIntField("pcReturned", 0),
        NDRIntField("status", 0),
    ]


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


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


class RpcGetPrinterDriver2_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 RpcGetPrinterDriver2_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 RpcFindClosePrinterChangeNotification_Request(NDRPacket):
    fields_desc = [NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle)]


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


class RpcReplyOpenPrinter_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("pMachine", ""),
        NDRIntField("dwPrinterRemote", 0),
        NDRIntField("dwType", 0),
        NDRIntField("cbBuffer", None, size_of="pBuffer"),
        NDRConfStrLenField("pBuffer", "", size_is=lambda pkt: pkt.cbBuffer),
    ]


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


class RpcRouterReplyPrinter_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hNotify", NDRContextHandle(), NDRContextHandle),
        NDRIntField("fdwFlags", 0),
        NDRIntField("cbBuffer", None, size_of="pBuffer"),
        NDRConfStrLenField("pBuffer", "", size_is=lambda pkt: pkt.cbBuffer),
    ]


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


class RpcReplyClosePrinter_Request(NDRPacket):
    fields_desc = [NDRPacketField("phNotify", NDRContextHandle(), NDRContextHandle)]


class RpcReplyClosePrinter_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("phNotify", NDRContextHandle(), NDRContextHandle),
        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 RpcAddPortEx_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
        NDRPacketField("pPortContainer", PORT_CONTAINER(), PORT_CONTAINER),
        NDRPacketField("pPortVarContainer", PORT_VAR_CONTAINER(), PORT_VAR_CONTAINER),
        NDRConfVarStrNullFieldUtf16("pMonitorName", ""),
    ]


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


class RpcRemoteFindFirstPrinterChangeNotification_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("fdwFlags", 0),
        NDRIntField("fdwOptions", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pszLocalMachine", "")),
        NDRIntField("dwPrinterLocal", 0),
        NDRIntField("cbBuffer", None, size_of="pBuffer"),
        NDRConfStrLenField("pBuffer", "", size_is=lambda pkt: pkt.cbBuffer),
    ]


class RpcRemoteFindFirstPrinterChangeNotification_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pBuffer", "", size_is=lambda pkt: pkt.cbBuffer),
        NDRIntField("status", 0),
    ]


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 RpcRemoteFindFirstPrinterChangeNotificationEx_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("fdwFlags", 0),
        NDRIntField("fdwOptions", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pszLocalMachine", "")),
        NDRIntField("dwPrinterLocal", 0),
        NDRFullPointerField(
            NDRPacketField("pOptions", RPC_V2_NOTIFY_OPTIONS(), RPC_V2_NOTIFY_OPTIONS)
        ),
    ]


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


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 SYSTEMTIME_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("cbBuf", 0),
        NDRFullPointerField(
            NDRPacketField("pSystemTime", SYSTEMTIME(), SYSTEMTIME), 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 RpcRouterReplyPrinterEx_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hNotify", NDRContextHandle(), NDRContextHandle),
        NDRIntField("dwColor", 0),
        NDRIntField("fdwFlags", 0),
        NDRIntField("dwReplyType", 0),
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "Reply", RPC_V2_NOTIFY_INFO(), RPC_V2_NOTIFY_INFO
                        )
                    ),
                    (
                        (lambda pkt: getattr(pkt, "dwReplyType", None) == 0),
                        (lambda _, val: val.tag == 0),
                    ),
                )
            ],
            StrFixedLenField("Reply", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
    ]


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


class RpcRouterRefreshPrinterChangeNotification_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("dwColor", 0),
        NDRFullPointerField(
            NDRPacketField("pOptions", RPC_V2_NOTIFY_OPTIONS(), RPC_V2_NOTIFY_OPTIONS)
        ),
    ]


class RpcRouterRefreshPrinterChangeNotification_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("ppInfo", RPC_V2_NOTIFY_INFO(), RPC_V2_NOTIFY_INFO)
        ),
        NDRIntField("status", 0),
    ]


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 RpcOpenPrinterEx_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 RpcOpenPrinterEx_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class RpcAddPrinterEx_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 RpcAddPrinterEx_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


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


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


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


class RpcEnumPrinterData_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 RpcDeletePrinterData_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRConfVarStrNullFieldUtf16("pValueName", ""),
    ]


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


class RpcSetPrinterDataEx_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 RpcSetPrinterDataEx_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


class RpcXcvData_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 RpcXcvData_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pOutputData", "", size_is=lambda pkt: pkt.cbOutputData),
        NDRIntField("pcbOutputNeeded", 0),
        NDRIntField("pdwStatus", 0),
        NDRIntField("status", 0),
    ]


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


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


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


class RpcFlushPrinter_Response(NDRPacket):
    fields_desc = [NDRIntField("pcWritten", 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 RpcSendRecvBidiData_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pAction", "")),
        NDRPacketField(
            "pReqData", RPC_BIDI_REQUEST_CONTAINER(), RPC_BIDI_REQUEST_CONTAINER
        ),
    ]


class RpcSendRecvBidiData_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField(
                "ppRespData", RPC_BIDI_RESPONSE_CONTAINER(), RPC_BIDI_RESPONSE_CONTAINER
            )
        ),
        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 RpcGetCorePrinterDrivers_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 RpcGetCorePrinterDrivers_Response(NDRPacket):
    fields_desc = [
        NDRConfPacketListField(
            "pCorePrinterDrivers",
            [],
            CORE_PRINTER_DRIVER,
            size_is=lambda pkt: pkt.cCorePrinterDrivers,
        ),
        NDRIntField("status", 0),
    ]


class RpcGetPrinterDriverPackagePath_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 RpcGetPrinterDriverPackagePath_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenFieldUtf16(
            "pszDriverPackageCab", "", size_is=lambda pkt: pkt.cchDriverPackageCab
        ),
        NDRIntField("pcchRequiredSize", 0),
        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 RpcGetJobNamedPropertyValue_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("JobId", 0),
        NDRConfVarStrNullFieldUtf16("pszName", ""),
    ]


class RpcGetJobNamedPropertyValue_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 RpcSetJobNamedProperty_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("JobId", 0),
        NDRPacketField("pProperty", RPC_PrintNamedProperty(), RPC_PrintNamedProperty),
    ]


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


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


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


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


class RpcEnumJobNamedProperties_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 RpcLogJobInfoForBranchOffice_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRPacketField(
            "pBranchOfficeJobDataContainer",
            RPC_BranchOfficeJobDataContainer(),
            RPC_BranchOfficeJobDataContainer,
        ),
    ]


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


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


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


class RpcIppCreateJobOnPrinter_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("jobId", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pdlFormat", "")),
        NDRIntField(
            "jobAttributeGroupBufferSize", None, size_of="jobAttributeGroupBuffer"
        ),
        NDRConfStrLenField(
            "jobAttributeGroupBuffer",
            "",
            size_is=lambda pkt: pkt.jobAttributeGroupBufferSize,
        ),
    ]


class RpcIppCreateJobOnPrinter_Response(NDRPacket):
    fields_desc = [
        NDRIntField("ippResponseBufferSize", None, size_of="ippResponseBuffer"),
        NDRConfStrLenField(
            "ippResponseBuffer", "", size_is=lambda pkt: pkt.ippResponseBufferSize
        ),
        NDRIntField("status", 0),
    ]


class RpcIppGetJobAttributes_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("jobId", 0),
        NDRIntField("attributeNameCount", None, size_of="attributeNames"),
        NDRConfVarStrLenFieldUtf16(
            "attributeNames", "", size_is=lambda pkt: pkt.attributeNameCount
        ),
    ]


class RpcIppGetJobAttributes_Response(NDRPacket):
    fields_desc = [
        NDRIntField("ippResponseBufferSize", None, size_of="ippResponseBuffer"),
        NDRConfStrLenField(
            "ippResponseBuffer", "", size_is=lambda pkt: pkt.ippResponseBufferSize
        ),
        NDRIntField("status", 0),
    ]


class RpcIppSetJobAttributes_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("jobId", 0),
        NDRIntField(
            "jobAttributeGroupBufferSize", None, size_of="jobAttributeGroupBuffer"
        ),
        NDRConfStrLenField(
            "jobAttributeGroupBuffer",
            "",
            size_is=lambda pkt: pkt.jobAttributeGroupBufferSize,
        ),
    ]


class RpcIppSetJobAttributes_Response(NDRPacket):
    fields_desc = [
        NDRIntField("ippResponseBufferSize", None, size_of="ippResponseBuffer"),
        NDRConfStrLenField(
            "ippResponseBuffer", "", size_is=lambda pkt: pkt.ippResponseBufferSize
        ),
        NDRIntField("status", 0),
    ]


class RpcIppGetPrinterAttributes_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField("attributeNameCount", None, size_of="attributeNames"),
        NDRConfVarStrLenFieldUtf16(
            "attributeNames", "", size_is=lambda pkt: pkt.attributeNameCount
        ),
    ]


class RpcIppGetPrinterAttributes_Response(NDRPacket):
    fields_desc = [
        NDRIntField("ippResponseBufferSize", None, size_of="ippResponseBuffer"),
        NDRConfStrLenField(
            "ippResponseBuffer", "", size_is=lambda pkt: pkt.ippResponseBufferSize
        ),
        NDRIntField("status", 0),
    ]


class RpcIppSetPrinterAttributes_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hPrinter", NDRContextHandle(), NDRContextHandle),
        NDRIntField(
            "jobAttributeGroupBufferSize", None, size_of="jobAttributeGroupBuffer"
        ),
        NDRConfStrLenField(
            "jobAttributeGroupBuffer",
            "",
            size_is=lambda pkt: pkt.jobAttributeGroupBufferSize,
        ),
    ]


class RpcIppSetPrinterAttributes_Response(NDRPacket):
    fields_desc = [
        NDRIntField("ippResponseBufferSize", None, size_of="ippResponseBuffer"),
        NDRConfStrLenField(
            "ippResponseBuffer", "", size_is=lambda pkt: pkt.ippResponseBufferSize
        ),
        NDRIntField("status", 0),
    ]


WINSPOOL_OPNUMS = {
    0: DceRpcOp(RpcEnumPrinters_Request, RpcEnumPrinters_Response),
    1: DceRpcOp(RpcOpenPrinter_Request, RpcOpenPrinter_Response),
    2: DceRpcOp(RpcSetJob_Request, RpcSetJob_Response),
    3: DceRpcOp(RpcGetJob_Request, RpcGetJob_Response),
    4: DceRpcOp(RpcEnumJobs_Request, RpcEnumJobs_Response),
    5: DceRpcOp(RpcAddPrinter_Request, RpcAddPrinter_Response),
    6: DceRpcOp(RpcDeletePrinter_Request, RpcDeletePrinter_Response),
    7: DceRpcOp(RpcSetPrinter_Request, RpcSetPrinter_Response),
    8: DceRpcOp(RpcGetPrinter_Request, RpcGetPrinter_Response),
    9: DceRpcOp(RpcAddPrinterDriver_Request, RpcAddPrinterDriver_Response),
    10: DceRpcOp(RpcEnumPrinterDrivers_Request, RpcEnumPrinterDrivers_Response),
    11: DceRpcOp(RpcGetPrinterDriver_Request, RpcGetPrinterDriver_Response),
    12: DceRpcOp(
        RpcGetPrinterDriverDirectory_Request, RpcGetPrinterDriverDirectory_Response
    ),
    13: DceRpcOp(RpcDeletePrinterDriver_Request, RpcDeletePrinterDriver_Response),
    14: DceRpcOp(RpcAddPrintProcessor_Request, RpcAddPrintProcessor_Response),
    15: DceRpcOp(RpcEnumPrintProcessors_Request, RpcEnumPrintProcessors_Response),
    16: DceRpcOp(
        RpcGetPrintProcessorDirectory_Request, RpcGetPrintProcessorDirectory_Response
    ),
    17: DceRpcOp(RpcStartDocPrinter_Request, RpcStartDocPrinter_Response),
    18: DceRpcOp(RpcStartPagePrinter_Request, RpcStartPagePrinter_Response),
    19: DceRpcOp(RpcWritePrinter_Request, RpcWritePrinter_Response),
    20: DceRpcOp(RpcEndPagePrinter_Request, RpcEndPagePrinter_Response),
    21: DceRpcOp(RpcAbortPrinter_Request, RpcAbortPrinter_Response),
    22: DceRpcOp(RpcReadPrinter_Request, RpcReadPrinter_Response),
    23: DceRpcOp(RpcEndDocPrinter_Request, RpcEndDocPrinter_Response),
    24: DceRpcOp(RpcAddJob_Request, RpcAddJob_Response),
    25: DceRpcOp(RpcScheduleJob_Request, RpcScheduleJob_Response),
    26: DceRpcOp(RpcGetPrinterData_Request, RpcGetPrinterData_Response),
    27: DceRpcOp(RpcSetPrinterData_Request, RpcSetPrinterData_Response),
    28: DceRpcOp(RpcWaitForPrinterChange_Request, RpcWaitForPrinterChange_Response),
    29: DceRpcOp(RpcClosePrinter_Request, RpcClosePrinter_Response),
    30: DceRpcOp(RpcAddForm_Request, RpcAddForm_Response),
    31: DceRpcOp(RpcDeleteForm_Request, RpcDeleteForm_Response),
    32: DceRpcOp(RpcGetForm_Request, RpcGetForm_Response),
    33: DceRpcOp(RpcSetForm_Request, RpcSetForm_Response),
    34: DceRpcOp(RpcEnumForms_Request, RpcEnumForms_Response),
    35: DceRpcOp(RpcEnumPorts_Request, RpcEnumPorts_Response),
    36: DceRpcOp(RpcEnumMonitors_Request, RpcEnumMonitors_Response),
    # 37: Opnum37NotUsedOnWire,
    # 38: Opnum38NotUsedOnWire,
    39: DceRpcOp(RpcDeletePort_Request, RpcDeletePort_Response),
    40: DceRpcOp(RpcCreatePrinterIC_Request, RpcCreatePrinterIC_Response),
    41: DceRpcOp(
        RpcPlayGdiScriptOnPrinterIC_Request, RpcPlayGdiScriptOnPrinterIC_Response
    ),
    42: DceRpcOp(RpcDeletePrinterIC_Request, RpcDeletePrinterIC_Response),
    # 43: Opnum43NotUsedOnWire,
    # 44: Opnum44NotUsedOnWire,
    # 45: Opnum45NotUsedOnWire,
    46: DceRpcOp(RpcAddMonitor_Request, RpcAddMonitor_Response),
    47: DceRpcOp(RpcDeleteMonitor_Request, RpcDeleteMonitor_Response),
    48: DceRpcOp(RpcDeletePrintProcessor_Request, RpcDeletePrintProcessor_Response),
    # 49: Opnum49NotUsedOnWire,
    # 50: Opnum50NotUsedOnWire,
    51: DceRpcOp(
        RpcEnumPrintProcessorDatatypes_Request, RpcEnumPrintProcessorDatatypes_Response
    ),
    52: DceRpcOp(RpcResetPrinter_Request, RpcResetPrinter_Response),
    53: DceRpcOp(RpcGetPrinterDriver2_Request, RpcGetPrinterDriver2_Response),
    # 54: Opnum54NotUsedOnWire,
    # 55: Opnum55NotUsedOnWire,
    56: DceRpcOp(
        RpcFindClosePrinterChangeNotification_Request,
        RpcFindClosePrinterChangeNotification_Response,
    ),
    # 57: Opnum57NotUsedOnWire,
    58: DceRpcOp(RpcReplyOpenPrinter_Request, RpcReplyOpenPrinter_Response),
    59: DceRpcOp(RpcRouterReplyPrinter_Request, RpcRouterReplyPrinter_Response),
    60: DceRpcOp(RpcReplyClosePrinter_Request, RpcReplyClosePrinter_Response),
    61: DceRpcOp(RpcAddPortEx_Request, RpcAddPortEx_Response),
    62: DceRpcOp(
        RpcRemoteFindFirstPrinterChangeNotification_Request,
        RpcRemoteFindFirstPrinterChangeNotification_Response,
    ),
    # 63: Opnum63NotUsedOnWire,
    # 64: Opnum64NotUsedOnWire,
    65: DceRpcOp(
        RpcRemoteFindFirstPrinterChangeNotificationEx_Request,
        RpcRemoteFindFirstPrinterChangeNotificationEx_Response,
    ),
    66: DceRpcOp(RpcRouterReplyPrinterEx_Request, RpcRouterReplyPrinterEx_Response),
    67: DceRpcOp(
        RpcRouterRefreshPrinterChangeNotification_Request,
        RpcRouterRefreshPrinterChangeNotification_Response,
    ),
    # 68: Opnum68NotUsedOnWire,
    69: DceRpcOp(RpcOpenPrinterEx_Request, RpcOpenPrinterEx_Response),
    70: DceRpcOp(RpcAddPrinterEx_Request, RpcAddPrinterEx_Response),
    71: DceRpcOp(RpcSetPort_Request, RpcSetPort_Response),
    72: DceRpcOp(RpcEnumPrinterData_Request, RpcEnumPrinterData_Response),
    73: DceRpcOp(RpcDeletePrinterData_Request, RpcDeletePrinterData_Response),
    # 74: Opnum74NotUsedOnWire,
    # 75: Opnum75NotUsedOnWire,
    # 76: Opnum76NotUsedOnWire,
    77: DceRpcOp(RpcSetPrinterDataEx_Request, RpcSetPrinterDataEx_Response),
    78: DceRpcOp(RpcGetPrinterDataEx_Request, RpcGetPrinterDataEx_Response),
    79: DceRpcOp(RpcEnumPrinterDataEx_Request, RpcEnumPrinterDataEx_Response),
    80: DceRpcOp(RpcEnumPrinterKey_Request, RpcEnumPrinterKey_Response),
    81: DceRpcOp(RpcDeletePrinterDataEx_Request, RpcDeletePrinterDataEx_Response),
    82: DceRpcOp(RpcDeletePrinterKey_Request, RpcDeletePrinterKey_Response),
    # 83: Opnum83NotUsedOnWire,
    84: DceRpcOp(RpcDeletePrinterDriverEx_Request, RpcDeletePrinterDriverEx_Response),
    85: DceRpcOp(
        RpcAddPerMachineConnection_Request, RpcAddPerMachineConnection_Response
    ),
    86: DceRpcOp(
        RpcDeletePerMachineConnection_Request, RpcDeletePerMachineConnection_Response
    ),
    87: DceRpcOp(
        RpcEnumPerMachineConnections_Request, RpcEnumPerMachineConnections_Response
    ),
    88: DceRpcOp(RpcXcvData_Request, RpcXcvData_Response),
    89: DceRpcOp(RpcAddPrinterDriverEx_Request, RpcAddPrinterDriverEx_Response),
    # 90: Opnum90NotUsedOnWire,
    # 91: Opnum91NotUsedOnWire,
    # 92: Opnum92NotUsedOnWire,
    # 93: Opnum93NotUsedOnWire,
    # 94: Opnum94NotUsedOnWire,
    # 95: Opnum95NotUsedOnWire,
    96: DceRpcOp(RpcFlushPrinter_Request, RpcFlushPrinter_Response),
    97: DceRpcOp(RpcSendRecvBidiData_Request, RpcSendRecvBidiData_Response),
    # 98: Opnum98NotUsedOnWire,
    # 99: Opnum99NotUsedOnWire,
    # 100: Opnum100NotUsedOnWire,
    # 101: Opnum101NotUsedOnWire,
    102: DceRpcOp(RpcGetCorePrinterDrivers_Request, RpcGetCorePrinterDrivers_Response),
    # 103: Opnum103NotUsedOnWire,
    104: DceRpcOp(
        RpcGetPrinterDriverPackagePath_Request, RpcGetPrinterDriverPackagePath_Response
    ),
    # 105: Opnum105NotUsedOnWire,
    # 106: Opnum106NotUsedOnWire,
    # 107: Opnum107NotUsedOnWire,
    # 108: Opnum108NotUsedOnWire,
    # 109: Opnum109NotUsedOnWire,
    110: DceRpcOp(
        RpcGetJobNamedPropertyValue_Request, RpcGetJobNamedPropertyValue_Response
    ),
    111: DceRpcOp(RpcSetJobNamedProperty_Request, RpcSetJobNamedProperty_Response),
    112: DceRpcOp(
        RpcDeleteJobNamedProperty_Request, RpcDeleteJobNamedProperty_Response
    ),
    113: DceRpcOp(
        RpcEnumJobNamedProperties_Request, RpcEnumJobNamedProperties_Response
    ),
    # 114: Opnum114NotUsedOnWire,
    # 115: Opnum115NotUsedOnWire,
    116: DceRpcOp(
        RpcLogJobInfoForBranchOffice_Request, RpcLogJobInfoForBranchOffice_Response
    ),
    117: DceRpcOp(
        RpcRegeneratePrintDeviceCapabilities_Request,
        RpcRegeneratePrintDeviceCapabilities_Response,
    ),
    # 118: Opnum118NotUsedOnWire,
    119: DceRpcOp(RpcIppCreateJobOnPrinter_Request, RpcIppCreateJobOnPrinter_Response),
    120: DceRpcOp(RpcIppGetJobAttributes_Request, RpcIppGetJobAttributes_Response),
    121: DceRpcOp(RpcIppSetJobAttributes_Request, RpcIppSetJobAttributes_Response),
    122: DceRpcOp(
        RpcIppGetPrinterAttributes_Request, RpcIppGetPrinterAttributes_Response
    ),
    123: DceRpcOp(
        RpcIppSetPrinterAttributes_Request, RpcIppSetPrinterAttributes_Response
    ),
}
register_dcerpc_interface(
    name="winspool",
    uuid=uuid.UUID("12345678-1234-ABCD-EF00-0123456789AB"),
    version="1.0",
    opnums=WINSPOOL_OPNUMS,
)
