iea has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

i´ve got a function that returns a value containing the
address of an allocated buffer. It seems like this adress
is binary packt ... but i´m not sure.

I get something like that.
p♣

if i unpack it using
unpack("W",$lpBuffer);
I get 38.

No my question is, how can i read the information stored at the address?

thanks

Replies are listed 'Best First'.
Re: Print Buffer
by Anonymous Monk on Aug 11, 2008 at 14:39 UTC
      Sry ... I´ll try it more precisely.

      Yes I am using win32::api an the definition of the function is:

      When the function returns, this value contains the address of an allocated buffer, containing the information.
      I defined my buffer like this

      my $lpBuffer = " " x 1024;

      And there is also something in $lpBuffer it should be a address =).

      How can i get the information of the buffer with this address?

      See in my first post the information i recieve.

      I am not sure if i need to use unpack no.
      thanks

        When the function returns, this value contains the address of an allocated buffer, containing the information. I defined my buffer like this...

        Does this function have a name and a return type? :--)

        In general: sometimes you get back the true length of the buffer $lpBuffer which you can use to decode the actual value. Sometimes $lpBuffer contains a \0, the C string terminator/delimiter so you have to trim the value.

        We need more context. What you provided is insufficient and confusing. $lpBuffer is intended to contain the packed structure, example
        use strict; use warnings; use Win32::API; my $GetTempPath = new Win32::API( 'kernel32', 'GetTempPath', 'NP', 'N'); my $lpBuffer = " " x 80; my $return = $GetTempPath->Call(80, $lpBuffer); my $TempPath = substr($lpBuffer, 0, $return); print $TempPath,$/;
        Get it?
Re: Print Buffer
by dHarry (Abbot) on Aug 11, 2008 at 14:24 UTC

    Could you please be a bit more specific, c.q. post some code. Is this Win32:API stuff? Do you initialize $lpBuffer correctly? Are you sure unpack("W",$lpBuffer) is correct?