Error On External Call

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Error On External Call

Richard A. Harmon
I created Win32Structure subclass: #TIMEZONEINFORMATION and added
class method:

defineFields
        "Define the fields of the Win32 TIME_ZONE_INFORMATION structure"

        self defineField: #bias type: DWORDField new;
                defineField: #standardName type: (StringField length: 32)
beReadOnly;
                defineField: #standardDate type: (StructureField type:
SYSTEMTIME) beReadOnly;
                defineField: #standardBias type: DWORDField new;
                defineField: #daylightName type: (StringField length: 32)
beReadOnly;
                defineField: #daylightDate type: (StructureField type:
SYSTEMTIME) beReadOnly;
                defineField: #daylightBias type: DWORDField new

"typedef struct _TIME_ZONE_INFORMATION
{
    LONG       Bias;
    WCHAR      StandardName[ 32 ];
    SYSTEMTIME StandardDate;
    LONG       StandardBias;
    WCHAR      DaylightName[ 32 ];
    SYSTEMTIME DaylightDate;
    LONG       DaylightBias;
} TIME_ZONE_INFORMATION;
"

I suspect I didn't get the fields defined correctly because it blew up
Dolphin when I then evaluated "Locale default timeZoneInformation"
after adding Locale method:

timeZoneInformation
        | timeZoneInfo rc |
        timeZoneInfo := TIMEZONEINFORMATION new.
        rc := KernelLibrary default getTimeZoneInformation: timeZoneInfo.
        rc ifFalse: [KernelLibrary default systemError].
        ^Array with: rc with: timeZoneInfo "leftString: nameSize
asInteger"

and adding KernelLibrary method:

getTimeZoneInformation: lpTimeZoneInformation
        "Set the fields of lpTimeZoneInformation with th current
time-zone parameters.  If successful it answers the which fields apply
or unknown, else an error indicator.
        These parameters control the translations between Coordinated
Universal Time (UTC) and local time.

        DWORD GetTimeZoneInformation(
          LPTIME_ZONE_INFORMATION lpTimeZoneInformation // time zone
        );"

        <stdcall: dword GetTimeZoneInformation TIMEZONEINFORMATION* >
        ^self invalidCall

I checked the TIME_ZONE_INFORMATION strucure size in C++, but I may
have the call parms or return wrong.  Anyone spot anything obvious?

First time I ran it I think it got through the call.  Reloaded and
tried stepping through it, and got program performed illegal etc.  I
saw "Bad Oop" as I scanned the dump.


Thanks Bill and Blair for the "External ..." page on the Dolphin wiki.
That helped get me started after the Dev. Guide.


--
Richard A. Harmon          "The only good zombie is a dead zombie"
[hidden email]           E. G. McCarthy


Reply | Threaded
Open this post in threaded view
|

Re: Error On External Call

Blair McGlashan
Richard

"Richard A. Harmon" <[hidden email]> wrote in message
news:[hidden email]...
> I created Win32Structure subclass: #TIMEZONEINFORMATION and added
> class method:
> ...snip...
> I suspect I didn't get the fields defined correctly because it blew up
> Dolphin when I then evaluated "Locale default timeZoneInformation"
> after adding Locale method:

The character arrays in the structure are Unicode strings, and so you're
structure is too small and thus memory corruption is likely when
GetTimeZoneInformation is called. Try the attached.

Regards

Blair
























