Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
504d6eaa
Commit
504d6eaa
authored
Jul 30, 2020
by
Jacek Caban
Committed by
Alexandre Julliard
Jul 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wineconsole: Move WINECON_Spawn call to WINECON_Init.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
78831ae9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
60 deletions
+53
-60
wineconsole.c
programs/wineconsole/wineconsole.c
+53
-60
No files found.
programs/wineconsole/wineconsole.c
View file @
504d6eaa
...
@@ -580,6 +580,53 @@ static BOOL WINECON_GetServerConfig(struct inner_data* data)
...
@@ -580,6 +580,53 @@ static BOOL WINECON_GetServerConfig(struct inner_data* data)
}
}
/******************************************************************
/******************************************************************
* WINECON_Spawn
*
* Spawn the child process when invoked with wineconsole foo bar
*/
static
BOOL
WINECON_Spawn
(
struct
inner_data
*
data
,
LPWSTR
cmdLine
)
{
PROCESS_INFORMATION
info
;
STARTUPINFOW
startup
;
BOOL
done
;
/* we're in the case wineconsole <exe> <options>... spawn the new process */
memset
(
&
startup
,
0
,
sizeof
(
startup
));
startup
.
cb
=
sizeof
(
startup
);
startup
.
dwFlags
=
STARTF_USESTDHANDLES
;
/* the attributes of wineconsole's handles are not adequate for inheritance, so
* get them with the correct attributes before process creation
*/
if
(
!
DuplicateHandle
(
GetCurrentProcess
(),
data
->
hConIn
,
GetCurrentProcess
(),
&
startup
.
hStdInput
,
GENERIC_READ
|
GENERIC_WRITE
|
SYNCHRONIZE
,
TRUE
,
0
)
||
!
DuplicateHandle
(
GetCurrentProcess
(),
data
->
hConOut
,
GetCurrentProcess
(),
&
startup
.
hStdOutput
,
GENERIC_READ
|
GENERIC_WRITE
,
TRUE
,
0
)
||
!
DuplicateHandle
(
GetCurrentProcess
(),
data
->
hConOut
,
GetCurrentProcess
(),
&
startup
.
hStdError
,
GENERIC_READ
|
GENERIC_WRITE
,
TRUE
,
0
))
{
WINE_ERR
(
"Can't dup handles
\n
"
);
/* no need to delete handles, we're exiting the program anyway */
return
FALSE
;
}
done
=
CreateProcessW
(
NULL
,
cmdLine
,
NULL
,
NULL
,
TRUE
,
0L
,
NULL
,
NULL
,
&
startup
,
&
info
);
if
(
done
)
{
data
->
hProcess
=
info
.
hProcess
;
CloseHandle
(
info
.
hThread
);
}
else
printf_res
(
IDS_CMD_LAUNCH_FAILED
,
wine_dbgstr_w
(
cmdLine
));
/* we no longer need the handles passed to the child for the console */
CloseHandle
(
startup
.
hStdInput
);
CloseHandle
(
startup
.
hStdOutput
);
CloseHandle
(
startup
.
hStdError
);
return
done
;
}
/******************************************************************
* WINECON_Init
* WINECON_Init
*
*
* Initialisation part I. Creation of server object (console input and
* Initialisation part I. Creation of server object (console input and
...
@@ -587,7 +634,7 @@ static BOOL WINECON_GetServerConfig(struct inner_data* data)
...
@@ -587,7 +634,7 @@ static BOOL WINECON_GetServerConfig(struct inner_data* data)
*/
*/
static
struct
inner_data
*
WINECON_Init
(
HINSTANCE
hInst
,
DWORD
pid
,
LPCWSTR
appname
,
static
struct
inner_data
*
WINECON_Init
(
HINSTANCE
hInst
,
DWORD
pid
,
LPCWSTR
appname
,
enum
init_return
(
*
backend
)(
struct
inner_data
*
),
enum
init_return
(
*
backend
)(
struct
inner_data
*
),
INT
nCmdShow
)
INT
nCmdShow
,
WCHAR
*
cmdline
)
{
{
struct
condrv_input_info_params
input_params
;
struct
condrv_input_info_params
input_params
;
OBJECT_ATTRIBUTES
attr
=
{
sizeof
(
attr
)};
OBJECT_ATTRIBUTES
attr
=
{
sizeof
(
attr
)};
...
@@ -708,7 +755,9 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna
...
@@ -708,7 +755,9 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna
lstrlenW
(
appname
)
*
sizeof
(
WCHAR
),
NULL
,
0
,
NULL
,
NULL
);
lstrlenW
(
appname
)
*
sizeof
(
WCHAR
),
NULL
,
0
,
NULL
,
NULL
);
if
(
!
ret
)
goto
error
;
if
(
!
ret
)
goto
error
;
if
(
cmdline
&&
!
WINECON_Spawn
(
data
,
cmdline
))
goto
error
;
return
data
;
return
data
;
case
init_failed
:
case
init_failed
:
break
;
break
;
}
}
...
@@ -720,52 +769,6 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna
...
@@ -720,52 +769,6 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna
return
NULL
;
return
NULL
;
}
}
/******************************************************************
* WINECON_Spawn
*
* Spawn the child process when invoked with wineconsole foo bar
*/
static
int
WINECON_Spawn
(
struct
inner_data
*
data
,
LPWSTR
cmdLine
)
{
PROCESS_INFORMATION
info
;
STARTUPINFOW
startup
;
BOOL
done
;
/* we're in the case wineconsole <exe> <options>... spawn the new process */
memset
(
&
startup
,
0
,
sizeof
(
startup
));
startup
.
cb
=
sizeof
(
startup
);
startup
.
dwFlags
=
STARTF_USESTDHANDLES
;
/* the attributes of wineconsole's handles are not adequate for inheritance, so
* get them with the correct attributes before process creation
*/
if
(
!
DuplicateHandle
(
GetCurrentProcess
(),
data
->
hConIn
,
GetCurrentProcess
(),
&
startup
.
hStdInput
,
GENERIC_READ
|
GENERIC_WRITE
|
SYNCHRONIZE
,
TRUE
,
0
)
||
!
DuplicateHandle
(
GetCurrentProcess
(),
data
->
hConOut
,
GetCurrentProcess
(),
&
startup
.
hStdOutput
,
GENERIC_READ
|
GENERIC_WRITE
,
TRUE
,
0
)
||
!
DuplicateHandle
(
GetCurrentProcess
(),
data
->
hConOut
,
GetCurrentProcess
(),
&
startup
.
hStdError
,
GENERIC_READ
|
GENERIC_WRITE
,
TRUE
,
0
))
{
WINE_ERR
(
"Can't dup handles
\n
"
);
/* no need to delete handles, we're exiting the program anyway */
return
1
;
}
done
=
CreateProcessW
(
NULL
,
cmdLine
,
NULL
,
NULL
,
TRUE
,
0L
,
NULL
,
NULL
,
&
startup
,
&
info
);
if
(
done
)
{
data
->
hProcess
=
info
.
hProcess
;
CloseHandle
(
info
.
hThread
);
}
/* we no longer need the handles passed to the child for the console */
CloseHandle
(
startup
.
hStdInput
);
CloseHandle
(
startup
.
hStdOutput
);
CloseHandle
(
startup
.
hStdError
);
return
!
done
;
}
struct
wc_init
{
struct
wc_init
{
LPCSTR
ptr
;
LPCSTR
ptr
;
enum
{
from_event
,
from_process_name
}
mode
;
enum
{
from_event
,
from_process_name
}
mode
;
...
@@ -859,7 +862,7 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh
...
@@ -859,7 +862,7 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh
{
{
case
from_event
:
case
from_event
:
/* case of wineconsole <evt>, signal process that created us that we're up and running */
/* case of wineconsole <evt>, signal process that created us that we're up and running */
if
(
!
(
data
=
WINECON_Init
(
hInst
,
0
,
NULL
,
wci
.
backend
,
nCmdShow
)))
return
1
;
if
(
!
(
data
=
WINECON_Init
(
hInst
,
0
,
NULL
,
wci
.
backend
,
nCmdShow
,
NULL
)))
return
1
;
ret
=
!
SetEvent
(
wci
.
event
);
ret
=
!
SetEvent
(
wci
.
event
);
if
(
ret
!=
0
)
WINE_ERR
(
"SetEvent failed.
\n
"
);
if
(
ret
!=
0
)
WINE_ERR
(
"SetEvent failed.
\n
"
);
break
;
break
;
...
@@ -876,19 +879,9 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh
...
@@ -876,19 +879,9 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh
MultiByteToWideChar
(
CP_ACP
,
0
,
wci
.
ptr
,
-
1
,
buffer
,
len
);
MultiByteToWideChar
(
CP_ACP
,
0
,
wci
.
ptr
,
-
1
,
buffer
,
len
);
if
(
!
(
data
=
WINECON_Init
(
hInst
,
GetCurrentProcessId
(),
buffer
,
wci
.
backend
,
nCmdShow
)))
data
=
WINECON_Init
(
hInst
,
GetCurrentProcessId
(),
buffer
,
wci
.
backend
,
nCmdShow
,
buffer
);
{
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
return
1
;
}
ret
=
WINECON_Spawn
(
data
,
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
if
(
ret
!=
0
)
if
(
!
data
)
return
1
;
{
WINECON_Delete
(
data
);
printf_res
(
IDS_CMD_LAUNCH_FAILED
,
wine_dbgstr_a
(
wci
.
ptr
));
return
ret
;
}
}
}
break
;
break
;
default:
default:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment