### ms-tsts_legacy.idl
"""
RPC definitions for the following interfaces:
- IcaApi (v1.0): 5ca4a760-ebb1-11cf-8611-00a0245420ed
This file is auto-generated by midl-to-scapy, do not modify.
"""

import uuid


from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRByteField,
    NDRConfPacketListField,
    NDRConfStrLenField,
    NDRConfStrLenFieldUtf16,
    NDRConfVarStrLenField,
    NDRConfVarStrLenFieldUtf16,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRContextHandle,
    NDRFullPointerField,
    NDRInt3264Field,
    NDRIntField,
    NDRPacketField,
    NDRShortField,
    NDRSignedIntField,
    NDRSignedLongField,
    register_dcerpc_interface,
)


class RpcWinStationOpenServer_Request(NDRPacket):
    fields_desc = []


class RpcWinStationOpenServer_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pResult", 0),
        NDRPacketField("phServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class RpcWinStationCloseServer_Request(NDRPacket):
    fields_desc = [NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle)]


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


class RpcIcaServerPing_Request(NDRPacket):
    fields_desc = [NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle)]


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


class RpcWinStationEnumerate_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("pEntries", 0),
        NDRFullPointerField(
            NDRConfStrLenField("pLogonId", "", size_is=lambda pkt: pkt.pByteCount)
        ),
        NDRIntField("pByteCount", None, size_of="pLogonId"),
        NDRIntField("pIndex", 0),
    ]


class RpcWinStationEnumerate_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pResult", 0),
        NDRIntField("pEntries", 0),
        NDRFullPointerField(
            NDRConfStrLenField("pLogonId", "", size_is=lambda pkt: pkt.pByteCount)
        ),
        NDRIntField("pByteCount", None, size_of="pLogonId"),
        NDRIntField("pIndex", 0),
        NDRIntField("status", 0),
    ]


class RpcWinStationRename_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRConfStrLenFieldUtf16(
            "pWinStationNameOld", "", size_is=lambda pkt: pkt.NameOldSize
        ),
        NDRIntField("NameOldSize", None, size_of="pWinStationNameOld"),
        NDRConfStrLenFieldUtf16(
            "pWinStationNameNew", "", size_is=lambda pkt: pkt.NameNewSize
        ),
        NDRIntField("NameNewSize", None, size_of="pWinStationNameNew"),
    ]


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


class RpcWinStationQueryInformation_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("LogonId", 0),
        NDRIntField("WinStationInformationClass", 0),
        NDRFullPointerField(
            NDRConfStrLenField(
                "pWinStationInformation",
                "",
                size_is=lambda pkt: pkt.WinStationInformationLength,
            )
        ),
        NDRIntField(
            "WinStationInformationLength", None, size_of="pWinStationInformation"
        ),
    ]


class RpcWinStationQueryInformation_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pResult", 0),
        NDRFullPointerField(
            NDRConfStrLenField(
                "pWinStationInformation",
                "",
                size_is=lambda pkt: pkt.WinStationInformationLength,
            )
        ),
        NDRIntField("pReturnLength", 0),
        NDRIntField("status", 0),
    ]


class RpcWinStationSetInformation_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("LogonId", 0),
        NDRIntField("WinStationInformationClass", 0),
        NDRFullPointerField(
            NDRConfStrLenField(
                "pWinStationInformation",
                "",
                size_is=lambda pkt: pkt.WinStationInformationLength,
            )
        ),
        NDRIntField(
            "WinStationInformationLength", None, size_of="pWinStationInformation"
        ),
    ]


class RpcWinStationSetInformation_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pResult", 0),
        NDRFullPointerField(
            NDRConfStrLenField(
                "pWinStationInformation",
                "",
                size_is=lambda pkt: pkt.WinStationInformationLength,
            )
        ),
        NDRIntField("status", 0),
    ]


class RpcWinStationSendMessage_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("LogonId", 0),
        NDRConfStrLenFieldUtf16("pTitle", "", size_is=lambda pkt: pkt.TitleLength),
        NDRIntField("TitleLength", None, size_of="pTitle"),
        NDRConfStrLenFieldUtf16("pMessage", "", size_is=lambda pkt: pkt.MessageLength),
        NDRIntField("MessageLength", None, size_of="pMessage"),
        NDRIntField("Style", 0),
        NDRIntField("Timeout", 0),
        NDRByteField("DoNotWait", 0),
    ]