begin 666 TimeZoneInfo.pac
M?"!P86-K86=E('P-"G!A8VMA9V4@.CT@4&%C:V%G92!N86UE.B G5&EM95IO
M;F5);F9O)RX-"G!A8VMA9V4@<&%X5F5R<VEO;CH@,#L-"@EB87-I8T-O;6UE
M;G0Z("<G+@T*#0IP86-K86=E(&)A<VEC4&%C:V%G959E<G-I;VXZ("<G+@T*
M#0HB061D('1H92!P86-K86=E('-C<FEP=',B#0H-"B)!9&0@=&AE(&-L87-S
M(&YA;65S+"!L;V]S92!M971H;V0@;F%M97,L(&=L;V)A;"!N86UE<RP@<F5S
M;W5R8V4@;F%M97,B#0IP86-K86=E(&-L87-S3F%M97,-"@EA9&0Z("-424U%
M7UI/3D5?24Y&3U)-051)3TX[#0H)>6]U<G-E;&8N#0H-"G!A8VMA9V4@;65T
M:&]D3F%M97,-"@EA9&0Z("-+97)N96Q,:6)R87)Y("T^("-G9714:6UE6F]N
M94EN9F]R;6%T:6]N.CL-"@EA9&0Z("-,;V-A;&4@+3X@(W1I;65:;VYE26YF
M;W)M871I;VX[#0H)>6]U<G-E;&8N#0H-"G!A8VMA9V4@9VQO8F%L3F%M97,-
M"@EY;W5R<V5L9BX-"@T*<&%C:V%G92!R97-O=7)C94YA;65S#0H)>6]U<G-E
M;&8N#0H-"B)":6YA<GD@1VQO8F%L($YA;65S(@T*<&%C:V%G92!B:6YA<GE'
M;&]B86Q.86UE<SH@*%-E="!N97<-"@EY;W5R<V5L9BDN#0HB4F5S;W5R8V4@
M3F%M97,B#0IP86-K86=E(&%L;%)E<V]U<F-E3F%M97,Z("A3970@;F5W#0H)
M>6]U<G-E;&8I+@T*#0HB061D('1H92!P<F5R97%U:7-I=&4@;F%M97,B#0IP
M86-K86=E('-E=%!R97)E<75I<VET97,Z("A)9&5N=&ET>5-E="!N97<-"@EA
M9&0Z("=$;VQP:&EN)SL-"@EY;W5R<V5L9BDN#0H-"G!A8VMA9V4A#0H-"B)#
M;&%S<R!$969I;FET:6]N<R(A#0H-"E=I;C,R4W1R=6-T=7)E('-U8F-L87-S
M.B C5$E-15]:3TY%7TE.1D]234%424].#0H):6YS=&%N8V5687)I86)L94YA
M;65S.B G)PT*"6-L87-S5F%R:6%B;&5.86UE<SH@)R<-"@EP;V]L1&EC=&EO
M;F%R:65S.B G)PT*"6-L87-S26YS=&%N8V5687)I86)L94YA;65S.B G)R$-
M"B),;V]S92!-971H;V1S(B$-"@T*(4ME<FYE;$QI8G)A<GD@;65T:&]D<T9O
M<B$-"@T*9V5T5&EM95IO;F5);F9O<FUA=&EO;CH@;'!4:6UE6F]N94EN9F]R
M;6%T:6]N#0H)(E!O<'5L871E('1H92!F:65L9',@;V8@;'!4:6UE6F]N94EN
M9F]R;6%T:6]N('=I=&@@=&AE(&-U<G)E;G0-"@ET:6UE+7IO;F4@<&%R86UE
M=&5R<RX@268@<W5C8V5S<V9U;"!A;G-W97)S('1H92!W:&EC:"!F:65L9',@
M87!P;'D-"@EO<B!U;FMN;W=N+"!E;'-E(&%N(&5R<F]R(&EN9&EC871O<BX-
M"@E4:&5S92!P87)A;65T97)S(&-O;G1R;VP@=&AE('1R86YS;&%T:6]N<R!B
M971W965N($-O;W)D:6YA=&5D#0H)56YI=F5R<V%L(%1I;64@*%540RD@86YD
M(&QO8V%L('1I;64N#0H-"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%7TE.1D]234%424].(&-L87-S(&UE=&AO9'-&;W(A#0H-
M"F1E9FEN949I96QD<PT*(D1E9FEN92!T:&4@9FEE;&1S(&]F('1H92!7:6XS
M,B!424U%7UI/3D5?24Y&3U)-051)3TX@<W1R=6-T=7)E#0H)"7-E;&8@8V]M
M<&EL941E9FEN:71I;VX-"@T*"71Y<&5D968@<W1R=6-T(%]424U%7UI/3D5?
M24Y&3U)-051)3TX-"@E[#0H)"4Q/3D<@0FEA<SL-"@D)5T-(05(@4W1A;F1A
M<F1.86UE6R S,B!=.PT*"0E365-414U424U%(%-T86YD87)D1&%T93L-"@D)
M3$].1R!3=&%N9&%R9$)I87,[#0H)"5=#2$%2($1A>6QI9VAT3F%M95L@,S(@
M73L-"@D)4UE35$5-5$E-12!$87EL:6=H=$1A=&4[#0H)"4Q/3D<@1&%Y;&EG
M:'1":6%S.PT*"7T@5$E-15]:3TY%7TE.1D]234%424]..R(-"@T*#0H)<V5L
M9B -"@D)9&5F:6YE1FEE;&0Z("-B:6%S('1Y<&4Z(%-$5T]21$9I96QD(')E
M861/;FQY.PT*"0ED969I;F5&:65L9#H@(W-T86YD87)D3F%M92!T>7!E.B H
M07)R87E&:65L9"!T>7!E.B!5;FEC;V1E4W1R:6YG(&QE;F=T:#H@,S(I(&)E
M4F5A9$]N;'D[#0H)"61E9FEN949I96QD.B C<W1A;F1A<F1$871E('1Y<&4Z
M("A3=')U8W1U<F5&:65L9"!T>7!E.B!365-414U424U%*2!B95)E861/;FQY
M.PT*"0ED969I;F5&:65L9#H@(W-T86YD87)D0FEA<R!T>7!E.B!31%=/4D1&
M:65L9"!R96%D3VYL>3L-"@D)9&5F:6YE1FEE;&0Z("-D87EL:6=H=$YA;64@
M='EP93H@*$%R<F%Y1FEE;&0@='EP93H@56YI8V]D95-T<FEN9R!L96YG=&@Z
M(#,R*2!B95)E861/;FQY.PT*"0ED969I;F5&:65L9#H@(V1A>6QI9VAT1&%T
M92!T>7!E.B H4W1R=6-T=7)E1FEE;&0@='EP93H@4UE35$5-5$E-12D@8F52
M96%D3VYL>3L-"@D)9&5F:6YE1FEE;&0Z("-D87EL:6=H=$)I87,@='EP93H@
M4T173U)$1FEE;&0@<F5A9$]N;'DA("$-"B%424U%7UI/3D5?24Y&3U)-051)
M3TX@8VQA<W,@8V%T96=O<FEE<T9O<CH@(V1E9FEN949I96QD<R$J+75N8VQA
M<W-I9FEE9"%P=6)L:6,A("$-"@T*( T*(D)I;F%R>2!';&]B86QS(B$-"@T*
0(E)E<V]U<F-E<R(A#0H-"@``
`
end