Thu Feb 02 11:55:59 2012: Request 74578 was acted upon. Transaction: Correspondence added by rur...@cpanel.net Queue: Win32-API Subject: Re: [rt.cpan.org #74578] Win32::API::Struct not aligned on 64 bit Broken in: 0.64 Severity: Normal Owner: Nobody Requestors: do...@cpan.org Status: open Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=74578 >
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" <bug-win32-...@rt.cpan.org> > 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 libwin32@perl.org 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