### ms-csra.idl
"""
RPC definitions for the following interfaces:
- ICertAdminD (v0.0): d99e6e71-fc88-11d0-b498-00a0c90312f3
- ICertAdminD2 (v0.0): 7fe0d935-dda6-443f-85d0-1cfb58fe41dd
This file is auto-generated by midl-to-scapy, do not modify.
"""

from enum import IntEnum
import uuid


from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRConfFieldListField,
    NDRConfPacketListField,
    NDRConfStrLenField,
    NDRConfStrLenFieldUtf16,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRFullPointerField,
    NDRIntField,
    NDRLongField,
    NDRPacketField,
    NDRRecursiveField,
    NDRRefEmbPointerField,
    NDRShortField,
    NDRSignedIntField,
    NDRSignedLongField,
    register_com_interface,
)


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


class SetExtension_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("dwRequestId", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszExtensionName", "")),
        NDRIntField("dwType", 0),
        NDRIntField("dwFlags", 0),
        NDRPacketField("pctbValue", CERTTRANSBLOB(), CERTTRANSBLOB),
    ]


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


class SetAttributes_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("dwRequestId", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAttributes", "")),
    ]


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


class ResubmitRequest_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("dwRequestId", 0),
    ]


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


class DenyRequest_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("dwRequestId", 0),
    ]


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


class IsValidCertificate_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pSerialNumber", "")),
    ]


class IsValidCertificate_Response(NDRPacket):
    fields_desc = [
        NDRSignedIntField("pRevocationReason", 0),
        NDRSignedIntField("pDisposition", 0),
        NDRIntField("status", 0),
    ]


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


class PublishCRL_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRPacketField("FileTime", FILETIME(), FILETIME),
    ]


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


class GetCRL_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", ""))
    ]


class GetCRL_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pctbCRL", CERTTRANSBLOB(), CERTTRANSBLOB),
        NDRIntField("status", 0),
    ]


class RevokeCertificate_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszSerialNumber", "")),
        NDRIntField("Reason", 0),
        NDRPacketField("FileTime", FILETIME(), FILETIME),
    ]


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


class EnumViewColumn_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("iColumn", 0),
        NDRIntField("cColumn", 0),
    ]


class EnumViewColumn_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pcColumn", 0),
        NDRPacketField("pctbColumnInfo", CERTTRANSBLOB(), CERTTRANSBLOB),
        NDRIntField("status", 0),
    ]


class GetViewDefaultColumnSet_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("iColumnSetDefault", 0),
    ]


class GetViewDefaultColumnSet_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pcColumn", 0),
        NDRPacketField("pctbColumnInfo", CERTTRANSBLOB(), CERTTRANSBLOB),
        NDRIntField("status", 0),
    ]


class EnumAttributesOrExtensions_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("RowId", 0),
        NDRIntField("Flags", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszLast", "")),
        NDRIntField("celt", 0),
    ]


class EnumAttributesOrExtensions_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pceltFetched", 0),
        NDRPacketField("pctbOut", CERTTRANSBLOB(), CERTTRANSBLOB),
        NDRIntField("status", 0),
    ]


class CERTVIEWRESTRICTION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("ColumnIndex", 0),
        NDRSignedIntField("SeekOperator", 0),
        NDRSignedIntField("SortOrder", 0),
        NDRFullPointerField(
            NDRConfStrLenField("pbValue", "", size_is=lambda pkt: pkt.cbValue),
            deferred=True,
        ),
        NDRIntField("cbValue", None, size_of="pbValue"),
    ]


class OpenView_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("ccvr", None, size_of="acvr"),
        NDRConfPacketListField(
            "acvr", [], CERTVIEWRESTRICTION, size_is=lambda pkt: pkt.ccvr
        ),
        NDRIntField("ccolOut", None, size_of="acolOut"),
        NDRConfFieldListField(
            "acolOut", [], NDRIntField("", 0), size_is=lambda pkt: pkt.ccolOut
        ),
        NDRIntField("ielt", 0),
        NDRIntField("celt", 0),
    ]


class OpenView_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pceltFetched", 0),
        NDRPacketField("pctbResultRows", CERTTRANSBLOB(), CERTTRANSBLOB),
        NDRIntField("status", 0),
    ]


class EnumView_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("ielt", 0),
        NDRIntField("celt", 0),
    ]