class RpcWinStationSendMessage_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pResult", 0),
        NDRIntField("pResponse", 0),
        NDRIntField("status", 0),
    ]


class RpcLogonIdFromWinStationName_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRConfStrLenFieldUtf16(
            "pWinStationName", "", size_is=lambda pkt: pkt.NameSize
        ),
        NDRIntField("NameSize", None, size_of="pWinStationName"),
    ]


class RpcLogonIdFromWinStationName_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pResult", 0),
        NDRIntField("pLogonId", 0),
        NDRIntField("status", 0),
    ]


class RpcWinStationNameFromLogonId_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("LoginId", 0),
        NDRConfStrLenFieldUtf16(
            "pWinStationName", "", size_is=lambda pkt: pkt.NameSize
        ),
        NDRIntField("NameSize", None, size_of="pWinStationName"),
    ]


class RpcWinStationNameFromLogonId_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pResult", 0),
        NDRConfStrLenFieldUtf16(
            "pWinStationName", "", size_is=lambda pkt: pkt.NameSize
        ),
        NDRIntField("status", 0),
    ]


class RpcWinStationConnect_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("ClientLogonId", 0),
        NDRIntField("ConnectLogonId", 0),
        NDRIntField("TargetLogonId", 0),
        NDRConfStrLenFieldUtf16("pPassword", "", size_is=lambda pkt: pkt.PasswordSize),
        NDRIntField("PasswordSize", None, size_of="pPassword"),
        NDRByteField("Wait", 0),
    ]


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


class RpcWinStationDisconnect_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("LogonId", 0),
        NDRByteField("bWait", 0),
    ]


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


class RpcWinStationReset_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("LogonId", 0),
        NDRByteField("bWait", 0),
    ]


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


class RpcWinStationShutdownSystem_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("ClientLogonId", 0),
        NDRIntField("ShutdownFlags", 0),
    ]


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


class RpcWinStationWaitSystemEvent_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("EventMask", 0),
    ]


class RpcWinStationWaitSystemEvent_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pResult", 0),
        NDRIntField("pEventFlags", 0),
        NDRIntField("status", 0),
    ]


class RpcWinStationShadow_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("LogonId", 0),
        NDRFullPointerField(
            NDRConfStrLenFieldUtf16(
                "pTargetServerName", "", size_is=lambda pkt: pkt.NameSize
            )
        ),
        NDRIntField("NameSize", None, size_of="pTargetServerName"),
        NDRIntField("TargetLogonId", 0),
        NDRByteField("HotKeyVk", 0),
        NDRShortField("HotkeyModifiers", 0),
    ]


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


class RpcWinStationBreakPoint_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("LogonId", 0),
        NDRByteField("KernelFlag", 0),
    ]


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


class RpcWinStationReadRegistry_Request(NDRPacket):
    fields_desc = [NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle)]


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


class OldRpcWinStationEnumerateProcesses_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("ByteCount", 0),
    ]


class OldRpcWinStationEnumerateProcesses_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pResult", 0),
        NDRConfStrLenField("pProcessBuffer", "", size_is=lambda pkt: pkt.ByteCount),
        NDRIntField("status", 0),
    ]


class RpcWinStationEnumerateProcesses_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("ByteCount", 0),
    ]


class RpcWinStationEnumerateProcesses_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pResult", 0),
        NDRConfStrLenField("pProcessBuffer", "", size_is=lambda pkt: pkt.ByteCount),
        NDRIntField("status", 0),
    ]


class RpcWinStationTerminateProcess_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("ProcessId", 0),
        NDRIntField("ExitCode", 0),
    ]


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


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


class TS_UNICODE_STRING(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRShortField("Length", None, size_of="Buffer"),
        NDRShortField("MaximumLength", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfVarStrLenFieldUtf16(
                "Buffer",
                "",
                size_is=lambda pkt: pkt.MaximumLength,
                length_is=lambda pkt: pkt.Length,
            ),
            deferred=True,
        ),
    ]


