#pragma once

#include "KswordArkProcessIoctl.h"

// ============================================================
// KswordArkDynDataIoctl.h
// Purpose:
// - Shared R3/R0 protocol for querying DynData profile status, field offsets,
//   and derived feature capability flags.
// - This file is the only shared protocol surface for Phase 0 DynData queries.
// ============================================================

#define KSWORD_ARK_DYNDATA_PROTOCOL_VERSION 1UL

#define KSWORD_ARK_IOCTL_FUNCTION_QUERY_DYN_STATUS 0x807
#define KSWORD_ARK_IOCTL_FUNCTION_QUERY_DYN_FIELDS 0x808
#define KSWORD_ARK_IOCTL_FUNCTION_QUERY_CAPABILITIES 0x809
#define KSWORD_ARK_IOCTL_FUNCTION_APPLY_DYN_PROFILE 0x82F
#define KSWORD_ARK_IOCTL_FUNCTION_APPLY_DYN_PROFILE_EX 0x830
#define KSWORD_ARK_IOCTL_FUNCTION_APPLY_DYN_PROFILE_V4 0x860
#define KSWORD_ARK_IOCTL_FUNCTION_QUERY_DYN_V4_MODULES 0x861
#define KSWORD_ARK_IOCTL_FUNCTION_QUERY_DYN_V4_CAPABILITY_GROUPS 0x862
#define KSWORD_ARK_IOCTL_FUNCTION_QUERY_DYN_V4_MISSING_ITEMS 0x863
#define KSWORD_ARK_IOCTL_FUNCTION_QUERY_DYN_V4_ITEMS 0x864

#define IOCTL_KSWORD_ARK_QUERY_DYN_STATUS \
    CTL_CODE( \
        KSWORD_ARK_IOCTL_DEVICE_TYPE, \
        KSWORD_ARK_IOCTL_FUNCTION_QUERY_DYN_STATUS, \
        METHOD_BUFFERED, \
        FILE_ANY_ACCESS)

#define IOCTL_KSWORD_ARK_QUERY_DYN_FIELDS \
    CTL_CODE( \
        KSWORD_ARK_IOCTL_DEVICE_TYPE, \
        KSWORD_ARK_IOCTL_FUNCTION_QUERY_DYN_FIELDS, \
        METHOD_BUFFERED, \
        FILE_ANY_ACCESS)

#define IOCTL_KSWORD_ARK_QUERY_CAPABILITIES \
    CTL_CODE( \
        KSWORD_ARK_IOCTL_DEVICE_TYPE, \
        KSWORD_ARK_IOCTL_FUNCTION_QUERY_CAPABILITIES, \
        METHOD_BUFFERED, \
        FILE_ANY_ACCESS)

#define IOCTL_KSWORD_ARK_APPLY_DYN_PROFILE \
    CTL_CODE( \
        KSWORD_ARK_IOCTL_DEVICE_TYPE, \
        KSWORD_ARK_IOCTL_FUNCTION_APPLY_DYN_PROFILE, \
        METHOD_BUFFERED, \
        FILE_WRITE_ACCESS)

#define IOCTL_KSWORD_ARK_APPLY_DYN_PROFILE_EX \
    CTL_CODE( \
        KSWORD_ARK_IOCTL_DEVICE_TYPE, \
        KSWORD_ARK_IOCTL_FUNCTION_APPLY_DYN_PROFILE_EX, \
        METHOD_BUFFERED, \
        FILE_WRITE_ACCESS)

#define IOCTL_KSWORD_ARK_APPLY_DYN_PROFILE_V4 \
    CTL_CODE( \
        KSWORD_ARK_IOCTL_DEVICE_TYPE, \
        KSWORD_ARK_IOCTL_FUNCTION_APPLY_DYN_PROFILE_V4, \
        METHOD_BUFFERED, \
        FILE_ANY_ACCESS)

#define IOCTL_KSWORD_ARK_QUERY_DYN_V4_MODULES \
    CTL_CODE( \
        KSWORD_ARK_IOCTL_DEVICE_TYPE, \
        KSWORD_ARK_IOCTL_FUNCTION_QUERY_DYN_V4_MODULES, \
        METHOD_BUFFERED, \
        FILE_ANY_ACCESS)

#define IOCTL_KSWORD_ARK_QUERY_DYN_V4_CAPABILITY_GROUPS \
    CTL_CODE( \
        KSWORD_ARK_IOCTL_DEVICE_TYPE, \
        KSWORD_ARK_IOCTL_FUNCTION_QUERY_DYN_V4_CAPABILITY_GROUPS, \
        METHOD_BUFFERED, \
        FILE_ANY_ACCESS)

#define IOCTL_KSWORD_ARK_QUERY_DYN_V4_MISSING_ITEMS \
    CTL_CODE( \
        KSWORD_ARK_IOCTL_DEVICE_TYPE, \
        KSWORD_ARK_IOCTL_FUNCTION_QUERY_DYN_V4_MISSING_ITEMS, \
        METHOD_BUFFERED, \
        FILE_ANY_ACCESS)

#define IOCTL_KSWORD_ARK_QUERY_DYN_V4_ITEMS \
    CTL_CODE( \
        KSWORD_ARK_IOCTL_DEVICE_TYPE, \
        KSWORD_ARK_IOCTL_FUNCTION_QUERY_DYN_V4_ITEMS, \
        METHOD_BUFFERED, \
        FILE_ANY_ACCESS)

#define KSW_CAP_DYN_NTOS_ACTIVE             0x0000000000000001ULL
#define KSW_CAP_DYN_LXCORE_ACTIVE           0x0000000000000002ULL
#define KSW_CAP_OBJECT_TYPE_FIELDS          0x0000000000000004ULL
#define KSW_CAP_HANDLE_TABLE_DECODE         0x0000000000000008ULL
#define KSW_CAP_PROCESS_OBJECT_TABLE        0x0000000000000010ULL
#define KSW_CAP_THREAD_STACK_FIELDS         0x0000000000000020ULL
#define KSW_CAP_THREAD_IO_COUNTERS          0x0000000000000040ULL
#define KSW_CAP_ALPC_FIELDS                 0x0000000000000080ULL
#define KSW_CAP_SECTION_CONTROL_AREA        0x0000000000000100ULL
#define KSW_CAP_PROCESS_PROTECTION_PATCH    0x0000000000000200ULL
#define KSW_CAP_WSL_LXCORE_FIELDS           0x0000000000000400ULL
#define KSW_CAP_ETW_GUID_FIELDS             0x0000000000000800ULL
#define KSW_CAP_CALLBACK_NOTIFY_GLOBALS     0x0000000000001000ULL
#define KSW_CAP_CALLBACK_REGISTRY_GLOBALS   0x0000000000002000ULL
#define KSW_CAP_CALLBACK_OBJECT_FIELDS      0x0000000000004000ULL
#define KSW_CAP_PROCESS_LIST_FIELDS         0x0000000000008000ULL
#define KSW_CAP_THREAD_LIST_FIELDS          0x0000000000010000ULL
#define KSW_CAP_CID_TABLE_WALK              0x0000000000020000ULL
#define KSW_CAP_KERNEL_MODULE_LIST_FIELDS   0x0000000000040000ULL
#define KSW_CAP_DRIVER_OBJECT_FIELDS        0x0000000000080000ULL
#define KSW_CAP_KERNEL_GLOBALS              0x0000000000100000ULL
#define KSW_CAP_TOKEN_INTEGRITY_FIELDS      0x0000000000200000ULL
#define KSW_CAP_TOKEN_PRIVATE_FIELDS        0x0000000000400000ULL