class EnumView_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pceltFetched", 0),
        NDRPacketField("pctbResultRows", CERTTRANSBLOB(), CERTTRANSBLOB),
        NDRIntField("status", 0),
    ]


class CloseView_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", ""))
    ]


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


class ServerControl_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("dwControlFlags", 0),
    ]


class ServerControl_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pctbOut", CERTTRANSBLOB(), CERTTRANSBLOB),
        NDRIntField("status", 0),
    ]


class Ping_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", ""))
    ]


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


class GetServerState_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", ""))
    ]


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


class BackupPrepare_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("grbitJet", 0),
        NDRIntField("dwBackupFlags", 0),
        NDRShortField("pwszBackupAnnotation", 0),
        NDRIntField("dwClientIdentifier", 0),
    ]


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


class BackupEnd_Request(NDRPacket):
    fields_desc = []


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


class BackupGetAttachmentInformation_Request(NDRPacket):
    fields_desc = []


class BackupGetAttachmentInformation_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenFieldUtf16(
            "ppwszzDBFiles", "", size_is=lambda pkt: pkt.pcwcDBFiles
        ),
        NDRSignedIntField("pcwcDBFiles", None, size_of="ppwszzDBFiles"),
        NDRIntField("status", 0),
    ]


class BackupGetBackupLogs_Request(NDRPacket):
    fields_desc = []


class BackupGetBackupLogs_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenFieldUtf16(
            "ppwszzLogFiles", "", size_is=lambda pkt: pkt.pcwcLogFiles
        ),
        NDRSignedIntField("pcwcLogFiles", None, size_of="ppwszzLogFiles"),
        NDRIntField("status", 0),
    ]


class BackupOpenFile_Request(NDRPacket):
    fields_desc = [NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszPath", ""))]


class BackupOpenFile_Response(NDRPacket):
    fields_desc = [NDRLongField("pliLength", 0), NDRIntField("status", 0)]


class BackupReadFile_Request(NDRPacket):
    fields_desc = [NDRSignedIntField("cbBuffer", 0)]


class BackupReadFile_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("pbBuffer", "", size_is=lambda pkt: pkt.cbBuffer),
        NDRSignedIntField("pcbRead", 0),
        NDRIntField("status", 0),
    ]


class BackupCloseFile_Request(NDRPacket):
    fields_desc = []


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


class BackupTruncateLogs_Request(NDRPacket):
    fields_desc = []


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


class ImportCertificate_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRPacketField("pctbCertificate", CERTTRANSBLOB(), CERTTRANSBLOB),
        NDRSignedIntField("dwFlags", 0),
    ]


class ImportCertificate_Response(NDRPacket):
    fields_desc = [NDRSignedIntField("pdwRequestId", 0), NDRIntField("status", 0)]


class BackupGetDynamicFiles_Request(NDRPacket):
    fields_desc = []


class BackupGetDynamicFiles_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenFieldUtf16("ppwszzFiles", "", size_is=lambda pkt: pkt.pcwcFiles),
        NDRSignedIntField("pcwcFiles", None, size_of="ppwszzFiles"),
        NDRIntField("status", 0),
    ]


class RestoreGetDatabaseLocations_Request(NDRPacket):
    fields_desc = []


class RestoreGetDatabaseLocations_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenFieldUtf16(
            "ppwszzDatabaseLocations", "", size_is=lambda pkt: pkt.pcwcPaths
        ),
        NDRSignedIntField("pcwcPaths", None, size_of="ppwszzDatabaseLocations"),
        NDRIntField("status", 0),
    ]


