Re: [rt.cpan.org #74578] Win32::API::Struct not aligned on 64 bit

[email protected] (Reini Urban)
Newsgroups perl.libwin32
Message-ID <[email protected]>
Am 01.02.2012 um 11:00 schrieb Cosimo Streppone:

> This is RT#74578 about Win32::API structs packing/unpacking.
> Can you help us?
> 
> ------- Forwarded message -------
> From: "Douglas Wilson via RT" <[email protected]>
> Subject: [rt.cpan.org #74578] Win32::API::Struct not aligned on 64 bit
> Date: Wed, 01 Feb 2012 17:27:37 +0100
> 
>        Queue: Win32-API
>  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=74578 >
> 
> On Wed Feb 01 02:15:26 2012, COSIMO wrote:
>> Hi Doug, thanks for filing this.
>> 
>> What do to about it?
>> Not sure, other than CC'ing [email protected] as you did.
> 
> Cool, I didn't know RT cc'd the mailing list (maybe someone else will
> know what to do). What I've done is hack Struct.pm getPack() and
> getUnpack():
> 
> in getPack():
>             $type_align = (($packed_size + $type_size) % $type_size);
> #            $packing .= "x" x $type_align . $type;
>             $packing .= $type;
>             $packed_size += $type_size;
> #            $packed_size += $type_size + $type_align;
>         }
> 
> in getUnpack():
> 	    $type_align = (($packed_size + $type_size) % $type_size);
> #	    $packing .= "x" x $type_align . $type;
> 	    $packing .= $type;
> #	    $packed_size += $type_size + $type_align;
> 	    $packed_size += $type_size;
> 
>             push(@items, $name);
>         }
> 


I'm pretty sure deleting type_align on 64bit is wrong. There must be an error in the 
size calculation for 8 byte sizes, which will result in the needed type_align=0.

I have got no win64 bit vm (yet), but I will try to study it today.

> Perhaps if this change were wrapped in is_64bit() type logic, then it
> would work everywhere? I don't know enough about this to really know for
> sure, and I'm not even sure if I haven't broken something else. And if
> this change is headed in the right direction, there should probably be
> some changes to the align() and sizeof() methods.


Reini
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.