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