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
039aa423
Commit
039aa423
authored
Jun 11, 1999
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return console handles in alloc_console request.
Fixed read_console_input parameters to conform to the reply structure declaration.
parent
7990b7c0
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
97 additions
and
102 deletions
+97
-102
server.h
include/server.h
+8
-2
console.c
server/console.c
+48
-10
object.h
server/object.h
+2
-1
process.c
server/process.c
+0
-33
process.h
server/process.h
+0
-3
trace.c
server/trace.c
+15
-6
make_requests
tools/make_requests
+2
-2
console.c
win32/console.c
+22
-45
No files found.
include/server.h
View file @
039aa423
...
...
@@ -532,7 +532,13 @@ struct create_pipe_reply
/* Allocate a console for the current process */
struct
alloc_console_request
{
int
dummy
;
unsigned
int
access
;
/* wanted access rights */
int
inherit
;
/* inherit flag */
};
struct
alloc_console_reply
{
int
handle_in
;
/* handle to console input */
int
handle_out
;
/* handle to console output */
};
...
...
@@ -605,7 +611,7 @@ struct get_console_info_reply
int
cursor_size
;
/* size of cursor (percentage filled) */
int
cursor_visible
;
/* cursor visibility flag */
int
pid
;
/* pid of xterm (hack) */
/* char title[0]; */
/* console title */
char
title
[
0
];
/* console title */
};
...
...
server/console.c
View file @
039aa423
...
...
@@ -99,7 +99,7 @@ static const struct object_ops screen_buffer_ops =
};
int
create_console
(
int
fd
,
struct
object
*
obj
[
2
]
)
static
int
create_console
(
int
fd
,
struct
object
*
obj
[
2
]
)
{
struct
console_input
*
console_input
;
struct
screen_buffer
*
screen_buffer
;
...
...
@@ -156,6 +156,30 @@ int create_console( int fd, struct object *obj[2] )
return
1
;
}
/* allocate a console for this process */
int
alloc_console
(
struct
process
*
process
)
{
struct
object
*
obj
[
2
];
if
(
process
->
console_in
||
process
->
console_out
)
{
SET_ERROR
(
ERROR_ACCESS_DENIED
);
return
0
;
}
if
(
!
create_console
(
-
1
,
obj
))
return
0
;
process
->
console_in
=
obj
[
0
];
process
->
console_out
=
obj
[
1
];
return
1
;
}
/* free the console for this process */
int
free_console
(
struct
process
*
process
)
{
if
(
process
->
console_in
)
release_object
(
process
->
console_in
);
if
(
process
->
console_out
)
release_object
(
process
->
console_out
);
process
->
console_in
=
process
->
console_out
=
NULL
;
return
1
;
}
static
int
set_console_fd
(
int
handle
,
int
fd
,
int
pid
)
{
struct
console_input
*
input
;
...
...
@@ -324,12 +348,14 @@ static int write_console_input( int handle, int count, INPUT_RECORD *records )
static
int
read_console_input
(
int
handle
,
int
count
,
int
flush
)
{
struct
console_input
*
console
;
struct
read_console_input_reply
reply
;
if
(
!
(
console
=
(
struct
console_input
*
)
get_handle_obj
(
current
->
process
,
handle
,
GENERIC_READ
,
&
console_input_ops
)))
return
-
1
;
if
((
count
<
0
)
||
(
count
>
console
->
recnum
))
count
=
console
->
recnum
;
send_reply
(
current
,
-
1
,
1
,
console
->
records
,
count
*
sizeof
(
INPUT_RECORD
)
);
send_reply
(
current
,
-
1
,
2
,
&
reply
,
sizeof
(
reply
),
console
->
records
,
count
*
sizeof
(
INPUT_RECORD
)
);
if
(
flush
)
{
int
i
;
...
...
@@ -491,8 +517,23 @@ static void screen_buffer_destroy( struct object *obj )
/* allocate a console for the current process */
DECL_HANDLER
(
alloc_console
)
{
alloc_console
(
current
->
process
);
send_reply
(
current
,
-
1
,
0
);
struct
alloc_console_reply
reply
=
{
-
1
,
-
1
};
if
(
!
alloc_console
(
current
->
process
))
goto
done
;
if
((
reply
.
handle_in
=
alloc_handle
(
current
->
process
,
current
->
process
->
console_in
,
req
->
access
,
req
->
inherit
))
!=
-
1
)
{
if
((
reply
.
handle_out
=
alloc_handle
(
current
->
process
,
current
->
process
->
console_out
,
req
->
access
,
req
->
inherit
))
!=
-
1
)
goto
done
;
/* everything is fine */
close_handle
(
current
->
process
,
reply
.
handle_in
);
reply
.
handle_in
=
-
1
;
}
free_console
(
current
->
process
);
done
:
send_reply
(
current
,
-
1
,
1
,
&
reply
,
sizeof
(
reply
)
);
}
/* free the console of the current process */
...
...
@@ -505,13 +546,10 @@ DECL_HANDLER(free_console)
/* open a handle to the process console */
DECL_HANDLER
(
open_console
)
{
struct
object
*
obj
;
struct
open_console_reply
reply
=
{
-
1
};
if
((
obj
=
get_console
(
current
->
process
,
req
->
output
)))
{
reply
.
handle
=
alloc_handle
(
current
->
process
,
obj
,
req
->
access
,
req
->
inherit
);
release_object
(
obj
);
}
struct
object
*
obj
=
req
->
output
?
current
->
process
->
console_out
:
current
->
process
->
console_in
;
if
(
obj
)
reply
.
handle
=
alloc_handle
(
current
->
process
,
obj
,
req
->
access
,
req
->
inherit
);
send_reply
(
current
,
-
1
,
1
,
&
reply
,
sizeof
(
reply
)
);
}
...
...
server/object.h
View file @
039aa423
...
...
@@ -161,7 +161,8 @@ extern void file_set_error(void);
/* console functions */
extern
int
create_console
(
int
fd
,
struct
object
*
obj
[
2
]
);
extern
int
alloc_console
(
struct
process
*
process
);
extern
int
free_console
(
struct
process
*
process
);
/* debugger functions */
...
...
server/process.c
View file @
039aa423
...
...
@@ -308,39 +308,6 @@ static void set_process_info( struct process *process,
}
}
/* allocate a console for this process */
int
alloc_console
(
struct
process
*
process
)
{
struct
object
*
obj
[
2
];
if
(
process
->
console_in
||
process
->
console_out
)
{
SET_ERROR
(
ERROR_ACCESS_DENIED
);
return
0
;
}
if
(
!
create_console
(
-
1
,
obj
))
return
0
;
process
->
console_in
=
obj
[
0
];
process
->
console_out
=
obj
[
1
];
return
1
;
}
/* free the console for this process */
int
free_console
(
struct
process
*
process
)
{
if
(
process
->
console_in
)
release_object
(
process
->
console_in
);
if
(
process
->
console_out
)
release_object
(
process
->
console_out
);
process
->
console_in
=
process
->
console_out
=
NULL
;
return
1
;
}
/* get the process console */
struct
object
*
get_console
(
struct
process
*
process
,
int
output
)
{
struct
object
*
obj
;
if
(
!
(
obj
=
output
?
process
->
console_out
:
process
->
console_in
))
return
NULL
;
return
grab_object
(
obj
);
}
/* take a snapshot of currently running processes */
struct
process_snapshot
*
process_snap
(
int
*
count
)
{
...
...
server/process.h
View file @
039aa423
...
...
@@ -58,9 +58,6 @@ extern void remove_process_thread( struct process *process,
extern
void
suspend_process
(
struct
process
*
process
);
extern
void
resume_process
(
struct
process
*
process
);
extern
void
kill_process
(
struct
process
*
process
,
int
exit_code
);
extern
int
alloc_console
(
struct
process
*
process
);
extern
int
free_console
(
struct
process
*
process
);
extern
struct
object
*
get_console
(
struct
process
*
process
,
int
output
);
extern
struct
process_snapshot
*
process_snap
(
int
*
count
);
#endif
/* __WINE_SERVER_PROCESS_H */
server/trace.c
View file @
039aa423
...
...
@@ -521,7 +521,15 @@ static int dump_create_pipe_reply( struct create_pipe_reply *req, int len )
static
int
dump_alloc_console_request
(
struct
alloc_console_request
*
req
,
int
len
)
{
fprintf
(
stderr
,
" dummy=%d"
,
req
->
dummy
);
fprintf
(
stderr
,
" access=%08x,"
,
req
->
access
);
fprintf
(
stderr
,
" inherit=%d"
,
req
->
inherit
);
return
(
int
)
sizeof
(
*
req
);
}
static
int
dump_alloc_console_reply
(
struct
alloc_console_reply
*
req
,
int
len
)
{
fprintf
(
stderr
,
" handle_in=%d,"
,
req
->
handle_in
);
fprintf
(
stderr
,
" handle_out=%d"
,
req
->
handle_out
);
return
(
int
)
sizeof
(
*
req
);
}
...
...
@@ -591,8 +599,9 @@ static int dump_get_console_info_reply( struct get_console_info_reply *req, int
{
fprintf
(
stderr
,
" cursor_size=%d,"
,
req
->
cursor_size
);
fprintf
(
stderr
,
" cursor_visible=%d,"
,
req
->
cursor_visible
);
fprintf
(
stderr
,
" pid=%d"
,
req
->
pid
);
return
(
int
)
sizeof
(
*
req
);
fprintf
(
stderr
,
" pid=%d,"
,
req
->
pid
);
fprintf
(
stderr
,
" title="
);
return
dump_chars
(
req
+
1
,
len
-
(
int
)
sizeof
(
*
req
)
)
+
sizeof
(
*
req
);
}
static
int
dump_write_console_input_request
(
struct
write_console_input_request
*
req
,
int
len
)
...
...
@@ -870,7 +879,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
(
dump_func
)
0
,
(
dump_func
)
0
,
(
dump_func
)
dump_create_pipe_reply
,
(
dump_func
)
0
,
(
dump_func
)
dump_alloc_console_reply
,
(
dump_func
)
0
,
(
dump_func
)
dump_open_console_reply
,
(
dump_func
)
0
,
...
...
@@ -988,14 +997,14 @@ void trace_kill( int exit_code )
void
trace_reply
(
struct
thread
*
thread
,
int
type
,
int
pass_fd
,
struct
iovec
*
vec
,
int
veclen
)
{
static
char
buffer
[
MAX_MSG_LENGTH
];
static
unsigned
char
buffer
[
MAX_MSG_LENGTH
];
if
(
!
thread
)
return
;
fprintf
(
stderr
,
"%08x: %s() = %d"
,
(
unsigned
int
)
thread
,
req_names
[
thread
->
last_req
],
type
);
if
(
veclen
)
{
char
*
p
=
buffer
;
unsigned
char
*
p
=
buffer
;
int
len
;
for
(;
veclen
;
veclen
--
,
vec
++
)
{
...
...
tools/make_requests
View file @
039aa423
...
...
@@ -140,14 +140,14 @@ void trace_kill( int exit_code )
void trace_reply( struct thread *thread, int type, int pass_fd,
struct iovec *vec, int veclen )
{
static char buffer[MAX_MSG_LENGTH];
static
unsigned
char buffer[MAX_MSG_LENGTH];
if (!thread) return;
fprintf( stderr, "%08x: %s() = %d",
(unsigned int)thread, req_names[thread->last_req], type );
if (veclen)
{
char *p = buffer;
unsigned
char *p = buffer;
int len;
for (; veclen; veclen--, vec++)
{
...
...
win32/console.c
View file @
039aa423
...
...
@@ -546,61 +546,30 @@ static BOOL CONSOLE_make_complex(HANDLE handle)
*/
BOOL
WINAPI
AllocConsole
(
VOID
)
{
struct
open_console_request
req
;
struct
open_console_reply
reply
;
HANDLE
hIn
,
hOut
,
hErr
;
DWORD
ret
;
struct
alloc_console_request
req
;
struct
alloc_console_reply
reply
;
HANDLE
hStderr
;
TRACE
(
"()
\n
"
);
CLIENT_SendRequest
(
REQ_ALLOC_CONSOLE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
ret
=
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
if
(
ret
!=
ERROR_SUCCESS
)
{
/* Hmm, error returned by server when we already have an
* opened console. however, we might have inherited it(?)
* and our handles are wrong? puzzling -MM 990330
*/
if
(
ret
!=
ERROR_ACCESS_DENIED
)
{
ERR
(
" failed to allocate console: %ld
\n
"
,
ret
);
return
FALSE
;
}
}
req
.
output
=
0
;
req
.
access
=
GENERIC_READ
|
GENERIC_WRITE
|
SYNCHRONIZE
;
req
.
inherit
=
FALSE
;
CLIENT_SendRequest
(
REQ_OPEN_CONSOLE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
ret
=
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
if
(
ret
!=
ERROR_SUCCESS
)
{
/* FIXME: free console */
ERR
(
" open console error %ld
\n
"
,
ret
);
return
FALSE
;
}
hIn
=
reply
.
handle
;
req
.
output
=
1
;
CLIENT_SendRequest
(
REQ_OPEN_CONSOLE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_ALLOC_CONSOLE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
)
!=
ERROR_SUCCESS
)
{
CloseHandle
(
hIn
);
/* FIXME: free console */
return
FALSE
;
}
hOut
=
reply
.
handle
;
if
(
!
DuplicateHandle
(
GetCurrentProcess
(),
hOut
,
GetCurrentProcess
(),
&
hErr
,
if
(
!
DuplicateHandle
(
GetCurrentProcess
(),
reply
.
handle_out
,
GetCurrentProcess
(),
&
hStderr
,
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
))
{
CloseHandle
(
hIn
);
CloseHandle
(
hOut
);
CloseHandle
(
reply
.
handle_in
);
CloseHandle
(
reply
.
handle_out
);
FreeConsole
();
return
FALSE
;
}
/* NT resets the STD_*_HANDLEs on console alloc */
SetStdHandle
(
STD_INPUT_HANDLE
,
hIn
);
SetStdHandle
(
STD_OUTPUT_HANDLE
,
hOut
);
SetStdHandle
(
STD_ERROR_HANDLE
,
hErr
);
SetStdHandle
(
STD_INPUT_HANDLE
,
reply
.
handle_in
);
SetStdHandle
(
STD_OUTPUT_HANDLE
,
reply
.
handle_out
);
SetStdHandle
(
STD_ERROR_HANDLE
,
hStderr
);
SetLastError
(
ERROR_SUCCESS
);
SetConsoleTitleA
(
"Wine Console"
);
...
...
@@ -824,6 +793,7 @@ BOOL WINAPI ReadConsoleA( HANDLE hConsoleInput,
int
charsread
=
0
;
LPSTR
xbuf
=
(
LPSTR
)
lpBuffer
;
struct
read_console_input_request
req
;
struct
read_console_input_reply
reply
;
INPUT_RECORD
ir
;
TRACE
(
"(%d,%p,%ld,%p,%p)
\n
"
,
...
...
@@ -843,8 +813,9 @@ BOOL WINAPI ReadConsoleA( HANDLE hConsoleInput,
int
len
;
CLIENT_SendRequest
(
REQ_READ_CONSOLE_INPUT
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitReply
(
&
len
,
NULL
,
1
,
&
ir
,
sizeof
(
ir
)
))
if
(
CLIENT_WaitReply
(
&
len
,
NULL
,
2
,
&
reply
,
sizeof
(
reply
)
,
&
ir
,
sizeof
(
ir
)
))
return
FALSE
;
len
-=
sizeof
(
reply
);
assert
(
!
(
len
%
sizeof
(
ir
))
);
if
(
!
len
)
break
;
if
(
!
ir
.
Event
.
KeyEvent
.
bKeyDown
)
...
...
@@ -903,6 +874,7 @@ BOOL WINAPI ReadConsoleInputA(HANDLE hConsoleInput,
DWORD
nLength
,
LPDWORD
lpNumberOfEventsRead
)
{
struct
read_console_input_request
req
;
struct
read_console_input_reply
reply
;
int
len
;
req
.
handle
=
hConsoleInput
;
...
...
@@ -913,8 +885,10 @@ BOOL WINAPI ReadConsoleInputA(HANDLE hConsoleInput,
for
(;;)
{
CLIENT_SendRequest
(
REQ_READ_CONSOLE_INPUT
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitReply
(
&
len
,
NULL
,
1
,
lpBuffer
,
nLength
*
sizeof
(
*
lpBuffer
)
))
if
(
CLIENT_WaitReply
(
&
len
,
NULL
,
2
,
&
reply
,
sizeof
(
reply
),
lpBuffer
,
nLength
*
sizeof
(
*
lpBuffer
)
))
return
FALSE
;
len
-=
sizeof
(
reply
);
assert
(
!
(
len
%
sizeof
(
INPUT_RECORD
))
);
if
(
len
)
break
;
CONSOLE_get_input
(
hConsoleInput
,
TRUE
);
...
...
@@ -963,6 +937,7 @@ BOOL WINAPI PeekConsoleInputA( HANDLE handle, LPINPUT_RECORD buffer,
DWORD
count
,
LPDWORD
read
)
{
struct
read_console_input_request
req
;
struct
read_console_input_reply
reply
;
int
len
;
CONSOLE_get_input
(
handle
,
FALSE
);
...
...
@@ -971,8 +946,10 @@ BOOL WINAPI PeekConsoleInputA( HANDLE handle, LPINPUT_RECORD buffer,
req
.
flush
=
0
;
CLIENT_SendRequest
(
REQ_READ_CONSOLE_INPUT
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitReply
(
&
len
,
NULL
,
1
,
buffer
,
count
*
sizeof
(
*
buffer
)
))
if
(
CLIENT_WaitReply
(
&
len
,
NULL
,
2
,
&
reply
,
sizeof
(
reply
),
buffer
,
count
*
sizeof
(
*
buffer
)
))
return
FALSE
;
len
-=
sizeof
(
reply
);
assert
(
!
(
len
%
sizeof
(
INPUT_RECORD
))
);
if
(
read
)
*
read
=
len
/
sizeof
(
INPUT_RECORD
);
return
TRUE
;
...
...
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