none
Structure annotation RRS feed

  • Question

  • Hi All,

    Any one can explain what is the meaning of the following code used in the array declaration?

     _Field_size_bytes_(DataLength) UCHAR Data[1]; 

    typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
        ULONG   TitleIndex;
        ULONG   Type;
        ULONG   DataLength;
        _Field_size_bytes_(DataLength) UCHAR Data[1]; // Variable size
    } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;


    Thanks


    • Edited by skri Monday, September 23, 2019 4:47 PM
    Monday, September 23, 2019 5:42 AM

Answers

  • This line is probably the last element of a structure.  What it means is that the element DataLength which is a scalar defines the number of bytes at a minimum that Data will have.   This is a common approach in Windows for a variable length element in a structure.


    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

    • Marked as answer by skri Tuesday, September 24, 2019 5:00 AM
    Monday, September 23, 2019 11:08 AM