ICERTADMIND_OPNUMS = {
    0: DceRpcOp(SetExtension_Request, SetExtension_Response),
    1: DceRpcOp(SetAttributes_Request, SetAttributes_Response),
    2: DceRpcOp(ResubmitRequest_Request, ResubmitRequest_Response),
    3: DceRpcOp(DenyRequest_Request, DenyRequest_Response),
    4: DceRpcOp(IsValidCertificate_Request, IsValidCertificate_Response),
    5: DceRpcOp(PublishCRL_Request, PublishCRL_Response),
    6: DceRpcOp(GetCRL_Request, GetCRL_Response),
    7: DceRpcOp(RevokeCertificate_Request, RevokeCertificate_Response),
    8: DceRpcOp(EnumViewColumn_Request, EnumViewColumn_Response),
    9: DceRpcOp(GetViewDefaultColumnSet_Request, GetViewDefaultColumnSet_Response),
    10: DceRpcOp(
        EnumAttributesOrExtensions_Request, EnumAttributesOrExtensions_Response
    ),
    11: DceRpcOp(OpenView_Request, OpenView_Response),
    12: DceRpcOp(EnumView_Request, EnumView_Response),
    13: DceRpcOp(CloseView_Request, CloseView_Response),
    14: DceRpcOp(ServerControl_Request, ServerControl_Response),
    15: DceRpcOp(Ping_Request, Ping_Response),
    16: DceRpcOp(GetServerState_Request, GetServerState_Response),
    17: DceRpcOp(BackupPrepare_Request, BackupPrepare_Response),
    18: DceRpcOp(BackupEnd_Request, BackupEnd_Response),
    19: DceRpcOp(
        BackupGetAttachmentInformation_Request, BackupGetAttachmentInformation_Response
    ),
    20: DceRpcOp(BackupGetBackupLogs_Request, BackupGetBackupLogs_Response),
    21: DceRpcOp(BackupOpenFile_Request, BackupOpenFile_Response),
    22: DceRpcOp(BackupReadFile_Request, BackupReadFile_Response),
    23: DceRpcOp(BackupCloseFile_Request, BackupCloseFile_Response),
    24: DceRpcOp(BackupTruncateLogs_Request, BackupTruncateLogs_Response),
    25: DceRpcOp(ImportCertificate_Request, ImportCertificate_Response),
    26: DceRpcOp(BackupGetDynamicFiles_Request, BackupGetDynamicFiles_Response),
    27: DceRpcOp(
        RestoreGetDatabaseLocations_Request, RestoreGetDatabaseLocations_Response
    ),
}
register_com_interface(
    name="ICertAdminD",
    uuid=uuid.UUID("d99e6e71-fc88-11d0-b498-00a0c90312f3"),
    opnums=ICERTADMIND_OPNUMS,
)


class PublishCRLs_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRPacketField("FileTime", FILETIME(), FILETIME),
        NDRIntField("Flags", 0),
    ]


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


class GetCAProperty_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRSignedIntField("PropId", 0),
        NDRSignedIntField("PropIndex", 0),
        NDRSignedIntField("PropType", 0),
    ]


class GetCAProperty_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pctbPropertyValue", CERTTRANSBLOB(), CERTTRANSBLOB),
        NDRIntField("status", 0),
    ]


class SetCAProperty_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRSignedIntField("PropId", 0),
        NDRSignedIntField("PropIndex", 0),
        NDRSignedIntField("PropType", 0),
        NDRPacketField("pctbPropertyValue", CERTTRANSBLOB(), CERTTRANSBLOB),
    ]


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


class GetCAPropertyInfo_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", ""))
    ]


class GetCAPropertyInfo_Response(NDRPacket):
    fields_desc = [
        NDRSignedIntField("pcProperty", 0),
        NDRPacketField("pctbPropInfo", CERTTRANSBLOB(), CERTTRANSBLOB),
        NDRIntField("status", 0),
    ]


class EnumViewColumnTable_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("iTable", 0),
        NDRIntField("iColumn", 0),
        NDRIntField("cColumn", 0),
    ]


class EnumViewColumnTable_Response(NDRPacket):
    fields_desc = [
        NDRIntField("pcColumn", 0),
        NDRPacketField("pctbColumnInfo", CERTTRANSBLOB(), CERTTRANSBLOB),
        NDRIntField("status", 0),
    ]


class GetCASecurity_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", ""))
    ]


class GetCASecurity_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pctbSD", CERTTRANSBLOB(), CERTTRANSBLOB),
        NDRIntField("status", 0),
    ]


class SetCASecurity_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRPacketField("pctbSD", CERTTRANSBLOB(), CERTTRANSBLOB),
    ]


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


class Ping2_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", ""))
    ]


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


class GetArchivedKey_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("dwRequestId", 0),
    ]


class GetArchivedKey_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pctbArchivedKey", CERTTRANSBLOB(), CERTTRANSBLOB),
        NDRIntField("status", 0),
    ]


class GetAuditFilter_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", ""))
    ]


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


class SetAuditFilter_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("dwFilter", 0),
    ]


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


class GetOfficerRights_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", ""))
    ]


