develooper Front page | perl.libwin32 | Postings from May 2012

Re: 3 Win32::API bugs

Thread Previous | Thread Next
From:
$Bill Luebkert
Date:
May 16, 2012 07:48
Subject:
Re: 3 Win32::API bugs
Message ID:
4FB2A40E.10502@roadrunner.com
On 05/14/2012 11:33, bulk 88 wrote:
>
> I'm going to restart this discussion at http://www.perlmonks.org/?node_id=970481 . I hope more pairs of eyes see there and respond there.

I can't log in there at the moment - won't take my password or email me a new one.

Wouldn't something like this work at the start of the new function:

# existing code:

sub new {
     my ($class, $dll, $proc, $in, $out, $callconvention) = @_;
     my $hdll;
     my $self = {};

# New code to add to handle dynamic DLL function address

     if (ref $dll) { # if DLL is a ref must be dynamic func addr
         my $hproc = ${$dll};
         if (not defined $in and not defined $out) {
             ($proc, $self->{in}, $self->{intypes}, $self->{out},
	      $self->{cdecl}) = parse_prototype ($proc);
             return undef unless $proc;
             $self->{proto} = 1;
         }
         $self->{procname} = $proc;
         $self->{dll}      = undef;	# no DLL
         $self->{dllname}  = undef;	# no DLL name
         $self->{proc}     = $hproc;
         DEBUG "Dynamic address object blessed!\n";
         bless ($self, $class);
         return $self;
     }

# rest of old code
	...

This would also not break Win32::API::Prototype which would also
have to change if you add args to the new call.  The only non
obvious thing is how to specify the reference to the function addr
(is it a packed address pointer or what ?).


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About