#define KSW_DYN_STATUS_FLAG_INITIALIZED      0x00000001UL
#define KSW_DYN_STATUS_FLAG_NTOS_ACTIVE      0x00000002UL
#define KSW_DYN_STATUS_FLAG_LXCORE_ACTIVE    0x00000004UL
#define KSW_DYN_STATUS_FLAG_EXTRA_ACTIVE     0x00000008UL
#define KSW_DYN_STATUS_FLAG_PDB_PROFILE_ACTIVE 0x00000010UL
#define KSW_DYN_STATUS_FLAG_CALLBACK_PROFILE_ACTIVE 0x00000020UL

#define KSW_DYN_MODULE_NAME_CHARS 64U
#define KSW_DYN_REASON_CHARS 160U
#define KSW_DYN_FIELD_NAME_CHARS 64U
#define KSW_DYN_FIELD_SOURCE_CHARS 32U
#define KSW_DYN_FIELD_FEATURE_CHARS 64U
#define KSW_DYN_PROFILE_NAME_CHARS 96U
#define KSW_DYN_PDB_NAME_CHARS 64U
#define KSW_DYN_PDB_GUID_CHARS 40U
#define KSW_DYN_PROFILE_MAX_FIELDS 256U
#define KSW_DYN_PROFILE_EX_MAX_ITEMS 384U
#define KSW_DYN_PROFILE_OFFSET_MAX 0x0000FFFFUL
#define KSW_DYN_PROFILE_GLOBAL_RVA_MAX 0x7FFFFFFFUL
#define KSW_DYN_PROFILE_FLAG_TRANSPORT_IOCTL 0x00000001UL
#define KSW_DYN_PROFILE_FLAG_TRANSPORT_SECTION_RESERVED 0x00000002UL

#define KSW_DYN_PROFILE_CLASS_NTOSKRNL 0U
#define KSW_DYN_PROFILE_CLASS_NTKRLA57 1U
#define KSW_DYN_PROFILE_CLASS_LXCORE 2U
#define KSW_DYN_PROFILE_CLASS_WIN32K 16U
#define KSW_DYN_PROFILE_CLASS_WIN32KBASE 17U
#define KSW_DYN_PROFILE_CLASS_WIN32KFULL 18U
#define KSW_DYN_PROFILE_CLASS_TCPIP 32U
#define KSW_DYN_PROFILE_CLASS_NDIS 33U
#define KSW_DYN_PROFILE_CLASS_NETIO 34U
#define KSW_DYN_PROFILE_CLASS_FLTMGR 48U
#define KSW_DYN_PROFILE_CLASS_FVEVOL 64U
#define KSW_DYN_PROFILE_CLASS_CI 65U

#define KSW_DYN_FIELD_SOURCE_UNAVAILABLE 0UL
#define KSW_DYN_FIELD_SOURCE_SYSTEM_INFORMER 1UL
#define KSW_DYN_FIELD_SOURCE_RUNTIME_PATTERN 2UL
#define KSW_DYN_FIELD_SOURCE_KSWORD_EXTRA_TABLE 3UL
#define KSW_DYN_FIELD_SOURCE_PDB_PROFILE 4UL

#define KSW_DYN_FIELD_FLAG_PRESENT 0x00000001UL
#define KSW_DYN_FIELD_FLAG_REQUIRED 0x00000002UL
#define KSW_DYN_FIELD_FLAG_OPTIONAL 0x00000004UL