class PTS_SYS_PROCESS_INFORMATION(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRIntField("NextEntryOffset", 0),
        NDRIntField("NumberOfThreads", 0),
        NDRPacketField("SpareLi1", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("SpareLi2", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("SpareLi3", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("CreateTime", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("UserTime", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("KernelTime", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("ImageName", TS_UNICODE_STRING(), TS_UNICODE_STRING),
        NDRSignedIntField("BasePriority", 0),
        NDRIntField("UniqueProcessId", 0),
        NDRIntField("InheritedFromUniqueProcessId", 0),
        NDRIntField("HandleCount", 0),
        NDRIntField("SessionId", 0),
        NDRIntField("SpareUl3", 0),
        NDRInt3264Field("PeakVirtualSize", 0),
        NDRInt3264Field("VirtualSize", 0),
        NDRIntField("PageFaultCount", 0),
        NDRIntField("PeakWorkingSetSize", 0),
        NDRIntField("WorkingSetSize", 0),
        NDRInt3264Field("QuotaPeakPagedPoolUsage", 0),
        NDRInt3264Field("QuotaPagedPoolUsage", 0),
        NDRInt3264Field("QuotaPeakNonPagedPoolUsage", 0),
        NDRInt3264Field("QuotaNonPagedPoolUsage", 0),
        NDRInt3264Field("PagefileUsage", 0),
        NDRInt3264Field("PeakPagefileUsage", 0),
        NDRInt3264Field("PrivatePageCount", 0),
    ]


class PTS_ALL_PROCESSES_INFO(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField(
                "pTsProcessInfo",
                PTS_SYS_PROCESS_INFORMATION(),
                PTS_SYS_PROCESS_INFORMATION,
            ),
            deferred=True,
        ),
        NDRIntField("SizeOfSid", None, size_of="pSid"),
        NDRFullPointerField(
            NDRConfStrLenField("pSid", "", size_is=lambda pkt: pkt.SizeOfSid),
            deferred=True,
        ),
    ]


class RpcWinStationGetAllProcesses_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("Level", 0),
        NDRIntField("pNumberOfProcesses", 0),
    ]


class RpcWinStationGetAllProcesses_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pResult", 0),
        NDRIntField("pNumberOfProcesses", None, size_of="ppTsAllProcessesInfo"),
        NDRConfPacketListField(
            "ppTsAllProcessesInfo",
            [],
            PTS_ALL_PROCESSES_INFO,
            size_is=lambda pkt: pkt.pNumberOfProcesses,
            ptr_pack=True,
        ),
        NDRIntField("status", 0),
    ]


class RpcWinStationGetProcessSid_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("dwUniqueProcessId", 0),
        NDRPacketField("ProcessStartTime", LARGE_INTEGER(), LARGE_INTEGER),
        NDRFullPointerField(
            NDRConfStrLenField("pProcessUserSid", "", size_is=lambda pkt: pkt.dwSidSize)
        ),
        NDRIntField("dwSidSize", None, size_of="pProcessUserSid"),
        NDRIntField("pdwSizeNeeded", 0),
    ]


class RpcWinStationGetProcessSid_Response(NDRPacket):
    fields_desc = [
        NDRSignedIntField("pResult", 0),
        NDRFullPointerField(
            NDRConfStrLenField("pProcessUserSid", "", size_is=lambda pkt: pkt.dwSidSize)
        ),
        NDRIntField("pdwSizeNeeded", 0),
        NDRIntField("status", 0),
    ]


class TS_COUNTER_HEADER(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("dwCounterID", 0), NDRIntField("bResult", 0)]


class PTS_COUNTER(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRPacketField("counterHead", TS_COUNTER_HEADER(), TS_COUNTER_HEADER),
        NDRIntField("dwValue", 0),
        NDRPacketField("startTime", LARGE_INTEGER(), LARGE_INTEGER),
    ]


class RpcWinStationGetTermSrvCountersValue_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("dwEntries", None, size_of="pCounter"),
        NDRConfPacketListField(
            "pCounter", [PTS_COUNTER()], PTS_COUNTER, size_is=lambda pkt: pkt.dwEntries
        ),
    ]


class RpcWinStationGetTermSrvCountersValue_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pResult", 0),
        NDRConfPacketListField(
            "pCounter", [PTS_COUNTER()], PTS_COUNTER, size_is=lambda pkt: pkt.dwEntries
        ),
        NDRIntField("status", 0),
    ]


