National Instruments 320685D-01 Drums User Manual


 
Chapter 4 Windows 3.1 Compiler/Linker Issues
LabWindows/CVI Programmer Reference Manual 4-18
©
National Instruments Corporation
If a DLL Receives a Pointer that Points to Other Pointers
Assume the following DLL functions:
int f(char *ptrs[]);
struct x {
char *name;
};
int g(struct x *ptr);
For the function f, the glue code that LabWindows/CVI generates converts the pointer to the
array
ptrs to a 16-bit far pointer when you pass it to the DLL function, but does not convert
the pointers inside the array
(ptrs[0], ptrs[1], ...). Similarly, for the function g, the
glue code that LabWindows/CVI generates converts the pointer to the structure (
ptr), but not
the pointer inside the structure (
name).
If your DLL has functions with these types of parameters, then your DLL cannot use glue
code automatically generated at load time. You can use the Generate DLL Glue Source
command to generate glue code and then modify it in the following manner.
1. Before the call to
InvokeIndirectFunction,
a. Save the hidden pointer in a local variable.
b. Replace the hidden pointer with a 16-bit alias by calling
Alloc16BitAlias.
2. After the call to
InvokeIndirectFunction,
a. Free the 16-bit alias by calling
Free16BitAlias.
b. Restore the hidden pointer with the value you saved in step 1.
For the functions
f and g, the glue code that LabWindows/CVI generates looks like the
following excerpt:
int f(char **ptrs)
{
int retval;
unsigned short cw387;
cw387 = Get387CW();
retval = (int) InvokeIndirectFunction(__static_f, ptrs);
Set387CW(cw387);
return retval;
}
int g(struct x *ptr)
{
int retval;
unsigned short cw387;
00ProRef.book : 06chap04.fm Page 18 Monday, March 9, 1998 3:23 PM