#define KSW_DYN_FIELD_ID_EP_OBJECT_TABLE 1UL
#define KSW_DYN_FIELD_ID_EP_SECTION_OBJECT 2UL
#define KSW_DYN_FIELD_ID_HT_HANDLE_CONTENTION_EVENT 3UL
#define KSW_DYN_FIELD_ID_OT_NAME 4UL
#define KSW_DYN_FIELD_ID_OT_INDEX 5UL
#define KSW_DYN_FIELD_ID_OB_DECODE_SHIFT 6UL
#define KSW_DYN_FIELD_ID_OB_ATTRIBUTES_SHIFT 7UL
#define KSW_DYN_FIELD_ID_KT_INITIAL_STACK 8UL
#define KSW_DYN_FIELD_ID_KT_STACK_LIMIT 9UL
#define KSW_DYN_FIELD_ID_KT_STACK_BASE 10UL
#define KSW_DYN_FIELD_ID_KT_KERNEL_STACK 11UL
#define KSW_DYN_FIELD_ID_KT_READ_OPERATION_COUNT 12UL
#define KSW_DYN_FIELD_ID_KT_WRITE_OPERATION_COUNT 13UL
#define KSW_DYN_FIELD_ID_KT_OTHER_OPERATION_COUNT 14UL
#define KSW_DYN_FIELD_ID_KT_READ_TRANSFER_COUNT 15UL
#define KSW_DYN_FIELD_ID_KT_WRITE_TRANSFER_COUNT 16UL
#define KSW_DYN_FIELD_ID_KT_OTHER_TRANSFER_COUNT 17UL
#define KSW_DYN_FIELD_ID_MM_SECTION_CONTROL_AREA 18UL
#define KSW_DYN_FIELD_ID_MM_CONTROL_AREA_LIST_HEAD 19UL
#define KSW_DYN_FIELD_ID_MM_CONTROL_AREA_LOCK 20UL
#define KSW_DYN_FIELD_ID_ALPC_COMMUNICATION_INFO 21UL
#define KSW_DYN_FIELD_ID_ALPC_OWNER_PROCESS 22UL
#define KSW_DYN_FIELD_ID_ALPC_CONNECTION_PORT 23UL
#define KSW_DYN_FIELD_ID_ALPC_SERVER_COMMUNICATION_PORT 24UL
#define KSW_DYN_FIELD_ID_ALPC_CLIENT_COMMUNICATION_PORT 25UL
#define KSW_DYN_FIELD_ID_ALPC_HANDLE_TABLE 26UL
#define KSW_DYN_FIELD_ID_ALPC_HANDLE_TABLE_LOCK 27UL
#define KSW_DYN_FIELD_ID_ALPC_ATTRIBUTES 28UL
#define KSW_DYN_FIELD_ID_ALPC_ATTRIBUTES_FLAGS 29UL
#define KSW_DYN_FIELD_ID_ALPC_PORT_CONTEXT 30UL
#define KSW_DYN_FIELD_ID_ALPC_PORT_OBJECT_LOCK 31UL
#define KSW_DYN_FIELD_ID_ALPC_SEQUENCE_NO 32UL
#define KSW_DYN_FIELD_ID_ALPC_STATE 33UL
#define KSW_DYN_FIELD_ID_LX_PICO_PROC 34UL
#define KSW_DYN_FIELD_ID_LX_PICO_PROC_INFO 35UL
#define KSW_DYN_FIELD_ID_LX_PICO_PROC_INFO_PID 36UL
#define KSW_DYN_FIELD_ID_LX_PICO_THRD_INFO 37UL
#define KSW_DYN_FIELD_ID_LX_PICO_THRD_INFO_TID 38UL
#define KSW_DYN_FIELD_ID_EP_PROTECTION 39UL
#define KSW_DYN_FIELD_ID_EP_SIGNATURE_LEVEL 40UL
#define KSW_DYN_FIELD_ID_EP_SECTION_SIGNATURE_LEVEL 41UL
#define KSW_DYN_FIELD_ID_EGE_GUID 42UL
#define KSW_DYN_FIELD_ID_ERE_GUID_ENTRY 43UL
#define KSW_DYN_FIELD_ID_CB_PSP_CREATE_PROCESS_NOTIFY_ROUTINE 44UL
#define KSW_DYN_FIELD_ID_CB_PSP_CREATE_THREAD_NOTIFY_ROUTINE 45UL
#define KSW_DYN_FIELD_ID_CB_PSP_LOAD_IMAGE_NOTIFY_ROUTINE 46UL
#define KSW_DYN_FIELD_ID_CB_PSP_NOTIFY_ENABLE_MASK 47UL
#define KSW_DYN_FIELD_ID_CB_CM_CALLBACK_LIST_HEAD 48UL
#define KSW_DYN_FIELD_ID_CB_OBJECT_TYPE_CALLBACK_LIST 49UL
#define KSW_DYN_FIELD_ID_CB_CALLBACK_ENTRY_ITEM_ENTRY_LIST 50UL
#define KSW_DYN_FIELD_ID_CB_CALLBACK_ENTRY_ITEM_PRE_OPERATION 51UL
#define KSW_DYN_FIELD_ID_CB_CALLBACK_ENTRY_ITEM_POST_OPERATION 52UL
#define KSW_DYN_FIELD_ID_CB_CALLBACK_ENTRY_ITEM_OPERATIONS 53UL
#define KSW_DYN_FIELD_ID_CB_CALLBACK_ENTRY_ITEM_CALLBACK_ENTRY 54UL
#define KSW_DYN_FIELD_ID_CB_CALLBACK_ENTRY_ALTITUDE 55UL
#define KSW_DYN_FIELD_ID_CB_CALLBACK_ENTRY_REGISTRATION_CONTEXT 56UL
#define KSW_DYN_FIELD_ID_EP_UNIQUE_PROCESS_ID 57UL
#define KSW_DYN_FIELD_ID_EP_ACTIVE_PROCESS_LINKS 58UL
#define KSW_DYN_FIELD_ID_EP_THREAD_LIST_HEAD 59UL
#define KSW_DYN_FIELD_ID_EP_IMAGE_FILE_NAME 60UL
#define KSW_DYN_FIELD_ID_EP_TOKEN 61UL
#define KSW_DYN_FIELD_ID_ET_CID 62UL
#define KSW_DYN_FIELD_ID_ET_THREAD_LIST_ENTRY 63UL
#define KSW_DYN_FIELD_ID_ET_START_ADDRESS 64UL
#define KSW_DYN_FIELD_ID_ET_WIN32_START_ADDRESS 65UL
#define KSW_DYN_FIELD_ID_KT_PROCESS 66UL
#define KSW_DYN_FIELD_ID_HT_TABLE_CODE 67UL
#define KSW_DYN_FIELD_ID_HT_HANDLE_COUNT 68UL
#define KSW_DYN_FIELD_ID_HTE_LOW_VALUE 69UL
#define KSW_DYN_FIELD_ID_KLDR_IN_LOAD_ORDER_LINKS 70UL
#define KSW_DYN_FIELD_ID_KLDR_DLL_BASE 71UL
#define KSW_DYN_FIELD_ID_KLDR_SIZE_OF_IMAGE 72UL
#define KSW_DYN_FIELD_ID_KLDR_FULL_DLL_NAME 73UL
#define KSW_DYN_FIELD_ID_KLDR_BASE_DLL_NAME 74UL
#define KSW_DYN_FIELD_ID_KLDR_FLAGS 75UL
#define KSW_DYN_FIELD_ID_DO_DRIVER_START 76UL
#define KSW_DYN_FIELD_ID_DO_DRIVER_SIZE 77UL
#define KSW_DYN_FIELD_ID_DO_DRIVER_SECTION 78UL
#define KSW_DYN_FIELD_ID_DO_MAJOR_FUNCTION 79UL
#define KSW_DYN_FIELD_ID_DO_FAST_IO_DISPATCH 80UL
#define KSW_DYN_FIELD_ID_DO_DRIVER_UNLOAD 81UL
#define KSW_DYN_FIELD_ID_KG_PSP_CID_TABLE 82UL
#define KSW_DYN_FIELD_ID_KG_PS_LOADED_MODULE_LIST 83UL
#define KSW_DYN_FIELD_ID_KG_MM_UNLOADED_DRIVERS 84UL
#define KSW_DYN_FIELD_ID_KG_PIDDB_CACHE_TABLE 85UL
#define KSW_DYN_FIELD_ID_KG_KE_SERVICE_DESCRIPTOR_TABLE_SHADOW 86UL
#define KSW_DYN_FIELD_ID_KG_MM_LAST_UNLOADED_DRIVER 87UL
#define KSW_DYN_FIELD_ID_ULD_NAME 88UL
#define KSW_DYN_FIELD_ID_ULD_START_ADDRESS 89UL
#define KSW_DYN_FIELD_ID_ULD_END_ADDRESS 90UL
#define KSW_DYN_FIELD_ID_ULD_CURRENT_TIME 91UL
#define KSW_DYN_FIELD_ID_ULD_TYPE_SIZE 92UL
#define KSW_DYN_FIELD_ID_RTL_AVL_BALANCED_ROOT 93UL
#define KSW_DYN_FIELD_ID_RTL_AVL_ORDERED_POINTER 94UL
#define KSW_DYN_FIELD_ID_RTL_AVL_WHICH_ORDERED_ELEMENT 95UL
#define KSW_DYN_FIELD_ID_RTL_AVL_NUMBER_GENERIC_TABLE_ELEMENTS 96UL
#define KSW_DYN_FIELD_ID_RTL_AVL_DEPTH_OF_TREE 97UL
#define KSW_DYN_FIELD_ID_RTL_AVL_RESTART_KEY 98UL
#define KSW_DYN_FIELD_ID_RTL_AVL_DELETE_COUNT 99UL
#define KSW_DYN_FIELD_ID_RTL_AVL_TYPE_SIZE 100UL
// Optional _EPROCESS field offsets. 中文说明：追加在现有 ID 之后，保持旧
// profile/pack 的字段编号稳定；这些字段默认可选，不影响旧 capability。
#define KSW_DYN_FIELD_ID_EP_FLAGS 101UL
#define KSW_DYN_FIELD_ID_EP_FLAGS2 102UL
#define KSW_DYN_FIELD_ID_EP_RUNDOWN_PROTECT 103UL
#define KSW_DYN_FIELD_ID_EP_PROCESS_LOCK 104UL
#define KSW_DYN_FIELD_ID_EP_CREATE_TIME 105UL
#define KSW_DYN_FIELD_ID_EP_EXIT_TIME 106UL
#define KSW_DYN_FIELD_ID_EP_EXIT_STATUS 107UL
#define KSW_DYN_FIELD_ID_EP_PEB 108UL
#define KSW_DYN_FIELD_ID_EP_SESSION 109UL
#define KSW_DYN_FIELD_ID_EP_WIN32_PROCESS 110UL
#define KSW_DYN_FIELD_ID_EP_WOW64_PROCESS 111UL
#define KSW_DYN_FIELD_ID_EP_INHERITED_FROM_UNIQUE_PROCESS_ID 112UL
#define KSW_DYN_FIELD_ID_EP_SE_AUDIT_PROCESS_CREATION_INFO 113UL
#define KSW_DYN_FIELD_ID_EP_JOB 114UL
#define KSW_DYN_FIELD_ID_EP_DEVICE_MAP 115UL
#define KSW_DYN_FIELD_ID_EP_DEBUG_PORT 116UL
#define KSW_DYN_FIELD_ID_EP_EXCEPTION_PORT_DATA 117UL
#define KSW_DYN_FIELD_ID_EP_SECTION_BASE_ADDRESS 118UL
#define KSW_DYN_FIELD_ID_EP_IMAGE_FILE_POINTER 119UL
#define KSW_DYN_FIELD_ID_EP_PRIORITY_CLASS 120UL
#define KSW_DYN_FIELD_ID_EP_ACTIVE_THREADS 121UL
#define KSW_DYN_FIELD_ID_EP_VAD_ROOT 122UL
#define KSW_DYN_FIELD_ID_EP_VAD_HINT 123UL
#define KSW_DYN_FIELD_ID_EP_CLONE_ROOT 124UL
#define KSW_DYN_FIELD_ID_EP_NUMBER_OF_PRIVATE_PAGES 125UL
#define KSW_DYN_FIELD_ID_EP_NUMBER_OF_LOCKED_PAGES 126UL
#define KSW_DYN_FIELD_ID_EP_COMMIT_CHARGE 127UL
#define KSW_DYN_FIELD_ID_EP_COMMIT_CHARGE_PEAK 128UL
#define KSW_DYN_FIELD_ID_EP_PEAK_VIRTUAL_SIZE 129UL
#define KSW_DYN_FIELD_ID_EP_VIRTUAL_SIZE 130UL
#define KSW_DYN_FIELD_ID_EP_SESSION_PROCESS_LINKS 131UL
#define KSW_DYN_FIELD_ID_EP_MITIGATION_FLAGS 132UL
#define KSW_DYN_FIELD_ID_EP_MITIGATION_FLAGS2 133UL
#define KSW_DYN_FIELD_ID_EP_PROCESS_QUOTA_USAGE 134UL
#define KSW_DYN_FIELD_ID_EP_PROCESS_QUOTA_PEAK 135UL
#define KSW_DYN_FIELD_ID_EP_ADDRESS_CREATION_LOCK 136UL
#define KSW_DYN_FIELD_ID_EP_PAGE_TABLE_COMMITMENT_LOCK 137UL
#define KSW_DYN_FIELD_ID_EP_ROTATE_IN_PROGRESS 138UL
#define KSW_DYN_FIELD_ID_EP_FORK_IN_PROGRESS 139UL
#define KSW_DYN_FIELD_ID_EP_COMMIT_CHARGE_JOB 140UL
#define KSW_DYN_FIELD_ID_EP_COOKIE 141UL
#define KSW_DYN_FIELD_ID_EP_WORKING_SET_WATCH 142UL
#define KSW_DYN_FIELD_ID_EP_WIN32_WINDOW_STATION 143UL
#define KSW_DYN_FIELD_ID_EP_OWNER_PROCESS_ID 144UL
#define KSW_DYN_FIELD_ID_EP_QUOTA_BLOCK 145UL
#define KSW_DYN_FIELD_ID_EP_ETW_DATA_SOURCE 146UL
#define KSW_DYN_FIELD_ID_EP_PAGE_DIRECTORY_PTE 147UL
#define KSW_DYN_FIELD_ID_EP_SECURITY_PORT 148UL
#define KSW_DYN_FIELD_ID_EP_JOB_LINKS 149UL
#define KSW_DYN_FIELD_ID_EP_HIGHEST_USER_ADDRESS 150UL
#define KSW_DYN_FIELD_ID_EP_IMAGE_PATH_HASH 151UL
#define KSW_DYN_FIELD_ID_EP_DEFAULT_HARD_ERROR_PROCESSING 152UL
#define KSW_DYN_FIELD_ID_EP_LAST_THREAD_EXIT_STATUS 153UL
#define KSW_DYN_FIELD_ID_EP_PREFETCH_TRACE 154UL
#define KSW_DYN_FIELD_ID_EP_LOCKED_PAGES_LIST 155UL
#define KSW_DYN_FIELD_ID_EP_READ_OPERATION_COUNT 156UL
#define KSW_DYN_FIELD_ID_EP_WRITE_OPERATION_COUNT 157UL
#define KSW_DYN_FIELD_ID_EP_OTHER_OPERATION_COUNT 158UL
#define KSW_DYN_FIELD_ID_EP_READ_TRANSFER_COUNT 159UL
#define KSW_DYN_FIELD_ID_EP_WRITE_TRANSFER_COUNT 160UL
#define KSW_DYN_FIELD_ID_EP_OTHER_TRANSFER_COUNT 161UL
#define KSW_DYN_FIELD_ID_EP_COMMIT_CHARGE_LIMIT 162UL
#define KSW_DYN_FIELD_ID_EP_VM 163UL
#define KSW_DYN_FIELD_ID_EP_MM_PROCESS_LINKS 164UL
#define KSW_DYN_FIELD_ID_EP_MODIFIED_PAGE_COUNT 165UL
#define KSW_DYN_FIELD_ID_EP_VAD_COUNT 166UL
#define KSW_DYN_FIELD_ID_EP_VAD_PHYSICAL_PAGES 167UL
#define KSW_DYN_FIELD_ID_EP_VAD_PHYSICAL_PAGES_LIMIT 168UL
#define KSW_DYN_FIELD_ID_EP_ALPC_CONTEXT 169UL
#define KSW_DYN_FIELD_ID_EP_TIMER_RESOLUTION_LINK 170UL
#define KSW_DYN_FIELD_ID_EP_TIMER_RESOLUTION_STACK_RECORD 171UL
#define KSW_DYN_FIELD_ID_EP_REQUESTED_TIMER_RESOLUTION 172UL
#define KSW_DYN_FIELD_ID_EP_SMALLEST_TIMER_RESOLUTION 173UL
#define KSW_DYN_FIELD_ID_EP_INVERTED_FUNCTION_TABLE 174UL
#define KSW_DYN_FIELD_ID_EP_INVERTED_FUNCTION_TABLE_LOCK 175UL
#define KSW_DYN_FIELD_ID_EP_ACTIVE_THREADS_HIGH_WATERMARK 176UL
#define KSW_DYN_FIELD_ID_EP_LARGE_PRIVATE_VAD_COUNT 177UL
#define KSW_DYN_FIELD_ID_EP_THREAD_LIST_LOCK 178UL
#define KSW_DYN_FIELD_ID_EP_WNF_CONTEXT 179UL
#define KSW_DYN_FIELD_ID_EP_FLAGS3 180UL
#define KSW_DYN_FIELD_ID_EP_DISK_COUNTERS 181UL
// Optional _TOKEN field offsets. 中文说明：这些 ID 追加在现有字段之后，
// 用于 PDB 精确匹配后的 Token 私有字段读取/修改，不改变旧字段编号。
#define KSW_DYN_FIELD_ID_TOK_TOKEN_SOURCE 182UL
#define KSW_DYN_FIELD_ID_TOK_TOKEN_ID 183UL
#define KSW_DYN_FIELD_ID_TOK_AUTHENTICATION_ID 184UL
#define KSW_DYN_FIELD_ID_TOK_PARENT_TOKEN_ID 185UL
#define KSW_DYN_FIELD_ID_TOK_EXPIRATION_TIME 186UL
#define KSW_DYN_FIELD_ID_TOK_TOKEN_LOCK 187UL
#define KSW_DYN_FIELD_ID_TOK_MODIFIED_ID 188UL
#define KSW_DYN_FIELD_ID_TOK_PRIVILEGES 189UL
#define KSW_DYN_FIELD_ID_TOK_AUDIT_POLICY 190UL
#define KSW_DYN_FIELD_ID_TOK_SESSION_ID 191UL
#define KSW_DYN_FIELD_ID_TOK_USER_AND_GROUP_COUNT 192UL
#define KSW_DYN_FIELD_ID_TOK_RESTRICTED_SID_COUNT 193UL
#define KSW_DYN_FIELD_ID_TOK_VARIABLE_LENGTH 194UL
#define KSW_DYN_FIELD_ID_TOK_DYNAMIC_CHARGED 195UL
#define KSW_DYN_FIELD_ID_TOK_DYNAMIC_AVAILABLE 196UL
#define KSW_DYN_FIELD_ID_TOK_DEFAULT_OWNER_INDEX 197UL
#define KSW_DYN_FIELD_ID_TOK_USER_AND_GROUPS 198UL
#define KSW_DYN_FIELD_ID_TOK_RESTRICTED_SIDS 199UL
#define KSW_DYN_FIELD_ID_TOK_PRIMARY_GROUP 200UL
#define KSW_DYN_FIELD_ID_TOK_DYNAMIC_PART 201UL
#define KSW_DYN_FIELD_ID_TOK_DEFAULT_DACL 202UL
#define KSW_DYN_FIELD_ID_TOK_TOKEN_TYPE 203UL
#define KSW_DYN_FIELD_ID_TOK_IMPERSONATION_LEVEL 204UL
#define KSW_DYN_FIELD_ID_TOK_TOKEN_FLAGS 205UL
#define KSW_DYN_FIELD_ID_TOK_TOKEN_IN_USE 206UL
#define KSW_DYN_FIELD_ID_TOK_INTEGRITY_LEVEL_INDEX 207UL
#define KSW_DYN_FIELD_ID_TOK_MANDATORY_POLICY 208UL
#define KSW_DYN_FIELD_ID_TOK_LOGON_SESSION 209UL
#define KSW_DYN_FIELD_ID_TOK_ORIGINATING_LOGON_SESSION 210UL
#define KSW_DYN_FIELD_ID_TOK_SID_HASH 211UL
#define KSW_DYN_FIELD_ID_TOK_RESTRICTED_SID_HASH 212UL
#define KSW_DYN_FIELD_ID_TOK_P_SECURITY_ATTRIBUTES 213UL
#define KSW_DYN_FIELD_ID_TOK_PACKAGE 214UL
#define KSW_DYN_FIELD_ID_TOK_CAPABILITIES 215UL
#define KSW_DYN_FIELD_ID_TOK_CAPABILITY_COUNT 216UL
#define KSW_DYN_FIELD_ID_TOK_CAPABILITIES_HASH 217UL
#define KSW_DYN_FIELD_ID_TOK_LOWBOX_NUMBER_ENTRY 218UL
#define KSW_DYN_FIELD_ID_TOK_LOWBOX_HANDLES_ENTRY 219UL
#define KSW_DYN_FIELD_ID_TOK_P_CLAIM_ATTRIBUTES 220UL
#define KSW_DYN_FIELD_ID_TOK_TRUST_LEVEL_SID 221UL
#define KSW_DYN_FIELD_ID_TOK_TRUST_LINKED_TOKEN 222UL
#define KSW_DYN_FIELD_ID_TOK_INTEGRITY_LEVEL_SID_VALUE 223UL
#define KSW_DYN_FIELD_ID_TOK_TOKEN_SID_VALUES 224UL
#define KSW_DYN_FIELD_ID_TOK_SESSION_OBJECT 225UL
#define KSW_DYN_FIELD_ID_TOK_VARIABLE_PART 226UL
#define KSW_DYN_FIELD_ID_PIDDB_DRIVER_NAME 227UL
#define KSW_DYN_FIELD_ID_PIDDB_TIME_DATE_STAMP 228UL
#define KSW_DYN_FIELD_ID_PIDDB_LOAD_STATUS 229UL
#define KSW_DYN_FIELD_ID_PIDDB_TYPE_SIZE 230UL
#define KSW_DYN_FIELD_ID_KG_PIDDB_LOCK 231UL
#define KSW_DYN_FIELD_ID_MAX KSW_DYN_FIELD_ID_KG_PIDDB_LOCK