class RpcWinStationReInitializeSecurity_Request(NDRPacket):
    fields_desc = [NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle)]


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


class RpcWinStationGetLanAdapterName_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("PdNameSize", None, size_of="pPdName"),
        NDRConfStrLenFieldUtf16("pPdName", "", size_is=lambda pkt: pkt.PdNameSize),
        NDRIntField("LanAdapter", 0),
    ]


class RpcWinStationGetLanAdapterName_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pResult", 0),
        NDRIntField("pLength", None, size_of="ppLanAdapter"),
        NDRConfStrLenFieldUtf16("ppLanAdapter", "", size_is=lambda pkt: pkt.pLength),
        NDRIntField("status", 0),
    ]


class RpcWinStationUpdateSettings_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("SettingsClass", 0),
        NDRIntField("SettingsParameters", 0),
    ]


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


class RpcWinStationShadowStop_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("LogonId", 0),
        NDRByteField("bWait", 0),
    ]


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


class RpcWinStationCloseServerEx_Request(NDRPacket):
    fields_desc = [NDRPacketField("phServer", NDRContextHandle(), NDRContextHandle)]


class RpcWinStationCloseServerEx_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("phServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("pResult", 0),
        NDRIntField("status", 0),
    ]


class RpcWinStationIsHelpAssistantSession_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("SessionId", 0),
    ]


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


class RpcWinStationGetMachinePolicy_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRConfStrLenField("pPolicy", "", size_is=lambda pkt: pkt.bufferSize),
        NDRIntField("bufferSize", None, size_of="pPolicy"),
    ]


class RpcWinStationGetMachinePolicy_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pPolicy", "", size_is=lambda pkt: pkt.bufferSize),
        NDRIntField("status", 0),
    ]


class RpcWinStationCheckLoopBack_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("ClientLogonId", 0),
        NDRIntField("TargetLogonId", 0),
        NDRConfStrLenFieldUtf16(
            "pTargetServerName", "", size_is=lambda pkt: pkt.NameSize
        ),
        NDRIntField("NameSize", None, size_of="pTargetServerName"),
    ]


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


class RpcConnectCallback_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("TimeOut", 0),
        NDRIntField("AddressType", 0),
        NDRConfStrLenField("pAddress", "", size_is=lambda pkt: pkt.AddressSize),
        NDRIntField("AddressSize", None, size_of="pAddress"),
    ]


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


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


