--- In [email protected], "entropyreduction" <[EMAIL PROTECTED]> wrote:
>
> --- In [email protected], "swzoh" <seanzoh@> wrote:
>
> I've modified this, trying out new dll plugin features, and
> reintroduced PP crashes on a font name containing whitespace.
>
> Do you remember what eliminated that problem? Was it possibly:
I already mailed about this. Anyway, it was not the white-space, but
the length of the font name: if not less than 8, CreateFontIndirect
with LogFont crashed PP.
However, this happened only with create_array. If using create_struct
instead it just worked fine. I attached a sample script to test it.
The result wasn't affected even if specifying terminating null, BTW.
> > Notice that I don't have
> > specified terminating null for sFaceName in tLogFont struct, which
> > doesn't seem to matter anyway. The usage is
>
> ...which does make you wonder, if there's no terminating NULL, how
> LOGFONT ever works. I guess it's location specific: you _have_ to
> pass it on the stack (not by pointer), and as the last parameter, so
> you know the end of the struct is the end of the stack. Weird.
Although I'm not quite sure what this does really mean (:remember I'm
not a programmer), it seems similar to what I guessed. If you tried
the attached script, you'll notice the length with array is always
greater than expected by 1. No symptom like this with struct. So, this
extra byte in case of array could be the cause of the crash. I
concluded this extra-allocated byte is not initialized, so cause the
crash.
What I guessed about the mechanism of CreateFontIndirect referencing
LogFont was the following. It tries to read all the allocated memory,
possibly up to 28+32, without caring whether there exists or not a
null in the middle of sFaceName parameter. After then, parses the
sFaceName, and if it meets null in it just end there, or if not use
whole name (till the end of allocation).
This might explain the crash with array, even when accompanying
terminating null: (last) uninitialized allocated byte. Then, however,
meet a difficulty with the fact that no crash when the sFaceName is
less than 8 in length: might be some safe-guard in this case?
----------------------------------------------------------------------
local sFaceName,hFont,tLogFont,atFace,at
at=0 ;; set to 0/1 for struct/array
sFaceName="PMingLiU" ;; "Tahoma"
do("atFace=dll.create_"++ifelse(at,"array","struct");;+
++?'("c"++esc("|0n",0),sFaceName["."])')
;++?'("c"++esc("|0n",0),sFaceName["."]++"000")')
tLogFont=dll.create_struct("i i i i i uc uc uc uc uc uc uc uc ";;+
++ifelse(at,"a","t"),-16,0,0,0,400,"","","","","","","","",atFace)
win.debug(tLogFont.get_size,28+length(sFaceName))
wait.for(1000)
hFont=dll.call("CreateFontIndirect|t* i",tLogFont)
win.debug(hFont)
dll.call("DeleteObject|ui",hFont)
quit
----------------------------------------------------------------------
Sean
------------------------ Yahoo! Groups Sponsor --------------------~-->
Great things are happening at Yahoo! Groups. See the new email design.
http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/JV_rlB/TM
--------------------------------------------------------------------~->
Attention: PowerPro's Web site has moved: http://www.ppro.org
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/power-pro/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/