I am trying to use a third-party DLL to control their PCI board. The first call to the DLL works, but the second causes the entire Perl process to die with the following error in a dialog box:
The instruction at "0x280414c5" referenced memory at "0x00000004". The memory could not be "written".
My first suspicion is the stack is being corrupted because of mismatched parameter types. But to test this theory, I repeatedly called the working function with no problems. The DLL procedure objects appear to be created correctly - the lower word of the address matches the DLL offset for the procedures. Here is a code snippet. (I have changed the function names to protect the privacy of our vendor.)
$Card_Check = new Win32::API($XXX_DLL,'_CheckCards',[],'L'); die "**ERROR** unable to create Win32::API object" if !$CheckCard; $Card_Open = new Win32::API($XXX_DLL,'_CardOpen','L','L');
$CardPresent = $Card_Check->Call(); die "**ERROR** installation error\n\n" if $CardPresent != 1;
$CardStatus = $Card_Open->Call(1); die "**ERROR** Card_Open error\n\n" if $CardStatus != 0;
I have set env var PERL_DL_DEBUG = 9, hoping to get useful output, but nothing that helped.
My understanding is that parameter type 'L' (or 'N') on Win32 is 32-bits.
Any help on how can I find the error source?
the standard version of Win32::API does not support api's declared with 'cdecl'.
maybe your dll has functions declared that way?
If this is the case, see a patch I made to Win32::API, to support cdecl type functions too:
see http://www.xs4all.nl/~itsme/projects/perl/
willem
_______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs