Re: 3 Win32::API bugs

[email protected] ("$Bill Luebkert")
Newsgroups perl.libwin32
Message-ID <[email protected]>
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 ?).
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.