### ms-tsch_SchRpc.idl
"""
RPC definitions for the following interfaces:
- ITaskSchedulerService (v1.0): 86D35949-83C9-4044-B424-DB363231FD0C
This file is auto-generated by midl-to-scapy, do not modify.
"""

import uuid

from scapy.fields import StrFixedLenField
from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRConfPacketListField,
    NDRConfVarStrLenField,
    NDRConfVarStrLenFieldUtf16,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRFullPointerField,
    NDRIntField,
    NDRPacketField,
    NDRShortField,
    register_dcerpc_interface,
)


class SchRpcHighestVersion_Request(NDRPacket):
    fields_desc = []


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


class TASK_USER_CRED(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("userId", ""), deferred=True),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("password", ""), deferred=True),
        NDRIntField("flags", 0),
    ]


class PTASK_XML_ERROR_INFO(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("line", 0),
        NDRIntField("column", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("node", ""), deferred=True),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("value", ""), deferred=True),
    ]


class SchRpcRegisterTask_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("path", "")),
        NDRConfVarStrNullFieldUtf16("xml", ""),
        NDRIntField("flags", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("sddl", "")),
        NDRIntField("logonType", 0),
        NDRIntField("cCreds", None, size_of="pCreds"),
        NDRConfPacketListField(
            "pCreds", [], TASK_USER_CRED, size_is=lambda pkt: pkt.cCreds
        ),
    ]


class SchRpcRegisterTask_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pActualPath", "")),
        NDRFullPointerField(
            NDRPacketField("pErrorInfo", PTASK_XML_ERROR_INFO(), PTASK_XML_ERROR_INFO)
        ),
        NDRIntField("status", 0),
    ]


class SchRpcRetrieveTask_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("path", ""),
        NDRConfVarStrNullFieldUtf16("lpcwszLanguagesBuffer", ""),
        NDRIntField("pulNumLanguages", 0),
    ]


class SchRpcRetrieveTask_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pXml", "")),
        NDRIntField("status", 0),
    ]


class SchRpcCreateFolder_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("path", ""),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("sddl", "")),
        NDRIntField("flags", 0),
    ]


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


class SchRpcSetSecurity_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("path", ""),
        NDRConfVarStrNullFieldUtf16("sddl", ""),
        NDRIntField("flags", 0),
    ]


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


class SchRpcGetSecurity_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("path", ""),
        NDRIntField("securityInformation", 0),
    ]


class SchRpcGetSecurity_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("sddl", "")),
        NDRIntField("status", 0),
    ]


class SchRpcEnumFolders_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("path", ""),
        NDRIntField("flags", 0),
        NDRIntField("pStartIndex", 0),
        NDRIntField("cRequested", 0),
    ]


class SchRpcEnumFolders_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pStartIndex", 0),
        NDRIntField("pcNames", None, size_of="pNames"),
        NDRConfVarStrLenFieldUtf16("pNames", "", size_is=lambda pkt: pkt.pcNames),
        NDRIntField("status", 0),
    ]


class SchRpcEnumTasks_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("path", ""),
        NDRIntField("flags", 0),
        NDRIntField("startIndex", 0),
        NDRIntField("cRequested", 0),
    ]


class SchRpcEnumTasks_Response(NDRPacket):
    fields_desc = [
        NDRIntField("startIndex", 0),
        NDRIntField("pcNames", None, size_of="pNames"),
        NDRConfVarStrLenFieldUtf16("pNames", "", size_is=lambda pkt: pkt.pcNames),
        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 SchRpcEnumInstances_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("path", "")),
        NDRIntField("flags", 0),
    ]


class SchRpcEnumInstances_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pcGuids", None, size_of="pGuids"),
        NDRConfPacketListField(
            "pGuids", [], GUID, size_is=lambda pkt: pkt.pcGuids, ptr_pack=True
        ),
        NDRIntField("status", 0),
    ]


class SchRpcGetInstanceInfo_Request(NDRPacket):
    fields_desc = [NDRPacketField("guid", GUID(), GUID)]


class SchRpcGetInstanceInfo_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pPath", "")),
        NDRIntField("pState", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pCurrentAction", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pInfo", "")),
        NDRIntField("pcGroupInstances", None, size_of="pGroupInstances"),
        NDRConfPacketListField(
            "pGroupInstances",
            [],
            GUID,
            size_is=lambda pkt: pkt.pcGroupInstances,
            ptr_pack=True,
        ),
        NDRIntField("pEnginePID", 0),
        NDRIntField("status", 0),
    ]


class SchRpcStopInstance_Request(NDRPacket):
    fields_desc = [NDRPacketField("guid", GUID(), GUID), NDRIntField("flags", 0)]


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


