mirror of
https://github.com/reactos/reactos.git
synced 2025-06-05 17:30:32 +00:00
[shell32.dll]
- rewrite the parser to handle command line argument parsing - include basic description of what the rules for parsing are - some minor formatting here and there (couldn't be helped) svn path=/branches/shell32_new-bringup/; revision=53533
This commit is contained in:
parent
fc902e6f58
commit
18d876cbf2
1 changed files with 425 additions and 252 deletions
|
@ -32,6 +32,125 @@ static const WCHAR wszEmpty[] = {0};
|
||||||
|
|
||||||
#define SEE_MASK_CLASSALL (SEE_MASK_CLASSNAME | SEE_MASK_CLASSKEY)
|
#define SEE_MASK_CLASSALL (SEE_MASK_CLASSNAME | SEE_MASK_CLASSKEY)
|
||||||
|
|
||||||
|
static void ParseNoTildeEffect(PWSTR &res, LPCWSTR &args, DWORD &len, DWORD &used, int argNum)
|
||||||
|
{
|
||||||
|
bool firstCharQuote = false;
|
||||||
|
bool quotes_opened = false;
|
||||||
|
bool backslash_encountered = false;
|
||||||
|
|
||||||
|
for (int curArg=0; curArg<=argNum && *args; ++curArg)
|
||||||
|
{
|
||||||
|
firstCharQuote = false;
|
||||||
|
if (*args == '"')
|
||||||
|
{
|
||||||
|
quotes_opened = true;
|
||||||
|
firstCharQuote = true;
|
||||||
|
args++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(*args)
|
||||||
|
{
|
||||||
|
if (*args == '\\')
|
||||||
|
{
|
||||||
|
// if we found a backslash then flip the variable
|
||||||
|
backslash_encountered = !backslash_encountered;
|
||||||
|
}
|
||||||
|
else if (*args == '"')
|
||||||
|
{
|
||||||
|
if (quotes_opened)
|
||||||
|
{
|
||||||
|
if (*(args+1) != '"')
|
||||||
|
{
|
||||||
|
quotes_opened = false;
|
||||||
|
args++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
args++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
quotes_opened = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
backslash_encountered = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backslash_encountered = false;
|
||||||
|
if (*args == ' ' && !firstCharQuote)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curArg == argNum)
|
||||||
|
{
|
||||||
|
used++;
|
||||||
|
if (used < len)
|
||||||
|
*res++ = *args;
|
||||||
|
}
|
||||||
|
|
||||||
|
args++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(*args == ' ')
|
||||||
|
++args;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ParseTildeEffect(PWSTR &res, LPCWSTR &args, DWORD &len, DWORD &used, int argNum)
|
||||||
|
{
|
||||||
|
bool quotes_opened = false;
|
||||||
|
bool backslash_encountered = false;
|
||||||
|
|
||||||
|
for (int curArg=0; curArg<=argNum && *args; ++curArg)
|
||||||
|
{
|
||||||
|
while(*args)
|
||||||
|
{
|
||||||
|
if (*args == '\\')
|
||||||
|
{
|
||||||
|
// if we found a backslash then flip the variable
|
||||||
|
backslash_encountered = !backslash_encountered;
|
||||||
|
}
|
||||||
|
else if (*args == '"')
|
||||||
|
{
|
||||||
|
if (quotes_opened)
|
||||||
|
{
|
||||||
|
if (*(args+1) != '"')
|
||||||
|
{
|
||||||
|
quotes_opened = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
args++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
quotes_opened = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
backslash_encountered = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backslash_encountered = false;
|
||||||
|
if (*args == ' ' && !quotes_opened && curArg!=argNum)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curArg == argNum)
|
||||||
|
{
|
||||||
|
used++;
|
||||||
|
if (used < len)
|
||||||
|
*res++ = *args;
|
||||||
|
}
|
||||||
|
|
||||||
|
args++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* SHELL_ArgifyW [Internal]
|
* SHELL_ArgifyW [Internal]
|
||||||
|
@ -48,7 +167,18 @@ static const WCHAR wszEmpty[] = {0};
|
||||||
* %S ???
|
* %S ???
|
||||||
* %* all following parameters (see batfile)
|
* %* all following parameters (see batfile)
|
||||||
*
|
*
|
||||||
*/
|
* The way we parse the command line arguments was determined through extensive
|
||||||
|
* testing and can be summed up by the following rules"
|
||||||
|
*
|
||||||
|
* - %2
|
||||||
|
* - if first letter is " break on first non literal " and include any white spaces
|
||||||
|
* - if first letter is NOT " break on first " or white space
|
||||||
|
* - if " is opened any pair of consecutive " results in ONE literal "
|
||||||
|
*
|
||||||
|
* - %~2
|
||||||
|
* - use rules from here http://www.autohotkey.net/~deleyd/parameters/parameters.htm
|
||||||
|
*/
|
||||||
|
|
||||||
static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR* lpFile, LPITEMIDLIST pidl, LPCWSTR args, DWORD* out_len)
|
static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR* lpFile, LPITEMIDLIST pidl, LPCWSTR args, DWORD* out_len)
|
||||||
{
|
{
|
||||||
WCHAR xlpFile[1024];
|
WCHAR xlpFile[1024];
|
||||||
|
@ -57,10 +187,14 @@ static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR*
|
||||||
PWSTR res = out;
|
PWSTR res = out;
|
||||||
PCWSTR cmd;
|
PCWSTR cmd;
|
||||||
DWORD used = 0;
|
DWORD used = 0;
|
||||||
|
bool tildeEffect = false;
|
||||||
|
|
||||||
TRACE("%p, %d, %s, %s, %p, %p\n", out, len, debugstr_w(fmt),
|
TRACE("%p, %d, %s, %s, %p, %p\n", out, len, debugstr_w(fmt),
|
||||||
debugstr_w(lpFile), pidl, args);
|
debugstr_w(lpFile), pidl, args);
|
||||||
|
|
||||||
|
DbgPrint("[shell32, SHELL_ArgifyW] Processing %ws\n", args);
|
||||||
|
DbgPrint("[shell32, SHELL_ArgifyW] fmt = %ws\n", fmt);
|
||||||
|
|
||||||
while (*fmt)
|
while (*fmt)
|
||||||
{
|
{
|
||||||
if (*fmt == '%')
|
if (*fmt == '%')
|
||||||
|
@ -69,28 +203,19 @@ static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR*
|
||||||
{
|
{
|
||||||
case '\0':
|
case '\0':
|
||||||
case '%':
|
case '%':
|
||||||
|
{
|
||||||
used++;
|
used++;
|
||||||
if (used < len)
|
if (used < len)
|
||||||
*res++ = '%';
|
*res++ = '%';
|
||||||
break;
|
}; break;
|
||||||
|
|
||||||
case '2':
|
|
||||||
case '3':
|
|
||||||
case '4':
|
|
||||||
case '5':
|
|
||||||
case '6':
|
|
||||||
case '7':
|
|
||||||
case '8':
|
|
||||||
case '9':
|
|
||||||
case '0':
|
|
||||||
case '*':
|
case '*':
|
||||||
|
{
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
if (*fmt == '*')
|
if (*fmt == '*')
|
||||||
{
|
{
|
||||||
used++;
|
used++;
|
||||||
if (used < len)
|
|
||||||
*res++ = '"';
|
|
||||||
while(*args)
|
while(*args)
|
||||||
{
|
{
|
||||||
used++;
|
used++;
|
||||||
|
@ -100,30 +225,43 @@ static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR*
|
||||||
args++;
|
args++;
|
||||||
}
|
}
|
||||||
used++;
|
used++;
|
||||||
if (used < len)
|
|
||||||
*res++ = '"';
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
}; break;
|
||||||
|
|
||||||
|
case '~':
|
||||||
|
|
||||||
|
case '2':
|
||||||
|
case '3':
|
||||||
|
case '4':
|
||||||
|
case '5':
|
||||||
|
case '6':
|
||||||
|
case '7':
|
||||||
|
case '8':
|
||||||
|
case '9':
|
||||||
|
//case '0':
|
||||||
{
|
{
|
||||||
while(*args && !isspace(*args))
|
if (*fmt == '~')
|
||||||
{
|
{
|
||||||
used++;
|
fmt++;
|
||||||
if (used < len)
|
tildeEffect = true;
|
||||||
*res++ = *args++;
|
|
||||||
else
|
|
||||||
args++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while(isspace(*args))
|
if (args)
|
||||||
++args;
|
{
|
||||||
}
|
if (tildeEffect)
|
||||||
break;
|
{
|
||||||
|
ParseTildeEffect(res, args, len, used, *fmt - '2');
|
||||||
|
tildeEffect = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
break;
|
ParseNoTildeEffect(res, args, len, used, *fmt - '2');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}; break;
|
||||||
|
|
||||||
case '1':
|
case '1':
|
||||||
if (!done || (*fmt == '1'))
|
if (!done || (*fmt == '1'))
|
||||||
{
|
{
|
||||||
|
@ -150,7 +288,8 @@ static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR*
|
||||||
*/
|
*/
|
||||||
case 'l':
|
case 'l':
|
||||||
case 'L':
|
case 'L':
|
||||||
if (lpFile) {
|
if (lpFile)
|
||||||
|
{
|
||||||
used += wcslen(lpFile);
|
used += wcslen(lpFile);
|
||||||
if (used < len)
|
if (used < len)
|
||||||
{
|
{
|
||||||
|
@ -163,7 +302,8 @@ static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR*
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'I':
|
case 'I':
|
||||||
if (pidl) {
|
if (pidl)
|
||||||
|
{
|
||||||
DWORD chars = 0;
|
DWORD chars = 0;
|
||||||
/* %p should not exceed 8, maybe 16 when looking forward to 64bit.
|
/* %p should not exceed 8, maybe 16 when looking forward to 64bit.
|
||||||
* allowing a buffer of 100 should more than exceed all needs */
|
* allowing a buffer of 100 should more than exceed all needs */
|
||||||
|
@ -172,9 +312,12 @@ static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR*
|
||||||
HGLOBAL hmem = SHAllocShared(pidl, ILGetSize(pidl), 0);
|
HGLOBAL hmem = SHAllocShared(pidl, ILGetSize(pidl), 0);
|
||||||
pv = SHLockShared(hmem, 0);
|
pv = SHLockShared(hmem, 0);
|
||||||
chars = swprintf(buf, wszILPtr, pv);
|
chars = swprintf(buf, wszILPtr, pv);
|
||||||
|
|
||||||
if (chars >= sizeof(buf)/sizeof(WCHAR))
|
if (chars >= sizeof(buf)/sizeof(WCHAR))
|
||||||
ERR("pidl format buffer too small!\n");
|
ERR("pidl format buffer too small!\n");
|
||||||
|
|
||||||
used += chars;
|
used += chars;
|
||||||
|
|
||||||
if (used < len)
|
if (used < len)
|
||||||
{
|
{
|
||||||
wcscpy(res,buf);
|
wcscpy(res,buf);
|
||||||
|
@ -248,6 +391,8 @@ static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR*
|
||||||
if (out_len)
|
if (out_len)
|
||||||
*out_len = used;
|
*out_len = used;
|
||||||
|
|
||||||
|
DbgPrint("[shell32, SHELL_ArgifyW] Done result = %ws\n", out);
|
||||||
|
|
||||||
return found_p1;
|
return found_p1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +403,8 @@ static HRESULT SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl, LPWSTR psz
|
||||||
|
|
||||||
HRESULT hr = SHGetDesktopFolder(&desktop);
|
HRESULT hr = SHGetDesktopFolder(&desktop);
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
hr = desktop->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &strret);
|
hr = desktop->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &strret);
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
|
@ -298,17 +444,23 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
|
||||||
|
|
||||||
/* ShellExecute specifies the command from psei->lpDirectory
|
/* ShellExecute specifies the command from psei->lpDirectory
|
||||||
* if present. Not from the current dir as CreateProcess does */
|
* if present. Not from the current dir as CreateProcess does */
|
||||||
if( lpDirectory )
|
if ( lpDirectory )
|
||||||
if( ( gcdret = GetCurrentDirectoryW( MAX_PATH, curdir)))
|
if ( ( gcdret = GetCurrentDirectoryW( MAX_PATH, curdir)))
|
||||||
if( !SetCurrentDirectoryW( lpDirectory))
|
if ( !SetCurrentDirectoryW( lpDirectory))
|
||||||
ERR("cannot set directory %s\n", debugstr_w(lpDirectory));
|
ERR("cannot set directory %s\n", debugstr_w(lpDirectory));
|
||||||
|
|
||||||
ZeroMemory(&startup,sizeof(STARTUPINFOW));
|
ZeroMemory(&startup,sizeof(STARTUPINFOW));
|
||||||
startup.cb = sizeof(STARTUPINFOW);
|
startup.cb = sizeof(STARTUPINFOW);
|
||||||
startup.dwFlags = STARTF_USESHOWWINDOW;
|
startup.dwFlags = STARTF_USESHOWWINDOW;
|
||||||
startup.wShowWindow = psei->nShow;
|
startup.wShowWindow = psei->nShow;
|
||||||
dwCreationFlags = CREATE_UNICODE_ENVIRONMENT;
|
dwCreationFlags = CREATE_UNICODE_ENVIRONMENT;
|
||||||
|
|
||||||
if (psei->fMask & SEE_MASK_NO_CONSOLE)
|
if (psei->fMask & SEE_MASK_NO_CONSOLE)
|
||||||
dwCreationFlags |= CREATE_NEW_CONSOLE;
|
dwCreationFlags |= CREATE_NEW_CONSOLE;
|
||||||
|
|
||||||
|
//DbgPrint("[shell32, SHELL_ExecuteW] CreateProcessW cmd = %ws\n", (LPWSTR)lpCmd);
|
||||||
|
//DbgBreakPoint();
|
||||||
|
|
||||||
if (CreateProcessW(NULL, (LPWSTR)lpCmd, NULL, NULL, FALSE, dwCreationFlags, env,
|
if (CreateProcessW(NULL, (LPWSTR)lpCmd, NULL, NULL, FALSE, dwCreationFlags, env,
|
||||||
lpDirectory, &startup, &info))
|
lpDirectory, &startup, &info))
|
||||||
{
|
{
|
||||||
|
@ -318,6 +470,7 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
|
||||||
if (WaitForInputIdle( info.hProcess, 30000 ) == WAIT_FAILED)
|
if (WaitForInputIdle( info.hProcess, 30000 ) == WAIT_FAILED)
|
||||||
WARN("WaitForInputIdle failed: Error %d\n", GetLastError() );
|
WARN("WaitForInputIdle failed: Error %d\n", GetLastError() );
|
||||||
retval = 33;
|
retval = 33;
|
||||||
|
|
||||||
if (psei->fMask & SEE_MASK_NOCLOSEPROCESS)
|
if (psei->fMask & SEE_MASK_NOCLOSEPROCESS)
|
||||||
psei_out->hProcess = info.hProcess;
|
psei_out->hProcess = info.hProcess;
|
||||||
else
|
else
|
||||||
|
@ -333,6 +486,7 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
|
||||||
TRACE("returning %lu\n", retval);
|
TRACE("returning %lu\n", retval);
|
||||||
|
|
||||||
psei_out->hInstApp = (HINSTANCE)retval;
|
psei_out->hInstApp = (HINSTANCE)retval;
|
||||||
|
|
||||||
if( gcdret )
|
if( gcdret )
|
||||||
if( !SetCurrentDirectoryW( curdir))
|
if( !SetCurrentDirectoryW( curdir))
|
||||||
ERR("cannot return to directory %s\n", debugstr_w(curdir));
|
ERR("cannot return to directory %s\n", debugstr_w(curdir));
|
||||||
|
@ -628,6 +782,7 @@ static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOpera
|
||||||
filetypelen /= sizeof(WCHAR);
|
filetypelen /= sizeof(WCHAR);
|
||||||
if (filetypelen == sizeof(filetype)/sizeof(WCHAR))
|
if (filetypelen == sizeof(filetype)/sizeof(WCHAR))
|
||||||
filetypelen--;
|
filetypelen--;
|
||||||
|
|
||||||
filetype[filetypelen] = '\0';
|
filetype[filetypelen] = '\0';
|
||||||
TRACE("File type: %s\n", debugstr_w(filetype));
|
TRACE("File type: %s\n", debugstr_w(filetype));
|
||||||
}
|
}
|
||||||
|
@ -650,7 +805,7 @@ static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOpera
|
||||||
SHELL_ArgifyW(lpResult, resultLen, command, xlpFile, pidl, args, &finishedLen);
|
SHELL_ArgifyW(lpResult, resultLen, command, xlpFile, pidl, args, &finishedLen);
|
||||||
if (finishedLen > resultLen)
|
if (finishedLen > resultLen)
|
||||||
ERR("Argify buffer not large enough.. truncated\n");
|
ERR("Argify buffer not large enough.. truncated\n");
|
||||||
|
DbgPrint("[shell32, SHELL_FindExecutable] Remove double quotation marks and command line arguments\n");
|
||||||
/* Remove double quotation marks and command line arguments */
|
/* Remove double quotation marks and command line arguments */
|
||||||
if (*lpResult == '"')
|
if (*lpResult == '"')
|
||||||
{
|
{
|
||||||
|
@ -1370,11 +1525,14 @@ static UINT_PTR SHELL_quote_and_execute( LPCWSTR wcmd, LPCWSTR wszParameters, LP
|
||||||
strcpyW(wszQuotedCmd, wQuote);
|
strcpyW(wszQuotedCmd, wQuote);
|
||||||
strcatW(wszQuotedCmd, wcmd);
|
strcatW(wszQuotedCmd, wcmd);
|
||||||
strcatW(wszQuotedCmd, wQuote);
|
strcatW(wszQuotedCmd, wQuote);
|
||||||
if (wszParameters[0]) {
|
if (wszParameters[0])
|
||||||
|
{
|
||||||
strcatW(wszQuotedCmd, wSpace);
|
strcatW(wszQuotedCmd, wSpace);
|
||||||
strcatW(wszQuotedCmd, wszParameters);
|
strcatW(wszQuotedCmd, wszParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("%s/%s => %s/%s\n", debugstr_w(wszApplicationName), debugstr_w(psei->lpVerb), debugstr_w(wszQuotedCmd), debugstr_w(lpstrProtocol));
|
TRACE("%s/%s => %s/%s\n", debugstr_w(wszApplicationName), debugstr_w(psei->lpVerb), debugstr_w(wszQuotedCmd), debugstr_w(lpstrProtocol));
|
||||||
|
|
||||||
if (*lpstrProtocol)
|
if (*lpstrProtocol)
|
||||||
retval = execute_from_key(lpstrProtocol, wszApplicationName, env, psei->lpParameters, wcmd, execfunc, psei, psei_out);
|
retval = execute_from_key(lpstrProtocol, wszApplicationName, env, psei->lpParameters, wcmd, execfunc, psei, psei_out);
|
||||||
else
|
else
|
||||||
|
@ -1498,14 +1656,20 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
|
||||||
else if (*sei_tmp.lpFile == '\"')
|
else if (*sei_tmp.lpFile == '\"')
|
||||||
{
|
{
|
||||||
DWORD l = strlenW(sei_tmp.lpFile+1);
|
DWORD l = strlenW(sei_tmp.lpFile+1);
|
||||||
if(l >= dwApplicationNameLen) dwApplicationNameLen = l+1;
|
if(l >= dwApplicationNameLen)
|
||||||
|
dwApplicationNameLen = l+1;
|
||||||
|
|
||||||
wszApplicationName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen*sizeof(WCHAR));
|
wszApplicationName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen*sizeof(WCHAR));
|
||||||
memcpy(wszApplicationName, sei_tmp.lpFile+1, (l+1)*sizeof(WCHAR));
|
memcpy(wszApplicationName, sei_tmp.lpFile+1, (l+1)*sizeof(WCHAR));
|
||||||
|
|
||||||
if (wszApplicationName[l-1] == '\"')
|
if (wszApplicationName[l-1] == '\"')
|
||||||
wszApplicationName[l-1] = '\0';
|
wszApplicationName[l-1] = '\0';
|
||||||
appKnownSingular = TRUE;
|
appKnownSingular = TRUE;
|
||||||
|
|
||||||
TRACE("wszApplicationName=%s\n",debugstr_w(wszApplicationName));
|
TRACE("wszApplicationName=%s\n",debugstr_w(wszApplicationName));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
DWORD l = strlenW(sei_tmp.lpFile)+1;
|
DWORD l = strlenW(sei_tmp.lpFile)+1;
|
||||||
if(l > dwApplicationNameLen) dwApplicationNameLen = l+1;
|
if(l > dwApplicationNameLen) dwApplicationNameLen = l+1;
|
||||||
wszApplicationName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen*sizeof(WCHAR));
|
wszApplicationName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen*sizeof(WCHAR));
|
||||||
|
@ -1563,7 +1727,8 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
|
||||||
|
|
||||||
pSEH->Release();
|
pSEH->Release();
|
||||||
|
|
||||||
if (hr == S_OK) {
|
if (hr == S_OK)
|
||||||
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, wszApplicationName);
|
HeapFree(GetProcessHeap(), 0, wszApplicationName);
|
||||||
if (wszParameters != parametersBuffer)
|
if (wszParameters != parametersBuffer)
|
||||||
HeapFree(GetProcessHeap(), 0, wszParameters);
|
HeapFree(GetProcessHeap(), 0, wszParameters);
|
||||||
|
@ -1677,9 +1842,11 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
|
||||||
TRACE("execute:%s,%s,%s\n", debugstr_w(wszApplicationName), debugstr_w(wszParameters), debugstr_w(wszDir));
|
TRACE("execute:%s,%s,%s\n", debugstr_w(wszApplicationName), debugstr_w(wszParameters), debugstr_w(wszDir));
|
||||||
|
|
||||||
/* separate out command line arguments from executable file name */
|
/* separate out command line arguments from executable file name */
|
||||||
if (!*sei_tmp.lpParameters && !appKnownSingular) {
|
if (!*sei_tmp.lpParameters && !appKnownSingular)
|
||||||
|
{
|
||||||
/* If the executable path is quoted, handle the rest of the command line as parameters. */
|
/* If the executable path is quoted, handle the rest of the command line as parameters. */
|
||||||
if (sei_tmp.lpFile[0] == '"') {
|
if (sei_tmp.lpFile[0] == '"')
|
||||||
|
{
|
||||||
LPWSTR src = wszApplicationName/*sei_tmp.lpFile*/ + 1;
|
LPWSTR src = wszApplicationName/*sei_tmp.lpFile*/ + 1;
|
||||||
LPWSTR dst = wfileName;
|
LPWSTR dst = wfileName;
|
||||||
LPWSTR end;
|
LPWSTR end;
|
||||||
|
@ -1690,12 +1857,14 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
|
||||||
|
|
||||||
*dst = '\0';
|
*dst = '\0';
|
||||||
|
|
||||||
if (*src == '"') {
|
if (*src == '"')
|
||||||
|
{
|
||||||
end = ++src;
|
end = ++src;
|
||||||
|
|
||||||
while(isspace(*src))
|
while(isspace(*src))
|
||||||
++src;
|
++src;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
end = src;
|
end = src;
|
||||||
|
|
||||||
/* copy the parameter string to 'wszParameters' */
|
/* copy the parameter string to 'wszParameters' */
|
||||||
|
@ -1712,7 +1881,8 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
|
||||||
LPWSTR space, s;
|
LPWSTR space, s;
|
||||||
|
|
||||||
LPWSTR beg = wszApplicationName/*sei_tmp.lpFile*/;
|
LPWSTR beg = wszApplicationName/*sei_tmp.lpFile*/;
|
||||||
for(s=beg; (space= const_cast<LPWSTR>(strchrW(s, ' '))); s=space+1) {
|
for(s=beg; (space= const_cast<LPWSTR>(strchrW(s, ' '))); s=space+1)
|
||||||
|
{
|
||||||
int idx = space-sei_tmp.lpFile;
|
int idx = space-sei_tmp.lpFile;
|
||||||
memcpy(buffer, sei_tmp.lpFile, idx * sizeof(WCHAR));
|
memcpy(buffer, sei_tmp.lpFile, idx * sizeof(WCHAR));
|
||||||
buffer[idx] = '\0';
|
buffer[idx] = '\0';
|
||||||
|
@ -1735,7 +1905,8 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
|
||||||
|
|
||||||
lstrcpynW(wfileName, sei_tmp.lpFile,sizeof(wfileName)/sizeof(WCHAR));
|
lstrcpynW(wfileName, sei_tmp.lpFile,sizeof(wfileName)/sizeof(WCHAR));
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
lstrcpynW(wfileName, sei_tmp.lpFile,sizeof(wfileName)/sizeof(WCHAR));
|
lstrcpynW(wfileName, sei_tmp.lpFile,sizeof(wfileName)/sizeof(WCHAR));
|
||||||
|
|
||||||
lpFile = wfileName;
|
lpFile = wfileName;
|
||||||
|
@ -1750,13 +1921,15 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
|
||||||
wcmdLen = len;
|
wcmdLen = len;
|
||||||
}
|
}
|
||||||
strcpyW(wcmd, wszApplicationName);
|
strcpyW(wcmd, wszApplicationName);
|
||||||
if (sei_tmp.lpParameters[0]) {
|
if (sei_tmp.lpParameters[0])
|
||||||
|
{
|
||||||
strcatW(wcmd, wSpace);
|
strcatW(wcmd, wSpace);
|
||||||
strcatW(wcmd, wszParameters);
|
strcatW(wcmd, wszParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = execfunc(wcmd, NULL, FALSE, &sei_tmp, sei);
|
retval = execfunc(wcmd, NULL, FALSE, &sei_tmp, sei);
|
||||||
if (retval > 32) {
|
if (retval > 32)
|
||||||
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, wszApplicationName);
|
HeapFree(GetProcessHeap(), 0, wszApplicationName);
|
||||||
if (wszParameters != parametersBuffer)
|
if (wszParameters != parametersBuffer)
|
||||||
HeapFree(GetProcessHeap(), 0, wszParameters);
|
HeapFree(GetProcessHeap(), 0, wszParameters);
|
||||||
|
|
Loading…
Reference in a new issue