[Bug 49530] New: GetCommandLineA() behaves differently than it does on Windows
WineHQ Bugzilla
wine-bugs at winehq.org
Tue Jul 7 01:20:37 CDT 2020
https://bugs.winehq.org/show_bug.cgi?id=49530
Bug ID: 49530
Summary: GetCommandLineA() behaves differently than it does on
Windows
Product: Wine
Version: 5.12
Hardware: x86-64
OS: Linux
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: kernel32
Assignee: wine-bugs at winehq.org
Reporter: oguilherme at protonmail.com
Distribution: ---
Created attachment 67663
--> https://bugs.winehq.org/attachment.cgi?id=67663
Garbled string displayed in the input field
Hi people!
Let me being by saying that both the title and the affected Wine component I've
chosen, are just "educated guesses" of mine, so feel free to change them, if
necessary.
And although this seems to be a regression introduced on Wine 5.9, I'm not sure
if Wine is 100% at fault here.
But anyway, let's reproduce this bug:
1. Download this program called "Detect It Easy":
https://github.com/horsicq/DIE-engine/releases/download/2.05/die_win32_portable_2.05.zip
(sha1: fbaf9b98421a39f092eba1be83b5bb24e33682da)
2. Extract it.
3. There are two executables to choose from, but for this example, let's run
"DIEL.EXE", which is the Lite version.
The program should open just fine, but only on Wine 5.9+ you will get random
characters to appear in the first input field. Luckily, the source code is
available here:
diel.exe:
https://github.com/horsicq/DIE-engine/blob/c55449c85bed0d456cbdd409d1abaa7b21f68d7e/die_source/winloader_source/winloader_diel.cpp
As we can see, it merely acts as a launcher for the actual program, which sits
in the "base\" directory.
Anyway, I'm not a C/C++ programmer myself, but some of the logic in that
entry() function seems really questionable to me.
Regardless, if it works on Windows and it used to work on Wine 5.8, that surely
means it's a Wine regression, right? Well, maybe... The thing is, I am also
able to reproduce this on Windows, but only in a different way. I have to run
the "DIEL.EXE" binary using either the Command Prompt:
\> cd die_win32_portable_2.05\
\> diel.exe
Or PowerShell:
$ cd die_win32_portable_2.05\
$ .\diel.exe
Once I do that, I get the same garbled string I get on Wine -- which I'm
guessing is just uninitialized memory from the "szArgument" variable.
I can not, however, reproduce this on Windows anymore if I run "DIEL.EXE" by
double-click it.
And I learned that this happens because Windows will always add a trailing
whitespace to the return value of GetCommandLineA(). But it won't do the same
if the executable is running via the command line, apparently! And I'm not too
familiar with Windows APIs at all, so I don't know the reason for that.
And since "DIEL.EXE" relies on GetCommandLineA() to extract any program
arguments and forward them to the "real" executable inside the "base\"
directory, that weird (and wrong?) condition on line 70, actually prevents the
garbled string from ever showing up, because diel.exe considers that extra
whitespace as an argument, and initializes the "szArgument" variable with that
value.
So... I ran a git bisect (twice, just to be sure) between versions 5.8 and 5.9,
and the culprit appears to be commit 7cc9ccbd22511d71d23ee298cd9718da1e448dbc.
I wasn't able to revert said commit against the master branch, and I have no
idea on how to do it manually either. At least not without breaking everything
else. :)
So, yeah. Let me know if I can help with anything else.
Regards,
Guilherme
--
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.
More information about the wine-bugs
mailing list