class SchRpcStop_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("path", "")),
        NDRIntField("flags", 0),
    ]


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


class SchRpcRun_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("path", ""),
        NDRIntField("cArgs", None, size_of="pArgs"),
        NDRConfVarStrLenFieldUtf16("pArgs", "", size_is=lambda pkt: pkt.cArgs),
        NDRIntField("flags", 0),
        NDRIntField("sessionId", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("user", "")),
    ]


class SchRpcRun_Response(NDRPacket):
    fields_desc = [NDRPacketField("pGuid", GUID(), GUID), NDRIntField("status", 0)]


class SchRpcDelete_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("path", ""), NDRIntField("flags", 0)]


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


class SchRpcRename_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("path", ""),
        NDRConfVarStrNullFieldUtf16("newName", ""),
        NDRIntField("flags", 0),
    ]


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


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


class SchRpcScheduledRuntimes_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("path", ""),
        NDRFullPointerField(NDRPacketField("start", PSYSTEMTIME(), PSYSTEMTIME)),
        NDRFullPointerField(NDRPacketField("end", PSYSTEMTIME(), PSYSTEMTIME)),
        NDRIntField("flags", 0),
        NDRIntField("cRequested", 0),
    ]


class SchRpcScheduledRuntimes_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pcRuntimes", None, size_of="pRuntimes"),
        NDRConfPacketListField(
            "pRuntimes",
            [],
            PSYSTEMTIME,
            size_is=lambda pkt: pkt.pcRuntimes,
            ptr_pack=True,
        ),
        NDRIntField("status", 0),
    ]


class SchRpcGetLastRunInfo_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("path", "")]


class SchRpcGetLastRunInfo_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pLastRuntime", PSYSTEMTIME(), PSYSTEMTIME),
        NDRIntField("pLastReturnCode", 0),
        NDRIntField("status", 0),
    ]


class SchRpcGetTaskInfo_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("path", ""), NDRIntField("flags", 0)]


class SchRpcGetTaskInfo_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pEnabled", 0),
        NDRIntField("pState", 0),
        NDRIntField("status", 0),
    ]


class SchRpcGetNumberOfMissedRuns_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("path", "")]


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


class SchRpcEnableTask_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("path", ""), NDRIntField("enabled", 0)]


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


ITASKSCHEDULERSERVICE_OPNUMS = {
    0: DceRpcOp(SchRpcHighestVersion_Request, SchRpcHighestVersion_Response),
    1: DceRpcOp(SchRpcRegisterTask_Request, SchRpcRegisterTask_Response),
    2: DceRpcOp(SchRpcRetrieveTask_Request, SchRpcRetrieveTask_Response),
    3: DceRpcOp(SchRpcCreateFolder_Request, SchRpcCreateFolder_Response),
    4: DceRpcOp(SchRpcSetSecurity_Request, SchRpcSetSecurity_Response),
    5: DceRpcOp(SchRpcGetSecurity_Request, SchRpcGetSecurity_Response),
    6: DceRpcOp(SchRpcEnumFolders_Request, SchRpcEnumFolders_Response),
    7: DceRpcOp(SchRpcEnumTasks_Request, SchRpcEnumTasks_Response),
    8: DceRpcOp(SchRpcEnumInstances_Request, SchRpcEnumInstances_Response),
    9: DceRpcOp(SchRpcGetInstanceInfo_Request, SchRpcGetInstanceInfo_Response),
    10: DceRpcOp(SchRpcStopInstance_Request, SchRpcStopInstance_Response),
    11: DceRpcOp(SchRpcStop_Request, SchRpcStop_Response),
    12: DceRpcOp(SchRpcRun_Request, SchRpcRun_Response),
    13: DceRpcOp(SchRpcDelete_Request, SchRpcDelete_Response),
    14: DceRpcOp(SchRpcRename_Request, SchRpcRename_Response),
    15: DceRpcOp(SchRpcScheduledRuntimes_Request, SchRpcScheduledRuntimes_Response),
    16: DceRpcOp(SchRpcGetLastRunInfo_Request, SchRpcGetLastRunInfo_Response),
    17: DceRpcOp(SchRpcGetTaskInfo_Request, SchRpcGetTaskInfo_Response),
    18: DceRpcOp(
        SchRpcGetNumberOfMissedRuns_Request, SchRpcGetNumberOfMissedRuns_Response
    ),
    19: DceRpcOp(SchRpcEnableTask_Request, SchRpcEnableTask_Response),
}
register_dcerpc_interface(
    name="ITaskSchedulerService",
    uuid=uuid.UUID("86D35949-83C9-4044-B424-DB363231FD0C"),
    version="1.0",
    opnums=ITASKSCHEDULERSERVICE_OPNUMS,
)
