Name: Anonymous 2009-06-11 15:53
Hey fellas.
I pass to my dll:
pointer to structure:
with perl:
So what happens? Pointer addresses both in perl and in dll are the same, the dll properly shows two integers like I passed (20, 30), but when it comes to changing it it just crashes. Perl has encountered a problem and needs to close 'n'stuff. Access violation at 0xc0000005 offset 0x20002. I don't access any 0x20002 anywhere, wtf.
What pissed me off is that if I do
it crashes too but when I remove those two lines after return false; it doesn't.
How on the earth the code that isn't executed anywhere can cause or suspend program crash?
Apparently there's something wrong with the pointer, since commenting all references causes both dll and script to work like a charm. However, memory for pointer is fully allocated and pointer is referenced correctly so I have no idea how to fix it.
What do you think? I'm counting on you since I spent like 3x more time on figuring out how to pass that shit than on writing both script and dll.
I pass to my dll:
extern "C" __declspec ( dllexport ) bool __stdcall GetBandwidth ( int iAdapterIndex, DLInfo * Return ) {
code code code
}pointer to structure:
typedef struct {
DWORD dwULSpeed;
DWORD dwDLSpeed;
} DLInfo;with perl:
my $measurenetwork = new Win32::API ( 'bandwidth.dll', 'GetBandwidth@8', 'IP', 'I' );
my $speed = pack ( 'LL', ( 20, 30 ) );
$measurenetwork -> Call ( $adapterindex, $speed );So what happens? Pointer addresses both in perl and in dll are the same, the dll properly shows two integers like I passed (20, 30), but when it comes to changing it it just crashes. Perl has encountered a problem and needs to close 'n'stuff. Access violation at 0xc0000005 offset 0x20002. I don't access any 0x20002 anywhere, wtf.
What pissed me off is that if I do
return false;
Return -> dwULSpeed = DWORD ( dwCurrentSent / dwDifference );
Return -> dwDLSpeed = DWORD ( dwCurrentRecv / dwDifference );it crashes too but when I remove those two lines after return false; it doesn't.
How on the earth the code that isn't executed anywhere can cause or suspend program crash?
Apparently there's something wrong with the pointer, since commenting all references causes both dll and script to work like a charm. However, memory for pointer is fully allocated and pointer is referenced correctly so I have no idea how to fix it.
What do you think? I'm counting on you since I spent like 3x more time on figuring out how to pass that shit than on writing both script and dll.