#define KSW_DYN_PROFILE_EX_ITEM_KIND_STRUCT_OFFSET 1UL
#define KSW_DYN_PROFILE_EX_ITEM_KIND_GLOBAL_RVA 2UL

#define KSW_DYN_V4_PROTOCOL_VERSION 4UL
#define KSW_DYN_V4_PROFILE_NAME_CHARS 96U
#define KSW_DYN_V4_ITEM_NAME_CHARS 96U
#define KSW_DYN_V4_CAPABILITY_NAME_CHARS 96U
#define KSW_DYN_V4_MISSING_REASON_CHARS 128U
#define KSW_DYN_V4_MAX_MODULES 16U
#define KSW_DYN_V4_MAX_ITEMS_PER_MODULE 512U
#define KSW_DYN_V4_MAX_CAPABILITY_GROUPS_PER_MODULE 16U
#define KSW_DYN_V4_MAX_MISSING_SUMMARY 64U
#define KSW_DYN_V4_MAX_VALUE_U32 0xFFFFFFFFUL
#define KSW_DYN_V4_STATUS_FLAG_IDENTITY_MATCHED 0x00000001UL
#define KSW_DYN_V4_STATUS_FLAG_PROFILE_APPLIED 0x00000002UL
#define KSW_DYN_V4_STATUS_FLAG_REQUIRED_COMPLETE 0x00000004UL
#define KSW_DYN_V4_STATUS_FLAG_OPTIONAL_DEGRADED 0x00000008UL
#define KSW_DYN_V4_STATUS_FLAG_IDENTITY_REJECTED 0x00000010UL
#define KSW_DYN_V4_STATUS_FLAG_VALIDATION_FAILED 0x00000020UL
#define KSW_DYN_V4_ITEM_KIND_STRUCT_OFFSET 1UL
#define KSW_DYN_V4_ITEM_KIND_GLOBAL_RVA 2UL
#define KSW_DYN_V4_ITEM_KIND_FUNCTION_RVA 3UL
#define KSW_DYN_V4_ITEM_KIND_ENUM_VALUE 4UL
#define KSW_DYN_V4_ITEM_KIND_TYPE_SIZE 5UL
#define KSW_DYN_V4_ITEM_KIND_BIT_FIELD 6UL
#define KSW_DYN_V4_ITEM_KIND_LIST_HEAD_GLOBAL 7UL
#define KSW_DYN_V4_ITEM_FLAG_REQUIRED 0x00000001UL
#define KSW_DYN_V4_ITEM_FLAG_OPTIONAL 0x00000002UL
#define KSW_DYN_V4_MISSING_KIND_REQUIRED 1UL
#define KSW_DYN_V4_MISSING_KIND_OPTIONAL 2UL

// v4 capability groups and stable item IDs. 这些编号独立于 PDB 字段 ID，
// 用于跨版本保持 timer/DPC 等业务项的身份稳定。
#define KSW_DYN_V4_CAPABILITY_GROUP_NTOS_CORE 1UL
#define KSW_DYN_V4_CAPABILITY_GROUP_TIMER_DPC 2UL
#define KSW_DYN_V4_CAPABILITY_GROUP_FLTMGR_MINIFILTER 3UL
#define KSW_DYN_V4_CAPABILITY_GROUP_CI_KERNEL_HASH 4UL
#define KSW_DYN_V4_CAPABILITY_GROUP_WORK_QUEUE 5UL
#define KSW_DYN_V4_ITEM_ID_ETH_ACTIVE_EX_WORKER 1001UL
#define KSW_DYN_V4_ITEM_ID_KPRCB_TIMER_TABLE 1002UL
#define KSW_DYN_V4_ITEM_ID_KTIMER_TABLE_TIMER_ENTRIES 1003UL
#define KSW_DYN_V4_ITEM_ID_KTIMER_TABLE_ENTRY_LOCK 1004UL
#define KSW_DYN_V4_ITEM_ID_KTIMER_TABLE_ENTRY_ENTRY 1005UL
#define KSW_DYN_V4_ITEM_ID_KTIMER_TABLE_ENTRY_TIME 1006UL
#define KSW_DYN_V4_ITEM_ID_KTIMER_TIMER_LIST_ENTRY 1007UL
#define KSW_DYN_V4_ITEM_ID_KTIMER_DUE_TIME 1008UL
#define KSW_DYN_V4_ITEM_ID_KTIMER_DPC 1009UL
#define KSW_DYN_V4_ITEM_ID_KTIMER_TIMER_TYPE 1010UL
#define KSW_DYN_V4_ITEM_ID_KTIMER_PERIOD 1011UL
#define KSW_DYN_V4_ITEM_ID_KDPC_DEFERRED_ROUTINE 1012UL
#define KSW_DYN_V4_ITEM_ID_KDPC_DEFERRED_CONTEXT 1013UL
#define KSW_DYN_V4_ITEM_ID_KTIMER_TABLE_TYPE_SIZE 1014UL
#define KSW_DYN_V4_ITEM_ID_KTIMER_TABLE_ENTRY_TYPE_SIZE 1015UL
#define KSW_DYN_V4_ITEM_ID_KTIMER_TYPE_SIZE 1016UL
#define KSW_DYN_V4_ITEM_ID_KDPC_TYPE_SIZE 1017UL
#define KSW_DYN_V4_ITEM_ID_FLT_FILTER_OPERATIONS 1101UL
#define KSW_DYN_V4_ITEM_ID_CI_KERNEL_HASH_BUCKET_LIST 1201UL
#define KSW_DYN_V4_ITEM_ID_CI_HASH_CACHE_LOCK 1202UL
#define KSW_DYN_V4_ITEM_ID_CI_HASH_ENTRY_NEXT 1203UL
#define KSW_DYN_V4_ITEM_ID_CI_HASH_ENTRY_DRIVER_NAME 1204UL
#define KSW_DYN_V4_ITEM_ID_CI_HASH_ENTRY_TIME_DATE_STAMP 1205UL
#define KSW_DYN_V4_ITEM_ID_CI_HASH_ENTRY_LOAD_STATUS 1206UL
#define KSW_DYN_V4_ITEM_ID_CI_HASH_ENTRY_IMAGE_BASE 1207UL
#define KSW_DYN_V4_ITEM_ID_CI_HASH_ENTRY_IMAGE_SIZE 1208UL
#define KSW_DYN_V4_ITEM_ID_CI_HASH_ENTRY_TYPE_SIZE 1209UL
#define KSW_DYN_V4_ITEM_ID_WQ_PSP_SYSTEM_PARTITION 1301UL
#define KSW_DYN_V4_ITEM_ID_WQ_EXP_BUILTIN_PRIORITIES 1302UL
#define KSW_DYN_V4_ITEM_ID_WQ_EPARTITION_EX_PARTITION 1303UL
#define KSW_DYN_V4_ITEM_ID_WQ_EX_PARTITION_WORK_QUEUES 1304UL
#define KSW_DYN_V4_ITEM_ID_WQ_EX_WORK_QUEUE_WORK_PRI_QUEUE 1305UL
#define KSW_DYN_V4_ITEM_ID_WQ_EX_WORK_QUEUE_QUEUE_INDEX 1306UL
#define KSW_DYN_V4_ITEM_ID_WQ_KPRI_QUEUE_ENTRY_LIST_HEAD 1307UL
#define KSW_DYN_V4_ITEM_ID_WQ_KPRI_QUEUE_THREAD_LIST_HEAD 1308UL
#define KSW_DYN_V4_ITEM_ID_WQ_KTHREAD_QUEUE 1309UL
#define KSW_DYN_V4_ITEM_ID_WQ_KTHREAD_QUEUE_LIST_ENTRY 1310UL
#define KSW_DYN_V4_ITEM_ID_WQ_WORK_ITEM_LIST 1311UL
#define KSW_DYN_V4_ITEM_ID_WQ_WORK_ITEM_ROUTINE 1312UL
#define KSW_DYN_V4_ITEM_ID_WQ_WORK_ITEM_PARAMETER 1313UL
#define KSW_DYN_V4_ITEM_ID_WQ_EX_POOL_UNTRUSTED 1314UL
#define KSW_DYN_V4_ITEM_ID_WQ_EPARTITION_TYPE_SIZE 1315UL
#define KSW_DYN_V4_ITEM_ID_WQ_EX_PARTITION_TYPE_SIZE 1316UL
#define KSW_DYN_V4_ITEM_ID_WQ_EX_WORK_QUEUE_TYPE_SIZE 1317UL
#define KSW_DYN_V4_ITEM_ID_WQ_KPRI_QUEUE_TYPE_SIZE 1318UL
#define KSW_DYN_V4_ITEM_ID_WQ_KTHREAD_TYPE_SIZE 1319UL
#define KSW_DYN_V4_ITEM_ID_WQ_WORK_ITEM_TYPE_SIZE 1320UL
#define KSW_DYN_V4_ITEM_ID_WQ_ETHREAD_START_ADDRESS 1321UL
#define KSW_DYN_V4_ITEM_ID_WQ_ETHREAD_TYPE_SIZE 1322UL
#define KSW_DYN_V4_ITEM_ID_WQ_ETHREAD_TCB 1323UL

