ShellExecute swallowing empty parameter
-
Hi guys! I got a really strange behaviour on one customer machine I really cannot figure out - perhaps someone can help... A C++ plugin DLL of mine loaded into a third party application is calling one of my .NET applications using
ShellExecute
. Several arguments are passed along in this call, the last one being an empty string. Basically the call looks like this:ShellExecute(AfxGetMainWnd()->GetSafeHwnd(), NULL, "C:\\Program Files\\MyApp\\MyApp.exe", "/arg1 /arg2 /arg3 \"argument3\" /arg4 \"\"", "C:\\Program Files\\MyApp", SW_SHOW);
/arg1 and /arg2 are simple flags for my .NET app, whereas /arg3 and /arg4 require an additional parameter. The parameter for /arg4 is supposed to be an empty string for this call. The exact same version of this DLL works fine on many other machines, but on this particular one my .NET application won't start because it claims that the parameter for /arg4 is missing! I'm logging the arguments my application is called with and can see that the last parameter is missing, although the empty string is hard-coded inside the DLL and it works on every other machine I've come across so far. What can be the reason for
ShellExecute
silently swallowing the last parameter? Thanks in advance for every idea about how to proceed here...Regards, mav -- Black holes are the places where God divided by 0...
-
Hi guys! I got a really strange behaviour on one customer machine I really cannot figure out - perhaps someone can help... A C++ plugin DLL of mine loaded into a third party application is calling one of my .NET applications using
ShellExecute
. Several arguments are passed along in this call, the last one being an empty string. Basically the call looks like this:ShellExecute(AfxGetMainWnd()->GetSafeHwnd(), NULL, "C:\\Program Files\\MyApp\\MyApp.exe", "/arg1 /arg2 /arg3 \"argument3\" /arg4 \"\"", "C:\\Program Files\\MyApp", SW_SHOW);
/arg1 and /arg2 are simple flags for my .NET app, whereas /arg3 and /arg4 require an additional parameter. The parameter for /arg4 is supposed to be an empty string for this call. The exact same version of this DLL works fine on many other machines, but on this particular one my .NET application won't start because it claims that the parameter for /arg4 is missing! I'm logging the arguments my application is called with and can see that the last parameter is missing, although the empty string is hard-coded inside the DLL and it works on every other machine I've come across so far. What can be the reason for
ShellExecute
silently swallowing the last parameter? Thanks in advance for every idea about how to proceed here...Regards, mav -- Black holes are the places where God divided by 0...
mav.northwind wrote:
What can be the reason for ShellExecute silently swallowing the last parameter?
If it's empty, what's to swallow?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
mav.northwind wrote:
What can be the reason for ShellExecute silently swallowing the last parameter?
If it's empty, what's to swallow?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
That's the minute, but essential difference between passing no argument or an empty string as argument...
Regards, mav -- Black holes are the places where God divided by 0...
-
That's the minute, but essential difference between passing no argument or an empty string as argument...
Regards, mav -- Black holes are the places where God divided by 0...
But can the OS/shell differentiate between the two? For example, how would you execute that program from a command prompt?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
But can the OS/shell differentiate between the two? For example, how would you execute that program from a command prompt?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
app.exe /one /two
vs.
app.exe /one /two ""
You can easily try it out. In the first case, argc is 2, in the second one it's 3. It's very similar to what you have to do when one of the parameters contains white spaces, i.e. enclose the parameter in double quotes so that the shell can tell where one parameter ends and the next one begins.
Regards, mav -- Black holes are the places where God divided by 0...
-
app.exe /one /two
vs.
app.exe /one /two ""
You can easily try it out. In the first case, argc is 2, in the second one it's 3. It's very similar to what you have to do when one of the parameters contains white spaces, i.e. enclose the parameter in double quotes so that the shell can tell where one parameter ends and the next one begins.
Regards, mav -- Black holes are the places where God divided by 0...
So have you tried this with
CreateProcess()
instead?"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
So have you tried this with
CreateProcess()
instead?"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
No, I haven't tried anything that involves changing the DLL yet. It's rather complicated - I cannot just modify the DLL and redeploy. But perhaps we found something: The administrator at the customer's site found some malware during an AV scan and will now reset the machine to their standard image. So chances are some badly written malware was not passing along all the parameters in this case. I've just got to keep my fingers crossed that it'll work again afterwards.
Regards, mav -- Black holes are the places where God divided by 0...