class GetOfficerRights_Response(NDRPacket):
    fields_desc = [
        NDRSignedIntField("pfEnabled", 0),
        NDRPacketField("pctbSD", CERTTRANSBLOB(), CERTTRANSBLOB),
        NDRIntField("status", 0),
    ]


class SetOfficerRights_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRSignedIntField("fEnable", 0),
        NDRPacketField("pctbSD", CERTTRANSBLOB(), CERTTRANSBLOB),
    ]


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


class VARENUM(IntEnum):
    VT_EMPTY = 0
    VT_NULL = 1
    VT_I2 = 2
    VT_I4 = 3
    VT_R4 = 4
    VT_R8 = 5
    VT_CY = 6
    VT_DATE = 7
    VT_BSTR = 8
    VT_DISPATCH = 9
    VT_ERROR = 10
    VT_BOOL = 11
    VT_VARIANT = 12
    VT_UNKNOWN = 13
    VT_DECIMAL = 14
    VT_I1 = 16
    VT_UI1 = 17
    VT_UI2 = 18
    VT_UI4 = 19
    VT_I8 = 20
    VT_UI8 = 21
    VT_INT = 22
    VT_UINT = 23
    VT_VOID = 24
    VT_HRESULT = 25
    VT_PTR = 26
    VT_SAFEARRAY = 27
    VT_CARRAY = 28
    VT_USERDEFINED = 29
    VT_LPSTR = 30
    VT_LPWSTR = 31
    VT_RECORD = 36
    VT_INT_PTR = 37
    VT_UINT_PTR = 38
    VT_ARRAY = 8192
    VT_BYREF = 16384


class CURRENCY(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [NDRSignedLongField("int64", 0)]


class FLAGGED_WORD_BLOB(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["asData"]
    fields_desc = [
        NDRIntField("cBytes", 0),
        NDRIntField("clSize", None, size_of="asData"),
        NDRConfStrLenFieldUtf16(
            "asData", "", size_is=lambda pkt: pkt.clSize, conformant_in_struct=True
        ),
    ]


class MInterfacePointer(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["abData"]
    fields_desc = [
        NDRIntField("ulCntData", None, size_of="abData"),
        NDRConfStrLenField(
            "abData", "", size_is=lambda pkt: pkt.ulCntData, conformant_in_struct=True
        ),
    ]


class VARENUM(IntEnum):
    VT_EMPTY = 0
    VT_NULL = 1
    VT_I2 = 2
    VT_I4 = 3
    VT_R4 = 4
    VT_R8 = 5
    VT_CY = 6
    VT_DATE = 7
    VT_BSTR = 8
    VT_DISPATCH = 9
    VT_ERROR = 10
    VT_BOOL = 11
    VT_VARIANT = 12
    VT_UNKNOWN = 13
    VT_DECIMAL = 14
    VT_I1 = 16
    VT_UI1 = 17
    VT_UI2 = 18
    VT_UI4 = 19
    VT_I8 = 20
    VT_UI8 = 21
    VT_INT = 22
    VT_UINT = 23
    VT_VOID = 24
    VT_HRESULT = 25
    VT_PTR = 26
    VT_SAFEARRAY = 27
    VT_CARRAY = 28
    VT_USERDEFINED = 29
    VT_LPSTR = 30
    VT_LPWSTR = 31
    VT_RECORD = 36
    VT_INT_PTR = 37
    VT_UINT_PTR = 38
    VT_ARRAY = 8192
    VT_BYREF = 16384


class SF_TYPE(IntEnum):
    SF_ERROR = VARENUM.VT_ERROR
    SF_I1 = VARENUM.VT_I1
    SF_I2 = VARENUM.VT_I2
    SF_I4 = VARENUM.VT_I4
    SF_I8 = VARENUM.VT_I8
    SF_BSTR = VARENUM.VT_BSTR
    SF_UNKNOWN = VARENUM.VT_UNKNOWN
    SF_DISPATCH = VARENUM.VT_DISPATCH
    SF_VARIANT = VARENUM.VT_VARIANT
    SF_RECORD = VARENUM.VT_RECORD
    SF_HAVEIID = VARENUM.VT_UNKNOWN | 32768


class SAFEARR_BSTR(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Size", None, size_of="aBstr"),
        NDRRefEmbPointerField(
            NDRConfPacketListField(
                "aBstr", [], FLAGGED_WORD_BLOB, size_is=lambda pkt: pkt.Size
            ),
            deferred=True,
        ),
    ]


class SAFEARR_UNKNOWN(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Size", None, size_of="apUnknown"),
        NDRRefEmbPointerField(
            NDRConfPacketListField(
                "apUnknown", [], MInterfacePointer, size_is=lambda pkt: pkt.Size
            ),
            deferred=True,
        ),
    ]


class SAFEARR_DISPATCH(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Size", None, size_of="apDispatch"),
        NDRRefEmbPointerField(
            NDRConfPacketListField(
                "apDispatch", [], MInterfacePointer, size_is=lambda pkt: pkt.Size
            ),
            deferred=True,
        ),
    ]


class wireVARIANTStr(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("clSize", 0),
        NDRIntField("rpcReserved", 0),
        NDRShortField("vt", 0),
        NDRShortField("wReserved1", 0),
        NDRShortField("wReserved2", 0),
        NDRShortField("wReserved3", 0),
        NDRRecursiveField("_varUnion"),
    ]


class GetConfigEntry_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszNodePath", "")),
        NDRConfVarStrNullFieldUtf16("pwszEntry", ""),
    ]


class GetConfigEntry_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("pVariant", wireVARIANTStr(), wireVARIANTStr)
        ),
        NDRIntField("status", 0),
    ]


