USER32: win16 applications should not see long filenames returned from dialog control (try 2)

Alex Villací­s Lasso a_villacis at palosanto.com
Mon Nov 5 11:04:55 CST 2007


Robert Shearman escribió:
> Dmitry Timoshkov wrote:
>   
>> "Alex Villacís Lasso" <a_villacis at palosanto.com> wrote:
>>
>>   
>>     
>>>  BOOL16 WINAPI DlgDirSelectEx16( HWND16 hwnd, LPSTR str, INT16 len, INT16 id )
>>>  {
>>> -    return DlgDirSelectExA( WIN_Handle32(hwnd), str, len, id );
>>> +    BOOL16 ret = DlgDirSelectExA( WIN_Handle32(hwnd), str, len, id );
>>> +    GetShortPathNameA(str, str, len);
>>> +    return ret;
>>>  }
>>>     
>>>       
>>   
>>     
>>>  BOOL16 WINAPI DlgDirSelectComboBoxEx16( HWND16 hwnd, LPSTR str, INT16 len,
>>>                                          INT16 id )
>>>  {
>>> -    return DlgDirSelectComboBoxExA( WIN_Handle32(hwnd), str, len, id );
>>> +    BOOL16 ret = DlgDirSelectComboBoxExA( WIN_Handle32(hwnd), str, len, id );
>>> +    GetShortPathNameA(str, str, len);
>>> +    return ret;
>>>  }
>>>     
>>>       
>> You are passing garbage to GetShortPathNameA in the case of failure.
>>   
>>     
>
>   
I agree, thanks for spotting that. The attached code fixes this.
> And more importantly, the code in this patch is relying on 
> GetShortPathNameA creating a copy of the long filename before copying it 
> back.
>
>   

> Furthermore, the long file name might exceed the limit of len, whilst 
> the short file name might not, prematurely truncating the short file name.
>
>   
Also corrected. What do you think about this version?

Legacy Win16 applications display file/directory selection listboxes and
expect to receive a short name from the control. Currently the control
provides a long name instead, which causes undefined behavior in Win16 apps.
For example, ProImage for Windows 1.10 from ProLab Tech (a Win16 app) 
crashes
after receiving this long filename. The attached patch attempts to fix this
by converting the about-to-be-returned name to a short name when called from
the 16-bit wrapper.

Changelog:
* Win16 applications should not see long filenames. Change directory listbox
  to return short names when called from the 16-bit wrappers.

-- 
perl -e '$x=2.4;print sprintf("%.0f + %.0f = %.0f\n",$x,$x,$x+$x);'

-------------- next part --------------
A non-text attachment was scrubbed...
Name: wine-user32-dialog-no-longname-for-win16-try3.patch
Type: text/x-patch
Size: 1013 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20071105/cf3feed4/attachment.bin 


More information about the wine-patches mailing list