Many times, the protocol takes a byte, word, or dword, and makes each bit mean something. For example, a flag byte might be defined like this:
Byte Flags;
#define FLAGS_Dynamic_Tracking 0x01
#define FLAGS_Effective_Only 0x02
where the variable FLAGS is allowed to take on the value:
Flags = FLAGS_Dynamic_Tracking | FLAGS_Effective_Only.
If you need to specify a different string for both the on and off case, then use the FLAGS data type.
First, define the SET for the property:
LABELED_BIT NTCreateSecurityFlagsFLAGS[] =
{ { 0, // 0 bit = SMB_SECURITY_DYNAMIC_TRACKING,
"dynamic tracking bit not set",
"dynamic tracking"
},
{ 1, // 1th bit = SMB_SECURITY_EFFECTIVE_ONLY,
"effective only bit not set",
"Effective only"
}
};
SET NTCreateSecurityFlagsFLAGSET =
{sizeof(NTCreateSecurityFlagsFLAGS)/sizeof(LABELED_BIT),
NTCreateSecurityFlagsFLAGS};
Next, define the property (note that this is a piece of a larger property table):
// PROP_NTCREATE_SECURITYFLAGS
{ 0,0,
"Security Flags Dynamic Tracking",
"Specifies the security flags on the request",
PROP_TYPE_BYTE,
PROP_QUAL_FLAGS,
&NTCreateSecurityFlagsFLAGSET,
60 * 2,
FormatPropertyInstance },
Note that this property uses the generic property formatter called FormatPropertyInstance, which takes a property and formats it.
Important In the preceding example, the PROPERTYINFO for the qualifier FLAGS must include text-formatting space for all of the lines of text. The 60 * 2 line shows two lines, 60 columns each. You must include in this estimate the space needed to format the bits. For example, if you have a LABELED_BIT on a BYTE, with a string of "My String", then the formatting is going to look something like "......1. = My String" and the length would be 11 characters plus the length of the string itself ("My String").
Next, at attach time, the property instance is added:
// File Create Security Flags flag set
AttachPropertyInstance(hFrame,
property_table[PROP_NTCREATE_SECURITYFLAGSFLAGSET].hProperty,
sizeof(reqptr->SecurityFlags),
&reqptr->SecurityFlags, // ptr to data
SMBcreateX, // Help ID
PL_COMMAND+1, // level
0); // error
The generic formatter will take this and build a multSZ string, where each string entry is separated by a \0 and the last entry ends with a double \0.