#define KSW_DYN_PROFILE_EX_ITEM_FLAG_REQUIRED 0x00000001UL
#define KSW_DYN_PROFILE_EX_ITEM_FLAG_CALLBACK 0x00000002UL

typedef struct _KSW_DYN_MODULE_IDENTITY_PACKET
{
    unsigned long present;
    unsigned long classId;
    unsigned long machine;
    unsigned long timeDateStamp;
    unsigned long sizeOfImage;
    unsigned long long imageBase;
    wchar_t moduleName[KSW_DYN_MODULE_NAME_CHARS];
} KSW_DYN_MODULE_IDENTITY_PACKET;

typedef struct _KSW_DYN_V4_PDB_IDENTITY_PACKET
{
    char pdbName[KSW_DYN_PDB_NAME_CHARS];
    char pdbGuid[KSW_DYN_PDB_GUID_CHARS];
    unsigned long pdbAge;
    unsigned long reserved;
} KSW_DYN_V4_PDB_IDENTITY_PACKET;

typedef struct _KSW_DYN_V4_MODULE_IDENTITY_PACKET
{
    KSW_DYN_MODULE_IDENTITY_PACKET image;
    KSW_DYN_V4_PDB_IDENTITY_PACKET pdb;
    char profileName[KSW_DYN_V4_PROFILE_NAME_CHARS];
} KSW_DYN_V4_MODULE_IDENTITY_PACKET;

