05-19-2003 07:41 AM
05-19-2003 01:44 PM
05-20-2003 04:02 AM
05-20-2003 10:18 AM
05-20-2003 02:58 PM
05-22-2003 04:03 AM
05-22-2003 07:20 AM
05-13-2009 09:11 AM
This may be a related problem. I'm communicating (in CVI 8.5) with an Agilent N5242 PNA-X network analyzer using the Agilent-supplied type library 835x.tlb, installed by running the the file "pnaproxy.exe" supplied with the instrument, which also registers an Active-X server. I generate the driver as .c/.h files using the Active-X controller wizard. When I look at the generated C code for any wrapper function that returns a value, I notice that CVI first puts the value in a local buffer location, then tests the caller's return pointer for NULL, and if non-NULL, copies the value to the caller's location using the caller's pointer. If the function is one that returns multiple data values (e.g., a measured trace), CVI still allocates a buffer for ONE value! As a result, the returned values effectively cause a local buffer overflow, overwriting pointers and even code, ultimately causing a GPF. The fix is to edit the CVI-generated C code manually, putting the caller's pointer(s) in place of the pointer(s) to the local buffer, and deleting the code that NULL-tests the pointers before moving the data to the caller space. In effect, the data are stored in the caller's space directly by the internal library routine, skipping the NULL-pointer test.
If the wizard were smart enough to recognize type-library functions that return multiple data points, it might be possible to avoid this - possibly by testing the caller's pointers BEFORE calling the internal routine that retrieves the data. Or perhaps this should be done for ALL generated wrapper functions.
David Friedman
Sr. Principal Engr.
Symtx, Inc.
Austin, TX
11-23-2009 10:27 AM
Hi Gys
Perhaps someone has a CVI driver for PNA-X Analyzer?
TX
Arik