Author: mjansen
Date: Mon Jun 19 15:04:20 2017
New Revision: 75130
URL:
http://svn.reactos.org/svn/reactos?rev=75130&view=rev
Log:
[SHELL32] Partially sync shlexec with wine staging 2.9 CORE-13362 CORE-13407
Modified:
trunk/reactos/dll/win32/shell32/shlexec.cpp
Modified: trunk/reactos/dll/win32/shell32/shlexec.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shlexec.…
==============================================================================
--- trunk/reactos/dll/win32/shell32/shlexec.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/shlexec.cpp [iso-8859-1] Mon Jun 19 15:04:20 2017
@@ -1209,6 +1209,7 @@
{
UINT_PTR retval = SE_ERR_NOASSOC;
WCHAR old_dir[1024];
+ WCHAR res[MAX_PATH];
TRACE("File %s, Dir %s\n", debugstr_w(lpFile), debugstr_w(lpDirectory));
@@ -1222,7 +1223,9 @@
SetCurrentDirectoryW(lpDirectory);
}
- retval = SHELL_FindExecutable(lpDirectory, lpFile, wszOpen, lpResult, MAX_PATH, NULL,
NULL, NULL, NULL);
+ retval = SHELL_FindExecutable(lpDirectory, lpFile, wszOpen, res, MAX_PATH, NULL,
NULL, NULL, NULL);
+ if (retval > 32)
+ strcpyW(lpResult, res);
TRACE("returning %s\n", debugstr_w(lpResult));
if (lpDirectory)
@@ -1409,6 +1412,7 @@
if (!dataobj)
{
ERR("failed to get data object\n");
+ r = E_FAIL;
goto end;
}
@@ -1663,7 +1667,6 @@
DWORD error_code;
error_code = GetLastError();
-
if (retval == SE_ERR_NOASSOC)
LoadStringW(shell32_hInstance, IDS_SHLEXEC_NOASSOC, msg, sizeof(msg) /
sizeof(WCHAR));
else
@@ -1676,6 +1679,26 @@
(va_list*)msgArguments);
MessageBoxW(hwnd, msg, NULL, MB_ICONERROR);
+}
+
+static WCHAR *expand_environment( const WCHAR *str )
+{
+ WCHAR *buf;
+ DWORD len;
+
+ len = ExpandEnvironmentStringsW(str, NULL, 0);
+ if (!len) return NULL;
+
+ buf = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ if (!buf) return NULL;
+
+ len = ExpandEnvironmentStringsW(str, buf, len);
+ if (!len)
+ {
+ HeapFree(GetProcessHeap(), 0, buf);
+ return NULL;
+ }
+ return buf;
}
/*************************************************************************
@@ -1721,17 +1744,16 @@
wszApplicationName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen
* sizeof(WCHAR));
*wszApplicationName = '\0';
}
- else if (*sei_tmp.lpFile == '\"')
- {
- DWORD l = strlenW(sei_tmp.lpFile + 1);
- if(l >= dwApplicationNameLen)
- dwApplicationNameLen = l + 1;
+ else if (*sei_tmp.lpFile == '\"' && sei_tmp.lpFile[(len =
strlenW(sei_tmp.lpFile))-1] == '\"')
+ {
+ if(len-1 >= dwApplicationNameLen)
+ dwApplicationNameLen = len;
wszApplicationName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen
* sizeof(WCHAR));
- memcpy(wszApplicationName, sei_tmp.lpFile + 1, (l + 1)*sizeof(WCHAR));
-
- if (wszApplicationName[l-1] == L'\"')
- wszApplicationName[l-1] = L'\0';
+ memcpy(wszApplicationName, sei_tmp.lpFile + 1, len * sizeof(WCHAR));
+
+ if(len > 2)
+ wszApplicationName[len-2] = '\0';
appKnownSingular = TRUE;
TRACE("wszApplicationName=%s\n", debugstr_w(wszApplicationName));
@@ -1809,6 +1831,27 @@
TRACE("-- idlist=%p (%s)\n", sei_tmp.lpIDList,
debugstr_w(wszApplicationName));
}
+ if (sei_tmp.fMask & SEE_MASK_DOENVSUBST)
+ {
+ WCHAR *tmp;
+
+ tmp = expand_environment(sei_tmp.lpFile);
+ if (!tmp)
+ {
+ return FALSE;
+ }
+ HeapFree(GetProcessHeap(), 0, wszApplicationName);
+ sei_tmp.lpFile = wszApplicationName = tmp;
+
+ tmp = expand_environment(sei_tmp.lpDirectory);
+ if (!tmp)
+ {
+ return FALSE;
+ }
+ if (wszDir != dirBuffer) HeapFree(GetProcessHeap(), 0, wszDir);
+ sei_tmp.lpDirectory = wszDir = tmp;
+ }
+
if (ERROR_SUCCESS == ShellExecute_FromContextMenu(&sei_tmp))
{
sei->hInstApp = (HINSTANCE) 33;
@@ -1870,7 +1913,6 @@
}
HeapFree(GetProcessHeap(), 0, wszApplicationName);
- dwApplicationNameLen = lstrlenW(buf) + 1;
wszApplicationName = buf;
sei_tmp.lpFile = wszApplicationName;
}
@@ -1884,7 +1926,6 @@
ExpandEnvironmentStringsW(sei_tmp.lpFile, buf, len + 1);
HeapFree(GetProcessHeap(), 0, wszApplicationName);
- dwApplicationNameLen = len + 1;
wszApplicationName = buf;
/* appKnownSingular unmodified */
@@ -1931,7 +1972,7 @@
{
end = ++src;
- while(isspace(*src))
+ while(isspaceW(*src))
++src;
}
else