class PTS_SYS_PROCESS_INFORMATION_NT6(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRIntField("NextEntryOffset", 0),
        NDRIntField("NumberOfThreads", 0),
        NDRPacketField("SpareLi1", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("SpareLi2", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("SpareLi3", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("CreateTime", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("UserTime", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("KernelTime", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("ImageName", NT6_TS_UNICODE_STRING(), NT6_TS_UNICODE_STRING),
        NDRSignedIntField("BasePriority", 0),
        NDRIntField("UniqueProcessId", 0),
        NDRIntField("InheritedFromUniqueProcessId", 0),
        NDRIntField("HandleCount", 0),
        NDRIntField("SessionId", 0),
        NDRIntField("SpareUl3", 0),
        NDRInt3264Field("PeakVirtualSize", 0),
        NDRInt3264Field("VirtualSize", 0),
        NDRIntField("PageFaultCount", 0),
        NDRIntField("PeakWorkingSetSize", 0),
        NDRIntField("WorkingSetSize", 0),
        NDRInt3264Field("QuotaPeakPagedPoolUsage", 0),
        NDRInt3264Field("QuotaPagedPoolUsage", 0),
        NDRInt3264Field("QuotaPeakNonPagedPoolUsage", 0),
        NDRInt3264Field("QuotaNonPagedPoolUsage", 0),
        NDRInt3264Field("PagefileUsage", 0),
        NDRInt3264Field("PeakPagefileUsage", 0),
        NDRInt3264Field("PrivatePageCount", 0),
    ]


class PTS_ALL_PROCESSES_INFO_NT6(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField(
                "pTsProcessInfo",
                PTS_SYS_PROCESS_INFORMATION_NT6(),
                PTS_SYS_PROCESS_INFORMATION_NT6,
            ),
            deferred=True,
        ),
        NDRIntField("SizeOfSid", None, size_of="pSid"),
        NDRFullPointerField(
            NDRConfStrLenField("pSid", "", size_is=lambda pkt: pkt.SizeOfSid),
            deferred=True,
        ),
    ]


class RpcWinStationGetAllProcesses_NT6_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRIntField("Level", 0),
        NDRIntField("pNumberOfProcesses", 0),
    ]


class RpcWinStationGetAllProcesses_NT6_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pResult", 0),
        NDRIntField("pNumberOfProcesses", None, size_of="ppTsAllProcessesInfo"),
        NDRConfPacketListField(
            "ppTsAllProcessesInfo",
            [],
            PTS_ALL_PROCESSES_INFO_NT6,
            size_is=lambda pkt: pkt.pNumberOfProcesses,
            ptr_pack=True,
        ),
        NDRIntField("status", 0),
    ]


class RpcWinStationOpenSessionDirectory_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hServer", NDRContextHandle(), NDRContextHandle),
        NDRConfVarStrNullFieldUtf16("pszServerName", ""),
    ]


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


ICAAPI_OPNUMS = {
    0: DceRpcOp(RpcWinStationOpenServer_Request, RpcWinStationOpenServer_Response),
    1: DceRpcOp(RpcWinStationCloseServer_Request, RpcWinStationCloseServer_Response),
    2: DceRpcOp(RpcIcaServerPing_Request, RpcIcaServerPing_Response),
    3: DceRpcOp(RpcWinStationEnumerate_Request, RpcWinStationEnumerate_Response),
    4: DceRpcOp(RpcWinStationRename_Request, RpcWinStationRename_Response),
    5: DceRpcOp(
        RpcWinStationQueryInformation_Request, RpcWinStationQueryInformation_Response
    ),
    6: DceRpcOp(
        RpcWinStationSetInformation_Request, RpcWinStationSetInformation_Response
    ),
    7: DceRpcOp(RpcWinStationSendMessage_Request, RpcWinStationSendMessage_Response),
    8: DceRpcOp(
        RpcLogonIdFromWinStationName_Request, RpcLogonIdFromWinStationName_Response
    ),
    9: DceRpcOp(
        RpcWinStationNameFromLogonId_Request, RpcWinStationNameFromLogonId_Response
    ),
    10: DceRpcOp(RpcWinStationConnect_Request, RpcWinStationConnect_Response),
    # 11: Opnum11NotUsedOnWire,
    # 12: Opnum12NotUsedOnWire,
    13: DceRpcOp(RpcWinStationDisconnect_Request, RpcWinStationDisconnect_Response),
    14: DceRpcOp(RpcWinStationReset_Request, RpcWinStationReset_Response),
    15: DceRpcOp(
        RpcWinStationShutdownSystem_Request, RpcWinStationShutdownSystem_Response
    ),
    16: DceRpcOp(
        RpcWinStationWaitSystemEvent_Request, RpcWinStationWaitSystemEvent_Response
    ),
    17: DceRpcOp(RpcWinStationShadow_Request, RpcWinStationShadow_Response),
    # 18: Opnum18NotUsedOnWire,
    # 19: Opnum19NotUsedOnWire,
    # 20: Opnum20NotUsedOnWire,
    # 21: Opnum21NotUsedOnWire,
    # 22: Opnum22NotUsedOnWire,
    # 23: Opnum23NotUsedOnWire,
    # 24: Opnum24NotUsedOnWire,
    # 25: Opnum25NotUsedOnWire,
    # 26: Opnum26NotUsedOnWire,
    # 27: Opnum27NotUsedOnWire,
    # 28: Opnum28NotUsedOnWire,
    29: DceRpcOp(RpcWinStationBreakPoint_Request, RpcWinStationBreakPoint_Response),
    30: DceRpcOp(RpcWinStationReadRegistry_Request, RpcWinStationReadRegistry_Response),
    # 31: Opnum31NotUsedOnWire,
    # 32: Opnum32NotUsedOnWire,
    # 33: Opnum33NotUsedOnWire,
    34: DceRpcOp(
        OldRpcWinStationEnumerateProcesses_Request,
        OldRpcWinStationEnumerateProcesses_Response,
    ),
    # 35: Opnum35NotUsedOnWire,
    36: DceRpcOp(
        RpcWinStationEnumerateProcesses_Request,
        RpcWinStationEnumerateProcesses_Response,
    ),
    37: DceRpcOp(
        RpcWinStationTerminateProcess_Request, RpcWinStationTerminateProcess_Response
    ),
    # 38: Opnum38NotUsedOnWire,
    # 39: Opnum39NotUsedOnWire,
    # 40: Opnum40NotUsedOnWire,
    # 41: Opnum41NotUsedOnWire,
    # 42: Opnum42NotUsedOnWire,
    43: DceRpcOp(
        RpcWinStationGetAllProcesses_Request, RpcWinStationGetAllProcesses_Response
    ),
    44: DceRpcOp(
        RpcWinStationGetProcessSid_Request, RpcWinStationGetProcessSid_Response
    ),
    45: DceRpcOp(
        RpcWinStationGetTermSrvCountersValue_Request,
        RpcWinStationGetTermSrvCountersValue_Response,
    ),
    46: DceRpcOp(
        RpcWinStationReInitializeSecurity_Request,
        RpcWinStationReInitializeSecurity_Response,
    ),
    # 47: Opnum47NotUsedOnWire,
    # 48: Opnum48NotUsedOnWire,
    # 49: Opnum49NotUsedOnWire,
    # 50: Opnum50NotUsedOnWire,
    # 51: Opnum51NotUsedOnWire,
    # 52: Opnum52NotUsedOnWire,
    53: DceRpcOp(
        RpcWinStationGetLanAdapterName_Request, RpcWinStationGetLanAdapterName_Response
    ),
    # 54: Opnum54NotUsedOnWire,
    # 55: Opnum55NotUsedOnWire,
    # 56: Opnum56NotUsedOnWire,
    # 57: Opnum57NotUsedOnWire,
    58: DceRpcOp(
        RpcWinStationUpdateSettings_Request, RpcWinStationUpdateSettings_Response
    ),
    59: DceRpcOp(RpcWinStationShadowStop_Request, RpcWinStationShadowStop_Response),
    60: DceRpcOp(
        RpcWinStationCloseServerEx_Request, RpcWinStationCloseServerEx_Response
    ),
    61: DceRpcOp(
        RpcWinStationIsHelpAssistantSession_Request,
        RpcWinStationIsHelpAssistantSession_Response,
    ),
    62: DceRpcOp(
        RpcWinStationGetMachinePolicy_Request, RpcWinStationGetMachinePolicy_Response
    ),
    # 63: Opnum63NotUsedOnWire,
    # 64: Opnum64NotUsedOnWire,
    65: DceRpcOp(
        RpcWinStationCheckLoopBack_Request, RpcWinStationCheckLoopBack_Response
    ),
    66: DceRpcOp(RpcConnectCallback_Request, RpcConnectCallback_Response),
    # 67: Opnum67NotUsedOnWire,
    # 68: Opnum68NotUsedOnWire,
    # 69: Opnum69NotUsedOnWire,
    70: DceRpcOp(
        RpcWinStationGetAllProcesses_NT6_Request,
        RpcWinStationGetAllProcesses_NT6_Response,
    ),
    # 71: Opnum71NotUsedOnWire,
    # 72: Opnum72NotUsedOnWire,
    # 73: Opnum73NotUsedOnWire,
    # 74: Opnum74NotUsedOnWire,
    75: DceRpcOp(
        RpcWinStationOpenSessionDirectory_Request,
        RpcWinStationOpenSessionDirectory_Response,
    ),
}
register_dcerpc_interface(
    name="IcaApi",
    uuid=uuid.UUID("5ca4a760-ebb1-11cf-8611-00a0245420ed"),
    version="1.0",
    opnums=ICAAPI_OPNUMS,
)
