Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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.

    --jb

In reply to Re: pack()ing Win32 Structures by JayBonci
in thread pack()ing Win32 Structures by mothra

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (2)
    As of 2021-04-19 05:03 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?