[Bug 12371] Neural Noise Synthesizer (Thinstall virtualization wrapped app) fails to launch (GetEnvironmentVariableA/W needs to respect size limits for temp buffer allocation)
wine-bugs at winehq.org
wine-bugs at winehq.org
Thu May 29 06:11:05 CDT 2014
https://bugs.winehq.org/show_bug.cgi?id=12371
Anastasius Focht <focht at gmx.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |obfuscation
CC| |focht at gmx.net
Component|ntdll |kernel32
Summary|Neural Noise Synthesizer |Neural Noise Synthesizer
|fails to launch |(Thinstall virtualization
| |wrapped app) fails to
| |launch
| |(GetEnvironmentVariableA/W
| |needs to respect size
| |limits for temp buffer
| |allocation)
--- Comment #8 from Anastasius Focht <focht at gmx.net> ---
Hello folks,
confirming. The current problem is likely different to the one reported by OP
some years ago because Wine evolved.
Anyway, the app is wrapped with 'VMware ThinApp Thinstall' application
virtualization scheme.
It packages/unwraps its own .NET Framework 1.x in memory hence no .NET install
prior required.
There were lots of potential error cases hence it took some time to nail the
right one down :)
--- snip ---
$ pwd
/home/focht/.wine/drive_c/Program Files/Neural Noise Synthesizer
$ WINEDEBUG=+tid,+seh,+reay wine ./NeuralNoiseSynthesizer.exe >>log.txt 2>&1
...
0023:Call KERNEL32.SetEnvironmentVariableA(006cb8ac "HXi4_V2",006cb8c4 "60")
ret=7ff9399e
0023:Ret KERNEL32.SetEnvironmentVariableA() retval=00000001 ret=7ff9399e
...
0023:Call KERNEL32.WideCharToMultiByte(00000000,00000000,03268c60
L"HXi4_V2",00000008,0033ef28,00000009,00000000,0033edf8) ret=791d671b
0023:Ret KERNEL32.WideCharToMultiByte() retval=00000008 ret=791d671b
0023:Call KERNEL32.GetEnvironmentVariableA(0033ef28
"HXi4_V2",00180d28,fffffffe) ret=7ff24889
0023:Ret KERNEL32.GetEnvironmentVariableA() retval=00000000 ret=7ff24889
...
-- snip ---
At one point, the virtualization layer passes an invalid buffer size to
'GetEnvironmentVariableA' (not a mistake!).
Wine doesn't handle this properly.
http://msdn.microsoft.com/en-us/library/ms683188.aspx
--- quote ---
DWORD WINAPI GetEnvironmentVariable(
_In_opt_ LPCTSTR lpName,
_Out_opt_ LPTSTR lpBuffer,
_In_ DWORD nSize
);
Parameters
lpName [in, optional]
The name of the environment variable.
lpBuffer [out, optional]
A pointer to a buffer that receives the contents of the specified
environment variable as a null-terminated string. An environment variable has a
maximum size limit of 32,767 characters, including the null-terminating
character.
nSize [in]
The size of the buffer pointed to by the lpBuffer parameter, including the
null-terminating character, in characters.
...
Return value
If the function succeeds, the return value is the number of characters stored
in the buffer pointed to by lpBuffer, not including the terminating null
character.
--- quote ---
I wrote a small fix limiting temp buffer size to maximum allowed range (not
blindly taking input 'nSize') and it allowed the application to start.
Source:
http://source.winehq.org/git/wine.git/blob/7ab78b4e03c5263ab4f3d258f419f66b5eb875d0:/dlls/kernel32/environ.c#l167
--- snip ---
167 DWORD WINAPI GetEnvironmentVariableA( LPCSTR name, LPSTR value, DWORD size
)
168 {
169 UNICODE_STRING us_name;
170 PWSTR valueW;
171 DWORD ret;
172
173 if (!name || !*name)
174 {
175 SetLastError(ERROR_ENVVAR_NOT_FOUND);
176 return 0;
177 }
178
179 if (!(valueW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR))))
180 return 0;
...
--- snip ---
$ sha1sum NeuralNoiseSynthesizer.exe
664b9533475f59c4f0bb140aa241e7fa349dc4e3 NeuralNoiseSynthesizer.exe
$ du -sh NeuralNoiseSynthesizer.exe
11M NeuralNoiseSynthesizer.exe
$ wine --version
wine-1.7.19-70-gd6a59f7
Regards
--
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