_SHExpandEnvironmentStrings() should return input string if no % found to expand?

Dan Kegel dank at kegel.com
Sat Oct 23 14:00:27 CDT 2004


I'm trying to install an app using
Wine cvs as of about Sat Oct 23 07:00:00 PDT 2004
plus the patch http://article.gmane.org/gmane.comp.emulators.wine.patches/11184
from James Hawkins <truiken at gmail.com>
to get around the problem that the program terminates immediately
if it can't find at least a stub for WSCEnumProtocols.

The next problem was that SHGetFolderPath(CSIDL_INTERNET_CACHE)
was returning an empty string because _SHExpandEnvironmentStrings()
was passed an already-expanded string, and arbitrarily returned
an empty string instead of the input.

The following patch makes the problem go away for me, don't
know if it's the right fix, but it's plausible:

ChangeLog:
   * dlls/shell32/shellpath.c: make _SHExpandEnvironmentStrings() return input string if no % found to expand

License: LGPL
Signed-off-by: dank at kegel.com

Index: dlls/shell32/shellpath.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shellpath.c,v
retrieving revision 1.91
diff -u -r1.91 shellpath.c
--- dlls/shell32/shellpath.c	22 Oct 2004 20:26:23 -0000	1.91
+++ dlls/shell32/shellpath.c	23 Oct 2004 19:40:22 -0000
@@ -1476,6 +1476,8 @@

      *szDest = 0;
      strcpyW(szTemp, szSrc);
+    if (!SUCCEEDED(hr) || szTemp[0] != '%')
+	    strcpyW(szDest, szSrc);
      while (SUCCEEDED(hr) && szTemp[0] == '%')
      {
          if (!strncmpiW(szTemp, AllUsersProfileW, strlenW(AllUsersProfileW)))


Here's the trace of the original problem:

000b:trace:shell:SHGetFolderPathW (nil),0x40df9540,nFolder=0x8020
000b:trace:shell:_SHGetUserProfilePath (nil),0x00000000,0x20,0x40df8e14
000b:trace:shell:_SHGetUserShellFolderPath 0x80000001,(null),L"Cache",0x40df8e14
000b:trace:reg:NtCreateKey (0x30,L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",(null),0,f003f,0x40df8774)
Create key \\User\\dank\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders
000b:trace:reg:NtCreateKey <- 0xac
000b:trace:reg:NtCreateKey (0x30,L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders",(null),0,f003f,0x40df8770)
Create key \\User\\dank\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders
000b:trace:reg:NtCreateKey <- 0xb0
000b:trace:reg:RegQueryValueExW (0xb0,L"Cache",(nil),0x40df8768,0x40df8e14,0x40df876c=260)
000b:trace:reg:NtQueryValueKey (0xb0,L"Cache",2,0x40df8588,256)
Get key \\User\\dank\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders value "Cache"=str(2):"c:\\windows\\Temporary Internet Files"
000b:trace:shell:_SHExpandEnvironmentStrings L"c:\\windows\\Temporary Internet Files", 0x40df877c
000b:Call advapi32.RegCreateKeyExW(80000002,40ee8200 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",00000000,00000000,00000000,000f003f,00000000,40df7cf4,40df7ccc) ret=40e951e2
000b:Call ntdll.RtlInitUnicodeString(40df7bb0,40ee8200 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList") ret=4075c5c7
000b:trace:reg:NtCreateKey (0x1c,L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",(null),0,f003f,0x40df7cf4)
000b: create_key( parent=0x1c, access=000f003f, options=00000000, modif=0, namelen=112, name=L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList", class=L"" )
Create key \\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList
000b:trace:reg:NtCreateKey <- 0xb4
000b:Call shlwapi.PathAppendW(40df8118 L"%SystemDrive%",40ee8420 L"windows\\profiles") ret=40e9546a
000b:trace:shell:PathAppendW (L"%SystemDrive%",L"windows\\profiles")
000b:trace:shell:PathIsUNCW (L"windows\\profiles")
000b:trace:shell:PathCombineW (0x40df8118,L"%SystemDrive%",L"windows\\profiles")
000b:trace:shell:PathIsRelativeW (L"windows\\profiles")
000b:trace:shell:PathAddBackslashW (L"%SystemDrive%")
000b:trace:shell:PathCanonicalizeW (0x40df8118,L"%SystemDrive%\\windows\\profiles")
000b:trace:shell:_SHGetProfilesValue 0xb4,L"ProfilesDirectory",0x40df8328,L"%SystemDrive%\\windows\\profiles"
000b:Call advapi32.RegQueryValueExW(000000b4,40ee8280 L"ProfilesDirectory",00000000,40df7cb4,40df8328,40df7cb8) ret=40e95244
000b:trace:reg:RegQueryValueExW (0xb4,L"ProfilesDirectory",(nil),0x40df7cb4,0x40df8328,0x40df7cb8=520)
000b:Call ntdll.RtlInitUnicodeString(40df7ad0,40ee8280 L"ProfilesDirectory") ret=4075de3a
000b:trace:reg:NtQueryValueKey (0xb4,L"ProfilesDirectory",2,0x40df7ad8,256)
000b: get_key_value( hkey=0xb4, name=L"ProfilesDirectory" )
Get key \\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList value "ProfilesDirectory"=str(2):"%SystemDrive%\\windows\\profiles"
000b:trace:shell:_SHGetProfilesValue returning 0x00000000 (output value is L"%SystemDrive%\\windows\\profiles")
000b:trace:shell:_SHExpandEnvironmentStrings returning 0x00000000 (input was L"c:\\windows\\Temporary Internet Files", output is L"")
000b:trace:reg:NtSetValueKey (0xac,L"Cache",1,0x40df8e14,2)
000b:trace:shell:_SHGetUserShellFolderPath returning 0x00000000
000b:trace:shell:_SHGetUserProfilePath returning 0x00000000 (output path is L"")
000b:trace:shell:PathFileExistsW (L"")
000b:trace:file:GetFileAttributesW L""
000b:trace:file:RtlDosPathNameToNtPathName_U (L"",0x40df8c44,(nil),(nil))
000b:trace:shell:PathFileExistsW (L"")
000b:trace:file:GetFileAttributesW L""
000b:trace:file:RtlDosPathNameToNtPathName_U (L"",0x40df8c44,(nil),(nil))
000b:trace:file:CreateDirectoryW L""
000b:trace:file:RtlDosPathNameToNtPathName_U (L"",0x40df8d20,(nil),(nil))
000b:err:shell:SHGetFolderPathW Failed to create directory 'L""'.


-- 
Trying to get a job as a c++ developer?  See http://kegel.com/academy/getting-hired.html



More information about the wine-patches mailing list