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 ?).