Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
96c08d81
Commit
96c08d81
authored
Feb 28, 1999
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use server handles directly for Win32 handles. Removed use of K32OBJ.
parent
ee517e86
Show whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
174 additions
and
1641 deletions
+174
-1641
change.c
files/change.c
+1
-23
dos_fs.c
files/dos_fs.c
+1
-3
file.c
files/file.c
+13
-80
file.h
include/file.h
+1
-1
k32obj.h
include/k32obj.h
+0
-64
process.h
include/process.h
+9
-42
thread.h
include/thread.h
+1
-2
task.c
loader/task.c
+2
-2
virtual.c
memory/virtual.c
+10
-96
toolhelp.c
misc/toolhelp.c
+4
-22
Makefile.in
scheduler/Makefile.in
+0
-1
client.c
scheduler/client.c
+2
-56
critsection.c
scheduler/critsection.c
+2
-64
event.c
scheduler/event.c
+4
-39
handle.c
scheduler/handle.c
+44
-397
k32obj.c
scheduler/k32obj.c
+0
-278
mutex.c
scheduler/mutex.c
+4
-39
pipe.c
scheduler/pipe.c
+3
-37
process.c
scheduler/process.c
+14
-67
semaphore.c
scheduler/semaphore.c
+4
-38
synchro.c
scheduler/synchro.c
+1
-12
sysdeps.c
scheduler/sysdeps.c
+2
-2
thread.c
scheduler/thread.c
+31
-90
console.c
win32/console.c
+20
-183
device.c
win32/device.c
+1
-3
No files found.
files/change.c
View file @
96c08d81
...
@@ -17,12 +17,6 @@
...
@@ -17,12 +17,6 @@
#include "server.h"
#include "server.h"
#include "debug.h"
#include "debug.h"
/* The change notification object */
typedef
struct
{
K32OBJ
header
;
}
CHANGE_OBJECT
;
/****************************************************************************
/****************************************************************************
* FindFirstChangeNotification32A (KERNEL32.248)
* FindFirstChangeNotification32A (KERNEL32.248)
...
@@ -31,7 +25,6 @@ HANDLE WINAPI FindFirstChangeNotificationA( LPCSTR lpPathName,
...
@@ -31,7 +25,6 @@ HANDLE WINAPI FindFirstChangeNotificationA( LPCSTR lpPathName,
BOOL
bWatchSubtree
,
BOOL
bWatchSubtree
,
DWORD
dwNotifyFilter
)
DWORD
dwNotifyFilter
)
{
{
CHANGE_OBJECT
*
change
;
struct
create_change_notification_request
req
;
struct
create_change_notification_request
req
;
struct
create_change_notification_reply
reply
;
struct
create_change_notification_reply
reply
;
...
@@ -39,19 +32,7 @@ HANDLE WINAPI FindFirstChangeNotificationA( LPCSTR lpPathName,
...
@@ -39,19 +32,7 @@ HANDLE WINAPI FindFirstChangeNotificationA( LPCSTR lpPathName,
req
.
filter
=
dwNotifyFilter
;
req
.
filter
=
dwNotifyFilter
;
CLIENT_SendRequest
(
REQ_CREATE_CHANGE_NOTIFICATION
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_CREATE_CHANGE_NOTIFICATION
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
if
(
reply
.
handle
==
-
1
)
return
INVALID_HANDLE_VALUE
;
return
reply
.
handle
;
change
=
HeapAlloc
(
SystemHeap
,
0
,
sizeof
(
CHANGE_OBJECT
)
);
if
(
!
change
)
{
CLIENT_CloseHandle
(
reply
.
handle
);
return
INVALID_HANDLE_VALUE
;
}
change
->
header
.
type
=
K32OBJ_CHANGE
;
change
->
header
.
refcount
=
1
;
return
HANDLE_Alloc
(
PROCESS_Current
(),
&
change
->
header
,
STANDARD_RIGHTS_REQUIRED
|
SYNCHRONIZE
/*FIXME*/
,
FALSE
,
reply
.
handle
);
}
}
/****************************************************************************
/****************************************************************************
...
@@ -73,9 +54,6 @@ HANDLE WINAPI FindFirstChangeNotificationW( LPCWSTR lpPathName,
...
@@ -73,9 +54,6 @@ HANDLE WINAPI FindFirstChangeNotificationW( LPCWSTR lpPathName,
*/
*/
BOOL
WINAPI
FindNextChangeNotification
(
HANDLE
handle
)
BOOL
WINAPI
FindNextChangeNotification
(
HANDLE
handle
)
{
{
if
(
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handle
,
K32OBJ_FILE
,
0
)
==
-
1
)
return
FALSE
;
/* FIXME: do something */
/* FIXME: do something */
return
TRUE
;
return
TRUE
;
}
}
...
...
files/dos_fs.c
View file @
96c08d81
...
@@ -609,9 +609,7 @@ const DOS_DEVICE *DOSFS_GetDeviceByHandle( HFILE hFile )
...
@@ -609,9 +609,7 @@ const DOS_DEVICE *DOSFS_GetDeviceByHandle( HFILE hFile )
struct
get_file_info_request
req
;
struct
get_file_info_request
req
;
struct
get_file_info_reply
reply
;
struct
get_file_info_reply
reply
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hFile
,
req
.
handle
=
hFile
;
K32OBJ_FILE
,
0
))
==
-
1
)
return
NULL
;
CLIENT_SendRequest
(
REQ_GET_FILE_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_GET_FILE_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
!
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
)
&&
if
(
!
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
)
&&
(
reply
.
type
==
FILE_TYPE_UNKNOWN
))
(
reply
.
type
==
FILE_TYPE_UNKNOWN
))
...
...
files/file.c
View file @
96c08d81
...
@@ -50,13 +50,6 @@
...
@@ -50,13 +50,6 @@
#define MAP_ANON MAP_ANONYMOUS
#define MAP_ANON MAP_ANONYMOUS
#endif
#endif
/* The file object */
typedef
struct
{
K32OBJ
header
;
}
FILE_OBJECT
;
/* Size of per-process table of DOS handles */
/* Size of per-process table of DOS handles */
#define DOS_TABLE_SIZE 256
#define DOS_TABLE_SIZE 256
...
@@ -309,7 +302,6 @@ void FILE_SetDosError(void)
...
@@ -309,7 +302,6 @@ void FILE_SetDosError(void)
*/
*/
HFILE
FILE_DupUnixHandle
(
int
fd
,
DWORD
access
)
HFILE
FILE_DupUnixHandle
(
int
fd
,
DWORD
access
)
{
{
FILE_OBJECT
*
file
;
int
unix_handle
;
int
unix_handle
;
struct
create_file_request
req
;
struct
create_file_request
req
;
struct
create_file_reply
reply
;
struct
create_file_reply
reply
;
...
@@ -328,18 +320,7 @@ HFILE FILE_DupUnixHandle( int fd, DWORD access )
...
@@ -328,18 +320,7 @@ HFILE FILE_DupUnixHandle( int fd, DWORD access )
CLIENT_SendRequest
(
REQ_CREATE_FILE
,
unix_handle
,
1
,
CLIENT_SendRequest
(
REQ_CREATE_FILE
,
unix_handle
,
1
,
&
req
,
sizeof
(
req
)
);
&
req
,
sizeof
(
req
)
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
if
(
reply
.
handle
==
-
1
)
return
INVALID_HANDLE_VALUE
;
return
reply
.
handle
;
if
(
!
(
file
=
HeapAlloc
(
SystemHeap
,
0
,
sizeof
(
FILE_OBJECT
)
)))
{
CLIENT_CloseHandle
(
reply
.
handle
);
SetLastError
(
ERROR_TOO_MANY_OPEN_FILES
);
return
(
HFILE
)
NULL
;
}
file
->
header
.
type
=
K32OBJ_FILE
;
file
->
header
.
refcount
=
0
;
return
HANDLE_Alloc
(
PROCESS_Current
(),
&
file
->
header
,
req
.
access
,
req
.
inherit
,
reply
.
handle
);
}
}
...
@@ -352,7 +333,6 @@ HFILE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
...
@@ -352,7 +333,6 @@ HFILE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
LPSECURITY_ATTRIBUTES
sa
,
DWORD
creation
,
LPSECURITY_ATTRIBUTES
sa
,
DWORD
creation
,
DWORD
attributes
,
HANDLE
template
)
DWORD
attributes
,
HANDLE
template
)
{
{
FILE_OBJECT
*
file
;
struct
create_file_request
req
;
struct
create_file_request
req
;
struct
create_file_reply
reply
;
struct
create_file_reply
reply
;
...
@@ -382,20 +362,7 @@ HFILE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
...
@@ -382,20 +362,7 @@ HFILE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
}
}
}
}
if
(
reply
.
handle
==
-
1
)
return
INVALID_HANDLE_VALUE
;
return
reply
.
handle
;
/* Now build the FILE_OBJECT */
if
(
!
(
file
=
HeapAlloc
(
SystemHeap
,
0
,
sizeof
(
FILE_OBJECT
)
)))
{
SetLastError
(
ERROR_OUTOFMEMORY
);
CLIENT_CloseHandle
(
reply
.
handle
);
return
(
HFILE
)
INVALID_HANDLE_VALUE
;
}
file
->
header
.
type
=
K32OBJ_FILE
;
file
->
header
.
refcount
=
0
;
return
HANDLE_Alloc
(
PROCESS_Current
(),
&
file
->
header
,
req
.
access
,
req
.
inherit
,
reply
.
handle
);
}
}
...
@@ -406,7 +373,6 @@ HFILE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
...
@@ -406,7 +373,6 @@ HFILE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
*/
*/
HFILE
FILE_CreateDevice
(
int
client_id
,
DWORD
access
,
LPSECURITY_ATTRIBUTES
sa
)
HFILE
FILE_CreateDevice
(
int
client_id
,
DWORD
access
,
LPSECURITY_ATTRIBUTES
sa
)
{
{
FILE_OBJECT
*
file
;
struct
create_device_request
req
;
struct
create_device_request
req
;
struct
create_device_reply
reply
;
struct
create_device_reply
reply
;
...
@@ -415,20 +381,7 @@ HFILE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa )
...
@@ -415,20 +381,7 @@ HFILE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa )
req
.
id
=
client_id
;
req
.
id
=
client_id
;
CLIENT_SendRequest
(
REQ_CREATE_DEVICE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_CREATE_DEVICE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
if
(
reply
.
handle
==
-
1
)
return
INVALID_HANDLE_VALUE
;
return
reply
.
handle
;
/* Now build the FILE_OBJECT */
if
(
!
(
file
=
HeapAlloc
(
SystemHeap
,
0
,
sizeof
(
FILE_OBJECT
)
)))
{
SetLastError
(
ERROR_OUTOFMEMORY
);
CLIENT_CloseHandle
(
reply
.
handle
);
return
(
HFILE
)
INVALID_HANDLE_VALUE
;
}
file
->
header
.
type
=
K32OBJ_FILE
;
file
->
header
.
refcount
=
0
;
return
HANDLE_Alloc
(
PROCESS_Current
(),
&
file
->
header
,
req
.
access
,
req
.
inherit
,
reply
.
handle
);
}
}
...
@@ -597,9 +550,7 @@ DWORD WINAPI GetFileInformationByHandle( HFILE hFile,
...
@@ -597,9 +550,7 @@ DWORD WINAPI GetFileInformationByHandle( HFILE hFile,
struct
get_file_info_reply
reply
;
struct
get_file_info_reply
reply
;
if
(
!
info
)
return
0
;
if
(
!
info
)
return
0
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hFile
,
req
.
handle
=
hFile
;
K32OBJ_FILE
,
0
))
==
-
1
)
return
0
;
CLIENT_SendRequest
(
REQ_GET_FILE_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_GET_FILE_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
0
;
return
0
;
...
@@ -1141,9 +1092,7 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
...
@@ -1141,9 +1092,7 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
if
(
bytesRead
)
*
bytesRead
=
0
;
/* Do this before anything else */
if
(
bytesRead
)
*
bytesRead
=
0
;
/* Do this before anything else */
if
(
!
bytesToRead
)
return
TRUE
;
if
(
!
bytesToRead
)
return
TRUE
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hFile
,
req
.
handle
=
hFile
;
K32OBJ_UNKNOWN
,
GENERIC_READ
))
==
-
1
)
return
FALSE
;
CLIENT_SendRequest
(
REQ_GET_READ_FD
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_GET_READ_FD
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_WaitReply
(
NULL
,
&
unix_handle
,
0
);
CLIENT_WaitReply
(
NULL
,
&
unix_handle
,
0
);
if
(
unix_handle
==
-
1
)
return
FALSE
;
if
(
unix_handle
==
-
1
)
return
FALSE
;
...
@@ -1175,9 +1124,7 @@ BOOL WINAPI WriteFile( HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite,
...
@@ -1175,9 +1124,7 @@ BOOL WINAPI WriteFile( HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite,
if
(
bytesWritten
)
*
bytesWritten
=
0
;
/* Do this before anything else */
if
(
bytesWritten
)
*
bytesWritten
=
0
;
/* Do this before anything else */
if
(
!
bytesToWrite
)
return
TRUE
;
if
(
!
bytesToWrite
)
return
TRUE
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hFile
,
req
.
handle
=
hFile
;
K32OBJ_UNKNOWN
,
GENERIC_WRITE
))
==
-
1
)
return
FALSE
;
CLIENT_SendRequest
(
REQ_GET_WRITE_FD
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_GET_WRITE_FD
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_WaitReply
(
NULL
,
&
unix_handle
,
0
);
CLIENT_WaitReply
(
NULL
,
&
unix_handle
,
0
);
if
(
unix_handle
==
-
1
)
return
FALSE
;
if
(
unix_handle
==
-
1
)
return
FALSE
;
...
@@ -1293,9 +1240,7 @@ DWORD WINAPI SetFilePointer( HFILE hFile, LONG distance, LONG *highword,
...
@@ -1293,9 +1240,7 @@ DWORD WINAPI SetFilePointer( HFILE hFile, LONG distance, LONG *highword,
TRACE
(
file
,
"handle %d offset %ld origin %ld
\n
"
,
TRACE
(
file
,
"handle %d offset %ld origin %ld
\n
"
,
hFile
,
distance
,
method
);
hFile
,
distance
,
method
);
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hFile
,
req
.
handle
=
hFile
;
K32OBJ_FILE
,
0
))
==
-
1
)
return
0xffffffff
;
req
.
low
=
distance
;
req
.
low
=
distance
;
req
.
high
=
highword
?
*
highword
:
0
;
req
.
high
=
highword
?
*
highword
:
0
;
/* FIXME: assumes 1:1 mapping between Windows and Unix seek constants */
/* FIXME: assumes 1:1 mapping between Windows and Unix seek constants */
...
@@ -1493,9 +1438,7 @@ BOOL WINAPI FlushFileBuffers( HFILE hFile )
...
@@ -1493,9 +1438,7 @@ BOOL WINAPI FlushFileBuffers( HFILE hFile )
{
{
struct
flush_file_request
req
;
struct
flush_file_request
req
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hFile
,
req
.
handle
=
hFile
;
K32OBJ_FILE
,
0
))
==
-
1
)
return
FALSE
;
CLIENT_SendRequest
(
REQ_FLUSH_FILE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_FLUSH_FILE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
}
}
...
@@ -1508,9 +1451,7 @@ BOOL WINAPI SetEndOfFile( HFILE hFile )
...
@@ -1508,9 +1451,7 @@ BOOL WINAPI SetEndOfFile( HFILE hFile )
{
{
struct
truncate_file_request
req
;
struct
truncate_file_request
req
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hFile
,
req
.
handle
=
hFile
;
K32OBJ_FILE
,
0
))
==
-
1
)
return
FALSE
;
CLIENT_SendRequest
(
REQ_TRUNCATE_FILE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_TRUNCATE_FILE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
}
}
...
@@ -1667,9 +1608,7 @@ DWORD WINAPI GetFileType( HFILE hFile )
...
@@ -1667,9 +1608,7 @@ DWORD WINAPI GetFileType( HFILE hFile )
struct
get_file_info_request
req
;
struct
get_file_info_request
req
;
struct
get_file_info_reply
reply
;
struct
get_file_info_reply
reply
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hFile
,
req
.
handle
=
hFile
;
K32OBJ_UNKNOWN
,
0
))
==
-
1
)
return
FILE_TYPE_UNKNOWN
;
CLIENT_SendRequest
(
REQ_GET_FILE_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_GET_FILE_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
FILE_TYPE_UNKNOWN
;
return
FILE_TYPE_UNKNOWN
;
...
@@ -1950,9 +1889,7 @@ BOOL WINAPI SetFileTime( HFILE hFile,
...
@@ -1950,9 +1889,7 @@ BOOL WINAPI SetFileTime( HFILE hFile,
{
{
struct
set_file_time_request
req
;
struct
set_file_time_request
req
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hFile
,
req
.
handle
=
hFile
;
K32OBJ_FILE
,
GENERIC_WRITE
))
==
-
1
)
return
FALSE
;
if
(
lpLastAccessTime
)
if
(
lpLastAccessTime
)
req
.
access_time
=
DOSFS_FileTimeToUnixTime
(
lpLastAccessTime
,
NULL
);
req
.
access_time
=
DOSFS_FileTimeToUnixTime
(
lpLastAccessTime
,
NULL
);
else
else
...
@@ -1975,9 +1912,7 @@ BOOL WINAPI LockFile( HFILE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh
...
@@ -1975,9 +1912,7 @@ BOOL WINAPI LockFile( HFILE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh
{
{
struct
lock_file_request
req
;
struct
lock_file_request
req
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hFile
,
req
.
handle
=
hFile
;
K32OBJ_FILE
,
0
))
==
-
1
)
return
FALSE
;
req
.
offset_low
=
dwFileOffsetLow
;
req
.
offset_low
=
dwFileOffsetLow
;
req
.
offset_high
=
dwFileOffsetHigh
;
req
.
offset_high
=
dwFileOffsetHigh
;
req
.
count_low
=
nNumberOfBytesToLockLow
;
req
.
count_low
=
nNumberOfBytesToLockLow
;
...
@@ -1995,9 +1930,7 @@ BOOL WINAPI UnlockFile( HFILE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHi
...
@@ -1995,9 +1930,7 @@ BOOL WINAPI UnlockFile( HFILE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHi
{
{
struct
unlock_file_request
req
;
struct
unlock_file_request
req
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hFile
,
req
.
handle
=
hFile
;
K32OBJ_FILE
,
0
))
==
-
1
)
return
FALSE
;
req
.
offset_low
=
dwFileOffsetLow
;
req
.
offset_low
=
dwFileOffsetLow
;
req
.
offset_high
=
dwFileOffsetHigh
;
req
.
offset_high
=
dwFileOffsetHigh
;
req
.
count_low
=
nNumberOfBytesToUnlockLow
;
req
.
count_low
=
nNumberOfBytesToUnlockLow
;
...
...
include/file.h
View file @
96c08d81
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
#define __WINE_FILE_H
#define __WINE_FILE_H
#include <time.h>
/* time_t */
#include <time.h>
/* time_t */
#include "
k32obj
.h"
#include "
winbase
.h"
#define MAX_PATHNAME_LEN 1024
#define MAX_PATHNAME_LEN 1024
...
...
include/k32obj.h
deleted
100644 → 0
View file @
ee517e86
/*
* KERNEL32 objects
*
* Copyright 1996, 1998 Alexandre Julliard
*/
#ifndef __WINE_K32OBJ_H
#define __WINE_K32OBJ_H
#include "wintypes.h"
#include "winbase.h"
/* SECURITY_ATTRIBUTES */
/* Object types */
typedef
enum
{
K32OBJ_UNKNOWN
=
0
,
K32OBJ_SEMAPHORE
,
K32OBJ_EVENT
,
K32OBJ_MUTEX
,
K32OBJ_CRITICAL_SECTION
,
K32OBJ_PROCESS
,
K32OBJ_THREAD
,
K32OBJ_FILE
,
K32OBJ_CHANGE
,
K32OBJ_CONSOLE
,
K32OBJ_SCREEN_BUFFER
,
K32OBJ_MEM_MAPPED_FILE
,
K32OBJ_SERIAL
,
K32OBJ_DEVICE_IOCTL
,
K32OBJ_PIPE
,
K32OBJ_MAILSLOT
,
K32OBJ_TOOLHELP_SNAPSHOT
,
K32OBJ_SOCKET
,
K32OBJ_NBOBJECTS
}
K32OBJ_TYPE
;
/* Kernel object */
typedef
struct
{
K32OBJ_TYPE
type
;
LONG
refcount
;
}
K32OBJ
;
/* Kernel object operations */
typedef
struct
{
void
(
*
destroy
)(
K32OBJ
*
);
/* Destroy object on refcount==0 */
}
K32OBJ_OPS
;
extern
const
K32OBJ_OPS
*
const
K32OBJ_Ops
[
K32OBJ_NBOBJECTS
];
#define K32OBJ_OPS(obj) (K32OBJ_Ops[(obj)->type])
extern
void
K32OBJ_IncCount
(
K32OBJ
*
ptr
);
extern
void
K32OBJ_DecCount
(
K32OBJ
*
ptr
);
extern
BOOL
K32OBJ_IsValid
(
K32OBJ
*
ptr
,
K32OBJ_TYPE
type
);
extern
BOOL
K32OBJ_AddName
(
K32OBJ
*
obj
,
LPCSTR
name
);
extern
K32OBJ
*
K32OBJ_Create
(
K32OBJ_TYPE
type
,
DWORD
size
,
LPCSTR
name
,
int
server_handle
,
DWORD
access
,
SECURITY_ATTRIBUTES
*
sa
,
HANDLE
*
handle
);
extern
K32OBJ
*
K32OBJ_FindName
(
LPCSTR
name
);
extern
K32OBJ
*
K32OBJ_FindNameType
(
LPCSTR
name
,
K32OBJ_TYPE
type
);
#endif
/* __WINE_K32OBJ_H */
include/process.h
View file @
96c08d81
...
@@ -9,26 +9,10 @@
...
@@ -9,26 +9,10 @@
#include "wintypes.h"
#include "wintypes.h"
#include "module.h"
#include "module.h"
#include "k32obj.h"
struct
_NE_MODULE
;
struct
_NE_MODULE
;
struct
_THREAD_ENTRY
;
struct
_THREAD_ENTRY
;
/* Process handle entry */
typedef
struct
{
DWORD
access
;
/* Access flags */
K32OBJ
*
ptr
;
/* Object ptr */
int
server
;
/* Server handle (FIXME: tmp hack) */
}
HANDLE_ENTRY
;
/* Process handle table */
typedef
struct
{
DWORD
count
;
HANDLE_ENTRY
entries
[
1
];
}
HANDLE_TABLE
;
/* Current Process pseudo-handle - Returned by GetCurrentProcess*/
/* Current Process pseudo-handle - Returned by GetCurrentProcess*/
#define CURRENT_PROCESS_PSEUDOHANDLE ((HANDLE)0x7fffffff)
#define CURRENT_PROCESS_PSEUDOHANDLE ((HANDLE)0x7fffffff)
...
@@ -46,9 +30,9 @@ typedef struct
...
@@ -46,9 +30,9 @@ typedef struct
DWORD
unknown2
;
/* 20 Unknown */
DWORD
unknown2
;
/* 20 Unknown */
DWORD
inherit_console
;
/* 24 Inherit console flag */
DWORD
inherit_console
;
/* 24 Inherit console flag */
DWORD
break_type
;
/* 28 Console events flag */
DWORD
break_type
;
/* 28 Console events flag */
K32OBJ
*
break_sem
;
/* 2c SetConsoleCtrlHandler semaphore */
void
*
break_sem
;
/* 2c SetConsoleCtrlHandler semaphore */
K32OBJ
*
break_event
;
/* 30 SetConsoleCtrlHandler event */
void
*
break_event
;
/* 30 SetConsoleCtrlHandler event */
K32OBJ
*
break_thread
;
/* 34 SetConsoleCtrlHandler thread */
void
*
break_thread
;
/* 34 SetConsoleCtrlHandler thread */
void
*
break_handlers
;
/* 38 List of console handlers */
void
*
break_handlers
;
/* 38 List of console handlers */
/* The following are Wine-specific fields */
/* The following are Wine-specific fields */
CRITICAL_SECTION
section
;
/* 3c Env DB critical section */
CRITICAL_SECTION
section
;
/* 3c Env DB critical section */
...
@@ -59,9 +43,9 @@ typedef struct
...
@@ -59,9 +43,9 @@ typedef struct
/* Win32 process database */
/* Win32 process database */
typedef
struct
_PDB
typedef
struct
_PDB
{
{
K32OBJ
header
;
/* 00 Kernel object header */
LONG
header
[
2
];
/* 00 Kernel object header */
DWORD
unknown1
;
/* 08 Unknown */
DWORD
unknown1
;
/* 08 Unknown */
K32OBJ
*
event
;
/* 0c Pointer to an event object (unused) */
void
*
event
;
/* 0c Pointer to an event object (unused) */
DWORD
exit_code
;
/* 10 Process exit code */
DWORD
exit_code
;
/* 10 Process exit code */
DWORD
unknown2
;
/* 14 Unknown */
DWORD
unknown2
;
/* 14 Unknown */
HANDLE
heap
;
/* 18 Default process heap */
HANDLE
heap
;
/* 18 Default process heap */
...
@@ -78,7 +62,7 @@ typedef struct _PDB
...
@@ -78,7 +62,7 @@ typedef struct _PDB
HTASK
task
;
/* 38 Win16 task */
HTASK
task
;
/* 38 Win16 task */
void
*
mem_map_files
;
/* 3c Pointer to mem-mapped files */
void
*
mem_map_files
;
/* 3c Pointer to mem-mapped files */
ENVDB
*
env_db
;
/* 40 Environment database */
ENVDB
*
env_db
;
/* 40 Environment database */
HANDLE_TABLE
*
handle_table
;
/* 44 Handle table */
void
*
handle_table
;
/* 44 Handle table */
struct
_PDB
*
parent
;
/* 48 Parent process */
struct
_PDB
*
parent
;
/* 48 Parent process */
WINE_MODREF
*
modref_list
;
/* 4c MODREF list */
WINE_MODREF
*
modref_list
;
/* 4c MODREF list */
void
*
thread_list
;
/* 50 List of threads */
void
*
thread_list
;
/* 50 List of threads */
...
@@ -87,7 +71,7 @@ typedef struct _PDB
...
@@ -87,7 +71,7 @@ typedef struct _PDB
DWORD
unknown4
;
/* 5c Unknown */
DWORD
unknown4
;
/* 5c Unknown */
CRITICAL_SECTION
crit_section
;
/* 60 Critical section */
CRITICAL_SECTION
crit_section
;
/* 60 Critical section */
DWORD
unknown5
[
3
];
/* 78 Unknown */
DWORD
unknown5
[
3
];
/* 78 Unknown */
K32OBJ
*
console
;
/* 84 Console */
void
*
console
;
/* 84 Console */
DWORD
tls_bits
[
2
];
/* 88 TLS in-use bits */
DWORD
tls_bits
[
2
];
/* 88 TLS in-use bits */
DWORD
process_dword
;
/* 90 Unknown */
DWORD
process_dword
;
/* 90 Unknown */
struct
_PDB
*
group
;
/* 94 Process group */
struct
_PDB
*
group
;
/* 94 Process group */
...
@@ -97,7 +81,7 @@ typedef struct _PDB
...
@@ -97,7 +81,7 @@ typedef struct _PDB
HANDLE
heap_list
;
/* a4 Head of process heap list */
HANDLE
heap_list
;
/* a4 Head of process heap list */
void
*
heap_handles
;
/* a8 Head of heap handles list */
void
*
heap_handles
;
/* a8 Head of heap handles list */
DWORD
unknown6
;
/* ac Unknown */
DWORD
unknown6
;
/* ac Unknown */
K32OBJ
*
console_provider
;
/* b0 Console provider (??) */
void
*
console_provider
;
/* b0 Console provider (??) */
WORD
env_selector
;
/* b4 Selector to process environment */
WORD
env_selector
;
/* b4 Selector to process environment */
WORD
error_mode
;
/* b6 Error mode */
WORD
error_mode
;
/* b6 Error mode */
HANDLE
load_done_evt
;
/* b8 Event for process loading done */
HANDLE
load_done_evt
;
/* b8 Event for process loading done */
...
@@ -122,21 +106,6 @@ extern BOOL ENV_BuildEnvironment( PDB *pdb );
...
@@ -122,21 +106,6 @@ extern BOOL ENV_BuildEnvironment( PDB *pdb );
extern
BOOL
ENV_InheritEnvironment
(
PDB
*
pdb
,
LPCSTR
env
);
extern
BOOL
ENV_InheritEnvironment
(
PDB
*
pdb
,
LPCSTR
env
);
extern
void
ENV_FreeEnvironment
(
PDB
*
pdb
);
extern
void
ENV_FreeEnvironment
(
PDB
*
pdb
);
/* scheduler/handle.c */
extern
BOOL
HANDLE_CreateTable
(
PDB
*
pdb
,
BOOL
inherit
);
extern
HANDLE
HANDLE_Alloc
(
PDB
*
pdb
,
K32OBJ
*
ptr
,
DWORD
access
,
BOOL
inherit
,
int
server_handle
);
extern
int
HANDLE_GetServerHandle
(
PDB
*
pdb
,
HANDLE
handle
,
K32OBJ_TYPE
type
,
DWORD
access
);
extern
void
HANDLE_CloseAll
(
PDB
*
pdb
,
K32OBJ
*
ptr
);
/* Global handle macros */
#define HANDLE_OBFUSCATOR ((DWORD)0x544a4def)
#define HANDLE_IS_GLOBAL(h) (((DWORD)(h) ^ HANDLE_OBFUSCATOR) < 0x10000)
#define HANDLE_LOCAL_TO_GLOBAL(h) ((HANDLE)((DWORD)(h) ^ HANDLE_OBFUSCATOR))
#define HANDLE_GLOBAL_TO_LOCAL(h) ((HANDLE)((DWORD)(h) ^ HANDLE_OBFUSCATOR))
/* scheduler/process.c */
/* scheduler/process.c */
extern
BOOL
PROCESS_Init
(
void
);
extern
BOOL
PROCESS_Init
(
void
);
extern
PDB
*
PROCESS_Current
(
void
);
extern
PDB
*
PROCESS_Current
(
void
);
...
@@ -147,11 +116,9 @@ extern PDB *PROCESS_Create( struct _NE_MODULE *pModule, LPCSTR cmd_line,
...
@@ -147,11 +116,9 @@ extern PDB *PROCESS_Create( struct _NE_MODULE *pModule, LPCSTR cmd_line,
LPCSTR
env
,
HINSTANCE16
hInstance
,
LPCSTR
env
,
HINSTANCE16
hInstance
,
HINSTANCE16
hPrevInstance
,
BOOL
inherit
,
HINSTANCE16
hPrevInstance
,
BOOL
inherit
,
STARTUPINFOA
*
startup
,
PROCESS_INFORMATION
*
info
);
STARTUPINFOA
*
startup
,
PROCESS_INFORMATION
*
info
);
extern
void
PROCESS_FreePDB
(
PDB
*
pdb
);
extern
void
PROCESS_SuspendOtherThreads
(
void
);
extern
void
PROCESS_SuspendOtherThreads
(
void
);
extern
void
PROCESS_ResumeOtherThreads
(
void
);
extern
void
PROCESS_ResumeOtherThreads
(
void
);
extern
int
PROCESS_PDBList_Getsize
(
void
);
extern
PDB
*
PROCESS_PDBList_Getfirst
(
void
);
extern
PDB
*
PROCESS_PDBList_Getnext
(
PDB
*
);
#endif
/* __WINE_PROCESS_H */
#endif
/* __WINE_PROCESS_H */
include/thread.h
View file @
96c08d81
...
@@ -9,7 +9,6 @@
...
@@ -9,7 +9,6 @@
#include "config.h"
#include "config.h"
#include "winbase.h"
#include "winbase.h"
#include "k32obj.h"
#include "selectors.h"
/* for SET_FS */
#include "selectors.h"
/* for SET_FS */
#ifdef linux
#ifdef linux
...
@@ -58,7 +57,7 @@ typedef struct _TEB
...
@@ -58,7 +57,7 @@ typedef struct _TEB
/* Thread database */
/* Thread database */
typedef
struct
_THDB
typedef
struct
_THDB
{
{
K32OBJ
header
;
/* 00 Kernel object header */
LONG
header
[
2
];
/* 00 Kernel object header */
struct
_PDB
*
process
;
/* 08 Process owning this thread */
struct
_PDB
*
process
;
/* 08 Process owning this thread */
HANDLE
event
;
/* 0c Thread event */
HANDLE
event
;
/* 0c Thread event */
TEB
teb
;
/* 10 Thread exception block */
TEB
teb
;
/* 10 Thread exception block */
...
...
loader/task.c
View file @
96c08d81
...
@@ -538,8 +538,8 @@ static void TASK_DeleteTask( HTASK16 hTask )
...
@@ -538,8 +538,8 @@ static void TASK_DeleteTask( HTASK16 hTask )
/* Delete the Win32 part of the task */
/* Delete the Win32 part of the task */
K32OBJ_DecCount
(
&
pTask
->
thdb
->
process
->
header
);
/* PROCESS_FreePDB( pTask->thdb->process ); FIXME */
K32OBJ_DecCount
(
&
pTask
->
thdb
->
header
);
/* K32OBJ_DecCount( &pTask->thdb->header ); FIXME */
/* Free the selector aliases */
/* Free the selector aliases */
...
...
memory/virtual.c
View file @
96c08d81
...
@@ -27,12 +27,6 @@
...
@@ -27,12 +27,6 @@
#define MS_SYNC 0
#define MS_SYNC 0
#endif
#endif
/* File mapping */
typedef
struct
{
K32OBJ
header
;
}
FILE_MAPPING
;
/* File view */
/* File view */
typedef
struct
_FV
typedef
struct
_FV
{
{
...
@@ -1055,40 +1049,9 @@ HANDLE WINAPI CreateFileMappingA(
...
@@ -1055,40 +1049,9 @@ HANDLE WINAPI CreateFileMappingA(
DWORD
size_low
,
/* [in] Low-order 32 bits of object size */
DWORD
size_low
,
/* [in] Low-order 32 bits of object size */
LPCSTR
name
/* [in] Name of file-mapping object */
)
LPCSTR
name
/* [in] Name of file-mapping object */
)
{
{
FILE_MAPPING
*
mapping
=
NULL
;
struct
create_mapping_request
req
;
struct
create_mapping_request
req
;
struct
create_mapping_reply
reply
=
{
-
1
};
struct
create_mapping_reply
reply
;
HANDLE
handle
;
BYTE
vprot
;
BYTE
vprot
;
BOOL
inherit
=
(
sa
&&
(
sa
->
nLength
>=
sizeof
(
*
sa
))
&&
sa
->
bInheritHandle
);
/* First search for an object with the same name */
K32OBJ
*
obj
=
K32OBJ_FindName
(
name
);
if
(
obj
)
{
if
(
obj
->
type
==
K32OBJ_MEM_MAPPED_FILE
)
{
req
.
handle
=
-
1
;
CLIENT_SendRequest
(
REQ_CREATE_MAPPING
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
name
,
name
?
strlen
(
name
)
+
1
:
0
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
if
(
reply
.
handle
==
-
1
)
return
0
;
if
(
GetLastError
()
!=
ERROR_ALREADY_EXISTS
)
return
0
;
/* not supposed to happen */
handle
=
HANDLE_Alloc
(
PROCESS_Current
(),
obj
,
FILE_MAP_ALL_ACCESS
/*FIXME*/
,
inherit
,
reply
.
handle
);
}
else
{
SetLastError
(
ERROR_DUP_NAME
);
handle
=
0
;
}
K32OBJ_DecCount
(
obj
);
return
handle
;
}
/* Check parameters */
/* Check parameters */
...
@@ -1107,52 +1070,19 @@ HANDLE WINAPI CreateFileMappingA(
...
@@ -1107,52 +1070,19 @@ HANDLE WINAPI CreateFileMappingA(
else
vprot
|=
VPROT_COMMITTED
;
else
vprot
|=
VPROT_COMMITTED
;
if
(
protect
&
SEC_NOCACHE
)
vprot
|=
VPROT_NOCACHE
;
if
(
protect
&
SEC_NOCACHE
)
vprot
|=
VPROT_NOCACHE
;
/* Compute the size and extend the file if necessary */
if
(
hFile
!=
INVALID_HANDLE_VALUE
)
/* We have a file */
{
DWORD
access
=
GENERIC_READ
;
if
(((
protect
&
0xff
)
==
PAGE_READWRITE
)
||
((
protect
&
0xff
)
==
PAGE_WRITECOPY
)
||
((
protect
&
0xff
)
==
PAGE_EXECUTE_READWRITE
)
||
((
protect
&
0xff
)
==
PAGE_EXECUTE_WRITECOPY
))
access
|=
GENERIC_WRITE
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hFile
,
K32OBJ_FILE
,
access
))
==
-
1
)
goto
error
;
}
else
req
.
handle
=
-
1
;
/* Create the server object */
/* Create the server object */
req
.
handle
=
hFile
;
req
.
size_high
=
size_high
;
req
.
size_high
=
size_high
;
req
.
size_low
=
ROUND_SIZE
(
0
,
size_low
)
;
req
.
size_low
=
size_low
;
req
.
protect
=
vprot
;
req
.
protect
=
vprot
;
req
.
inherit
=
inherit
;
req
.
inherit
=
(
sa
&&
(
sa
->
nLength
>=
sizeof
(
*
sa
))
&&
sa
->
bInheritHandle
)
;
CLIENT_SendRequest
(
REQ_CREATE_MAPPING
,
-
1
,
2
,
CLIENT_SendRequest
(
REQ_CREATE_MAPPING
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
&
req
,
sizeof
(
req
),
name
,
name
?
strlen
(
name
)
+
1
:
0
);
name
,
name
?
strlen
(
name
)
+
1
:
0
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
goto
error
;
if
(
reply
.
handle
==
-
1
)
return
0
;
return
reply
.
handle
;
/* Allocate the mapping object */
if
(
!
(
mapping
=
HeapAlloc
(
SystemHeap
,
0
,
sizeof
(
*
mapping
)
)))
goto
error
;
mapping
->
header
.
type
=
K32OBJ_MEM_MAPPED_FILE
;
mapping
->
header
.
refcount
=
1
;
if
(
!
K32OBJ_AddName
(
&
mapping
->
header
,
name
))
handle
=
0
;
else
handle
=
HANDLE_Alloc
(
PROCESS_Current
(),
&
mapping
->
header
,
FILE_MAP_ALL_ACCESS
/*FIXME*/
,
inherit
,
reply
.
handle
);
K32OBJ_DecCount
(
&
mapping
->
header
);
SetLastError
(
0
);
/* Last error value is relevant. (see the start of fun) */
return
handle
;
error:
if
(
reply
.
handle
!=
-
1
)
CLIENT_CloseHandle
(
reply
.
handle
);
if
(
mapping
)
HeapFree
(
SystemHeap
,
0
,
mapping
);
return
0
;
}
}
...
@@ -1185,8 +1115,6 @@ HANDLE WINAPI OpenFileMappingA(
...
@@ -1185,8 +1115,6 @@ HANDLE WINAPI OpenFileMappingA(
BOOL
inherit
,
/* [in] Inherit flag */
BOOL
inherit
,
/* [in] Inherit flag */
LPCSTR
name
)
/* [in] Name of file-mapping object */
LPCSTR
name
)
/* [in] Name of file-mapping object */
{
{
HANDLE
handle
=
0
;
K32OBJ
*
obj
;
struct
open_named_obj_request
req
;
struct
open_named_obj_request
req
;
struct
open_named_obj_reply
reply
;
struct
open_named_obj_reply
reply
;
int
len
=
name
?
strlen
(
name
)
+
1
:
0
;
int
len
=
name
?
strlen
(
name
)
+
1
:
0
;
...
@@ -1196,21 +1124,8 @@ HANDLE WINAPI OpenFileMappingA(
...
@@ -1196,21 +1124,8 @@ HANDLE WINAPI OpenFileMappingA(
req
.
inherit
=
inherit
;
req
.
inherit
=
inherit
;
CLIENT_SendRequest
(
REQ_OPEN_NAMED_OBJ
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
name
,
len
);
CLIENT_SendRequest
(
REQ_OPEN_NAMED_OBJ
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
name
,
len
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
if
(
reply
.
handle
==
-
1
)
return
0
;
/* must return 0 on failure, not -1 */
if
(
reply
.
handle
!=
-
1
)
return
reply
.
handle
;
{
SYSTEM_LOCK
();
if
((
obj
=
K32OBJ_FindNameType
(
name
,
K32OBJ_MEM_MAPPED_FILE
)))
{
handle
=
HANDLE_Alloc
(
PROCESS_Current
(),
obj
,
access
,
inherit
,
reply
.
handle
);
K32OBJ_DecCount
(
obj
);
if
(
handle
==
INVALID_HANDLE_VALUE
)
handle
=
0
;
/* must return 0 on failure, not -1 */
}
else
CLIENT_CloseHandle
(
reply
.
handle
);
SYSTEM_UNLOCK
();
}
return
handle
;
}
}
...
@@ -1279,8 +1194,7 @@ LPVOID WINAPI MapViewOfFileEx(
...
@@ -1279,8 +1194,7 @@ LPVOID WINAPI MapViewOfFileEx(
return
NULL
;
return
NULL
;
}
}
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handle
,
req
.
handle
=
handle
;
K32OBJ_MEM_MAPPED_FILE
,
0
/* FIXME */
);
CLIENT_SendRequest
(
REQ_GET_MAPPING_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_GET_MAPPING_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitSimpleReply
(
&
info
,
sizeof
(
info
),
&
unix_handle
))
if
(
CLIENT_WaitSimpleReply
(
&
info
,
sizeof
(
info
),
&
unix_handle
))
goto
error
;
goto
error
;
...
...
misc/toolhelp.c
View file @
96c08d81
...
@@ -16,17 +16,10 @@
...
@@ -16,17 +16,10 @@
#include "tlhelp32.h"
#include "tlhelp32.h"
#include "toolhelp.h"
#include "toolhelp.h"
#include "heap.h"
#include "heap.h"
#include "k32obj.h"
#include "server.h"
#include "server.h"
#include "debug.h"
#include "debug.h"
/* The K32 snapshot object object */
typedef
struct
{
K32OBJ
header
;
}
SNAPSHOT_OBJECT
;
/* FIXME: to make this working, we have to callback all these registered
/* FIXME: to make this working, we have to callback all these registered
* functions from all over the WINE code. Someone with more knowledge than
* functions from all over the WINE code. Someone with more knowledge than
* me please do that. -Marcus
* me please do that. -Marcus
...
@@ -121,7 +114,6 @@ FARPROC16 tmp;
...
@@ -121,7 +114,6 @@ FARPROC16 tmp;
*/
*/
HANDLE
WINAPI
CreateToolhelp32Snapshot
(
DWORD
flags
,
DWORD
process
)
HANDLE
WINAPI
CreateToolhelp32Snapshot
(
DWORD
flags
,
DWORD
process
)
{
{
SNAPSHOT_OBJECT
*
snapshot
;
struct
create_snapshot_request
req
;
struct
create_snapshot_request
req
;
struct
create_snapshot_reply
reply
;
struct
create_snapshot_reply
reply
;
...
@@ -133,21 +125,13 @@ HANDLE WINAPI CreateToolhelp32Snapshot( DWORD flags, DWORD process )
...
@@ -133,21 +125,13 @@ HANDLE WINAPI CreateToolhelp32Snapshot( DWORD flags, DWORD process )
SetLastError
(
ERROR_CALL_NOT_IMPLEMENTED
);
SetLastError
(
ERROR_CALL_NOT_IMPLEMENTED
);
return
INVALID_HANDLE_VALUE
;
return
INVALID_HANDLE_VALUE
;
}
}
/* Now do the snapshot */
if
(
!
(
snapshot
=
HeapAlloc
(
SystemHeap
,
0
,
sizeof
(
*
snapshot
)
)))
return
INVALID_HANDLE_VALUE
;
snapshot
->
header
.
type
=
K32OBJ_TOOLHELP_SNAPSHOT
;
snapshot
->
header
.
refcount
=
1
;
/* Now do the snapshot */
req
.
flags
=
flags
&
~
TH32CS_INHERIT
;
req
.
flags
=
flags
&
~
TH32CS_INHERIT
;
req
.
inherit
=
(
flags
&
TH32CS_INHERIT
)
!=
0
;
req
.
inherit
=
(
flags
&
TH32CS_INHERIT
)
!=
0
;
CLIENT_SendRequest
(
REQ_CREATE_SNAPSHOT
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_CREATE_SNAPSHOT
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
{
return
reply
.
handle
;
HeapFree
(
SystemHeap
,
0
,
snapshot
);
return
INVALID_HANDLE_VALUE
;
}
return
HANDLE_Alloc
(
PROCESS_Current
(),
&
snapshot
->
header
,
0
,
req
.
inherit
,
reply
.
handle
);
}
}
...
@@ -167,9 +151,7 @@ static BOOL TOOLHELP_Process32Next( HANDLE handle, LPPROCESSENTRY lppe, BOOL fir
...
@@ -167,9 +151,7 @@ static BOOL TOOLHELP_Process32Next( HANDLE handle, LPPROCESSENTRY lppe, BOOL fir
ERR
(
toolhelp
,
"Result buffer too small
\n
"
);
ERR
(
toolhelp
,
"Result buffer too small
\n
"
);
return
FALSE
;
return
FALSE
;
}
}
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handle
,
req
.
handle
=
handle
;
K32OBJ_TOOLHELP_SNAPSHOT
,
0
))
==
-
1
)
return
FALSE
;
req
.
reset
=
first
;
req
.
reset
=
first
;
CLIENT_SendRequest
(
REQ_NEXT_PROCESS
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_NEXT_PROCESS
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
FALSE
;
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
FALSE
;
...
...
scheduler/Makefile.in
View file @
96c08d81
...
@@ -10,7 +10,6 @@ C_SRCS = \
...
@@ -10,7 +10,6 @@ C_SRCS = \
critsection.c
\
critsection.c
\
event.c
\
event.c
\
handle.c
\
handle.c
\
k32obj.c
\
mutex.c
\
mutex.c
\
pipe.c
\
pipe.c
\
process.c
\
process.c
\
...
...
scheduler/client.c
View file @
96c08d81
...
@@ -288,9 +288,9 @@ int CLIENT_NewThread( THDB *thdb, int *thandle, int *phandle )
...
@@ -288,9 +288,9 @@ int CLIENT_NewThread( THDB *thdb, int *thandle, int *phandle )
fcntl
(
fd
[
0
],
F_SETFD
,
1
);
/* set close on exec flag */
fcntl
(
fd
[
0
],
F_SETFD
,
1
);
/* set close on exec flag */
if
(
thandle
)
*
thandle
=
reply
.
thandle
;
if
(
thandle
)
*
thandle
=
reply
.
thandle
;
else
if
(
reply
.
thandle
!=
-
1
)
C
LIENT_C
loseHandle
(
reply
.
thandle
);
else
if
(
reply
.
thandle
!=
-
1
)
CloseHandle
(
reply
.
thandle
);
if
(
phandle
)
*
phandle
=
reply
.
phandle
;
if
(
phandle
)
*
phandle
=
reply
.
phandle
;
else
if
(
reply
.
phandle
!=
-
1
)
C
LIENT_C
loseHandle
(
reply
.
phandle
);
else
if
(
reply
.
phandle
!=
-
1
)
CloseHandle
(
reply
.
phandle
);
return
0
;
return
0
;
error:
error:
...
@@ -330,57 +330,3 @@ int CLIENT_SetDebug( int level )
...
@@ -330,57 +330,3 @@ int CLIENT_SetDebug( int level )
CLIENT_SendRequest
(
REQ_SET_DEBUG
,
-
1
,
1
,
&
level
,
sizeof
(
level
)
);
CLIENT_SendRequest
(
REQ_SET_DEBUG
,
-
1
,
1
,
&
level
,
sizeof
(
level
)
);
return
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
return
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
}
}
/***********************************************************************
* CLIENT_CloseHandle
*
* Send a close handle request. Return 0 if OK.
*/
int
CLIENT_CloseHandle
(
int
handle
)
{
CLIENT_SendRequest
(
REQ_CLOSE_HANDLE
,
-
1
,
1
,
&
handle
,
sizeof
(
handle
)
);
return
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
}
/***********************************************************************
* CLIENT_DuplicateHandle
*
* Send a duplicate handle request. Return 0 if OK.
*/
int
CLIENT_DuplicateHandle
(
int
src_process
,
int
src_handle
,
int
dst_process
,
int
dst_handle
,
DWORD
access
,
BOOL
inherit
,
DWORD
options
)
{
struct
dup_handle_request
req
;
struct
dup_handle_reply
reply
;
req
.
src_process
=
src_process
;
req
.
src_handle
=
src_handle
;
req
.
dst_process
=
dst_process
;
req
.
access
=
access
;
req
.
inherit
=
inherit
;
req
.
options
=
options
;
CLIENT_SendRequest
(
REQ_DUP_HANDLE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
return
reply
.
handle
;
}
/***********************************************************************
* CLIENT_OpenProcess
*
* Open a handle to a process.
*/
int
CLIENT_OpenProcess
(
void
*
pid
,
DWORD
access
,
BOOL
inherit
)
{
struct
open_process_request
req
;
struct
open_process_reply
reply
;
req
.
pid
=
pid
;
req
.
access
=
access
;
req
.
inherit
=
inherit
;
CLIENT_SendRequest
(
REQ_OPEN_PROCESS
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
return
reply
.
handle
;
}
scheduler/critsection.c
View file @
96c08d81
...
@@ -8,24 +8,13 @@
...
@@ -8,24 +8,13 @@
#include <errno.h>
#include <errno.h>
#include <stdio.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/sem.h>
#include "debug.h"
#include "debug.h"
#include "winerror.h"
#include "winerror.h"
#include "winbase.h"
#include "winbase.h"
#include "heap.h"
#include "heap.h"
#include "k32obj.h"
#include "debug.h"
#include "debug.h"
#include "thread.h"
#include "thread.h"
/* On some systems this is supposed to be defined in the program */
#ifndef HAVE_UNION_SEMUN
union
semun
{
int
val
;
struct
semid_ds
*
buf
;
ushort
*
array
;
};
#endif
/***********************************************************************
/***********************************************************************
* InitializeCriticalSection (KERNEL32.472) (NTDLL.406)
* InitializeCriticalSection (KERNEL32.472) (NTDLL.406)
...
@@ -36,23 +25,8 @@ void WINAPI InitializeCriticalSection( CRITICAL_SECTION *crit )
...
@@ -36,23 +25,8 @@ void WINAPI InitializeCriticalSection( CRITICAL_SECTION *crit )
crit
->
RecursionCount
=
0
;
crit
->
RecursionCount
=
0
;
crit
->
OwningThread
=
0
;
crit
->
OwningThread
=
0
;
crit
->
LockSemaphore
=
0
;
crit
->
LockSemaphore
=
0
;
if
(
SystemHeap
)
{
crit
->
LockSemaphore
=
CreateSemaphoreA
(
NULL
,
0
,
1
,
NULL
);
crit
->
LockSemaphore
=
CreateSemaphoreA
(
NULL
,
0
,
1
,
NULL
);
crit
->
Reserved
=
(
DWORD
)
-
1
;
crit
->
Reserved
=
(
DWORD
)
-
1
;
}
else
{
union
semun
val
;
crit
->
Reserved
=
(
DWORD
)
semget
(
IPC_PRIVATE
,
1
,
IPC_CREAT
|
0777
);
if
(
crit
->
Reserved
==
(
DWORD
)
-
1
)
{
perror
(
"semget"
);
return
;
}
val
.
val
=
0
;
semctl
(
(
int
)
crit
->
Reserved
,
0
,
SETVAL
,
val
);
}
}
}
...
@@ -71,10 +45,6 @@ void WINAPI DeleteCriticalSection( CRITICAL_SECTION *crit )
...
@@ -71,10 +45,6 @@ void WINAPI DeleteCriticalSection( CRITICAL_SECTION *crit )
CloseHandle
(
crit
->
LockSemaphore
);
CloseHandle
(
crit
->
LockSemaphore
);
crit
->
LockSemaphore
=
0
;
crit
->
LockSemaphore
=
0
;
}
}
else
if
(
crit
->
Reserved
!=
(
DWORD
)
-
1
)
{
semctl
(
(
int
)
crit
->
Reserved
,
0
,
IPC_RMID
,
(
union
semun
)
0
);
}
}
}
...
@@ -83,9 +53,8 @@ void WINAPI DeleteCriticalSection( CRITICAL_SECTION *crit )
...
@@ -83,9 +53,8 @@ void WINAPI DeleteCriticalSection( CRITICAL_SECTION *crit )
*/
*/
void
WINAPI
EnterCriticalSection
(
CRITICAL_SECTION
*
crit
)
void
WINAPI
EnterCriticalSection
(
CRITICAL_SECTION
*
crit
)
{
{
if
(
(
crit
->
Reserved
==-
1
)
&&
!
(
crit
->
LockSemaphore
)
&&
if
(
!
crit
->
LockSemaphore
)
(
crit
!=
HEAP_SystemLock
)
{
)
{
FIXME
(
win32
,
"entering uninitialized section(%p)?
\n
"
,
crit
);
FIXME
(
win32
,
"entering uninitialized section(%p)?
\n
"
,
crit
);
InitializeCriticalSection
(
crit
);
InitializeCriticalSection
(
crit
);
}
}
...
@@ -97,29 +66,9 @@ void WINAPI EnterCriticalSection( CRITICAL_SECTION *crit )
...
@@ -97,29 +66,9 @@ void WINAPI EnterCriticalSection( CRITICAL_SECTION *crit )
return
;
return
;
}
}
/* Now wait for it */
/* Now wait for it */
if
(
crit
->
LockSemaphore
)
{
/* FIXME: should set a timeout and raise an exception */
/* FIXME: should set a timeout and raise an exception */
WaitForSingleObject
(
crit
->
LockSemaphore
,
INFINITE
);
WaitForSingleObject
(
crit
->
LockSemaphore
,
INFINITE
);
}
}
else
if
(
crit
->
Reserved
!=
(
DWORD
)
-
1
)
{
int
ret
;
struct
sembuf
sop
;
sop
.
sem_num
=
0
;
sop
.
sem_op
=
-
1
;
sop
.
sem_flg
=
0
/*SEM_UNDO*/
;
do
{
ret
=
semop
(
(
int
)
crit
->
Reserved
,
&
sop
,
1
);
}
while
((
ret
==
-
1
)
&&
(
errno
==
EINTR
));
}
else
{
MSG
(
"Uninitialized critical section (%p)
\n
"
,
crit
);
return
;
}
}
crit
->
OwningThread
=
GetCurrentThreadId
();
crit
->
OwningThread
=
GetCurrentThreadId
();
crit
->
RecursionCount
=
1
;
crit
->
RecursionCount
=
1
;
}
}
...
@@ -163,19 +112,8 @@ void WINAPI LeaveCriticalSection( CRITICAL_SECTION *crit )
...
@@ -163,19 +112,8 @@ void WINAPI LeaveCriticalSection( CRITICAL_SECTION *crit )
if
(
InterlockedDecrement
(
&
crit
->
LockCount
)
>=
0
)
if
(
InterlockedDecrement
(
&
crit
->
LockCount
)
>=
0
)
{
{
/* Someone is waiting */
/* Someone is waiting */
if
(
crit
->
LockSemaphore
)
{
ReleaseSemaphore
(
crit
->
LockSemaphore
,
1
,
NULL
);
ReleaseSemaphore
(
crit
->
LockSemaphore
,
1
,
NULL
);
}
}
else
if
(
crit
->
Reserved
!=
(
DWORD
)
-
1
)
{
struct
sembuf
sop
;
sop
.
sem_num
=
0
;
sop
.
sem_op
=
1
;
sop
.
sem_flg
=
0
/*SEM_UNDO*/
;
semop
(
(
int
)
crit
->
Reserved
,
&
sop
,
1
);
}
}
}
}
...
...
scheduler/event.c
View file @
96c08d81
...
@@ -7,19 +7,11 @@
...
@@ -7,19 +7,11 @@
#include <assert.h>
#include <assert.h>
#include <string.h>
#include <string.h>
#include "winerror.h"
#include "winerror.h"
#include "k32obj.h"
#include "process.h"
#include "thread.h"
#include "heap.h"
#include "heap.h"
#include "syslevel.h"
#include "syslevel.h"
#include "server/request.h"
#include "server/request.h"
#include "server.h"
#include "server.h"
typedef
struct
{
K32OBJ
header
;
}
EVENT
;
/***********************************************************************
/***********************************************************************
* CreateEvent32A (KERNEL32.156)
* CreateEvent32A (KERNEL32.156)
...
@@ -30,25 +22,14 @@ HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
...
@@ -30,25 +22,14 @@ HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
struct
create_event_request
req
;
struct
create_event_request
req
;
struct
create_event_reply
reply
;
struct
create_event_reply
reply
;
int
len
=
name
?
strlen
(
name
)
+
1
:
0
;
int
len
=
name
?
strlen
(
name
)
+
1
:
0
;
HANDLE
handle
;
EVENT
*
event
;
req
.
manual_reset
=
manual_reset
;
req
.
manual_reset
=
manual_reset
;
req
.
initial_state
=
initial_state
;
req
.
initial_state
=
initial_state
;
req
.
inherit
=
(
sa
&&
(
sa
->
nLength
>=
sizeof
(
*
sa
))
&&
sa
->
bInheritHandle
);
req
.
inherit
=
(
sa
&&
(
sa
->
nLength
>=
sizeof
(
*
sa
))
&&
sa
->
bInheritHandle
);
CLIENT_SendRequest
(
REQ_CREATE_EVENT
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
name
,
len
);
CLIENT_SendRequest
(
REQ_CREATE_EVENT
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
name
,
len
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
if
(
reply
.
handle
==
-
1
)
return
0
;
if
(
reply
.
handle
==
-
1
)
return
0
;
return
reply
.
handle
;
SYSTEM_LOCK
();
event
=
(
EVENT
*
)
K32OBJ_Create
(
K32OBJ_EVENT
,
sizeof
(
*
event
),
name
,
reply
.
handle
,
EVENT_ALL_ACCESS
,
sa
,
&
handle
);
if
(
event
)
K32OBJ_DecCount
(
&
event
->
header
);
SYSTEM_UNLOCK
();
if
(
handle
==
INVALID_HANDLE_VALUE
)
handle
=
0
;
return
handle
;
}
}
...
@@ -78,8 +59,6 @@ HANDLE WINAPI WIN16_CreateEvent( BOOL manual_reset, BOOL initial_state )
...
@@ -78,8 +59,6 @@ HANDLE WINAPI WIN16_CreateEvent( BOOL manual_reset, BOOL initial_state )
*/
*/
HANDLE
WINAPI
OpenEventA
(
DWORD
access
,
BOOL
inherit
,
LPCSTR
name
)
HANDLE
WINAPI
OpenEventA
(
DWORD
access
,
BOOL
inherit
,
LPCSTR
name
)
{
{
HANDLE
handle
=
0
;
K32OBJ
*
obj
;
struct
open_named_obj_request
req
;
struct
open_named_obj_request
req
;
struct
open_named_obj_reply
reply
;
struct
open_named_obj_reply
reply
;
int
len
=
name
?
strlen
(
name
)
+
1
:
0
;
int
len
=
name
?
strlen
(
name
)
+
1
:
0
;
...
@@ -89,20 +68,8 @@ HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name )
...
@@ -89,20 +68,8 @@ HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name )
req
.
inherit
=
inherit
;
req
.
inherit
=
inherit
;
CLIENT_SendRequest
(
REQ_OPEN_NAMED_OBJ
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
name
,
len
);
CLIENT_SendRequest
(
REQ_OPEN_NAMED_OBJ
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
name
,
len
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
if
(
reply
.
handle
!=
-
1
)
if
(
reply
.
handle
==
-
1
)
return
0
;
/* must return 0 on failure, not -1 */
{
return
(
HANDLE
)
reply
.
handle
;
SYSTEM_LOCK
();
if
((
obj
=
K32OBJ_FindNameType
(
name
,
K32OBJ_EVENT
))
!=
NULL
)
{
handle
=
HANDLE_Alloc
(
PROCESS_Current
(),
obj
,
access
,
inherit
,
reply
.
handle
);
K32OBJ_DecCount
(
obj
);
if
(
handle
==
INVALID_HANDLE_VALUE
)
handle
=
0
;
/* must return 0 on failure, not -1 */
}
else
CLIENT_CloseHandle
(
reply
.
handle
);
SYSTEM_UNLOCK
();
}
return
handle
;
}
}
...
@@ -127,9 +94,7 @@ static BOOL EVENT_Operation( HANDLE handle, enum event_op op )
...
@@ -127,9 +94,7 @@ static BOOL EVENT_Operation( HANDLE handle, enum event_op op )
{
{
struct
event_op_request
req
;
struct
event_op_request
req
;
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handle
,
req
.
handle
=
handle
;
K32OBJ_EVENT
,
EVENT_MODIFY_STATE
);
if
(
req
.
handle
==
-
1
)
return
FALSE
;
req
.
op
=
op
;
req
.
op
=
op
;
CLIENT_SendRequest
(
REQ_EVENT_OP
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_EVENT_OP
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
...
...
scheduler/handle.c
View file @
96c08d81
...
@@ -7,296 +7,7 @@
...
@@ -7,296 +7,7 @@
#include <assert.h>
#include <assert.h>
#include <stdio.h>
#include <stdio.h>
#include "winbase.h"
#include "winbase.h"
#include "winerror.h"
#include "heap.h"
#include "process.h"
#include "server.h"
#include "server.h"
#include "thread.h"
#include "debug.h"
#define HTABLE_SIZE 0x30
/* Handle table initial size */
#define HTABLE_INC 0x10
/* Handle table increment */
/* Reserved access rights */
#define RESERVED_ALL (0x0007 << RESERVED_SHIFT)
#define RESERVED_SHIFT 25
#define RESERVED_INHERIT (HANDLE_FLAG_INHERIT<<RESERVED_SHIFT)
#define RESERVED_CLOSE_PROTECT (HANDLE_FLAG_PROTECT_FROM_CLOSE<<RESERVED_SHIFT)
/***********************************************************************
* HANDLE_GrowTable
*/
static
BOOL
HANDLE_GrowTable
(
PDB
*
process
,
INT
incr
)
{
HANDLE_TABLE
*
table
;
SYSTEM_LOCK
();
table
=
process
->
handle_table
;
table
=
HeapReAlloc
(
process
->
system_heap
,
HEAP_ZERO_MEMORY
|
HEAP_NO_SERIALIZE
,
table
,
sizeof
(
HANDLE_TABLE
)
+
(
table
->
count
+
incr
-
1
)
*
sizeof
(
HANDLE_ENTRY
)
);
if
(
table
)
{
table
->
count
+=
incr
;
process
->
handle_table
=
table
;
}
SYSTEM_UNLOCK
();
return
(
table
!=
NULL
);
}
/***********************************************************************
* HANDLE_CreateTable
*
* Create a process handle table, optionally inheriting the parent's handles.
*/
BOOL
HANDLE_CreateTable
(
PDB
*
pdb
,
BOOL
inherit
)
{
DWORD
size
;
/* Process must not already have a handle table */
assert
(
!
pdb
->
handle_table
);
/* If this is the first process, simply allocate a table */
if
(
!
pdb
->
parent
)
inherit
=
FALSE
;
SYSTEM_LOCK
();
size
=
inherit
?
pdb
->
parent
->
handle_table
->
count
:
HTABLE_SIZE
;
if
((
pdb
->
handle_table
=
HeapAlloc
(
pdb
->
system_heap
,
HEAP_ZERO_MEMORY
|
HEAP_NO_SERIALIZE
,
sizeof
(
HANDLE_TABLE
)
+
(
size
-
1
)
*
sizeof
(
HANDLE_ENTRY
)
)))
{
pdb
->
handle_table
->
count
=
size
;
if
(
inherit
)
{
HANDLE_ENTRY
*
src
=
pdb
->
parent
->
handle_table
->
entries
;
HANDLE_ENTRY
*
dst
=
pdb
->
handle_table
->
entries
;
HANDLE
h
;
for
(
h
=
0
;
h
<
size
;
h
++
,
src
++
,
dst
++
)
{
/* Check if handle is valid and inheritable */
if
(
src
->
ptr
&&
(
src
->
access
&
RESERVED_INHERIT
))
{
dst
->
access
=
src
->
access
;
dst
->
ptr
=
src
->
ptr
;
dst
->
server
=
src
->
server
;
K32OBJ_IncCount
(
dst
->
ptr
);
}
}
}
/* Handle 1 is the process itself (unless the parent decided otherwise) */
if
(
!
pdb
->
handle_table
->
entries
[
1
].
ptr
)
{
pdb
->
handle_table
->
entries
[
1
].
ptr
=
&
pdb
->
header
;
pdb
->
handle_table
->
entries
[
1
].
access
=
PROCESS_ALL_ACCESS
;
pdb
->
handle_table
->
entries
[
1
].
server
=
-
1
;
/* FIXME */
K32OBJ_IncCount
(
&
pdb
->
header
);
}
}
SYSTEM_UNLOCK
();
return
(
pdb
->
handle_table
!=
NULL
);
}
/***********************************************************************
* HANDLE_Alloc
*
* Allocate a handle for a kernel object and increment its refcount.
*/
HANDLE
HANDLE_Alloc
(
PDB
*
pdb
,
K32OBJ
*
ptr
,
DWORD
access
,
BOOL
inherit
,
int
server_handle
)
{
HANDLE
h
;
HANDLE_ENTRY
*
entry
;
assert
(
ptr
);
/* Set the inherit reserved flag */
access
&=
~
RESERVED_ALL
;
if
(
inherit
)
access
|=
RESERVED_INHERIT
;
SYSTEM_LOCK
();
K32OBJ_IncCount
(
ptr
);
/* Don't try to allocate handle 0 */
entry
=
pdb
->
handle_table
->
entries
+
1
;
for
(
h
=
1
;
h
<
pdb
->
handle_table
->
count
;
h
++
,
entry
++
)
if
(
!
entry
->
ptr
)
break
;
if
((
h
<
pdb
->
handle_table
->
count
)
||
HANDLE_GrowTable
(
pdb
,
HTABLE_INC
))
{
entry
=
&
pdb
->
handle_table
->
entries
[
h
];
entry
->
access
=
access
;
entry
->
ptr
=
ptr
;
entry
->
server
=
server_handle
;
SYSTEM_UNLOCK
();
return
h
;
}
K32OBJ_DecCount
(
ptr
);
SYSTEM_UNLOCK
();
if
(
server_handle
!=
-
1
)
CLIENT_CloseHandle
(
server_handle
);
SetLastError
(
ERROR_OUTOFMEMORY
);
return
INVALID_HANDLE_VALUE
;
}
/***********************************************************************
* HANDLE_GetObjPtr
*
* Retrieve a pointer to a kernel object and increments its reference count.
* The refcount must be decremented when the pointer is no longer used.
*/
K32OBJ
*
HANDLE_GetObjPtr
(
PDB
*
pdb
,
HANDLE
handle
,
K32OBJ_TYPE
type
,
DWORD
access
,
int
*
server_handle
)
{
K32OBJ
*
ptr
=
NULL
;
SYSTEM_LOCK
();
if
(
HANDLE_IS_GLOBAL
(
handle
))
{
handle
=
HANDLE_GLOBAL_TO_LOCAL
(
handle
);
pdb
=
PROCESS_Initial
();
}
if
((
handle
>
0
)
&&
(
handle
<
pdb
->
handle_table
->
count
))
{
HANDLE_ENTRY
*
entry
=
&
pdb
->
handle_table
->
entries
[
handle
];
if
((
entry
->
access
&
access
)
!=
access
)
WARN
(
win32
,
"Handle %08x bad access (acc=%08lx req=%08lx)
\n
"
,
handle
,
entry
->
access
,
access
);
ptr
=
entry
->
ptr
;
if
(
server_handle
)
*
server_handle
=
entry
->
server
;
}
else
if
(
handle
==
CURRENT_THREAD_PSEUDOHANDLE
)
{
ptr
=
(
K32OBJ
*
)
THREAD_Current
();
if
(
server_handle
)
*
server_handle
=
CURRENT_THREAD_PSEUDOHANDLE
;
}
else
if
(
handle
==
CURRENT_PROCESS_PSEUDOHANDLE
)
{
ptr
=
(
K32OBJ
*
)
PROCESS_Current
();
if
(
server_handle
)
*
server_handle
=
CURRENT_PROCESS_PSEUDOHANDLE
;
}
if
(
ptr
&&
((
type
==
K32OBJ_UNKNOWN
)
||
(
ptr
->
type
==
type
)))
K32OBJ_IncCount
(
ptr
);
else
ptr
=
NULL
;
SYSTEM_UNLOCK
();
if
(
!
ptr
)
SetLastError
(
ERROR_INVALID_HANDLE
);
return
ptr
;
}
/***********************************************************************
* HANDLE_GetServerHandle
*
* Retrieve the server handle associated to an object.
*/
int
HANDLE_GetServerHandle
(
PDB
*
pdb
,
HANDLE
handle
,
K32OBJ_TYPE
type
,
DWORD
access
)
{
int
server_handle
;
K32OBJ
*
obj
;
SYSTEM_LOCK
();
if
((
obj
=
HANDLE_GetObjPtr
(
pdb
,
handle
,
type
,
access
,
&
server_handle
)))
K32OBJ_DecCount
(
obj
);
else
server_handle
=
-
1
;
SYSTEM_UNLOCK
();
return
server_handle
;
}
/*********************************************************************
* HANDLE_GetAccess
*/
static
BOOL
HANDLE_GetAccess
(
PDB
*
pdb
,
HANDLE
handle
,
LPDWORD
access
)
{
BOOL
ret
=
FALSE
;
SYSTEM_LOCK
();
if
((
handle
>
0
)
&&
(
handle
<
pdb
->
handle_table
->
count
))
{
HANDLE_ENTRY
*
entry
=
&
pdb
->
handle_table
->
entries
[
handle
];
if
(
entry
->
ptr
)
{
*
access
=
entry
->
access
&
~
RESERVED_ALL
;
ret
=
TRUE
;
}
}
SYSTEM_UNLOCK
();
if
(
!
ret
)
SetLastError
(
ERROR_INVALID_HANDLE
);
return
ret
;
}
/*********************************************************************
* HANDLE_Close
*/
static
BOOL
HANDLE_Close
(
PDB
*
pdb
,
HANDLE
handle
)
{
BOOL
ret
=
FALSE
;
K32OBJ
*
ptr
;
if
(
HANDLE_IS_GLOBAL
(
handle
))
{
handle
=
HANDLE_GLOBAL_TO_LOCAL
(
handle
);
pdb
=
PROCESS_Initial
();
}
SYSTEM_LOCK
();
if
((
handle
>
0
)
&&
(
handle
<
pdb
->
handle_table
->
count
))
{
HANDLE_ENTRY
*
entry
=
&
pdb
->
handle_table
->
entries
[
handle
];
if
((
ptr
=
entry
->
ptr
))
{
if
(
!
(
entry
->
access
&
RESERVED_CLOSE_PROTECT
))
{
entry
->
access
=
0
;
entry
->
ptr
=
NULL
;
if
(
entry
->
server
!=
-
1
)
CLIENT_CloseHandle
(
entry
->
server
);
K32OBJ_DecCount
(
ptr
);
ret
=
TRUE
;
}
/* FIXME: else SetLastError */
}
}
SYSTEM_UNLOCK
();
if
(
!
ret
)
SetLastError
(
ERROR_INVALID_HANDLE
);
return
ret
;
}
/*********************************************************************
* HANDLE_CloseAll
*
* Close all handles pointing to a given object (or all handles of the
* process if the object is NULL)
*/
void
HANDLE_CloseAll
(
PDB
*
pdb
,
K32OBJ
*
obj
)
{
HANDLE_ENTRY
*
entry
;
K32OBJ
*
ptr
;
HANDLE
handle
;
SYSTEM_LOCK
();
entry
=
pdb
->
handle_table
->
entries
;
for
(
handle
=
0
;
handle
<
pdb
->
handle_table
->
count
;
handle
++
,
entry
++
)
{
if
(
!
(
ptr
=
entry
->
ptr
))
continue
;
/* empty slot */
if
(
obj
&&
(
ptr
!=
obj
))
continue
;
/* not the right object */
entry
->
access
=
0
;
entry
->
ptr
=
NULL
;
if
(
entry
->
server
!=
-
1
)
CLIENT_CloseHandle
(
entry
->
server
);
K32OBJ_DecCount
(
ptr
);
}
SYSTEM_UNLOCK
();
}
/*********************************************************************
/*********************************************************************
...
@@ -304,7 +15,9 @@ void HANDLE_CloseAll( PDB *pdb, K32OBJ *obj )
...
@@ -304,7 +15,9 @@ void HANDLE_CloseAll( PDB *pdb, K32OBJ *obj )
*/
*/
BOOL
WINAPI
CloseHandle
(
HANDLE
handle
)
BOOL
WINAPI
CloseHandle
(
HANDLE
handle
)
{
{
return
HANDLE_Close
(
PROCESS_Current
(),
handle
);
struct
close_handle_request
req
=
{
handle
};
CLIENT_SendRequest
(
REQ_CLOSE_HANDLE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
}
}
...
@@ -313,23 +26,14 @@ BOOL WINAPI CloseHandle( HANDLE handle )
...
@@ -313,23 +26,14 @@ BOOL WINAPI CloseHandle( HANDLE handle )
*/
*/
BOOL
WINAPI
GetHandleInformation
(
HANDLE
handle
,
LPDWORD
flags
)
BOOL
WINAPI
GetHandleInformation
(
HANDLE
handle
,
LPDWORD
flags
)
{
{
BOOL
ret
=
FALSE
;
struct
get_handle_info_request
req
;
PDB
*
pdb
=
PROCESS_Current
();
struct
get_handle_info_reply
reply
;
SYSTEM_LOCK
();
req
.
handle
=
handle
;
if
((
handle
>
0
)
&&
(
handle
<
pdb
->
handle_table
->
count
))
CLIENT_SendRequest
(
REQ_GET_HANDLE_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
{
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
FALSE
;
HANDLE_ENTRY
*
entry
=
&
pdb
->
handle_table
->
entries
[
handle
];
if
(
flags
)
*
flags
=
reply
.
flags
;
if
(
entry
->
ptr
)
return
TRUE
;
{
if
(
flags
)
*
flags
=
(
entry
->
access
&
RESERVED_ALL
)
>>
RESERVED_SHIFT
;
ret
=
TRUE
;
}
}
SYSTEM_UNLOCK
();
if
(
!
ret
)
SetLastError
(
ERROR_INVALID_HANDLE
);
return
ret
;
}
}
...
@@ -338,24 +42,13 @@ BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
...
@@ -338,24 +42,13 @@ BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
*/
*/
BOOL
WINAPI
SetHandleInformation
(
HANDLE
handle
,
DWORD
mask
,
DWORD
flags
)
BOOL
WINAPI
SetHandleInformation
(
HANDLE
handle
,
DWORD
mask
,
DWORD
flags
)
{
{
BOOL
ret
=
FALSE
;
struct
set_handle_info_request
req
;
PDB
*
pdb
=
PROCESS_Current
();
mask
=
(
mask
<<
RESERVED_SHIFT
)
&
RESERVED_ALL
;
req
.
handle
=
handle
;
flags
=
(
flags
<<
RESERVED_SHIFT
)
&
RESERVED_ALL
;
req
.
flags
=
flags
;
SYSTEM_LOCK
();
req
.
mask
=
mask
;
if
((
handle
>
0
)
&&
(
handle
<
pdb
->
handle_table
->
count
))
CLIENT_SendRequest
(
REQ_SET_HANDLE_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
{
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
HANDLE_ENTRY
*
entry
=
&
pdb
->
handle_table
->
entries
[
handle
];
if
(
entry
->
ptr
)
{
entry
->
access
=
(
entry
->
access
&
~
mask
)
|
flags
;
ret
=
TRUE
;
}
}
SYSTEM_UNLOCK
();
if
(
!
ret
)
SetLastError
(
ERROR_INVALID_HANDLE
);
return
ret
;
}
}
...
@@ -366,52 +59,20 @@ BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
...
@@ -366,52 +59,20 @@ BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
HANDLE
dest_process
,
HANDLE
*
dest
,
HANDLE
dest_process
,
HANDLE
*
dest
,
DWORD
access
,
BOOL
inherit
,
DWORD
options
)
DWORD
access
,
BOOL
inherit
,
DWORD
options
)
{
{
PDB
*
src_pdb
=
NULL
,
*
dst_pdb
=
NULL
;
struct
dup_handle_request
req
;
K32OBJ
*
obj
=
NULL
;
struct
dup_handle_reply
reply
;
BOOL
ret
=
FALSE
;
HANDLE
handle
;
req
.
src_process
=
source_process
;
int
src_process
,
src_handle
,
dst_process
,
dst_handle
;
req
.
src_handle
=
source
;
req
.
dst_process
=
dest_process
;
SYSTEM_LOCK
();
req
.
access
=
access
;
req
.
inherit
=
inherit
;
if
(
!
(
src_pdb
=
(
PDB
*
)
HANDLE_GetObjPtr
(
PROCESS_Current
(),
source_process
,
req
.
options
=
options
;
K32OBJ_PROCESS
,
PROCESS_DUP_HANDLE
,
&
src_process
)))
goto
done
;
CLIENT_SendRequest
(
REQ_DUP_HANDLE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
!
(
obj
=
HANDLE_GetObjPtr
(
src_pdb
,
source
,
K32OBJ_UNKNOWN
,
0
,
&
src_handle
)))
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
FALSE
;
goto
done
;
if
(
dest
)
*
dest
=
reply
.
handle
;
return
TRUE
;
/* Now that we are sure the source is valid, handle the options */
if
(
options
&
DUPLICATE_SAME_ACCESS
)
HANDLE_GetAccess
(
src_pdb
,
source
,
&
access
);
if
(
options
&
DUPLICATE_CLOSE_SOURCE
)
HANDLE_Close
(
src_pdb
,
source
);
/* And duplicate the handle in the dest process */
if
(
!
(
dst_pdb
=
(
PDB
*
)
HANDLE_GetObjPtr
(
PROCESS_Current
(),
dest_process
,
K32OBJ_PROCESS
,
PROCESS_DUP_HANDLE
,
&
dst_process
)))
goto
done
;
if
((
src_process
!=
-
1
)
&&
(
src_handle
!=
-
1
)
&&
(
dst_process
!=
-
1
))
dst_handle
=
CLIENT_DuplicateHandle
(
src_process
,
src_handle
,
dst_process
,
-
1
,
access
,
inherit
,
options
);
else
dst_handle
=
-
1
;
if
((
handle
=
HANDLE_Alloc
(
dst_pdb
,
obj
,
access
,
inherit
,
dst_handle
))
!=
INVALID_HANDLE_VALUE
)
{
if
(
dest
)
*
dest
=
handle
;
ret
=
TRUE
;
}
done:
if
(
dst_pdb
)
K32OBJ_DecCount
(
&
dst_pdb
->
header
);
if
(
obj
)
K32OBJ_DecCount
(
obj
);
if
(
src_pdb
)
K32OBJ_DecCount
(
&
src_pdb
->
header
);
SYSTEM_UNLOCK
();
return
ret
;
}
}
...
@@ -420,31 +81,17 @@ done:
...
@@ -420,31 +81,17 @@ done:
*/
*/
HANDLE
WINAPI
ConvertToGlobalHandle
(
HANDLE
hSrc
)
HANDLE
WINAPI
ConvertToGlobalHandle
(
HANDLE
hSrc
)
{
{
int
src_handle
,
dst_handle
;
struct
dup_handle_request
req
;
HANDLE
handle
;
struct
dup_handle_reply
reply
;
K32OBJ
*
obj
=
NULL
;
DWORD
access
;
req
.
src_process
=
GetCurrentProcess
();
req
.
src_handle
=
hSrc
;
if
(
HANDLE_IS_GLOBAL
(
hSrc
))
req
.
dst_process
=
-
1
;
return
hSrc
;
req
.
access
=
0
;
req
.
inherit
=
FALSE
;
if
(
!
(
obj
=
HANDLE_GetObjPtr
(
PROCESS_Current
(),
hSrc
,
K32OBJ_UNKNOWN
,
0
,
&
src_handle
)))
req
.
options
=
DUP_HANDLE_MAKE_GLOBAL
|
DUP_HANDLE_SAME_ACCESS
;
return
0
;
CLIENT_SendRequest
(
REQ_DUP_HANDLE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
HANDLE_GetAccess
(
PROCESS_Current
(),
hSrc
,
&
access
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
return
reply
.
handle
;
if
(
src_handle
!=
-
1
)
dst_handle
=
CLIENT_DuplicateHandle
(
GetCurrentProcess
(),
src_handle
,
-
1
,
-
1
,
0
,
FALSE
,
DUP_HANDLE_MAKE_GLOBAL
|
DUP_HANDLE_SAME_ACCESS
);
else
dst_handle
=
-
1
;
if
((
handle
=
HANDLE_Alloc
(
PROCESS_Initial
(),
obj
,
access
,
FALSE
,
dst_handle
))
!=
INVALID_HANDLE_VALUE
)
handle
=
HANDLE_LOCAL_TO_GLOBAL
(
handle
);
else
handle
=
0
;
CloseHandle
(
hSrc
);
return
handle
;
}
}
scheduler/k32obj.c
deleted
100644 → 0
View file @
ee517e86
/*
* KERNEL32 objects
*
* Copyright 1996 Alexandre Julliard
*/
#include <assert.h>
#include <string.h>
#include "winerror.h"
#include "k32obj.h"
#include "heap.h"
#include "process.h"
#include "server.h"
/* The declarations are here to avoid including a lot of unnecessary files */
extern
const
K32OBJ_OPS
PROCESS_Ops
;
extern
const
K32OBJ_OPS
THREAD_Ops
;
static
const
K32OBJ_OPS
K32OBJ_NullOps
=
{
NULL
/* destroy */
};
static
void
K32OBJ_Destroy
(
K32OBJ
*
obj
);
static
const
K32OBJ_OPS
K32OBJ_DefaultOps
=
{
K32OBJ_Destroy
/* destroy */
};
const
K32OBJ_OPS
*
const
K32OBJ_Ops
[
K32OBJ_NBOBJECTS
]
=
{
NULL
,
&
K32OBJ_DefaultOps
,
/* K32OBJ_SEMAPHORE */
&
K32OBJ_DefaultOps
,
/* K32OBJ_EVENT */
&
K32OBJ_DefaultOps
,
/* K32OBJ_MUTEX */
&
K32OBJ_NullOps
,
/* K32OBJ_CRITICAL_SECTION */
&
PROCESS_Ops
,
/* K32OBJ_PROCESS */
&
THREAD_Ops
,
/* K32OBJ_THREAD */
&
K32OBJ_DefaultOps
,
/* K32OBJ_FILE */
&
K32OBJ_DefaultOps
,
/* K32OBJ_CHANGE */
&
K32OBJ_DefaultOps
,
/* K32OBJ_CONSOLE */
&
K32OBJ_NullOps
,
/* K32OBJ_SCREEN_BUFFER */
&
K32OBJ_DefaultOps
,
/* K32OBJ_MEM_MAPPED_FILE */
&
K32OBJ_NullOps
,
/* K32OBJ_SERIAL */
&
K32OBJ_NullOps
,
/* K32OBJ_DEVICE_IOCTL */
&
K32OBJ_DefaultOps
,
/* K32OBJ_PIPE */
&
K32OBJ_NullOps
,
/* K32OBJ_MAILSLOT */
&
K32OBJ_DefaultOps
,
/* K32OBJ_TOOLHELP_SNAPSHOT */
&
K32OBJ_NullOps
/* K32OBJ_SOCKET */
};
typedef
struct
_NE
{
struct
_NE
*
next
;
K32OBJ
*
obj
;
UINT
len
;
char
name
[
1
];
}
NAME_ENTRY
;
static
NAME_ENTRY
*
K32OBJ_FirstEntry
=
NULL
;
/***********************************************************************
* K32OBJ_IncCount
*/
void
K32OBJ_IncCount
(
K32OBJ
*
ptr
)
{
assert
(
ptr
->
type
&&
((
unsigned
)
ptr
->
type
<
K32OBJ_NBOBJECTS
)
);
SYSTEM_LOCK
();
ptr
->
refcount
++
;
SYSTEM_UNLOCK
();
assert
(
ptr
->
refcount
>
0
);
/* No wrap-around allowed */
}
/***********************************************************************
* K32OBJ_DecCount
*/
void
K32OBJ_DecCount
(
K32OBJ
*
ptr
)
{
NAME_ENTRY
**
pptr
;
assert
(
ptr
->
type
&&
((
unsigned
)
ptr
->
type
<
K32OBJ_NBOBJECTS
)
);
assert
(
ptr
->
refcount
>
0
);
SYSTEM_LOCK
();
if
(
--
ptr
->
refcount
)
{
SYSTEM_UNLOCK
();
return
;
}
/* Check if the object has a name entry and free it */
pptr
=
&
K32OBJ_FirstEntry
;
while
(
*
pptr
&&
((
*
pptr
)
->
obj
!=
ptr
))
pptr
=
&
(
*
pptr
)
->
next
;
if
(
*
pptr
)
{
NAME_ENTRY
*
entry
=
*
pptr
;
*
pptr
=
entry
->
next
;
HeapFree
(
SystemHeap
,
0
,
entry
);
}
/* Free the object */
if
(
K32OBJ_Ops
[
ptr
->
type
]
->
destroy
)
K32OBJ_Ops
[
ptr
->
type
]
->
destroy
(
ptr
);
SYSTEM_UNLOCK
();
}
/***********************************************************************
* K32OBJ_Destroy
*
* Generic destroy functions for objects that don't need any special treatment.
*/
static
void
K32OBJ_Destroy
(
K32OBJ
*
obj
)
{
obj
->
type
=
K32OBJ_UNKNOWN
;
HeapFree
(
SystemHeap
,
0
,
obj
);
}
/***********************************************************************
* K32OBJ_IsValid
*
* Check if a pointer is a valid kernel object
*/
BOOL
K32OBJ_IsValid
(
K32OBJ
*
ptr
,
K32OBJ_TYPE
type
)
{
if
(
IsBadReadPtr
(
ptr
,
sizeof
(
*
ptr
)
))
return
FALSE
;
return
(
ptr
->
type
==
type
);
}
/***********************************************************************
* K32OBJ_AddName
*
* Add a name entry for an object. We don't check for duplicates here.
* FIXME: should use some sort of hashing.
*/
BOOL
K32OBJ_AddName
(
K32OBJ
*
obj
,
LPCSTR
name
)
{
NAME_ENTRY
*
entry
;
UINT
len
;
if
(
!
name
)
return
TRUE
;
/* Anonymous object */
len
=
strlen
(
name
);
SYSTEM_LOCK
();
if
(
!
(
entry
=
HeapAlloc
(
SystemHeap
,
0
,
sizeof
(
NAME_ENTRY
)
+
len
)))
{
SYSTEM_UNLOCK
();
SetLastError
(
ERROR_OUTOFMEMORY
);
return
FALSE
;
}
entry
->
next
=
K32OBJ_FirstEntry
;
entry
->
obj
=
obj
;
entry
->
len
=
len
;
lstrcpyA
(
entry
->
name
,
name
);
K32OBJ_FirstEntry
=
entry
;
SYSTEM_UNLOCK
();
return
TRUE
;
}
/***********************************************************************
* K32OBJ_Create
*
* Create a named kernel object.
* Returns NULL if there was an error _or_ if the object already existed.
* The refcount of the object must be decremented once it is initialized.
*/
K32OBJ
*
K32OBJ_Create
(
K32OBJ_TYPE
type
,
DWORD
size
,
LPCSTR
name
,
int
server_handle
,
DWORD
access
,
SECURITY_ATTRIBUTES
*
sa
,
HANDLE
*
handle
)
{
BOOL
inherit
=
(
sa
&&
(
sa
->
nLength
>=
sizeof
(
*
sa
))
&&
sa
->
bInheritHandle
);
/* Check if the name already exists */
K32OBJ
*
obj
=
K32OBJ_FindName
(
name
);
if
(
obj
)
{
if
(
obj
->
type
==
type
)
{
SetLastError
(
ERROR_ALREADY_EXISTS
);
*
handle
=
HANDLE_Alloc
(
PROCESS_Current
(),
obj
,
access
,
inherit
,
server_handle
);
}
else
{
SetLastError
(
ERROR_DUP_NAME
);
*
handle
=
INVALID_HANDLE_VALUE
;
if
(
server_handle
!=
-
1
)
CLIENT_CloseHandle
(
server_handle
);
}
K32OBJ_DecCount
(
obj
);
return
NULL
;
}
/* Create the object */
SYSTEM_LOCK
();
if
(
!
(
obj
=
HeapAlloc
(
SystemHeap
,
0
,
size
)))
{
SYSTEM_UNLOCK
();
*
handle
=
INVALID_HANDLE_VALUE
;
if
(
server_handle
!=
-
1
)
CLIENT_CloseHandle
(
server_handle
);
return
NULL
;
}
obj
->
type
=
type
;
obj
->
refcount
=
1
;
/* Add a name for it */
if
(
!
K32OBJ_AddName
(
obj
,
name
))
{
/* Don't call the destroy function, as the object wasn't
* initialized properly */
HeapFree
(
SystemHeap
,
0
,
obj
);
SYSTEM_UNLOCK
();
*
handle
=
INVALID_HANDLE_VALUE
;
if
(
server_handle
!=
-
1
)
CLIENT_CloseHandle
(
server_handle
);
return
NULL
;
}
/* Allocate a handle */
*
handle
=
HANDLE_Alloc
(
PROCESS_Current
(),
obj
,
access
,
inherit
,
server_handle
);
SYSTEM_UNLOCK
();
return
obj
;
}
/***********************************************************************
* K32OBJ_FindName
*
* Find the object referenced by a given name.
* The reference count is incremented.
*/
K32OBJ
*
K32OBJ_FindName
(
LPCSTR
name
)
{
NAME_ENTRY
*
entry
;
UINT
len
;
if
(
!
name
)
return
NULL
;
/* Anonymous object */
len
=
strlen
(
name
);
SYSTEM_LOCK
();
entry
=
K32OBJ_FirstEntry
;
while
(
entry
)
{
if
((
len
==
entry
->
len
)
&&
!
strcmp
(
name
,
entry
->
name
))
{
K32OBJ
*
obj
=
entry
->
obj
;
K32OBJ_IncCount
(
obj
);
SYSTEM_UNLOCK
();
return
entry
->
obj
;
}
entry
=
entry
->
next
;
}
SYSTEM_UNLOCK
();
return
NULL
;
}
/***********************************************************************
* K32OBJ_FindNameType
*
* Find an object by name and check its type.
* The reference count is incremented.
*/
K32OBJ
*
K32OBJ_FindNameType
(
LPCSTR
name
,
K32OBJ_TYPE
type
)
{
K32OBJ
*
obj
=
K32OBJ_FindName
(
name
);
if
(
!
obj
)
return
NULL
;
if
(
obj
->
type
==
type
)
return
obj
;
SetLastError
(
ERROR_DUP_NAME
);
K32OBJ_DecCount
(
obj
);
return
NULL
;
}
scheduler/mutex.c
View file @
96c08d81
...
@@ -7,18 +7,10 @@
...
@@ -7,18 +7,10 @@
#include <assert.h>
#include <assert.h>
#include <string.h>
#include <string.h>
#include "winerror.h"
#include "winerror.h"
#include "k32obj.h"
#include "process.h"
#include "thread.h"
#include "heap.h"
#include "heap.h"
#include "server/request.h"
#include "server/request.h"
#include "server.h"
#include "server.h"
typedef
struct
_MUTEX
{
K32OBJ
header
;
}
MUTEX
;
/***********************************************************************
/***********************************************************************
* CreateMutex32A (KERNEL32.166)
* CreateMutex32A (KERNEL32.166)
...
@@ -29,24 +21,13 @@ HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner,
...
@@ -29,24 +21,13 @@ HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner,
struct
create_mutex_request
req
;
struct
create_mutex_request
req
;
struct
create_mutex_reply
reply
;
struct
create_mutex_reply
reply
;
int
len
=
name
?
strlen
(
name
)
+
1
:
0
;
int
len
=
name
?
strlen
(
name
)
+
1
:
0
;
HANDLE
handle
;
MUTEX
*
mutex
;
req
.
owned
=
owner
;
req
.
owned
=
owner
;
req
.
inherit
=
(
sa
&&
(
sa
->
nLength
>=
sizeof
(
*
sa
))
&&
sa
->
bInheritHandle
);
req
.
inherit
=
(
sa
&&
(
sa
->
nLength
>=
sizeof
(
*
sa
))
&&
sa
->
bInheritHandle
);
CLIENT_SendRequest
(
REQ_CREATE_MUTEX
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
name
,
len
);
CLIENT_SendRequest
(
REQ_CREATE_MUTEX
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
name
,
len
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
if
(
reply
.
handle
==
-
1
)
return
0
;
if
(
reply
.
handle
==
-
1
)
return
0
;
return
reply
.
handle
;
SYSTEM_LOCK
();
mutex
=
(
MUTEX
*
)
K32OBJ_Create
(
K32OBJ_MUTEX
,
sizeof
(
*
mutex
),
name
,
reply
.
handle
,
MUTEX_ALL_ACCESS
,
sa
,
&
handle
);
if
(
mutex
)
K32OBJ_DecCount
(
&
mutex
->
header
);
if
(
handle
==
INVALID_HANDLE_VALUE
)
handle
=
0
;
SYSTEM_UNLOCK
();
return
handle
;
}
}
...
@@ -68,8 +49,6 @@ HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner,
...
@@ -68,8 +49,6 @@ HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner,
*/
*/
HANDLE
WINAPI
OpenMutexA
(
DWORD
access
,
BOOL
inherit
,
LPCSTR
name
)
HANDLE
WINAPI
OpenMutexA
(
DWORD
access
,
BOOL
inherit
,
LPCSTR
name
)
{
{
HANDLE
handle
=
0
;
K32OBJ
*
obj
;
struct
open_named_obj_request
req
;
struct
open_named_obj_request
req
;
struct
open_named_obj_reply
reply
;
struct
open_named_obj_reply
reply
;
int
len
=
name
?
strlen
(
name
)
+
1
:
0
;
int
len
=
name
?
strlen
(
name
)
+
1
:
0
;
...
@@ -79,20 +58,8 @@ HANDLE WINAPI OpenMutexA( DWORD access, BOOL inherit, LPCSTR name )
...
@@ -79,20 +58,8 @@ HANDLE WINAPI OpenMutexA( DWORD access, BOOL inherit, LPCSTR name )
req
.
inherit
=
inherit
;
req
.
inherit
=
inherit
;
CLIENT_SendRequest
(
REQ_OPEN_NAMED_OBJ
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
name
,
len
);
CLIENT_SendRequest
(
REQ_OPEN_NAMED_OBJ
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
name
,
len
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
if
(
reply
.
handle
!=
-
1
)
if
(
reply
.
handle
==
-
1
)
return
0
;
/* must return 0 on failure, not -1 */
{
return
reply
.
handle
;
SYSTEM_LOCK
();
if
((
obj
=
K32OBJ_FindNameType
(
name
,
K32OBJ_MUTEX
))
!=
NULL
)
{
handle
=
HANDLE_Alloc
(
PROCESS_Current
(),
obj
,
access
,
inherit
,
reply
.
handle
);
K32OBJ_DecCount
(
obj
);
if
(
handle
==
INVALID_HANDLE_VALUE
)
handle
=
0
;
/* must return 0 on failure, not -1 */
}
else
CLIENT_CloseHandle
(
reply
.
handle
);
SYSTEM_UNLOCK
();
}
return
handle
;
}
}
...
@@ -115,9 +82,7 @@ BOOL WINAPI ReleaseMutex( HANDLE handle )
...
@@ -115,9 +82,7 @@ BOOL WINAPI ReleaseMutex( HANDLE handle )
{
{
struct
release_mutex_request
req
;
struct
release_mutex_request
req
;
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handle
,
req
.
handle
=
handle
;
K32OBJ_MUTEX
,
MUTEX_MODIFY_STATE
);
if
(
req
.
handle
==
-
1
)
return
FALSE
;
CLIENT_SendRequest
(
REQ_RELEASE_MUTEX
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_RELEASE_MUTEX
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
}
}
scheduler/pipe.c
View file @
96c08d81
...
@@ -6,18 +6,10 @@
...
@@ -6,18 +6,10 @@
#include <assert.h>
#include <assert.h>
#include "winerror.h"
#include "winerror.h"
#include "k32obj.h"
#include "winbase.h"
#include "process.h"
#include "thread.h"
#include "heap.h"
#include "server/request.h"
#include "server/request.h"
#include "server.h"
#include "server.h"
typedef
struct
_PIPE
{
K32OBJ
header
;
}
PIPE
;
/***********************************************************************
/***********************************************************************
* CreatePipe (KERNEL32.170)
* CreatePipe (KERNEL32.170)
...
@@ -27,39 +19,13 @@ BOOL WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
...
@@ -27,39 +19,13 @@ BOOL WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
{
{
struct
create_pipe_request
req
;
struct
create_pipe_request
req
;
struct
create_pipe_reply
reply
;
struct
create_pipe_reply
reply
;
PIPE
*
read_pipe
,
*
write_pipe
;
int
len
;
int
len
;
req
.
inherit
=
(
sa
&&
(
sa
->
nLength
>=
sizeof
(
*
sa
))
&&
sa
->
bInheritHandle
);
req
.
inherit
=
(
sa
&&
(
sa
->
nLength
>=
sizeof
(
*
sa
))
&&
sa
->
bInheritHandle
);
CLIENT_SendRequest
(
REQ_CREATE_PIPE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_CREATE_PIPE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitReply
(
&
len
,
NULL
,
1
,
&
reply
,
sizeof
(
reply
)
)
!=
ERROR_SUCCESS
)
if
(
CLIENT_WaitReply
(
&
len
,
NULL
,
1
,
&
reply
,
sizeof
(
reply
)
)
!=
ERROR_SUCCESS
)
return
FALSE
;
return
FALSE
;
*
hReadPipe
=
reply
.
handle_read
;
SYSTEM_LOCK
();
*
hWritePipe
=
reply
.
handle_write
;
if
(
!
(
read_pipe
=
(
PIPE
*
)
K32OBJ_Create
(
K32OBJ_PIPE
,
sizeof
(
*
read_pipe
),
NULL
,
reply
.
handle_read
,
STANDARD_RIGHTS_REQUIRED
|
SYNCHRONIZE
|
GENERIC_READ
,
sa
,
hReadPipe
)))
{
CLIENT_CloseHandle
(
reply
.
handle_write
);
/* handle_read already closed by K32OBJ_Create */
SYSTEM_UNLOCK
();
return
FALSE
;
}
K32OBJ_DecCount
(
&
read_pipe
->
header
);
if
(
!
(
write_pipe
=
(
PIPE
*
)
K32OBJ_Create
(
K32OBJ_PIPE
,
sizeof
(
*
write_pipe
),
NULL
,
reply
.
handle_write
,
STANDARD_RIGHTS_REQUIRED
|
SYNCHRONIZE
|
GENERIC_WRITE
,
sa
,
hWritePipe
)))
{
CloseHandle
(
*
hReadPipe
);
*
hReadPipe
=
INVALID_HANDLE_VALUE
;
SYSTEM_UNLOCK
();
return
FALSE
;
}
/* everything OK */
K32OBJ_DecCount
(
&
write_pipe
->
header
);
SetLastError
(
0
);
/* FIXME */
SYSTEM_UNLOCK
();
return
TRUE
;
return
TRUE
;
}
}
scheduler/process.c
View file @
96c08d81
...
@@ -24,12 +24,6 @@
...
@@ -24,12 +24,6 @@
#include "server.h"
#include "server.h"
#include "debug.h"
#include "debug.h"
static
void
PROCESS_Destroy
(
K32OBJ
*
obj
);
const
K32OBJ_OPS
PROCESS_Ops
=
{
PROCESS_Destroy
/* destroy */
};
/* The initial process PDB */
/* The initial process PDB */
static
PDB
initial_pdb
;
static
PDB
initial_pdb
;
...
@@ -66,8 +60,7 @@ static BOOL PROCESS_QueryInfo( HANDLE handle,
...
@@ -66,8 +60,7 @@ static BOOL PROCESS_QueryInfo( HANDLE handle,
struct
get_process_info_reply
*
reply
)
struct
get_process_info_reply
*
reply
)
{
{
struct
get_process_info_request
req
;
struct
get_process_info_request
req
;
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handle
,
req
.
handle
=
handle
;
K32OBJ_PROCESS
,
PROCESS_QUERY_INFORMATION
);
CLIENT_SendRequest
(
REQ_GET_PROCESS_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_GET_PROCESS_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
return
!
CLIENT_WaitSimpleReply
(
reply
,
sizeof
(
*
reply
),
NULL
);
return
!
CLIENT_WaitSimpleReply
(
reply
,
sizeof
(
*
reply
),
NULL
);
}
}
...
@@ -190,12 +183,10 @@ static BOOL PROCESS_InheritEnvDB( PDB *pdb, LPCSTR cmd_line, LPCSTR env,
...
@@ -190,12 +183,10 @@ static BOOL PROCESS_InheritEnvDB( PDB *pdb, LPCSTR cmd_line, LPCSTR env,
*
*
* Free a PDB and all associated storage.
* Free a PDB and all associated storage.
*/
*/
static
void
PROCESS_FreePDB
(
PDB
*
pdb
)
void
PROCESS_FreePDB
(
PDB
*
pdb
)
{
{
PDB
**
pptr
=
&
PROCESS_First
;
PDB
**
pptr
=
&
PROCESS_First
;
pdb
->
header
.
type
=
K32OBJ_UNKNOWN
;
if
(
pdb
->
handle_table
)
HANDLE_CloseAll
(
pdb
,
NULL
);
ENV_FreeEnvironment
(
pdb
);
ENV_FreeEnvironment
(
pdb
);
while
(
*
pptr
&&
(
*
pptr
!=
pdb
))
pptr
=
&
(
*
pptr
)
->
next
;
while
(
*
pptr
&&
(
*
pptr
!=
pdb
))
pptr
=
&
(
*
pptr
)
->
next
;
if
(
*
pptr
)
*
pptr
=
pdb
->
next
;
if
(
*
pptr
)
*
pptr
=
pdb
->
next
;
...
@@ -216,8 +207,6 @@ static PDB *PROCESS_CreatePDB( PDB *parent, BOOL inherit )
...
@@ -216,8 +207,6 @@ static PDB *PROCESS_CreatePDB( PDB *parent, BOOL inherit )
PDB
*
pdb
=
HeapAlloc
(
SystemHeap
,
HEAP_ZERO_MEMORY
,
sizeof
(
PDB
)
);
PDB
*
pdb
=
HeapAlloc
(
SystemHeap
,
HEAP_ZERO_MEMORY
,
sizeof
(
PDB
)
);
if
(
!
pdb
)
return
NULL
;
if
(
!
pdb
)
return
NULL
;
pdb
->
header
.
type
=
K32OBJ_PROCESS
;
pdb
->
header
.
refcount
=
1
;
pdb
->
exit_code
=
0x103
;
/* STILL_ACTIVE */
pdb
->
exit_code
=
0x103
;
/* STILL_ACTIVE */
pdb
->
threads
=
1
;
pdb
->
threads
=
1
;
pdb
->
running_threads
=
1
;
pdb
->
running_threads
=
1
;
...
@@ -229,15 +218,7 @@ static PDB *PROCESS_CreatePDB( PDB *parent, BOOL inherit )
...
@@ -229,15 +218,7 @@ static PDB *PROCESS_CreatePDB( PDB *parent, BOOL inherit )
pdb
->
heap
=
pdb
->
system_heap
;
/* will be changed later on */
pdb
->
heap
=
pdb
->
system_heap
;
/* will be changed later on */
pdb
->
next
=
PROCESS_First
;
pdb
->
next
=
PROCESS_First
;
PROCESS_First
=
pdb
;
PROCESS_First
=
pdb
;
/* Create the handle table */
if
(
!
HANDLE_CreateTable
(
pdb
,
inherit
))
goto
error
;
return
pdb
;
return
pdb
;
error:
PROCESS_FreePDB
(
pdb
);
return
NULL
;
}
}
...
@@ -264,8 +245,6 @@ BOOL PROCESS_Init(void)
...
@@ -264,8 +245,6 @@ BOOL PROCESS_Init(void)
THDB
*
thdb
;
THDB
*
thdb
;
/* Fill the initial process structure */
/* Fill the initial process structure */
initial_pdb
.
header
.
type
=
K32OBJ_PROCESS
;
initial_pdb
.
header
.
refcount
=
1
;
initial_pdb
.
exit_code
=
0x103
;
/* STILL_ACTIVE */
initial_pdb
.
exit_code
=
0x103
;
/* STILL_ACTIVE */
initial_pdb
.
threads
=
1
;
initial_pdb
.
threads
=
1
;
initial_pdb
.
running_threads
=
1
;
initial_pdb
.
running_threads
=
1
;
...
@@ -276,17 +255,16 @@ BOOL PROCESS_Init(void)
...
@@ -276,17 +255,16 @@ BOOL PROCESS_Init(void)
/* Initialize virtual memory management */
/* Initialize virtual memory management */
if
(
!
VIRTUAL_Init
())
return
FALSE
;
if
(
!
VIRTUAL_Init
())
return
FALSE
;
/* Create the system heap */
/* Create the initial thread structure */
if
(
!
(
SystemHeap
=
HeapCreate
(
HEAP_GROWABLE
,
0x10000
,
0
)))
return
FALSE
;
initial_pdb
.
system_heap
=
initial_pdb
.
heap
=
SystemHeap
;
/* Create the initial process and thread structures */
if
(
!
HANDLE_CreateTable
(
&
initial_pdb
,
FALSE
))
return
FALSE
;
if
(
!
(
thdb
=
THREAD_CreateInitialThread
(
&
initial_pdb
)))
return
FALSE
;
if
(
!
(
thdb
=
THREAD_CreateInitialThread
(
&
initial_pdb
)))
return
FALSE
;
/* Remember TEB selector of initial process for emergency use */
/* Remember TEB selector of initial process for emergency use */
SYSLEVEL_EmergencyTeb
=
thdb
->
teb_sel
;
SYSLEVEL_EmergencyTeb
=
thdb
->
teb_sel
;
/* Create the system heap */
if
(
!
(
SystemHeap
=
HeapCreate
(
HEAP_GROWABLE
,
0x10000
,
0
)))
return
FALSE
;
initial_pdb
.
system_heap
=
initial_pdb
.
heap
=
SystemHeap
;
/* Create the environment DB of the first process */
/* Create the environment DB of the first process */
if
(
!
PROCESS_BuildEnvDB
(
&
initial_pdb
))
return
FALSE
;
if
(
!
PROCESS_BuildEnvDB
(
&
initial_pdb
))
return
FALSE
;
...
@@ -351,12 +329,8 @@ PDB *PROCESS_Create( NE_MODULE *pModule, LPCSTR cmd_line, LPCSTR env,
...
@@ -351,12 +329,8 @@ PDB *PROCESS_Create( NE_MODULE *pModule, LPCSTR cmd_line, LPCSTR env,
if
(
!
(
thdb
=
THREAD_Create
(
pdb
,
size
,
hInstance
==
0
,
if
(
!
(
thdb
=
THREAD_Create
(
pdb
,
size
,
hInstance
==
0
,
&
server_thandle
,
&
server_phandle
,
NULL
,
NULL
)))
&
server_thandle
,
&
server_phandle
,
NULL
,
NULL
)))
goto
error
;
goto
error
;
if
((
info
->
hThread
=
HANDLE_Alloc
(
parent
,
&
thdb
->
header
,
THREAD_ALL_ACCESS
,
info
->
hThread
=
server_thandle
;
FALSE
,
server_thandle
))
==
INVALID_HANDLE_VALUE
)
info
->
hProcess
=
server_phandle
;
goto
error
;
if
((
info
->
hProcess
=
HANDLE_Alloc
(
parent
,
&
pdb
->
header
,
PROCESS_ALL_ACCESS
,
FALSE
,
server_phandle
))
==
INVALID_HANDLE_VALUE
)
goto
error
;
info
->
dwProcessId
=
(
DWORD
)
pdb
->
server_pid
;
info
->
dwProcessId
=
(
DWORD
)
pdb
->
server_pid
;
info
->
dwThreadId
=
(
DWORD
)
thdb
->
server_tid
;
info
->
dwThreadId
=
(
DWORD
)
thdb
->
server_tid
;
...
@@ -391,28 +365,12 @@ PDB *PROCESS_Create( NE_MODULE *pModule, LPCSTR cmd_line, LPCSTR env,
...
@@ -391,28 +365,12 @@ PDB *PROCESS_Create( NE_MODULE *pModule, LPCSTR cmd_line, LPCSTR env,
error:
error:
if
(
info
->
hThread
!=
INVALID_HANDLE_VALUE
)
CloseHandle
(
info
->
hThread
);
if
(
info
->
hThread
!=
INVALID_HANDLE_VALUE
)
CloseHandle
(
info
->
hThread
);
if
(
info
->
hProcess
!=
INVALID_HANDLE_VALUE
)
CloseHandle
(
info
->
hProcess
);
if
(
info
->
hProcess
!=
INVALID_HANDLE_VALUE
)
CloseHandle
(
info
->
hProcess
);
if
(
thdb
)
K32OBJ_DecCount
(
&
thdb
->
header
);
PROCESS_FreePDB
(
pdb
);
PROCESS_FreePDB
(
pdb
);
return
NULL
;
return
NULL
;
}
}
/***********************************************************************
/***********************************************************************
* PROCESS_Destroy
*/
static
void
PROCESS_Destroy
(
K32OBJ
*
ptr
)
{
PDB
*
pdb
=
(
PDB
*
)
ptr
;
assert
(
ptr
->
type
==
K32OBJ_PROCESS
);
/* Free everything */
ptr
->
type
=
K32OBJ_UNKNOWN
;
PROCESS_FreePDB
(
pdb
);
}
/***********************************************************************
* ExitProcess (KERNEL32.100)
* ExitProcess (KERNEL32.100)
*/
*/
void
WINAPI
ExitProcess
(
DWORD
status
)
void
WINAPI
ExitProcess
(
DWORD
status
)
...
@@ -424,11 +382,9 @@ void WINAPI ExitProcess( DWORD status )
...
@@ -424,11 +382,9 @@ void WINAPI ExitProcess( DWORD status )
if
(
pTask
&&
pTask
->
thdb
!=
THREAD_Current
()
)
if
(
pTask
&&
pTask
->
thdb
!=
THREAD_Current
()
)
ExitThread
(
status
);
ExitThread
(
status
);
SYSTEM_LOCK
();
/* FIXME: should kill all running threads of this process */
/* FIXME: should kill all running threads of this process */
pdb
->
exit_code
=
status
;
pdb
->
exit_code
=
status
;
if
(
pdb
->
console
)
FreeConsole
();
FreeConsole
();
SYSTEM_UNLOCK
();
__RESTORE_ES
;
/* Necessary for Pietrek's showseh example program */
__RESTORE_ES
;
/* Necessary for Pietrek's showseh example program */
TASK_KillCurrentTask
(
status
);
TASK_KillCurrentTask
(
status
);
...
@@ -441,9 +397,7 @@ void WINAPI ExitProcess( DWORD status )
...
@@ -441,9 +397,7 @@ void WINAPI ExitProcess( DWORD status )
BOOL
WINAPI
TerminateProcess
(
HANDLE
handle
,
DWORD
exit_code
)
BOOL
WINAPI
TerminateProcess
(
HANDLE
handle
,
DWORD
exit_code
)
{
{
struct
terminate_process_request
req
;
struct
terminate_process_request
req
;
req
.
handle
=
handle
;
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handle
,
K32OBJ_PROCESS
,
PROCESS_TERMINATE
);
req
.
exit_code
=
exit_code
;
req
.
exit_code
=
exit_code
;
CLIENT_SendRequest
(
REQ_TERMINATE_PROCESS
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_TERMINATE_PROCESS
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
...
@@ -463,18 +417,15 @@ HANDLE WINAPI GetCurrentProcess(void)
...
@@ -463,18 +417,15 @@ HANDLE WINAPI GetCurrentProcess(void)
*/
*/
HANDLE
WINAPI
OpenProcess
(
DWORD
access
,
BOOL
inherit
,
DWORD
id
)
HANDLE
WINAPI
OpenProcess
(
DWORD
access
,
BOOL
inherit
,
DWORD
id
)
{
{
PDB
*
pdb
;
struct
open_process_request
req
;
struct
open_process_request
req
;
struct
open_process_reply
reply
;
struct
open_process_reply
reply
;
if
(
!
(
pdb
=
PROCESS_IdToPDB
(
id
)))
return
0
;
req
.
pid
=
(
void
*
)
id
;
req
.
pid
=
(
void
*
)
id
;
req
.
access
=
access
;
req
.
access
=
access
;
req
.
inherit
=
inherit
;
req
.
inherit
=
inherit
;
CLIENT_SendRequest
(
REQ_OPEN_PROCESS
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_OPEN_PROCESS
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
0
;
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
0
;
return
HANDLE_Alloc
(
PROCESS_Current
(),
&
pdb
->
header
,
access
,
return
reply
.
handle
;
inherit
,
reply
.
handle
);
}
}
...
@@ -512,9 +463,7 @@ LCID WINAPI GetThreadLocale(void)
...
@@ -512,9 +463,7 @@ LCID WINAPI GetThreadLocale(void)
BOOL
WINAPI
SetPriorityClass
(
HANDLE
hprocess
,
DWORD
priorityclass
)
BOOL
WINAPI
SetPriorityClass
(
HANDLE
hprocess
,
DWORD
priorityclass
)
{
{
struct
set_process_info_request
req
;
struct
set_process_info_request
req
;
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hprocess
,
req
.
handle
=
hprocess
;
K32OBJ_PROCESS
,
PROCESS_SET_INFORMATION
);
if
(
req
.
handle
==
-
1
)
return
FALSE
;
req
.
priority
=
priorityclass
;
req
.
priority
=
priorityclass
;
req
.
mask
=
SET_PROCESS_INFO_PRIORITY
;
req
.
mask
=
SET_PROCESS_INFO_PRIORITY
;
CLIENT_SendRequest
(
REQ_SET_PROCESS_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_SET_PROCESS_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
...
@@ -539,9 +488,7 @@ DWORD WINAPI GetPriorityClass(HANDLE hprocess)
...
@@ -539,9 +488,7 @@ DWORD WINAPI GetPriorityClass(HANDLE hprocess)
BOOL
WINAPI
SetProcessAffinityMask
(
HANDLE
hProcess
,
DWORD
affmask
)
BOOL
WINAPI
SetProcessAffinityMask
(
HANDLE
hProcess
,
DWORD
affmask
)
{
{
struct
set_process_info_request
req
;
struct
set_process_info_request
req
;
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hProcess
,
req
.
handle
=
hProcess
;
K32OBJ_PROCESS
,
PROCESS_SET_INFORMATION
);
if
(
req
.
handle
==
-
1
)
return
FALSE
;
req
.
affinity
=
affmask
;
req
.
affinity
=
affmask
;
req
.
mask
=
SET_PROCESS_INFO_AFFINITY
;
req
.
mask
=
SET_PROCESS_INFO_AFFINITY
;
CLIENT_SendRequest
(
REQ_SET_PROCESS_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_SET_PROCESS_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
...
...
scheduler/semaphore.c
View file @
96c08d81
...
@@ -7,18 +7,10 @@
...
@@ -7,18 +7,10 @@
#include <assert.h>
#include <assert.h>
#include <string.h>
#include <string.h>
#include "winerror.h"
#include "winerror.h"
#include "k32obj.h"
#include "process.h"
#include "thread.h"
#include "heap.h"
#include "heap.h"
#include "server/request.h"
#include "server/request.h"
#include "server.h"
#include "server.h"
typedef
struct
{
K32OBJ
header
;
}
SEMAPHORE
;
/***********************************************************************
/***********************************************************************
* CreateSemaphore32A (KERNEL32.174)
* CreateSemaphore32A (KERNEL32.174)
...
@@ -29,8 +21,6 @@ HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial,
...
@@ -29,8 +21,6 @@ HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial,
struct
create_semaphore_request
req
;
struct
create_semaphore_request
req
;
struct
create_semaphore_reply
reply
;
struct
create_semaphore_reply
reply
;
int
len
=
name
?
strlen
(
name
)
+
1
:
0
;
int
len
=
name
?
strlen
(
name
)
+
1
:
0
;
HANDLE
handle
;
SEMAPHORE
*
sem
;
/* Check parameters */
/* Check parameters */
...
@@ -47,15 +37,7 @@ HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial,
...
@@ -47,15 +37,7 @@ HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial,
CLIENT_SendRequest
(
REQ_CREATE_SEMAPHORE
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
name
,
len
);
CLIENT_SendRequest
(
REQ_CREATE_SEMAPHORE
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
name
,
len
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
if
(
reply
.
handle
==
-
1
)
return
0
;
if
(
reply
.
handle
==
-
1
)
return
0
;
return
reply
.
handle
;
SYSTEM_LOCK
();
sem
=
(
SEMAPHORE
*
)
K32OBJ_Create
(
K32OBJ_SEMAPHORE
,
sizeof
(
*
sem
),
name
,
reply
.
handle
,
SEMAPHORE_ALL_ACCESS
,
sa
,
&
handle
);
if
(
sem
)
K32OBJ_DecCount
(
&
sem
->
header
);
SYSTEM_UNLOCK
();
if
(
handle
==
INVALID_HANDLE_VALUE
)
handle
=
0
;
return
handle
;
}
}
...
@@ -77,8 +59,6 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
...
@@ -77,8 +59,6 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
*/
*/
HANDLE
WINAPI
OpenSemaphoreA
(
DWORD
access
,
BOOL
inherit
,
LPCSTR
name
)
HANDLE
WINAPI
OpenSemaphoreA
(
DWORD
access
,
BOOL
inherit
,
LPCSTR
name
)
{
{
HANDLE
handle
=
0
;
K32OBJ
*
obj
;
struct
open_named_obj_request
req
;
struct
open_named_obj_request
req
;
struct
open_named_obj_reply
reply
;
struct
open_named_obj_reply
reply
;
int
len
=
name
?
strlen
(
name
)
+
1
:
0
;
int
len
=
name
?
strlen
(
name
)
+
1
:
0
;
...
@@ -88,20 +68,8 @@ HANDLE WINAPI OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name )
...
@@ -88,20 +68,8 @@ HANDLE WINAPI OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name )
req
.
inherit
=
inherit
;
req
.
inherit
=
inherit
;
CLIENT_SendRequest
(
REQ_OPEN_NAMED_OBJ
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
name
,
len
);
CLIENT_SendRequest
(
REQ_OPEN_NAMED_OBJ
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
name
,
len
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
if
(
reply
.
handle
!=
-
1
)
if
(
reply
.
handle
==
-
1
)
return
0
;
/* must return 0 on failure, not -1 */
{
return
reply
.
handle
;
SYSTEM_LOCK
();
if
((
obj
=
K32OBJ_FindNameType
(
name
,
K32OBJ_SEMAPHORE
))
!=
NULL
)
{
handle
=
HANDLE_Alloc
(
PROCESS_Current
(),
obj
,
access
,
inherit
,
reply
.
handle
);
K32OBJ_DecCount
(
obj
);
if
(
handle
==
INVALID_HANDLE_VALUE
)
handle
=
0
;
/* must return 0 on failure, not -1 */
}
else
CLIENT_CloseHandle
(
reply
.
handle
);
SYSTEM_UNLOCK
();
}
return
handle
;
}
}
...
@@ -130,9 +98,7 @@ BOOL WINAPI ReleaseSemaphore( HANDLE handle, LONG count, LONG *previous )
...
@@ -130,9 +98,7 @@ BOOL WINAPI ReleaseSemaphore( HANDLE handle, LONG count, LONG *previous )
SetLastError
(
ERROR_INVALID_PARAMETER
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
return
FALSE
;
}
}
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handle
,
req
.
handle
=
handle
;
K32OBJ_SEMAPHORE
,
SEMAPHORE_MODIFY_STATE
);
if
(
req
.
handle
==
-
1
)
return
FALSE
;
req
.
count
=
(
unsigned
int
)
count
;
req
.
count
=
(
unsigned
int
)
count
;
CLIENT_SendRequest
(
REQ_RELEASE_SEMAPHORE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_RELEASE_SEMAPHORE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
FALSE
;
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
FALSE
;
...
...
scheduler/synchro.c
View file @
96c08d81
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
#include <signal.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/time.h>
#include <unistd.h>
#include <unistd.h>
#include "k32obj.h"
#include "heap.h"
#include "heap.h"
#include "process.h"
#include "process.h"
#include "thread.h"
#include "thread.h"
...
@@ -85,17 +84,7 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
...
@@ -85,17 +84,7 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
return
WAIT_FAILED
;
return
WAIT_FAILED
;
}
}
for
(
i
=
0
;
i
<
count
;
i
++
)
for
(
i
=
0
;
i
<
count
;
i
++
)
server_handle
[
i
]
=
handles
[
i
];
{
TRACE
(
win32
,
"handle %d is %08x
\n
"
,
i
,
handles
[
i
]);
server_handle
[
i
]
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handles
[
i
],
K32OBJ_UNKNOWN
,
SYNCHRONIZE
);
if
(
server_handle
[
i
]
==
-
1
)
{
ERR
(
win32
,
"No server handle for %08x
\n
"
,
handles
[
i
]
);
return
WAIT_FAILED
;
}
}
req
.
count
=
count
;
req
.
count
=
count
;
req
.
flags
=
0
;
req
.
flags
=
0
;
...
...
scheduler/sysdeps.c
View file @
96c08d81
...
@@ -119,11 +119,11 @@ int SYSDEPS_SpawnThread( THDB *thread )
...
@@ -119,11 +119,11 @@ int SYSDEPS_SpawnThread( THDB *thread )
* SYSDEPS_ExitThread
* SYSDEPS_ExitThread
*
*
* Exit a running thread; must not return.
* Exit a running thread; must not return.
* Must not make any reference to the thread structures (THDB etc.) as
* they have already been deleted.
*/
*/
void
SYSDEPS_ExitThread
(
void
)
void
SYSDEPS_ExitThread
(
void
)
{
{
THDB
*
thdb
=
THREAD_Current
();
close
(
thdb
->
socket
);
_exit
(
0
);
_exit
(
0
);
}
}
...
...
scheduler/thread.c
View file @
96c08d81
...
@@ -28,13 +28,6 @@
...
@@ -28,13 +28,6 @@
THDB
*
pCurrentThread
;
THDB
*
pCurrentThread
;
#endif
#endif
static
void
THREAD_Destroy
(
K32OBJ
*
obj
);
const
K32OBJ_OPS
THREAD_Ops
=
{
THREAD_Destroy
/* destroy */
};
/* Is threading code initialized? */
/* Is threading code initialized? */
BOOL
THREAD_InitDone
=
FALSE
;
BOOL
THREAD_InitDone
=
FALSE
;
...
@@ -173,8 +166,6 @@ THDB *THREAD_CreateInitialThread( PDB *pdb )
...
@@ -173,8 +166,6 @@ THDB *THREAD_CreateInitialThread( PDB *pdb )
extern
void
server_init
(
int
fd
);
extern
void
server_init
(
int
fd
);
extern
void
select_loop
(
void
);
extern
void
select_loop
(
void
);
initial_thdb
.
header
.
type
=
K32OBJ_THREAD
;
initial_thdb
.
header
.
refcount
=
1
;
initial_thdb
.
process
=
pdb
;
initial_thdb
.
process
=
pdb
;
initial_thdb
.
teb
.
except
=
(
void
*
)
-
1
;
initial_thdb
.
teb
.
except
=
(
void
*
)
-
1
;
initial_thdb
.
teb
.
self
=
&
initial_thdb
.
teb
;
initial_thdb
.
teb
.
self
=
&
initial_thdb
.
teb
;
...
@@ -241,8 +232,6 @@ THDB *THREAD_Create( PDB *pdb, DWORD stack_size, BOOL alloc_stack16,
...
@@ -241,8 +232,6 @@ THDB *THREAD_Create( PDB *pdb, DWORD stack_size, BOOL alloc_stack16,
{
{
THDB
*
thdb
=
HeapAlloc
(
SystemHeap
,
HEAP_ZERO_MEMORY
,
sizeof
(
THDB
)
);
THDB
*
thdb
=
HeapAlloc
(
SystemHeap
,
HEAP_ZERO_MEMORY
,
sizeof
(
THDB
)
);
if
(
!
thdb
)
return
NULL
;
if
(
!
thdb
)
return
NULL
;
thdb
->
header
.
type
=
K32OBJ_THREAD
;
thdb
->
header
.
refcount
=
1
;
thdb
->
process
=
pdb
;
thdb
->
process
=
pdb
;
thdb
->
teb
.
except
=
(
void
*
)
-
1
;
thdb
->
teb
.
except
=
(
void
*
)
-
1
;
thdb
->
teb
.
htask16
=
pdb
->
task
;
thdb
->
teb
.
htask16
=
pdb
->
task
;
...
@@ -278,43 +267,6 @@ error:
...
@@ -278,43 +267,6 @@ error:
/***********************************************************************
/***********************************************************************
* THREAD_Destroy
*/
static
void
THREAD_Destroy
(
K32OBJ
*
ptr
)
{
THDB
*
thdb
=
(
THDB
*
)
ptr
;
THDB
**
pptr
=
&
THREAD_First
;
assert
(
ptr
->
type
==
K32OBJ_THREAD
);
ptr
->
type
=
K32OBJ_UNKNOWN
;
while
(
*
pptr
&&
(
*
pptr
!=
thdb
))
pptr
=
&
(
*
pptr
)
->
next
;
if
(
*
pptr
)
*
pptr
=
thdb
->
next
;
/* Free the associated memory */
#ifdef __i386__
{
/* Check if we are deleting the current thread */
WORD
fs
;
GET_FS
(
fs
);
if
(
fs
==
thdb
->
teb_sel
)
{
GET_DS
(
fs
);
SET_FS
(
fs
);
}
}
#endif
CloseHandle
(
thdb
->
event
);
close
(
thdb
->
socket
);
SELECTOR_FreeBlock
(
thdb
->
teb_sel
,
1
);
if
(
thdb
->
teb
.
stack_sel
)
SELECTOR_FreeBlock
(
thdb
->
teb
.
stack_sel
,
1
);
HeapFree
(
SystemHeap
,
0
,
thdb
);
}
/***********************************************************************
* THREAD_Start
* THREAD_Start
*
*
* Start execution of a newly created thread. Does not return.
* Start execution of a newly created thread. Does not return.
...
@@ -336,24 +288,18 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack,
...
@@ -336,24 +288,18 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack,
LPTHREAD_START_ROUTINE
start
,
LPVOID
param
,
LPTHREAD_START_ROUTINE
start
,
LPVOID
param
,
DWORD
flags
,
LPDWORD
id
)
DWORD
flags
,
LPDWORD
id
)
{
{
int
server_handle
=
-
1
;
int
handle
=
-
1
;
HANDLE
handle
=
INVALID_HANDLE_VALUE
;
BOOL
inherit
=
(
sa
&&
(
sa
->
nLength
>=
sizeof
(
*
sa
))
&&
sa
->
bInheritHandle
);
BOOL
inherit
=
(
sa
&&
(
sa
->
nLength
>=
sizeof
(
*
sa
))
&&
sa
->
bInheritHandle
);
THDB
*
thread
=
THREAD_Create
(
PROCESS_Current
(),
stack
,
THDB
*
thread
=
THREAD_Create
(
PROCESS_Current
(),
stack
,
TRUE
,
&
server_
handle
,
NULL
,
start
,
param
);
TRUE
,
&
handle
,
NULL
,
start
,
param
);
if
(
!
thread
)
return
INVALID_HANDLE_VALUE
;
if
(
!
thread
)
return
INVALID_HANDLE_VALUE
;
handle
=
HANDLE_Alloc
(
PROCESS_Current
(),
&
thread
->
header
,
if
(
SYSDEPS_SpawnThread
(
thread
)
==
-
1
)
THREAD_ALL_ACCESS
,
inherit
,
server_handle
);
{
if
(
handle
==
INVALID_HANDLE_VALUE
)
goto
error
;
CloseHandle
(
handle
);
if
(
SYSDEPS_SpawnThread
(
thread
)
==
-
1
)
goto
error
;
return
INVALID_HANDLE_VALUE
;
}
if
(
id
)
*
id
=
(
DWORD
)
thread
->
server_tid
;
if
(
id
)
*
id
=
(
DWORD
)
thread
->
server_tid
;
return
handle
;
return
handle
;
error:
if
(
handle
!=
INVALID_HANDLE_VALUE
)
CloseHandle
(
handle
);
K32OBJ_DecCount
(
&
thread
->
header
);
return
INVALID_HANDLE_VALUE
;
}
}
...
@@ -367,26 +313,32 @@ void WINAPI ExitThread(
...
@@ -367,26 +313,32 @@ void WINAPI ExitThread(
DWORD
code
)
/* [in] Exit code for this thread */
DWORD
code
)
/* [in] Exit code for this thread */
{
{
THDB
*
thdb
=
THREAD_Current
();
THDB
*
thdb
=
THREAD_Current
();
LONG
count
;
THDB
**
pptr
=
&
THREAD_First
;
WORD
ds
;
MODULE_InitializeDLLs
(
0
,
DLL_THREAD_DETACH
,
NULL
);
MODULE_InitializeDLLs
(
0
,
DLL_THREAD_DETACH
,
NULL
);
SYSTEM_LOCK
();
thdb
->
exit_code
=
code
;
thdb
->
exit_code
=
code
;
/* cleanup the message queue, if there's one */
/* cleanup the message queue, if there's one */
if
(
thdb
->
teb
.
queue
)
if
(
thdb
->
teb
.
queue
)
USER_QueueCleanup
(
thdb
->
teb
.
queue
);
USER_QueueCleanup
(
thdb
->
teb
.
queue
);
CloseHandle
(
thdb
->
event
);
while
(
*
pptr
&&
(
*
pptr
!=
thdb
))
pptr
=
&
(
*
pptr
)
->
next
;
if
(
*
pptr
)
*
pptr
=
thdb
->
next
;
/* Free the associated memory */
if
(
thdb
->
teb
.
stack_sel
)
SELECTOR_FreeBlock
(
thdb
->
teb
.
stack_sel
,
1
);
GET_DS
(
ds
);
SET_FS
(
ds
);
SELECTOR_FreeBlock
(
thdb
->
teb_sel
,
1
);
close
(
thdb
->
socket
);
HeapFree
(
SystemHeap
,
HEAP_NO_SERIALIZE
,
thdb
);
/* FIXME: should free the stack somehow */
/* FIXME: should free the stack somehow */
#if 0
/* FIXME: We cannot do this; once the current thread is destroyed,
synchronization primitives do not work properly. */
K32OBJ_DecCount( &thdb->header );
#endif
/* Completely unlock the system lock just in case */
count
=
SYSTEM_LOCK_COUNT
();
while
(
count
--
)
SYSTEM_UNLOCK
();
SYSDEPS_ExitThread
();
SYSDEPS_ExitThread
();
}
}
...
@@ -653,8 +605,7 @@ INT WINAPI GetThreadPriority(
...
@@ -653,8 +605,7 @@ INT WINAPI GetThreadPriority(
{
{
struct
get_thread_info_request
req
;
struct
get_thread_info_request
req
;
struct
get_thread_info_reply
reply
;
struct
get_thread_info_reply
reply
;
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hthread
,
req
.
handle
=
hthread
;
K32OBJ_THREAD
,
THREAD_QUERY_INFORMATION
);
CLIENT_SendRequest
(
REQ_GET_THREAD_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_GET_THREAD_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
THREAD_PRIORITY_ERROR_RETURN
;
return
THREAD_PRIORITY_ERROR_RETURN
;
...
@@ -674,9 +625,7 @@ BOOL WINAPI SetThreadPriority(
...
@@ -674,9 +625,7 @@ BOOL WINAPI SetThreadPriority(
INT
priority
)
/* [in] Thread priority level */
INT
priority
)
/* [in] Thread priority level */
{
{
struct
set_thread_info_request
req
;
struct
set_thread_info_request
req
;
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hthread
,
req
.
handle
=
hthread
;
K32OBJ_THREAD
,
THREAD_SET_INFORMATION
);
if
(
req
.
handle
==
-
1
)
return
FALSE
;
req
.
priority
=
priority
;
req
.
priority
=
priority
;
req
.
mask
=
SET_THREAD_INFO_PRIORITY
;
req
.
mask
=
SET_THREAD_INFO_PRIORITY
;
CLIENT_SendRequest
(
REQ_SET_THREAD_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_SET_THREAD_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
...
@@ -690,9 +639,7 @@ BOOL WINAPI SetThreadPriority(
...
@@ -690,9 +639,7 @@ BOOL WINAPI SetThreadPriority(
DWORD
WINAPI
SetThreadAffinityMask
(
HANDLE
hThread
,
DWORD
dwThreadAffinityMask
)
DWORD
WINAPI
SetThreadAffinityMask
(
HANDLE
hThread
,
DWORD
dwThreadAffinityMask
)
{
{
struct
set_thread_info_request
req
;
struct
set_thread_info_request
req
;
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hThread
,
req
.
handle
=
hThread
;
K32OBJ_THREAD
,
THREAD_SET_INFORMATION
);
if
(
req
.
handle
==
-
1
)
return
FALSE
;
req
.
affinity
=
dwThreadAffinityMask
;
req
.
affinity
=
dwThreadAffinityMask
;
req
.
mask
=
SET_THREAD_INFO_AFFINITY
;
req
.
mask
=
SET_THREAD_INFO_AFFINITY
;
CLIENT_SendRequest
(
REQ_SET_THREAD_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_SET_THREAD_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
...
@@ -713,9 +660,7 @@ BOOL WINAPI TerminateThread(
...
@@ -713,9 +660,7 @@ BOOL WINAPI TerminateThread(
DWORD
exitcode
)
/* [in] Exit code for thread */
DWORD
exitcode
)
/* [in] Exit code for thread */
{
{
struct
terminate_thread_request
req
;
struct
terminate_thread_request
req
;
req
.
handle
=
handle
;
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handle
,
K32OBJ_THREAD
,
THREAD_TERMINATE
);
req
.
exit_code
=
exitcode
;
req
.
exit_code
=
exitcode
;
CLIENT_SendRequest
(
REQ_TERMINATE_THREAD
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_TERMINATE_THREAD
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
...
@@ -735,8 +680,7 @@ BOOL WINAPI GetExitCodeThread(
...
@@ -735,8 +680,7 @@ BOOL WINAPI GetExitCodeThread(
{
{
struct
get_thread_info_request
req
;
struct
get_thread_info_request
req
;
struct
get_thread_info_reply
reply
;
struct
get_thread_info_reply
reply
;
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hthread
,
req
.
handle
=
hthread
;
K32OBJ_THREAD
,
THREAD_QUERY_INFORMATION
);
CLIENT_SendRequest
(
REQ_GET_THREAD_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_GET_THREAD_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
FALSE
;
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
FALSE
;
if
(
exitcode
)
*
exitcode
=
reply
.
exit_code
;
if
(
exitcode
)
*
exitcode
=
reply
.
exit_code
;
...
@@ -760,8 +704,7 @@ DWORD WINAPI ResumeThread(
...
@@ -760,8 +704,7 @@ DWORD WINAPI ResumeThread(
{
{
struct
resume_thread_request
req
;
struct
resume_thread_request
req
;
struct
resume_thread_reply
reply
;
struct
resume_thread_reply
reply
;
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hthread
,
req
.
handle
=
hthread
;
K32OBJ_THREAD
,
THREAD_SUSPEND_RESUME
);
CLIENT_SendRequest
(
REQ_RESUME_THREAD
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_RESUME_THREAD
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
0xffffffff
;
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
0xffffffff
;
return
reply
.
count
;
return
reply
.
count
;
...
@@ -780,8 +723,7 @@ DWORD WINAPI SuspendThread(
...
@@ -780,8 +723,7 @@ DWORD WINAPI SuspendThread(
{
{
struct
suspend_thread_request
req
;
struct
suspend_thread_request
req
;
struct
suspend_thread_reply
reply
;
struct
suspend_thread_reply
reply
;
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hthread
,
req
.
handle
=
hthread
;
K32OBJ_THREAD
,
THREAD_SUSPEND_RESUME
);
CLIENT_SendRequest
(
REQ_SUSPEND_THREAD
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_SUSPEND_THREAD
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
0xffffffff
;
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
0xffffffff
;
return
reply
.
count
;
return
reply
.
count
;
...
@@ -794,8 +736,7 @@ DWORD WINAPI SuspendThread(
...
@@ -794,8 +736,7 @@ DWORD WINAPI SuspendThread(
DWORD
WINAPI
QueueUserAPC
(
PAPCFUNC
func
,
HANDLE
hthread
,
ULONG_PTR
data
)
DWORD
WINAPI
QueueUserAPC
(
PAPCFUNC
func
,
HANDLE
hthread
,
ULONG_PTR
data
)
{
{
struct
queue_apc_request
req
;
struct
queue_apc_request
req
;
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hthread
,
req
.
handle
=
hthread
;
K32OBJ_THREAD
,
THREAD_SET_CONTEXT
);
req
.
func
=
func
;
req
.
func
=
func
;
req
.
param
=
(
void
*
)
data
;
req
.
param
=
(
void
*
)
data
;
CLIENT_SendRequest
(
REQ_QUEUE_APC
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_QUEUE_APC
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
...
...
win32/console.c
View file @
96c08d81
...
@@ -36,7 +36,6 @@
...
@@ -36,7 +36,6 @@
#include "winbase.h"
#include "winbase.h"
#include "wine/winuser16.h"
#include "wine/winuser16.h"
#include "wine/keyboard16.h"
#include "wine/keyboard16.h"
#include "k32obj.h"
#include "thread.h"
#include "thread.h"
#include "async.h"
#include "async.h"
#include "file.h"
#include "file.h"
...
@@ -49,10 +48,6 @@
...
@@ -49,10 +48,6 @@
#include "server/request.h"
#include "server/request.h"
#include "server.h"
#include "server.h"
/* The CONSOLE kernel32 Object */
typedef
struct
_CONSOLE
{
K32OBJ
header
;
}
CONSOLE
;
/* FIXME: Should be in an internal header file. OK, so which one?
/* FIXME: Should be in an internal header file. OK, so which one?
Used by CONSOLE_makecomplex. */
Used by CONSOLE_makecomplex. */
...
@@ -66,9 +61,7 @@ static BOOL CONSOLE_GetInfo( HANDLE handle, struct get_console_info_reply *reply
...
@@ -66,9 +61,7 @@ static BOOL CONSOLE_GetInfo( HANDLE handle, struct get_console_info_reply *reply
{
{
struct
get_console_info_request
req
;
struct
get_console_info_request
req
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handle
,
req
.
handle
=
handle
;
K32OBJ_CONSOLE
,
GENERIC_READ
))
==
-
1
)
return
FALSE
;
CLIENT_SendRequest
(
REQ_GET_CONSOLE_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_GET_CONSOLE_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
return
!
CLIENT_WaitSimpleReply
(
reply
,
sizeof
(
*
reply
),
NULL
);
return
!
CLIENT_WaitSimpleReply
(
reply
,
sizeof
(
*
reply
),
NULL
);
}
}
...
@@ -432,32 +425,8 @@ DWORD WINAPI GetLargestConsoleWindowSize( HANDLE hConsoleOutput )
...
@@ -432,32 +425,8 @@ DWORD WINAPI GetLargestConsoleWindowSize( HANDLE hConsoleOutput )
*/
*/
BOOL
WINAPI
FreeConsole
(
VOID
)
BOOL
WINAPI
FreeConsole
(
VOID
)
{
{
PDB
*
pdb
=
PROCESS_Current
();
CONSOLE
*
console
;
SYSTEM_LOCK
();
console
=
(
CONSOLE
*
)
pdb
->
console
;
if
(
console
==
NULL
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
CLIENT_SendRequest
(
REQ_FREE_CONSOLE
,
-
1
,
0
);
CLIENT_SendRequest
(
REQ_FREE_CONSOLE
,
-
1
,
0
);
if
(
CLIENT_WaitReply
(
NULL
,
NULL
,
0
)
!=
ERROR_SUCCESS
)
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
{
K32OBJ_DecCount
(
&
console
->
header
);
SYSTEM_UNLOCK
();
return
FALSE
;
}
HANDLE_CloseAll
(
pdb
,
&
console
->
header
);
K32OBJ_DecCount
(
&
console
->
header
);
pdb
->
console
=
NULL
;
SYSTEM_UNLOCK
();
return
TRUE
;
}
}
...
@@ -470,29 +439,13 @@ HANDLE CONSOLE_OpenHandle( BOOL output, DWORD access, LPSECURITY_ATTRIBUTES sa )
...
@@ -470,29 +439,13 @@ HANDLE CONSOLE_OpenHandle( BOOL output, DWORD access, LPSECURITY_ATTRIBUTES sa )
{
{
struct
open_console_request
req
;
struct
open_console_request
req
;
struct
open_console_reply
reply
;
struct
open_console_reply
reply
;
CONSOLE
*
console
;
HANDLE
handle
;
req
.
output
=
output
;
req
.
output
=
output
;
req
.
access
=
access
;
req
.
access
=
access
;
req
.
inherit
=
(
sa
&&
(
sa
->
nLength
>=
sizeof
(
*
sa
))
&&
sa
->
bInheritHandle
);
req
.
inherit
=
(
sa
&&
(
sa
->
nLength
>=
sizeof
(
*
sa
))
&&
sa
->
bInheritHandle
);
CLIENT_SendRequest
(
REQ_OPEN_CONSOLE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_OPEN_CONSOLE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
);
if
(
reply
.
handle
==
-
1
)
return
INVALID_HANDLE_VALUE
;
return
reply
.
handle
;
SYSTEM_LOCK
();
if
(
!
(
console
=
(
CONSOLE
*
)
HeapAlloc
(
SystemHeap
,
0
,
sizeof
(
*
console
))))
{
SYSTEM_UNLOCK
();
return
FALSE
;
}
console
->
header
.
type
=
K32OBJ_CONSOLE
;
console
->
header
.
refcount
=
1
;
handle
=
HANDLE_Alloc
(
PROCESS_Current
(),
&
console
->
header
,
req
.
access
,
req
.
inherit
,
reply
.
handle
);
SYSTEM_UNLOCK
();
K32OBJ_DecCount
(
&
console
->
header
);
return
handle
;
}
}
...
@@ -531,10 +484,6 @@ static BOOL CONSOLE_make_complex(HANDLE handle)
...
@@ -531,10 +484,6 @@ static BOOL CONSOLE_make_complex(HANDLE handle)
}
}
term
.
c_lflag
=
~
(
ECHO
|
ICANON
);
term
.
c_lflag
=
~
(
ECHO
|
ICANON
);
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handle
,
K32OBJ_CONSOLE
,
0
))
==
-
1
)
return
FALSE
;
if
(
wine_openpty
(
&
master
,
&
slave
,
NULL
,
&
term
,
NULL
)
<
0
)
if
(
wine_openpty
(
&
master
,
&
slave
,
NULL
,
&
term
,
NULL
)
<
0
)
return
FALSE
;
return
FALSE
;
...
@@ -549,6 +498,7 @@ static BOOL CONSOLE_make_complex(HANDLE handle)
...
@@ -549,6 +498,7 @@ static BOOL CONSOLE_make_complex(HANDLE handle)
exit
(
1
);
exit
(
1
);
}
}
req
.
handle
=
handle
;
req
.
pid
=
xpid
;
req
.
pid
=
xpid
;
CLIENT_SendRequest
(
REQ_SET_CONSOLE_FD
,
dup
(
slave
),
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_SET_CONSOLE_FD
,
dup
(
slave
),
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
...
@@ -591,37 +541,10 @@ BOOL WINAPI AllocConsole(VOID)
...
@@ -591,37 +541,10 @@ BOOL WINAPI AllocConsole(VOID)
{
{
struct
open_console_request
req
;
struct
open_console_request
req
;
struct
open_console_reply
reply
;
struct
open_console_reply
reply
;
PDB
*
pdb
=
PROCESS_Current
();
CONSOLE
*
console
;
HANDLE
hIn
,
hOut
,
hErr
;
HANDLE
hIn
,
hOut
,
hErr
;
SYSTEM_LOCK
();
/* FIXME: really only need to lock the process */
console
=
(
CONSOLE
*
)
pdb
->
console
;
/* don't create a console if we already have one */
if
(
console
!=
NULL
)
{
SetLastError
(
ERROR_ACCESS_DENIED
);
SYSTEM_UNLOCK
();
return
FALSE
;
}
if
(
!
(
console
=
(
CONSOLE
*
)
HeapAlloc
(
SystemHeap
,
0
,
sizeof
(
*
console
))))
{
SYSTEM_UNLOCK
();
return
FALSE
;
}
console
->
header
.
type
=
K32OBJ_CONSOLE
;
console
->
header
.
refcount
=
1
;
CLIENT_SendRequest
(
REQ_ALLOC_CONSOLE
,
-
1
,
0
);
CLIENT_SendRequest
(
REQ_ALLOC_CONSOLE
,
-
1
,
0
);
if
(
CLIENT_WaitReply
(
NULL
,
NULL
,
0
)
!=
ERROR_SUCCESS
)
if
(
CLIENT_WaitReply
(
NULL
,
NULL
,
0
)
!=
ERROR_SUCCESS
)
return
FALSE
;
{
K32OBJ_DecCount
(
&
console
->
header
);
SYSTEM_UNLOCK
();
return
FALSE
;
}
req
.
output
=
0
;
req
.
output
=
0
;
req
.
access
=
GENERIC_READ
|
GENERIC_WRITE
|
SYNCHRONIZE
;
req
.
access
=
GENERIC_READ
|
GENERIC_WRITE
|
SYNCHRONIZE
;
...
@@ -629,35 +552,20 @@ BOOL WINAPI AllocConsole(VOID)
...
@@ -629,35 +552,20 @@ BOOL WINAPI AllocConsole(VOID)
CLIENT_SendRequest
(
REQ_OPEN_CONSOLE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_OPEN_CONSOLE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
)
!=
ERROR_SUCCESS
)
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
)
!=
ERROR_SUCCESS
)
{
{
K32OBJ_DecCount
(
&
console
->
header
);
/* FIXME: free console */
SYSTEM_UNLOCK
();
return
FALSE
;
}
if
((
hIn
=
HANDLE_Alloc
(
pdb
,
&
console
->
header
,
req
.
access
,
FALSE
,
reply
.
handle
))
==
INVALID_HANDLE_VALUE
)
{
K32OBJ_DecCount
(
&
console
->
header
);
SYSTEM_UNLOCK
();
return
FALSE
;
return
FALSE
;
}
}
hIn
=
reply
.
handle
;
req
.
output
=
1
;
req
.
output
=
1
;
CLIENT_SendRequest
(
REQ_OPEN_CONSOLE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_OPEN_CONSOLE
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
)
!=
ERROR_SUCCESS
)
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
)
!=
ERROR_SUCCESS
)
{
{
CloseHandle
(
hIn
);
CloseHandle
(
hIn
);
K32OBJ_DecCount
(
&
console
->
header
);
/* FIXME: free console */
SYSTEM_UNLOCK
();
return
FALSE
;
}
if
((
hOut
=
HANDLE_Alloc
(
pdb
,
&
console
->
header
,
req
.
access
,
FALSE
,
reply
.
handle
))
==
INVALID_HANDLE_VALUE
)
{
CloseHandle
(
hIn
);
K32OBJ_DecCount
(
&
console
->
header
);
SYSTEM_UNLOCK
();
return
FALSE
;
return
FALSE
;
}
}
hOut
=
reply
.
handle
;
if
(
!
DuplicateHandle
(
GetCurrentProcess
(),
hOut
,
if
(
!
DuplicateHandle
(
GetCurrentProcess
(),
hOut
,
GetCurrentProcess
(),
&
hErr
,
GetCurrentProcess
(),
&
hErr
,
...
@@ -665,22 +573,15 @@ BOOL WINAPI AllocConsole(VOID)
...
@@ -665,22 +573,15 @@ BOOL WINAPI AllocConsole(VOID)
{
{
CloseHandle
(
hIn
);
CloseHandle
(
hIn
);
CloseHandle
(
hOut
);
CloseHandle
(
hOut
);
K32OBJ_DecCount
(
&
console
->
header
);
SYSTEM_UNLOCK
();
return
FALSE
;
return
FALSE
;
}
}
if
(
pdb
->
console
)
K32OBJ_DecCount
(
pdb
->
console
);
pdb
->
console
=
(
K32OBJ
*
)
console
;
K32OBJ_IncCount
(
pdb
->
console
);
/* NT resets the STD_*_HANDLEs on console alloc */
/* NT resets the STD_*_HANDLEs on console alloc */
SetStdHandle
(
STD_INPUT_HANDLE
,
hIn
);
SetStdHandle
(
STD_INPUT_HANDLE
,
hIn
);
SetStdHandle
(
STD_OUTPUT_HANDLE
,
hOut
);
SetStdHandle
(
STD_OUTPUT_HANDLE
,
hOut
);
SetStdHandle
(
STD_ERROR_HANDLE
,
hErr
);
SetStdHandle
(
STD_ERROR_HANDLE
,
hErr
);
SetLastError
(
ERROR_SUCCESS
);
SetLastError
(
ERROR_SUCCESS
);
SYSTEM_UNLOCK
();
SetConsoleTitleA
(
"Wine Console"
);
SetConsoleTitleA
(
"Wine Console"
);
return
TRUE
;
return
TRUE
;
}
}
...
@@ -714,9 +615,7 @@ BOOL WINAPI GetConsoleMode(HANDLE hcon,LPDWORD mode)
...
@@ -714,9 +615,7 @@ BOOL WINAPI GetConsoleMode(HANDLE hcon,LPDWORD mode)
struct
get_console_mode_request
req
;
struct
get_console_mode_request
req
;
struct
get_console_mode_reply
reply
;
struct
get_console_mode_reply
reply
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hcon
,
req
.
handle
=
hcon
;
K32OBJ_CONSOLE
,
GENERIC_READ
))
==
-
1
)
return
FALSE
;
CLIENT_SendRequest
(
REQ_GET_CONSOLE_MODE
,
-
1
,
1
,
&
req
,
sizeof
(
req
));
CLIENT_SendRequest
(
REQ_GET_CONSOLE_MODE
,
-
1
,
1
,
&
req
,
sizeof
(
req
));
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
FALSE
;
if
(
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
))
return
FALSE
;
*
mode
=
reply
.
mode
;
*
mode
=
reply
.
mode
;
...
@@ -739,9 +638,7 @@ BOOL WINAPI SetConsoleMode( HANDLE hcon, DWORD mode )
...
@@ -739,9 +638,7 @@ BOOL WINAPI SetConsoleMode( HANDLE hcon, DWORD mode )
{
{
struct
set_console_mode_request
req
;
struct
set_console_mode_request
req
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hcon
,
req
.
handle
=
hcon
;
K32OBJ_CONSOLE
,
GENERIC_READ
))
==
-
1
)
return
FALSE
;
req
.
mode
=
mode
;
req
.
mode
=
mode
;
CLIENT_SendRequest
(
REQ_SET_CONSOLE_MODE
,
-
1
,
1
,
&
req
,
sizeof
(
req
));
CLIENT_SendRequest
(
REQ_SET_CONSOLE_MODE
,
-
1
,
1
,
&
req
,
sizeof
(
req
));
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
return
!
CLIENT_WaitReply
(
NULL
,
NULL
,
0
);
...
@@ -762,12 +659,7 @@ DWORD WINAPI GetConsoleTitleA(LPSTR title,DWORD size)
...
@@ -762,12 +659,7 @@ DWORD WINAPI GetConsoleTitleA(LPSTR title,DWORD size)
if
((
hcon
=
CreateFileA
(
"CONOUT$"
,
GENERIC_READ
,
0
,
NULL
,
if
((
hcon
=
CreateFileA
(
"CONOUT$"
,
GENERIC_READ
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
))
==
INVALID_HANDLE_VALUE
)
OPEN_EXISTING
,
0
,
0
))
==
INVALID_HANDLE_VALUE
)
return
0
;
return
0
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hcon
,
req
.
handle
=
hcon
;
K32OBJ_CONSOLE
,
GENERIC_READ
))
==
-
1
)
{
CloseHandle
(
hcon
);
return
0
;
}
CLIENT_SendRequest
(
REQ_GET_CONSOLE_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_GET_CONSOLE_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
!
CLIENT_WaitReply
(
&
len
,
NULL
,
2
,
&
reply
,
sizeof
(
reply
),
title
,
size
))
if
(
!
CLIENT_WaitReply
(
&
len
,
NULL
,
2
,
&
reply
,
sizeof
(
reply
),
title
,
size
))
{
{
...
@@ -913,9 +805,6 @@ BOOL WINAPI ReadConsoleA( HANDLE hConsoleInput,
...
@@ -913,9 +805,6 @@ BOOL WINAPI ReadConsoleA( HANDLE hConsoleInput,
struct
read_console_input_request
req
;
struct
read_console_input_request
req
;
INPUT_RECORD
ir
;
INPUT_RECORD
ir
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hConsoleInput
,
K32OBJ_CONSOLE
,
GENERIC_READ
))
==
-
1
)
return
FALSE
;
TRACE
(
console
,
"(%d,%p,%ld,%p,%p)
\n
"
,
TRACE
(
console
,
"(%d,%p,%ld,%p,%p)
\n
"
,
hConsoleInput
,
lpBuffer
,
nNumberOfCharsToRead
,
hConsoleInput
,
lpBuffer
,
nNumberOfCharsToRead
,
lpNumberOfCharsRead
,
lpReserved
lpNumberOfCharsRead
,
lpReserved
...
@@ -923,6 +812,7 @@ BOOL WINAPI ReadConsoleA( HANDLE hConsoleInput,
...
@@ -923,6 +812,7 @@ BOOL WINAPI ReadConsoleA( HANDLE hConsoleInput,
CONSOLE_get_input
(
hConsoleInput
,
FALSE
);
CONSOLE_get_input
(
hConsoleInput
,
FALSE
);
req
.
handle
=
hConsoleInput
;
req
.
count
=
1
;
req
.
count
=
1
;
req
.
flush
=
1
;
req
.
flush
=
1
;
...
@@ -994,9 +884,7 @@ BOOL WINAPI ReadConsoleInputA(HANDLE hConsoleInput,
...
@@ -994,9 +884,7 @@ BOOL WINAPI ReadConsoleInputA(HANDLE hConsoleInput,
struct
read_console_input_request
req
;
struct
read_console_input_request
req
;
int
len
;
int
len
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hConsoleInput
,
req
.
handle
=
hConsoleInput
;
K32OBJ_CONSOLE
,
GENERIC_READ
))
==
-
1
)
return
FALSE
;
req
.
count
=
nLength
;
req
.
count
=
nLength
;
req
.
flush
=
1
;
req
.
flush
=
1
;
...
@@ -1035,9 +923,7 @@ BOOL WINAPI FlushConsoleInputBuffer( HANDLE handle )
...
@@ -1035,9 +923,7 @@ BOOL WINAPI FlushConsoleInputBuffer( HANDLE handle )
struct
read_console_input_request
req
;
struct
read_console_input_request
req
;
int
len
;
int
len
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handle
,
req
.
handle
=
handle
;
K32OBJ_CONSOLE
,
GENERIC_READ
))
==
-
1
)
return
FALSE
;
req
.
count
=
-
1
;
/* get all records */
req
.
count
=
-
1
;
/* get all records */
req
.
flush
=
1
;
req
.
flush
=
1
;
CLIENT_SendRequest
(
REQ_READ_CONSOLE_INPUT
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_READ_CONSOLE_INPUT
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
...
@@ -1058,11 +944,8 @@ BOOL WINAPI PeekConsoleInputA( HANDLE handle, LPINPUT_RECORD buffer,
...
@@ -1058,11 +944,8 @@ BOOL WINAPI PeekConsoleInputA( HANDLE handle, LPINPUT_RECORD buffer,
struct
read_console_input_request
req
;
struct
read_console_input_request
req
;
int
len
;
int
len
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handle
,
K32OBJ_CONSOLE
,
GENERIC_READ
))
==
-
1
)
return
FALSE
;
CONSOLE_get_input
(
handle
,
FALSE
);
CONSOLE_get_input
(
handle
,
FALSE
);
req
.
handle
=
handle
;
req
.
count
=
count
;
req
.
count
=
count
;
req
.
flush
=
0
;
req
.
flush
=
0
;
...
@@ -1098,9 +981,7 @@ BOOL WINAPI WriteConsoleInputA( HANDLE handle, INPUT_RECORD *buffer,
...
@@ -1098,9 +981,7 @@ BOOL WINAPI WriteConsoleInputA( HANDLE handle, INPUT_RECORD *buffer,
struct
write_console_input_request
req
;
struct
write_console_input_request
req
;
struct
write_console_input_reply
reply
;
struct
write_console_input_reply
reply
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handle
,
req
.
handle
=
handle
;
K32OBJ_CONSOLE
,
GENERIC_WRITE
))
==
-
1
)
return
FALSE
;
req
.
count
=
count
;
req
.
count
=
count
;
CLIENT_SendRequest
(
REQ_WRITE_CONSOLE_INPUT
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
CLIENT_SendRequest
(
REQ_WRITE_CONSOLE_INPUT
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
buffer
,
count
*
sizeof
(
*
buffer
)
);
buffer
,
count
*
sizeof
(
*
buffer
)
);
...
@@ -1121,47 +1002,6 @@ BOOL WINAPI WriteConsoleInputA( HANDLE handle, INPUT_RECORD *buffer,
...
@@ -1121,47 +1002,6 @@ BOOL WINAPI WriteConsoleInputA( HANDLE handle, INPUT_RECORD *buffer,
*/
*/
BOOL
WINAPI
SetConsoleTitleA
(
LPCSTR
title
)
BOOL
WINAPI
SetConsoleTitleA
(
LPCSTR
title
)
{
{
#if 0
PDB *pdb = PROCESS_Current();
CONSOLE *console;
DWORD written;
char titleformat[]="\033]2;%s\a"; /*this should work for xterms*/
LPSTR titlestring;
BOOL ret=FALSE;
TRACE(console,"(%s)\n",title);
console = (CONSOLE *)pdb->console;
if (!console)
return FALSE;
if(console->title) /* Free old title, if there is one */
HeapFree( SystemHeap, 0, console->title );
console->title = (LPSTR)HeapAlloc(SystemHeap, 0,strlen(title)+1);
if(console->title) strcpy(console->title,title);
titlestring = HeapAlloc(GetProcessHeap(), 0,strlen(title)+strlen(titleformat)+1);
if (!titlestring) {
K32OBJ_DecCount(&console->header);
return FALSE;
}
sprintf(titlestring,titleformat,title);
#if 0
/* only set title for complex console (own xterm) */
if (console->pid != -1) {
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),titlestring,strlen(titlestring),&written,NULL);
if (written == strlen(titlestring))
ret =TRUE;
} else
ret = TRUE;
#endif
HeapFree( GetProcessHeap(), 0, titlestring );
K32OBJ_DecCount(&console->header);
return ret;
#endif
struct
set_console_info_request
req
;
struct
set_console_info_request
req
;
struct
get_console_info_reply
info
;
struct
get_console_info_reply
info
;
HANDLE
hcon
;
HANDLE
hcon
;
...
@@ -1170,9 +1010,7 @@ BOOL WINAPI SetConsoleTitleA(LPCSTR title)
...
@@ -1170,9 +1010,7 @@ BOOL WINAPI SetConsoleTitleA(LPCSTR title)
if
((
hcon
=
CreateFileA
(
"CONOUT$"
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
if
((
hcon
=
CreateFileA
(
"CONOUT$"
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
))
==
INVALID_HANDLE_VALUE
)
OPEN_EXISTING
,
0
,
0
))
==
INVALID_HANDLE_VALUE
)
return
FALSE
;
return
FALSE
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hcon
,
req
.
handle
=
hcon
;
K32OBJ_CONSOLE
,
GENERIC_WRITE
))
==
-
1
)
goto
error
;
req
.
mask
=
SET_CONSOLE_INFO_TITLE
;
req
.
mask
=
SET_CONSOLE_INFO_TITLE
;
CLIENT_SendRequest
(
REQ_SET_CONSOLE_INFO
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
CLIENT_SendRequest
(
REQ_SET_CONSOLE_INFO
,
-
1
,
2
,
&
req
,
sizeof
(
req
),
title
,
strlen
(
title
)
+
1
);
title
,
strlen
(
title
)
+
1
);
...
@@ -1184,6 +1022,7 @@ BOOL WINAPI SetConsoleTitleA(LPCSTR title)
...
@@ -1184,6 +1022,7 @@ BOOL WINAPI SetConsoleTitleA(LPCSTR title)
WriteFile
(
hcon
,
title
,
strlen
(
title
),
&
written
,
NULL
);
WriteFile
(
hcon
,
title
,
strlen
(
title
),
&
written
,
NULL
);
WriteFile
(
hcon
,
"
\a
"
,
1
,
&
written
,
NULL
);
WriteFile
(
hcon
,
"
\a
"
,
1
,
&
written
,
NULL
);
}
}
CloseHandle
(
hcon
);
return
TRUE
;
return
TRUE
;
error:
error:
CloseHandle
(
hcon
);
CloseHandle
(
hcon
);
...
@@ -1307,9 +1146,7 @@ BOOL WINAPI SetConsoleCursorInfo(
...
@@ -1307,9 +1146,7 @@ BOOL WINAPI SetConsoleCursorInfo(
char
buf
[
8
];
char
buf
[
8
];
DWORD
xlen
;
DWORD
xlen
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
hcon
,
req
.
handle
=
hcon
;
K32OBJ_CONSOLE
,
GENERIC_WRITE
))
==
-
1
)
return
FALSE
;
CONSOLE_make_complex
(
hcon
);
CONSOLE_make_complex
(
hcon
);
sprintf
(
buf
,
"
\033
[?25%c"
,
cinfo
->
bVisible
?
'h'
:
'l'
);
sprintf
(
buf
,
"
\033
[?25%c"
,
cinfo
->
bVisible
?
'h'
:
'l'
);
WriteFile
(
hcon
,
buf
,
strlen
(
buf
),
&
xlen
,
NULL
);
WriteFile
(
hcon
,
buf
,
strlen
(
buf
),
&
xlen
,
NULL
);
...
...
win32/device.c
View file @
96c08d81
...
@@ -272,9 +272,7 @@ static const struct VxDInfo *DEVICE_GetInfo( HANDLE handle )
...
@@ -272,9 +272,7 @@ static const struct VxDInfo *DEVICE_GetInfo( HANDLE handle )
struct
get_file_info_request
req
;
struct
get_file_info_request
req
;
struct
get_file_info_reply
reply
;
struct
get_file_info_reply
reply
;
if
((
req
.
handle
=
HANDLE_GetServerHandle
(
PROCESS_Current
(),
handle
,
req
.
handle
=
handle
;
K32OBJ_FILE
,
0
))
==
-
1
)
return
NULL
;
CLIENT_SendRequest
(
REQ_GET_FILE_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
CLIENT_SendRequest
(
REQ_GET_FILE_INFO
,
-
1
,
1
,
&
req
,
sizeof
(
req
)
);
if
(
!
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
)
&&
if
(
!
CLIENT_WaitSimpleReply
(
&
reply
,
sizeof
(
reply
),
NULL
)
&&
(
reply
.
type
==
FILE_TYPE_UNKNOWN
)
&&
(
reply
.
type
==
FILE_TYPE_UNKNOWN
)
&&
...
...
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