Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: pack()ing Win32 Structures

by JayBonci (Curate)
on May 06, 2002 at 01:58 UTC ( #164205=note: print w/replies, xml ) Need Help??

in reply to pack()ing Win32 Structures

Good evening. It sounds like you have a good one there. Lemme see what I can do to help. I'm not a pack ninja, but I see a few things that might be wrong. From the MSDN documentation of TIME_ZONE_INFORMATION,
typedef struct _TIME_ZONE_INFORMATION { LONG Bias; WCHAR StandardName[ 32 ]; SYSTEMTIME StandardDate; LONG StandardBias; WCHAR DaylightName[ 32 ]; SYSTEMTIME DaylightDate; LONG DaylightBias; } TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION;
You're looking at Long, 32 Unicode characters, a structure, Long, 32 Unicode Characters, a structure, Long. The SYSTEMTIME structure is 8x16 bits, and that pack stucture looks right. However, where you seem to be going wrong is that you are packing a string where you should be packing the structure itself. Therefore, you are passing a packed string to the API function, and that probably isn't correct. Should your pack string look like this:
$tz_struct = pack("LU32S8LU32S8L", 0, " " x 32, unpack("S8",$systime_struct),0, " " x 32, unpack("S8",$systime_struct),0);
I think you might also want to use capital U in pack instead of lowercase u, meaning 32 characters, and not 32 strings, but I could be reading the doc wrong. Another way to test it might be to pack yourself a gigantic structure of zeros, and see if it still crashes. Where is it dying (what's the last statement that runs before it rolls over)? Good luck.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://164205]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2021-04-18 14:31 GMT
Find Nodes?
    Voting Booth?

    No recent polls found