typedef struct _KSW_DYN_V4_ITEM_PACKET
{
    unsigned long itemId;
    unsigned long itemKind;
    unsigned long flags;
    unsigned long capabilityGroupId;
    unsigned long valueLow;
    unsigned long valueHigh;
    unsigned long aux0;
    unsigned long aux1;
    unsigned long aux2;
    unsigned long aux3;
} KSW_DYN_V4_ITEM_PACKET;

typedef struct _KSW_DYN_V4_CAPABILITY_GROUP_PACKET
{
    unsigned long groupId;
    unsigned long flags;
    unsigned long requiredItemCount;
    unsigned long optionalItemCount;
    char groupName[KSW_DYN_V4_CAPABILITY_NAME_CHARS];
} KSW_DYN_V4_CAPABILITY_GROUP_PACKET;

typedef struct _KSW_APPLY_DYN_PROFILE_V4_REQUEST
{
    unsigned long size;
    unsigned long version;
    unsigned long flags;
    unsigned long itemCount;
    unsigned long capabilityGroupCount;
    unsigned long reserved;
    KSW_DYN_V4_MODULE_IDENTITY_PACKET module;
    KSW_DYN_V4_CAPABILITY_GROUP_PACKET capabilityGroups[KSW_DYN_V4_MAX_CAPABILITY_GROUPS_PER_MODULE];
    KSW_DYN_V4_ITEM_PACKET items[1];
} KSW_APPLY_DYN_PROFILE_V4_REQUEST;

#define KSW_APPLY_DYN_PROFILE_V4_REQUEST_HEADER_SIZE \
    (sizeof(KSW_APPLY_DYN_PROFILE_V4_REQUEST) - sizeof(KSW_DYN_V4_ITEM_PACKET))

typedef struct _KSW_APPLY_DYN_PROFILE_V4_RESPONSE
{
    unsigned long size;
    unsigned long version;
    long status;
    unsigned long statusFlags;
    unsigned long appliedItemCount;
    unsigned long rejectedItemCount;
    unsigned long requiredItemCount;
    unsigned long presentRequiredItemCount;
    unsigned long optionalItemCount;
    unsigned long presentOptionalItemCount;
    unsigned long activeCapabilityGroupCount;
    unsigned long missingRequiredItemCount;
    unsigned long missingOptionalItemCount;
    unsigned long reserved;
    KSW_DYN_V4_MODULE_IDENTITY_PACKET module;
    wchar_t message[KSW_DYN_REASON_CHARS];
} KSW_APPLY_DYN_PROFILE_V4_RESPONSE;

typedef struct _KSW_DYN_PROFILE_FIELD_PACKET
{
    unsigned long fieldId;
    unsigned long offset;
} KSW_DYN_PROFILE_FIELD_PACKET;

typedef struct _KSW_APPLY_DYN_PROFILE_REQUEST
{
    unsigned long size;
    unsigned long version;
    unsigned long flags;
    unsigned long fieldCount;
    KSW_DYN_MODULE_IDENTITY_PACKET ntoskrnl;
    char profileName[KSW_DYN_PROFILE_NAME_CHARS];
    char pdbName[KSW_DYN_PDB_NAME_CHARS];
    char pdbGuid[KSW_DYN_PDB_GUID_CHARS];
    unsigned long pdbAge;
    unsigned long reserved;
    KSW_DYN_PROFILE_FIELD_PACKET fields[1];
} KSW_APPLY_DYN_PROFILE_REQUEST;

#define KSW_APPLY_DYN_PROFILE_REQUEST_HEADER_SIZE \
    (sizeof(KSW_APPLY_DYN_PROFILE_REQUEST) - sizeof(KSW_DYN_PROFILE_FIELD_PACKET))

typedef struct _KSW_APPLY_DYN_PROFILE_RESPONSE
{
    unsigned long size;
    unsigned long version;
    long status;
    unsigned long appliedFieldCount;
    unsigned long rejectedFieldCount;
    unsigned long unknownFieldCount;
    unsigned long statusFlags;
    unsigned long long capabilityMask;
    wchar_t message[KSW_DYN_REASON_CHARS];
} KSW_APPLY_DYN_PROFILE_RESPONSE;

typedef struct _KSW_DYN_PROFILE_EX_ITEM_PACKET
{
    unsigned long itemId;
    unsigned long itemKind;
    unsigned long value;
    unsigned long flags;
} KSW_DYN_PROFILE_EX_ITEM_PACKET;

typedef struct _KSW_APPLY_DYN_PROFILE_EX_REQUEST
{
    unsigned long size;
    unsigned long version;
    unsigned long flags;
    unsigned long itemCount;
    KSW_DYN_MODULE_IDENTITY_PACKET ntoskrnl;
    char profileName[KSW_DYN_PROFILE_NAME_CHARS];
    char pdbName[KSW_DYN_PDB_NAME_CHARS];
    char pdbGuid[KSW_DYN_PDB_GUID_CHARS];
    unsigned long pdbAge;
    unsigned long reserved;
    KSW_DYN_PROFILE_EX_ITEM_PACKET items[1];
} KSW_APPLY_DYN_PROFILE_EX_REQUEST;

#define KSW_APPLY_DYN_PROFILE_EX_REQUEST_HEADER_SIZE \
    (sizeof(KSW_APPLY_DYN_PROFILE_EX_REQUEST) - sizeof(KSW_DYN_PROFILE_EX_ITEM_PACKET))

