The size_parameter_offset attribute identifies the argument containing the number of elements in an array, relative to the array argument.
In the example below, a function contains three arguments. The first argument specifies the number of elements in both the second and third arguments.
void myfunction1(long elementCnt, long *numlist, char **strlist);
The IDL definition of this declaration uses size_parameter_offset with numlist, and strlist to specify the location of the argument that contains the length of the arrays.
[api_to_hook] void myfunction1(
[in] long elementCnt,
[in,size_is(elementCnt), size_parameter_offset(-1)] long numlist,
[in,size_is(elementCnt), size_parameter_offset(-2)] LPSTR *strlist);
Note that size_parameter_offset is needed in addition to the standard IDL attribute, size_is(elementCnt). This is because the compiler removes the size_is() attribute, so that it is no longer available when the LoadRunner infrastructure needs the size information.
OFRA: Check if done?
The size_parameter_offset can also be applied to structures that contain array information.
typedef struct tag_mystruct1 {
unsigned long count;
struct myobject *objects;
} MYSTRUCT1;
The count member of MYSTRUCT1 defines the number of elements in the objects array. The IDL equivalent is:
typedef struct mystruct1 {
unsigned long count,
[size_is(count),size_parameter_offset(-1)] struct myobject objects;
} MYSTRUCT1;