Fun with argv

Paul Millar paulm at
Sat Feb 16 11:32:40 CST 2002

Hi everyone,

I've been looking at the installer for Office97. You call setup.exe 
which runs acmsetup.exe with a bunch of options, specifically:
'E:\~MSSETUP.T\~msstfof.t\acmsetup /T Off97Pro.stf /S "D:\office\" '

Here, I've used single quotes to delimit the string. I'll carry on this
convention because it will get confusing otherwise.

The problem is build_argv() assumes the command line is suitably escaped
(as from a bash command line, for example), and so mangles the above line
to the following values:
 'D:\office" '

But, the fun continues as you can pass arguments to setup.exe, which 
augment the arguments passed to acmsetup.exe, so running:

  wine setup.exe 'a a' '"b "B'

results in argv[] for setup.exe being:
  'a a'
  '"b "B'

setup.exe then calls GetCommandLineA, which returns:
  'setup.exe "a a" "\"b \"B"'

and then it tries to exec
  'E:\~MSSETUP.T\~msstfof.t\acmsetup /T Off97Pro.stf /S "D:\office\" "a a" 
"\"b \"B"'
A command line with both unix-style escaped quotes and normal text. The 
build_argv result is:
  'D:\office" a'
  'a "b'

and subsequent call to GetCommandLineA returns:
  'E:\~MSSETUP.T\~msstfof.t\acmsetup /T Off97Pro.stf /S "D:\office\" a" "a 
\"b" \"B'

What a mess!

More information about the wine-devel mailing list