[Bug 40482] Support set title in start, needed by latest MSYS2

wine-bugs at winehq.org wine-bugs at winehq.org
Sat Jul 13 08:03:37 CDT 2019


https://bugs.winehq.org/show_bug.cgi?id=40482

Damjan Jovanovic <damjan.jov at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |damjan.jov at gmail.com
           Keywords|                            |source

--- Comment #6 from Damjan Jovanovic <damjan.jov at gmail.com> ---
Some notes from going through the code, of what I think happens:

---PARENT PROCESS---
1. The "start" command must be called in the form:
wine start "\"title\"" cmd

(The cmd tool has its own long complicated way of starting child processes with
custom titles, in function WCMD_start() in file programs/cmd/builtins.c, but I
don't think we're there yet, we're only in "start" for now.)

"start" populates the title into STARTUPINFOW.lpTitle and passes this to...

1.1 CreateProcessW() just calls CreateProcessInternalW().

1.1.1 CreateProcessInternalW() passes the STARTUPINFOW to
create_process_params()

1.1.1.1 create_process_params() passes it to
1.1.1.1.1 RtlCreateProcessParametersEx() which saves it in
RTL_USER_PROCESS_PARAMETERS.
1.1.1.2 create_process_params() returns the RTL_USER_PROCESS_PARAMETERS.

1.1.2 CreateProcessInternalW() will then encounter type BINARY_PE and call
create_process() passing it the RTL_USER_PROCESS_PARAMETERS.

1.1.2.1 create_process() will call create_startup_info().
1.1.2.1.1 create_startup_info() converts RTL_USER_PROCESS_PARAMETERS into a
startup_info_t.
1.1.2.2 create_process() calls wineserver's "new_process" function, passing it
the startup_info_t.
1.1.2.2.1 wineserver stores a copy of it.
...
---PARENT PROCESS---

(OTHER THINGS HAPPEN)

---CHILD PROCESS---
1. Somehow, ntdll/loader.c __wine_process_init() gets called.
1.1 __wine_process_init calls thread_init().
1.1.1 thread_init() calls init_user_process_params().
1.1.1.1 init_user_process_params() calls wineserver's "get_startup_info"
function, retrieving the startup_info_t set by the parent.
1.1.1.2 init_user_process_params() converts it to RTL_USER_PROCESS_PARAMETERS
and saves it into NtCurrentTeb()->Peb->ProcessParameters.

2. Somehow, process_attach() in kernel32.dll gets called.
2.1 It calls ENV_CopyStartupInformation(), which converts
NtCurrentTeb()->Peb->ProcessParameters into a static global variable
startup_infoW of type STARTUPINFOW.

3. The child process can call GetStartupInfoW() in KERNEL32.DLL, to retrieve a
copy of startup_infoW.
---CHILD PROCESS---


That suggests patching cmd to call GetStartupInfoW() and then just call:
SetConsoleTitleW(startupInfoW.lpTitle);
should fix this bug.

Unfortunately that doesn't work, as the lpTitle returned from GetStartupInfoW()
is NULL.

Where does it get lost?

-- 
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