typedef struct _KSW_APPLY_DYN_PROFILE_EX_RESPONSE
{
    unsigned long size;
    unsigned long version;
    long status;
    unsigned long appliedItemCount;
    unsigned long rejectedItemCount;
    unsigned long unknownItemCount;
    unsigned long statusFlags;
    unsigned long long capabilityMask;
    wchar_t message[KSW_DYN_REASON_CHARS];
} KSW_APPLY_DYN_PROFILE_EX_RESPONSE;

typedef struct _KSW_QUERY_DYN_STATUS_RESPONSE
{
    unsigned long size;
    unsigned long version;
    unsigned long statusFlags;
    unsigned long systemInformerDataVersion;
    unsigned long systemInformerDataLength;
    long lastStatus;
    unsigned long matchedProfileClass;
    unsigned long matchedProfileOffset;
    unsigned long matchedFieldsId;
    unsigned long fieldCount;
    unsigned long reserved;
    unsigned long long capabilityMask;
    KSW_DYN_MODULE_IDENTITY_PACKET ntoskrnl;
    KSW_DYN_MODULE_IDENTITY_PACKET lxcore;
    wchar_t unavailableReason[KSW_DYN_REASON_CHARS];
} KSW_QUERY_DYN_STATUS_RESPONSE;

typedef struct _KSW_QUERY_CAPABILITIES_RESPONSE
{
    unsigned long size;
    unsigned long version;
    unsigned long statusFlags;
    unsigned long reserved;
    unsigned long long capabilityMask;
} KSW_QUERY_CAPABILITIES_RESPONSE;

typedef struct _KSW_DYN_FIELD_ENTRY
{
    unsigned long fieldId;
    unsigned long flags;
    unsigned long source;
    unsigned long offset;
    unsigned long long capabilityMask;
    char fieldName[KSW_DYN_FIELD_NAME_CHARS];
    char sourceName[KSW_DYN_FIELD_SOURCE_CHARS];
    char featureName[KSW_DYN_FIELD_FEATURE_CHARS];
} KSW_DYN_FIELD_ENTRY;

typedef struct _KSW_QUERY_DYN_FIELDS_RESPONSE
{
    unsigned long size;
    unsigned long version;
    unsigned long totalCount;
    unsigned long returnedCount;
    unsigned long entrySize;
    unsigned long reserved;
    KSW_DYN_FIELD_ENTRY entries[1];
} KSW_QUERY_DYN_FIELDS_RESPONSE;

typedef struct _KSW_DYN_V4_MODULE_STATUS_ENTRY
{
    unsigned long moduleIndex;
    unsigned long statusFlags;
    unsigned long itemCount;
    unsigned long capabilityGroupCount;
    unsigned long activeCapabilityGroupCount;
    unsigned long missingRequiredItemCount;
    unsigned long missingOptionalItemCount;
    unsigned long reserved;
    KSW_DYN_V4_MODULE_IDENTITY_PACKET module;
} KSW_DYN_V4_MODULE_STATUS_ENTRY;

typedef struct _KSW_QUERY_DYN_V4_MODULES_RESPONSE
{
    unsigned long size;
    unsigned long version;
    unsigned long totalCount;
    unsigned long returnedCount;
    unsigned long entrySize;
    unsigned long reserved;
    KSW_DYN_V4_MODULE_STATUS_ENTRY entries[1];
} KSW_QUERY_DYN_V4_MODULES_RESPONSE;

#define KSW_QUERY_DYN_V4_MODULES_RESPONSE_HEADER_SIZE \
    (sizeof(KSW_QUERY_DYN_V4_MODULES_RESPONSE) - sizeof(KSW_DYN_V4_MODULE_STATUS_ENTRY))

typedef struct _KSW_DYN_V4_CAPABILITY_GROUP_STATUS_ENTRY
{
    unsigned long moduleClassId;
    unsigned long groupId;
    unsigned long statusFlags;
    unsigned long requiredItemCount;
    unsigned long presentRequiredItemCount;
    unsigned long optionalItemCount;
    unsigned long presentOptionalItemCount;
    unsigned long reserved;
    char groupName[KSW_DYN_V4_CAPABILITY_NAME_CHARS];
} KSW_DYN_V4_CAPABILITY_GROUP_STATUS_ENTRY;

typedef struct _KSW_QUERY_DYN_V4_CAPABILITY_GROUPS_RESPONSE
{
    unsigned long size;
    unsigned long version;
    unsigned long totalCount;
    unsigned long returnedCount;
    unsigned long entrySize;
    unsigned long reserved;
    KSW_DYN_V4_CAPABILITY_GROUP_STATUS_ENTRY entries[1];
} KSW_QUERY_DYN_V4_CAPABILITY_GROUPS_RESPONSE;

#define KSW_QUERY_DYN_V4_CAPABILITY_GROUPS_RESPONSE_HEADER_SIZE \
    (sizeof(KSW_QUERY_DYN_V4_CAPABILITY_GROUPS_RESPONSE) - sizeof(KSW_DYN_V4_CAPABILITY_GROUP_STATUS_ENTRY))

typedef struct _KSW_DYN_V4_MISSING_ITEM_ENTRY
{
    unsigned long moduleClassId;
    unsigned long itemId;
    unsigned long itemKind;
    unsigned long capabilityGroupId;
    unsigned long missingKind;
    unsigned long reserved;
    char itemName[KSW_DYN_V4_ITEM_NAME_CHARS];
    char reason[KSW_DYN_V4_MISSING_REASON_CHARS];
} KSW_DYN_V4_MISSING_ITEM_ENTRY;

typedef struct _KSW_QUERY_DYN_V4_MISSING_ITEMS_RESPONSE
{
    unsigned long size;
    unsigned long version;
    unsigned long totalCount;
    unsigned long returnedCount;
    unsigned long entrySize;
    unsigned long reserved;
    KSW_DYN_V4_MISSING_ITEM_ENTRY entries[1];
} KSW_QUERY_DYN_V4_MISSING_ITEMS_RESPONSE;

#define KSW_QUERY_DYN_V4_MISSING_ITEMS_RESPONSE_HEADER_SIZE \
    (sizeof(KSW_QUERY_DYN_V4_MISSING_ITEMS_RESPONSE) - sizeof(KSW_DYN_V4_MISSING_ITEM_ENTRY))

typedef struct _KSW_DYN_V4_ITEM_STATUS_ENTRY
{
    unsigned long moduleClassId;
    unsigned long itemIndex;
    unsigned long reserved0;
    unsigned long reserved1;
    KSW_DYN_V4_ITEM_PACKET item;
} KSW_DYN_V4_ITEM_STATUS_ENTRY;

typedef struct _KSW_QUERY_DYN_V4_ITEMS_RESPONSE
{
    unsigned long size;
    unsigned long version;
    unsigned long totalCount;
    unsigned long returnedCount;
    unsigned long entrySize;
    unsigned long reserved;
    KSW_DYN_V4_ITEM_STATUS_ENTRY entries[1];
} KSW_QUERY_DYN_V4_ITEMS_RESPONSE;

#define KSW_QUERY_DYN_V4_ITEMS_RESPONSE_HEADER_SIZE \
    (sizeof(KSW_QUERY_DYN_V4_ITEMS_RESPONSE) - sizeof(KSW_DYN_V4_ITEM_STATUS_ENTRY))
