in reply to Re: calling a function from a dll
in thread calling a function from a dll

Am I perhaps calling the function wrong or something? as I get a
Not a CODE reference at xx.pl line 14
which is where the $function is called in the sub routine

#!/usr/bin/perl use Win32::API; my $function = Win32::API->new('C:\XYZClientLibrary\x86\XYZClientLibra +ry.dll', 'XYZDecrypt', 'PPP', 'I'); print call_function('9','8B3A06617FEC4276A5711FBA4861B467', '[000001]C +0808FC9B3062D91E7B9B1D9A7B79216'); sub call_function { my ($value, $key, $encrypted) = @_; # Here we pad $value to the expected length, to avoid a buffer ove +rrun # I guess that the result is at most as long as the encrypted stri +ng $value = ' ' x length($encrypted); print (" $value, $key, $encrypted\n"); $value = $function->( $value, $key, $encrypted ); $value =~ s!\0.*!!; # we assume that the first \0 returned indicat +es end of the string return $value };

Replies are listed 'Best First'.
Re^3: calling a function from a dll
by roboticus (Chancellor) on Dec 31, 2012 at 19:26 UTC

    nmeijer:

    Looking at the Win32::API docs, it looks like line 14 should be:

    $value = $function->Call( $value, $key, $encrypted );

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.