Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Sharing memory with dlls in perl

Name: Anonymous 2009-06-11 15:53

Hey fellas.

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.

Name: Anonymous 2009-06-11 16:02

Pointer access is rocket science.

Name: Anonymous 2009-06-11 16:04

Also, it crashes right on returning from dll since printf("a");return false; prints 'a' (then crashes) but  $measurenetwork -> Call ( $adapterindex, $speed );print'b'; doesn't print 'b', even with altered $|=1

Name: Anonymous 2009-06-11 16:07

why are you not using c♯?

Name: Anonymous 2009-06-11 16:12

I'm considering rewriting whole thing in perl, fuck that dll.

Name: Anonymous 2009-06-11 16:12

>>4
moar leik...

Why aren't you using *NIX as your Perl programming platform.
In b4 the Microsoft nutsack hangers bash *NIX. (How's that 12" cock feel in your ass, MS fanboys?).

Name: Anonymous 2009-06-11 16:13

>>4
c# is Microsoft Java

Name: Anonymous 2009-06-11 16:18

This is what happens when Perl programmers try real programming (and fail horribly, of course).

Name: Anonymous 2009-06-11 16:19

>>8
i knew c before learning perl, bro

Name: Anonymous 2009-06-11 16:22

>>7
actually it's more like python without the forced indentation.

>>6
c♯ works better on *nix than on windows. hows that forced indentation feel in your ass, guido fanboy?

Name: Anonymous 2009-06-11 16:26

Hey >>10. Meh.
My languages need no indentation, but if I can teach VIM to auto-indent them should I desire.

Name: Anonymous 2009-06-11 16:46

I pass to my dll

Stopped reading right there.

Name: Anonymous 2009-06-11 17:01

>>9
Doesn't look like it. Besides, you deserve nothing better for hungarian notation.

Name: Anonymous 2009-06-11 17:05

>>6
Feels good man.

Name: Anonymous 2009-06-11 17:11

>>1
$measurenetwork
I read that as `$pleasurenetwork`

Name: Anonymous 2009-06-11 18:49

>>1
Your function returns bool, but you specified 'I' as the return type. I don't know this in any detail, but perhaps you're fucking up the stack with that? Try changing it to int, maybe.

Name: Anonymous 2009-06-11 22:09

>>15
One word, TPOBCI, thread over.

Name: Anonymous 2009-06-11 22:26

>>17
Тровсі

Name: Anonymous 2009-06-12 13:53

>>17
the promotion of bool something integer?

Name: Anonymous 2009-06-12 14:15

>>19
Silly anonymous, ’something‘ doesn't start with C!

Name: Anonymous 2009-06-12 14:45

>>20
DONT SAGE ME BRO

Name: Anonymous 2009-06-12 15:01

I can only sage my own posts.

Name: Anonymous 2009-06-13 1:41

>>21
DONT BUMP THREADS FOR POINTLESS POSTS, GRANDSON

Name: Anonymous 2011-02-04 15:12

Don't change these.
Name: Email:
Entire Thread Thread List