class SetConfigEntry_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszNodePath", "")),
        NDRConfVarStrNullFieldUtf16("pwszEntry", ""),
        NDRFullPointerField(
            NDRPacketField("pVariant", wireVARIANTStr(), wireVARIANTStr)
        ),
    ]


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


class ImportKey_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("dwRequestId", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszCertHash", "")),
        NDRIntField("dwFlags", 0),
        NDRPacketField("pctbKey", CERTTRANSBLOB(), CERTTRANSBLOB),
    ]


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


class GetMyRoles_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", ""))
    ]


class GetMyRoles_Response(NDRPacket):
    fields_desc = [NDRSignedIntField("pdwRoles", 0), NDRIntField("status", 0)]


class DeleteRow_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pwszAuthority", "")),
        NDRIntField("dwFlags", 0),
        NDRPacketField("FileTime", FILETIME(), FILETIME),
        NDRIntField("dwTable", 0),
        NDRIntField("dwRowId", 0),
    ]


class DeleteRow_Response(NDRPacket):
    fields_desc = [NDRSignedIntField("pcDeleted", 0), NDRIntField("status", 0)]


ICERTADMIND2_OPNUMS = {
    0: DceRpcOp(PublishCRLs_Request, PublishCRLs_Response),
    1: DceRpcOp(GetCAProperty_Request, GetCAProperty_Response),
    2: DceRpcOp(SetCAProperty_Request, SetCAProperty_Response),
    3: DceRpcOp(GetCAPropertyInfo_Request, GetCAPropertyInfo_Response),
    4: DceRpcOp(EnumViewColumnTable_Request, EnumViewColumnTable_Response),
    5: DceRpcOp(GetCASecurity_Request, GetCASecurity_Response),
    6: DceRpcOp(SetCASecurity_Request, SetCASecurity_Response),
    7: DceRpcOp(Ping2_Request, Ping2_Response),
    8: DceRpcOp(GetArchivedKey_Request, GetArchivedKey_Response),
    9: DceRpcOp(GetAuditFilter_Request, GetAuditFilter_Response),
    10: DceRpcOp(SetAuditFilter_Request, SetAuditFilter_Response),
    11: DceRpcOp(GetOfficerRights_Request, GetOfficerRights_Response),
    12: DceRpcOp(SetOfficerRights_Request, SetOfficerRights_Response),
    13: DceRpcOp(GetConfigEntry_Request, GetConfigEntry_Response),
    14: DceRpcOp(SetConfigEntry_Request, SetConfigEntry_Response),
    15: DceRpcOp(ImportKey_Request, ImportKey_Response),
    16: DceRpcOp(GetMyRoles_Request, GetMyRoles_Response),
    17: DceRpcOp(DeleteRow_Request, DeleteRow_Response),
}
register_com_interface(
    name="ICertAdminD2",
    uuid=uuid.UUID("7fe0d935-dda6-443f-85d0-1cfb58fe41dd"),
    opnums=ICERTADMIND2_OPNUMS,
)
