Added handle_t type to server interface so that we can make handles

pointers later on.
Always use 0 to signal invalid handle in server requests.
This commit is contained in:
Alexandre Julliard 2001-01-05 04:08:07 +00:00
parent 980eeecf99
commit 8081e5a1e5
53 changed files with 423 additions and 402 deletions

View File

@ -44,7 +44,6 @@ HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -84,7 +83,6 @@ HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -121,7 +119,6 @@ HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name )
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -149,7 +146,6 @@ HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name )
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -271,7 +267,6 @@ HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name )
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -300,7 +295,6 @@ HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name )
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -333,7 +327,6 @@ HANDLE WINAPI OpenMutexA( DWORD access, BOOL inherit, LPCSTR name )
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -361,7 +354,6 @@ HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name )
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -423,7 +415,6 @@ HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max,
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -464,7 +455,6 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -492,7 +482,6 @@ HANDLE WINAPI OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name )
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -519,7 +508,6 @@ HANDLE WINAPI OpenSemaphoreW( DWORD access, BOOL inherit, LPCWSTR name )
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}

View File

@ -212,6 +212,7 @@ HANDLE WINAPI CreateToolhelp32Snapshot( DWORD flags, DWORD process )
ret = req->handle;
}
SERVER_END_REQ;
if (!ret) ret = INVALID_HANDLE_VALUE;
return ret;
}

View File

@ -107,7 +107,6 @@ NTSTATUS WINAPI NtOpenKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_ATTR
if (len > MAX_NAME_LENGTH) return STATUS_BUFFER_OVERFLOW;
if (!retkey) return STATUS_INVALID_PARAMETER;
*retkey = 0;
SERVER_START_REQ
{
@ -115,7 +114,8 @@ NTSTATUS WINAPI NtOpenKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_ATTR
req->parent = attr->RootDirectory;
req->access = access;
memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
if (!(ret = server_call_noerr( REQ_OPEN_KEY ))) *retkey = req->hkey;
ret = server_call_noerr( REQ_OPEN_KEY );
*retkey = req->hkey;
}
SERVER_END_REQ;
return ret;

View File

@ -36,8 +36,6 @@ NTSTATUS WINAPI NtCreateSemaphore( OUT PHANDLE SemaphoreHandle,
if ((MaximumCount <= 0) || (InitialCount < 0) || (InitialCount > MaximumCount))
return STATUS_INVALID_PARAMETER;
*SemaphoreHandle = 0;
SERVER_START_REQ
{
struct create_semaphore_request *req = server_alloc_req( sizeof(*req), len );
@ -45,8 +43,8 @@ NTSTATUS WINAPI NtCreateSemaphore( OUT PHANDLE SemaphoreHandle,
req->max = MaximumCount;
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
if (!(ret = server_call_noerr( REQ_CREATE_SEMAPHORE )))
*SemaphoreHandle = req->handle;
ret = server_call_noerr( REQ_CREATE_SEMAPHORE );
*SemaphoreHandle = req->handle;
}
SERVER_END_REQ;
return ret;
@ -62,16 +60,14 @@ NTSTATUS WINAPI NtOpenSemaphore( OUT PHANDLE SemaphoreHandle,
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
NTSTATUS ret;
*SemaphoreHandle = 0;
SERVER_START_REQ
{
struct open_semaphore_request *req = server_alloc_req( sizeof(*req), len );
req->access = access;
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
if (!(ret = server_call_noerr( REQ_OPEN_SEMAPHORE )))
*SemaphoreHandle = req->handle;
ret = server_call_noerr( REQ_OPEN_SEMAPHORE );
*SemaphoreHandle = req->handle;
}
SERVER_END_REQ;
return ret;
@ -129,8 +125,6 @@ NTSTATUS WINAPI NtCreateEvent(
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
NTSTATUS ret;
*EventHandle = 0;
SERVER_START_REQ
{
struct create_event_request *req = server_alloc_req( sizeof(*req), len );
@ -138,7 +132,8 @@ NTSTATUS WINAPI NtCreateEvent(
req->initial_state = InitialState;
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
if (!(ret = server_call_noerr( REQ_CREATE_EVENT ))) *EventHandle = req->handle;
ret = server_call_noerr( REQ_CREATE_EVENT );
*EventHandle = req->handle;
}
SERVER_END_REQ;
return ret;
@ -155,8 +150,6 @@ NTSTATUS WINAPI NtOpenEvent(
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
NTSTATUS ret;
*EventHandle = 0;
SERVER_START_REQ
{
struct open_event_request *req = server_alloc_req( sizeof(*req), len );
@ -164,7 +157,8 @@ NTSTATUS WINAPI NtOpenEvent(
req->access = DesiredAccess;
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
if (!(ret = server_call_noerr( REQ_OPEN_EVENT ))) *EventHandle = req->handle;
ret = server_call_noerr( REQ_OPEN_EVENT );
*EventHandle = req->handle;
}
SERVER_END_REQ;
return ret;

View File

@ -818,10 +818,10 @@ SOCKET WINAPI WSOCK32_accept(SOCKET s, struct sockaddr *addr,
req->access = GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE;
req->inherit = TRUE;
sock_server_call( REQ_ACCEPT_SOCKET );
as = req->handle;
as = (SOCKET)req->handle;
}
SERVER_END_REQ;
if( ((int)as) >= 0 )
if (as)
{
unsigned omask = _get_sock_mask( s );
int fd = _get_sock_fd( as );
@ -2223,10 +2223,10 @@ SOCKET WINAPI WSOCK32_socket(INT af, INT type, INT protocol)
req->access = GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE;
req->inherit = TRUE;
sock_server_call( REQ_CREATE_SOCKET );
ret = req->handle;
ret = (SOCKET)req->handle;
}
SERVER_END_REQ;
if ( ((int) ret) >= 0)
if (ret)
{
TRACE("\tcreated %04x\n", ret );
return ret;

View File

@ -697,7 +697,7 @@ const DOS_DEVICE *DOSFS_GetDeviceByHandle( HFILE hFile )
*/
static HANDLE DOSFS_CreateCommPort(LPCSTR name, DWORD access)
{
HANDLE ret = INVALID_HANDLE_VALUE;
HANDLE ret;
char devname[40];
TRACE("%s %lx\n", name, access);
@ -718,7 +718,8 @@ static HANDLE DOSFS_CreateCommPort(LPCSTR name, DWORD access)
req->sharing = FILE_SHARE_READ|FILE_SHARE_WRITE;
memcpy( server_data_ptr(req), devname, len );
SetLastError(0);
if (!(server_call( REQ_CREATE_SERIAL ))) ret = req->handle;
server_call( REQ_CREATE_SERIAL );
ret = req->handle;
}
SERVER_END_REQ;
@ -730,14 +731,14 @@ static HANDLE DOSFS_CreateCommPort(LPCSTR name, DWORD access)
* DOSFS_OpenDevice
*
* Open a DOS device. This might not map 1:1 into the UNIX device concept.
* Returns 0 on failure.
*/
HFILE DOSFS_OpenDevice( const char *name, DWORD access )
HANDLE DOSFS_OpenDevice( const char *name, DWORD access )
{
int i;
const char *p;
HFILE handle;
HANDLE handle;
if (!name) return (HFILE)NULL; /* if FILE_DupUnixHandle was used */
if (name[0] && (name[1] == ':')) name += 2;
if ((p = strrchr( name, '/' ))) name = p + 1;
if ((p = strrchr( name, '\\' ))) name = p + 1;
@ -752,9 +753,9 @@ HFILE DOSFS_OpenDevice( const char *name, DWORD access )
if (!strcmp(DOSFS_Devices[i].name,"NUL"))
return FILE_CreateFile( "/dev/null", access,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, 0, -1, TRUE );
OPEN_EXISTING, 0, 0, TRUE );
if (!strcmp(DOSFS_Devices[i].name,"CON")) {
HFILE to_dup;
HANDLE to_dup;
switch (access & (GENERIC_READ|GENERIC_WRITE)) {
case GENERIC_READ:
to_dup = GetStdHandle( STD_INPUT_HANDLE );
@ -764,12 +765,11 @@ HFILE DOSFS_OpenDevice( const char *name, DWORD access )
break;
default:
FIXME("can't open CON read/write\n");
return HFILE_ERROR;
break;
return 0;
}
if (!DuplicateHandle( GetCurrentProcess(), to_dup, GetCurrentProcess(),
&handle, 0, FALSE, DUPLICATE_SAME_ACCESS ))
handle = HFILE_ERROR;
handle = 0;
return handle;
}
if (!strcmp(DOSFS_Devices[i].name,"SCSIMGR$") ||
@ -782,11 +782,11 @@ HFILE DOSFS_OpenDevice( const char *name, DWORD access )
return handle;
FIXME("device open %s not supported (yet)\n",DOSFS_Devices[i].name);
return HFILE_ERROR;
return 0;
}
}
}
return HFILE_ERROR;
return 0;
}

View File

@ -181,7 +181,7 @@ void FILE_SetDosError(void)
*
* Duplicate a Unix handle into a task handle.
*/
HFILE FILE_DupUnixHandle( int fd, DWORD access )
HANDLE FILE_DupUnixHandle( int fd, DWORD access )
{
struct alloc_file_handle_request *req = get_req_buffer();
req->access = access;
@ -219,10 +219,11 @@ int FILE_GetUnixHandle( HANDLE handle, DWORD access )
* FILE_OpenConsole
*
* Open a handle to the current process console.
* Returns 0 on failure.
*/
static HANDLE FILE_OpenConsole( BOOL output, DWORD access, LPSECURITY_ATTRIBUTES sa )
{
int ret = -1;
HANDLE ret;
SERVER_START_REQ
{
@ -232,7 +233,8 @@ static HANDLE FILE_OpenConsole( BOOL output, DWORD access, LPSECURITY_ATTRIBUTES
req->access = access;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
SetLastError(0);
if (!server_call( REQ_OPEN_CONSOLE )) ret = req->handle;
server_call( REQ_OPEN_CONSOLE );
ret = req->handle;
}
SERVER_END_REQ;
return ret;
@ -243,6 +245,7 @@ static HANDLE FILE_OpenConsole( BOOL output, DWORD access, LPSECURITY_ATTRIBUTES
* FILE_CreateFile
*
* Implementation of CreateFile. Takes a Unix path name.
* Returns 0 on failure.
*/
HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
LPSECURITY_ATTRIBUTES sa, DWORD creation,
@ -256,7 +259,7 @@ HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
{
FIXME("filename '%s' too long\n", filename );
SetLastError( ERROR_INVALID_PARAMETER );
return -1;
return 0;
}
restart:
@ -277,7 +280,7 @@ HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
/* If write access failed, retry without GENERIC_WRITE */
if ((ret == -1) && !fail_read_only && (access & GENERIC_WRITE))
if (!ret && !fail_read_only && (access & GENERIC_WRITE))
{
if ((err == STATUS_MEDIA_WRITE_PROTECTED) || (err == STATUS_ACCESS_DENIED))
{
@ -288,7 +291,7 @@ HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
}
}
if (ret == -1)
if (!ret)
WARN("Unable to create file '%s' (GLE %ld)\n", filename,
GetLastError());
@ -300,10 +303,11 @@ HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
* FILE_CreateDevice
*
* Same as FILE_CreateFile but for a device
* Returns 0 on failure.
*/
HFILE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa )
HANDLE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa )
{
HFILE ret;
HANDLE ret;
SERVER_START_REQ
{
struct create_device_request *req = server_alloc_req( sizeof(*req), 0 );
@ -353,11 +357,12 @@ HANDLE WINAPI CreateFileA( LPCSTR filename, DWORD access, DWORD sharing,
DWORD attributes, HANDLE template )
{
DOS_FULL_NAME full_name;
HANDLE ret;
if (!filename)
{
SetLastError( ERROR_INVALID_PARAMETER );
return HFILE_ERROR;
return INVALID_HANDLE_VALUE;
}
TRACE("%s %s%s%s%s%s%s%s\n",filename,
((access & GENERIC_READ)==GENERIC_READ)?"GENERIC_READ ":"",
@ -380,13 +385,16 @@ HANDLE WINAPI CreateFileA( LPCSTR filename, DWORD access, DWORD sharing,
{
FIXME("UNC name (%s) not supported.\n", filename );
SetLastError( ERROR_PATH_NOT_FOUND );
return HFILE_ERROR;
return INVALID_HANDLE_VALUE;
}
}
if (!strncmp(filename, "\\\\.\\", 4)) {
if (!DOSFS_GetDevice( filename ))
return DEVICE_Open( filename+4, access, sa );
{
ret = DEVICE_Open( filename+4, access, sa );
goto done;
}
else
filename+=4; /* fall into DOSFS_Device case below */
}
@ -396,30 +404,36 @@ HANDLE WINAPI CreateFileA( LPCSTR filename, DWORD access, DWORD sharing,
{
FIXME("UNC name (%s) not supported.\n", filename );
SetLastError( ERROR_PATH_NOT_FOUND );
return HFILE_ERROR;
return INVALID_HANDLE_VALUE;
}
/* If the name contains a DOS wild card (* or ?), do no create a file */
if(strchr(filename,'*') || strchr(filename,'?'))
return HFILE_ERROR;
return INVALID_HANDLE_VALUE;
/* Open a console for CONIN$ or CONOUT$ */
if (!strcasecmp(filename, "CONIN$")) return FILE_OpenConsole( FALSE, access, sa );
if (!strcasecmp(filename, "CONOUT$")) return FILE_OpenConsole( TRUE, access, sa );
if (!strcasecmp(filename, "CONIN$"))
{
ret = FILE_OpenConsole( FALSE, access, sa );
goto done;
}
if (!strcasecmp(filename, "CONOUT$"))
{
ret = FILE_OpenConsole( TRUE, access, sa );
goto done;
}
if (DOSFS_GetDevice( filename ))
{
HFILE ret;
TRACE("opening device '%s'\n", filename );
if (HFILE_ERROR!=(ret=DOSFS_OpenDevice( filename, access )))
return ret;
/* Do not silence this please. It is a critical error. -MM */
ERR("Couldn't open device '%s'!\n",filename);
SetLastError( ERROR_FILE_NOT_FOUND );
return HFILE_ERROR;
if (!(ret = DOSFS_OpenDevice( filename, access )))
{
/* Do not silence this please. It is a critical error. -MM */
ERR("Couldn't open device '%s'!\n",filename);
SetLastError( ERROR_FILE_NOT_FOUND );
}
goto done;
}
/* check for filename, don't check for last entry if creating */
@ -429,12 +443,15 @@ HANDLE WINAPI CreateFileA( LPCSTR filename, DWORD access, DWORD sharing,
&full_name )) {
WARN("Unable to get full filename from '%s' (GLE %ld)\n",
filename, GetLastError());
return HFILE_ERROR;
return INVALID_HANDLE_VALUE;
}
return FILE_CreateFile( full_name.long_name, access, sharing,
sa, creation, attributes, template,
DRIVE_GetFlags(full_name.drive) & DRIVE_FAIL_READ_ONLY );
ret = FILE_CreateFile( full_name.long_name, access, sharing,
sa, creation, attributes, template,
DRIVE_GetFlags(full_name.drive) & DRIVE_FAIL_READ_ONLY );
done:
if (!ret) ret = INVALID_HANDLE_VALUE;
return ret;
}
@ -877,9 +894,9 @@ found:
}
hFileRet = FILE_CreateFile( full_name.long_name, access, sharing,
NULL, OPEN_EXISTING, 0, -1,
NULL, OPEN_EXISTING, 0, 0,
DRIVE_GetFlags(full_name.drive) & DRIVE_FAIL_READ_ONLY );
if (hFileRet == HFILE_ERROR) goto not_found;
if (!hFileRet) goto not_found;
GetFileTime( hFileRet, NULL, NULL, &filetime );
FileTimeToDosDateTime( &filetime, &filedatetime[0], &filedatetime[1] );

View File

@ -46,15 +46,14 @@ inline static char FILE_toupper( char c )
extern int FILE_strcasecmp( const char *str1, const char *str2 );
extern int FILE_strncasecmp( const char *str1, const char *str2, int len );
extern void FILE_SetDosError(void);
extern HFILE FILE_DupUnixHandle( int fd, DWORD access );
extern HANDLE FILE_DupUnixHandle( int fd, DWORD access );
extern int FILE_GetUnixHandle( HANDLE handle, DWORD access );
extern BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info );
extern HFILE16 FILE_Dup2( HFILE16 hFile1, HFILE16 hFile2 );
extern HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
LPSECURITY_ATTRIBUTES sa, DWORD creation,
DWORD attributes, HANDLE template, BOOL fail_read_only );
extern HFILE FILE_CreateDevice( int client_id, DWORD access,
LPSECURITY_ATTRIBUTES sa );
extern HANDLE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa );
extern LONG WINAPI WIN16_hread(HFILE16,SEGPTR,LONG);
@ -72,7 +71,7 @@ extern time_t DOSFS_FileTimeToUnixTime( const FILETIME *ft, DWORD *remainder );
extern BOOL DOSFS_ToDosFCBFormat( LPCSTR name, LPSTR buffer );
extern const DOS_DEVICE *DOSFS_GetDevice( const char *name );
extern const DOS_DEVICE *DOSFS_GetDeviceByHandle( HFILE hFile );
extern HFILE DOSFS_OpenDevice( const char *name, DWORD access );
extern HANDLE DOSFS_OpenDevice( const char *name, DWORD access );
extern BOOL DOSFS_FindUnixName( LPCSTR path, LPCSTR name, LPSTR long_buf,
INT long_len, LPSTR short_buf,
BOOL ignore_case );

View File

@ -219,7 +219,7 @@ extern HGLOBAL PE_LoadResource(HMODULE,HRSRC);
extern WINE_MODREF *PE_LoadLibraryExA(LPCSTR, DWORD);
extern HMODULE PE_LoadImage( HANDLE hFile, LPCSTR filename, DWORD flags );
extern WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename,
DWORD flags, HFILE hFile, BOOL builtin );
DWORD flags, HANDLE hFile, BOOL builtin );
extern void PE_InitTls(void);
extern BOOL PE_InitDLL( HMODULE module, DWORD type, LPVOID lpReserved );
@ -255,7 +255,7 @@ extern int BUILTIN32_dlclose( void *handle );
/* scheduler/process.c */
extern void PROCESS_CallUserSignalProc( UINT uCode, HMODULE hModule );
extern BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env,
extern BOOL PROCESS_Create( HANDLE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env,
LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
BOOL inherit, DWORD flags,
STARTUPINFOA *startup, PROCESS_INFORMATION *info,

View File

@ -44,6 +44,7 @@ struct request_max_size
/* max size of the variable part of a request */
#define REQUEST_MAX_VAR_SIZE 1024
typedef int handle_t;
/* definitions of the event data depending on the event code */
struct debug_event_exception
@ -53,15 +54,15 @@ struct debug_event_exception
};
struct debug_event_create_thread
{
int handle; /* handle to the new thread */
handle_t handle; /* handle to the new thread */
void *teb; /* thread teb (in debugged process address space) */
void *start; /* thread startup routine */
};
struct debug_event_create_process
{
int file; /* handle to the process exe file */
int process; /* handle to the new process */
int thread; /* handle to the new thread */
handle_t file; /* handle to the process exe file */
handle_t process; /* handle to the new process */
handle_t thread; /* handle to the new thread */
void *base; /* base of executable image */
int dbg_offset; /* offset of debug info in file */
int dbg_size; /* size of debug info */
@ -76,7 +77,7 @@ struct debug_event_exit
};
struct debug_event_load_dll
{
int handle; /* file handle for the dll */
handle_t handle; /* file handle for the dll */
void *base; /* base address of the dll */
int dbg_offset; /* offset of debug info in file */
int dbg_size; /* size of debug info */
@ -125,10 +126,10 @@ struct new_process_request
IN int inherit_all; /* inherit all handles from parent */
IN int create_flags; /* creation flags */
IN int start_flags; /* flags from startup info */
IN int exe_file; /* file handle for main exe */
IN int hstdin; /* handle for stdin */
IN int hstdout; /* handle for stdout */
IN int hstderr; /* handle for stderr */
IN handle_t exe_file; /* file handle for main exe */
IN handle_t hstdin; /* handle for stdin */
IN handle_t hstdout; /* handle for stdout */
IN handle_t hstderr; /* handle for stderr */
IN int cmd_show; /* main window show mode */
IN VARARG(filename,string); /* file name of main exe */
};
@ -143,10 +144,10 @@ struct wait_process_request
IN int timeout; /* wait timeout */
IN int cancel; /* cancel the process creation? */
OUT void* pid; /* process id */
OUT int phandle; /* process handle (in the current process) */
OUT handle_t phandle; /* process handle (in the current process) */
OUT void* tid; /* thread id */
OUT int thandle; /* thread handle (in the current process) */
OUT int event; /* event handle to signal startup */
OUT handle_t thandle; /* thread handle (in the current process) */
OUT handle_t event; /* event handle to signal startup */
};
@ -154,10 +155,10 @@ struct wait_process_request
struct new_thread_request
{
REQUEST_HEADER; /* request header */
IN int suspend; /* new thread should be suspended on creation */
IN int suspend; /* new thread should be suspended on creation */
IN int inherit; /* inherit flag */
OUT void* tid; /* thread id */
OUT int handle; /* thread handle (in the current process) */
OUT handle_t handle; /* thread handle (in the current process) */
};
@ -177,10 +178,10 @@ struct init_process_request
IN int ppid; /* parent Unix pid */
OUT int start_flags; /* flags from startup info */
OUT unsigned int server_start; /* server start time (GetTickCount) */
OUT int exe_file; /* file handle for main exe */
OUT int hstdin; /* handle for stdin */
OUT int hstdout; /* handle for stdout */
OUT int hstderr; /* handle for stderr */
OUT handle_t exe_file; /* file handle for main exe */
OUT handle_t hstdin; /* handle for stdin */
OUT handle_t hstdout; /* handle for stdout */
OUT handle_t hstderr; /* handle for stderr */
OUT int cmd_show; /* main window show mode */
OUT VARARG(filename,string); /* file name of main exe */
};
@ -225,7 +226,7 @@ struct get_thread_buffer_request
struct terminate_process_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* process handle to terminate */
IN handle_t handle; /* process handle to terminate */
IN int exit_code; /* process exit code */
OUT int self; /* suicide? */
};
@ -235,7 +236,7 @@ struct terminate_process_request
struct terminate_thread_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* thread handle to terminate */
IN handle_t handle; /* thread handle to terminate */
IN int exit_code; /* thread exit code */
OUT int self; /* suicide? */
OUT int last; /* last thread in this process? */
@ -246,7 +247,7 @@ struct terminate_thread_request
struct get_process_info_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* process handle */
IN handle_t handle; /* process handle */
OUT void* pid; /* server process id */
OUT int debugged; /* debugged? */
OUT int exit_code; /* process exit code */
@ -260,7 +261,7 @@ struct get_process_info_request
struct set_process_info_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* process handle */
IN handle_t handle; /* process handle */
IN int mask; /* setting mask (see below) */
IN int priority; /* priority class */
IN int affinity; /* affinity mask */
@ -273,7 +274,7 @@ struct set_process_info_request
struct get_thread_info_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* thread handle */
IN handle_t handle; /* thread handle */
IN void* tid_in; /* thread id (optional) */
OUT void* tid; /* server thread id */
OUT void* teb; /* thread teb pointer */
@ -286,7 +287,7 @@ struct get_thread_info_request
struct set_thread_info_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* thread handle */
IN handle_t handle; /* thread handle */
IN int mask; /* setting mask (see below) */
IN int priority; /* priority class */
IN int affinity; /* affinity mask */
@ -299,7 +300,7 @@ struct set_thread_info_request
struct suspend_thread_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* thread handle */
IN handle_t handle; /* thread handle */
OUT int count; /* new suspend count */
};
@ -308,7 +309,7 @@ struct suspend_thread_request
struct resume_thread_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* thread handle */
IN handle_t handle; /* thread handle */
OUT int count; /* new suspend count */
};
@ -317,7 +318,7 @@ struct resume_thread_request
struct load_dll_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* file handle */
IN handle_t handle; /* file handle */
IN void* base; /* base address */
IN int dbg_offset; /* debug info offset */
IN int dbg_size; /* debug info size */
@ -337,7 +338,7 @@ struct unload_dll_request
struct queue_apc_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* thread handle */
IN handle_t handle; /* thread handle */
IN void* func; /* function to call */
IN void* param; /* param for function to call */
};
@ -358,7 +359,7 @@ enum apc_type { APC_NONE, APC_USER, APC_TIMER, APC_ASYNC };
struct close_handle_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to close */
IN handle_t handle; /* handle to close */
OUT int fd; /* associated fd to close */
};
@ -367,7 +368,7 @@ struct close_handle_request
struct set_handle_info_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle we are interested in */
IN handle_t handle; /* handle we are interested in */
IN int flags; /* new handle flags */
IN int mask; /* mask for flags to set */
IN int fd; /* file descriptor or -1 */
@ -380,13 +381,13 @@ struct set_handle_info_request
struct dup_handle_request
{
REQUEST_HEADER; /* request header */
IN int src_process; /* src process handle */
IN int src_handle; /* src handle to duplicate */
IN int dst_process; /* dst process handle */
IN handle_t src_process; /* src process handle */
IN handle_t src_handle; /* src handle to duplicate */
IN handle_t dst_process; /* dst process handle */
IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */
IN int options; /* duplicate options (see below) */
OUT int handle; /* duplicated handle in dst process */
OUT handle_t handle; /* duplicated handle in dst process */
OUT int fd; /* associated fd to close */
};
#define DUP_HANDLE_CLOSE_SOURCE DUPLICATE_CLOSE_SOURCE
@ -401,7 +402,7 @@ struct open_process_request
IN void* pid; /* process id to open */
IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */
OUT int handle; /* handle to the process */
OUT handle_t handle; /* handle to the process */
};
@ -412,7 +413,7 @@ struct select_request
IN int flags; /* wait flags (see below) */
IN int timeout; /* timeout in ms */
OUT int signaled; /* signaled handle */
IN VARARG(handles,ints); /* handles to select on */
IN VARARG(handles,handles); /* handles to select on */
};
#define SELECT_ALL 1
#define SELECT_ALERTABLE 2
@ -426,7 +427,7 @@ struct create_event_request
IN int manual_reset; /* manual reset event */
IN int initial_state; /* initial state of the event */
IN int inherit; /* inherit flag */
OUT int handle; /* handle to the event */
OUT handle_t handle; /* handle to the event */
IN VARARG(name,unicode_str); /* object name */
};
@ -434,7 +435,7 @@ struct create_event_request
struct event_op_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to event */
IN handle_t handle; /* handle to event */
IN int op; /* event operation (see below) */
};
enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
@ -446,7 +447,7 @@ struct open_event_request
REQUEST_HEADER; /* request header */
IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */
OUT int handle; /* handle to the event */
OUT handle_t handle; /* handle to the event */
IN VARARG(name,unicode_str); /* object name */
};
@ -457,7 +458,7 @@ struct create_mutex_request
REQUEST_HEADER; /* request header */
IN int owned; /* initially owned? */
IN int inherit; /* inherit flag */
OUT int handle; /* handle to the mutex */
OUT handle_t handle; /* handle to the mutex */
IN VARARG(name,unicode_str); /* object name */
};
@ -466,7 +467,7 @@ struct create_mutex_request
struct release_mutex_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the mutex */
IN handle_t handle; /* handle to the mutex */
};
@ -476,7 +477,7 @@ struct open_mutex_request
REQUEST_HEADER; /* request header */
IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */
OUT int handle; /* handle to the mutex */
OUT handle_t handle; /* handle to the mutex */
IN VARARG(name,unicode_str); /* object name */
};
@ -488,7 +489,7 @@ struct create_semaphore_request
IN unsigned int initial; /* initial count */
IN unsigned int max; /* maximum count */
IN int inherit; /* inherit flag */
OUT int handle; /* handle to the semaphore */
OUT handle_t handle; /* handle to the semaphore */
IN VARARG(name,unicode_str); /* object name */
};
@ -497,7 +498,7 @@ struct create_semaphore_request
struct release_semaphore_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the semaphore */
IN handle_t handle; /* handle to the semaphore */
IN unsigned int count; /* count to add to semaphore */
OUT unsigned int prev_count; /* previous semaphore count */
};
@ -509,7 +510,7 @@ struct open_semaphore_request
REQUEST_HEADER; /* request header */
IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */
OUT int handle; /* handle to the semaphore */
OUT handle_t handle; /* handle to the semaphore */
IN VARARG(name,unicode_str); /* object name */
};
@ -523,7 +524,7 @@ struct create_file_request
IN unsigned int sharing; /* sharing flags */
IN int create; /* file create action */
IN unsigned int attrs; /* file attributes for creation */
OUT int handle; /* handle to the file */
OUT handle_t handle; /* handle to the file */
IN VARARG(filename,string); /* file name */
};
@ -533,7 +534,7 @@ struct alloc_file_handle_request
{
REQUEST_HEADER; /* request header */
IN unsigned int access; /* wanted access rights */
OUT int handle; /* handle to the file */
OUT handle_t handle; /* handle to the file */
};
@ -541,7 +542,7 @@ struct alloc_file_handle_request
struct get_handle_fd_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the file */
IN handle_t handle; /* handle to the file */
IN unsigned int access; /* wanted access rights */
OUT int fd; /* file descriptor */
};
@ -551,7 +552,7 @@ struct get_handle_fd_request
struct set_file_pointer_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the file */
IN handle_t handle; /* handle to the file */
IN int low; /* position low word */
IN int high; /* position high word */
IN int whence; /* whence to seek */
@ -564,7 +565,7 @@ struct set_file_pointer_request
struct truncate_file_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the file */
IN handle_t handle; /* handle to the file */
};
@ -572,7 +573,7 @@ struct truncate_file_request
struct set_file_time_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the file */
IN handle_t handle; /* handle to the file */
IN time_t access_time; /* last access time */
IN time_t write_time; /* last write time */
};
@ -582,7 +583,7 @@ struct set_file_time_request
struct flush_file_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the file */
IN handle_t handle; /* handle to the file */
};
@ -590,7 +591,7 @@ struct flush_file_request
struct get_file_info_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the file */
IN handle_t handle; /* handle to the file */
OUT int type; /* file type */
OUT int attr; /* file attributes */
OUT time_t access_time; /* last access time */
@ -608,7 +609,7 @@ struct get_file_info_request
struct lock_file_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the file */
IN handle_t handle; /* handle to the file */
IN unsigned int offset_low; /* offset of start of lock */
IN unsigned int offset_high; /* offset of start of lock */
IN unsigned int count_low; /* count of bytes to lock */
@ -620,7 +621,7 @@ struct lock_file_request
struct unlock_file_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the file */
IN handle_t handle; /* handle to the file */
IN unsigned int offset_low; /* offset of start of unlock */
IN unsigned int offset_high; /* offset of start of unlock */
IN unsigned int count_low; /* count of bytes to unlock */
@ -633,8 +634,8 @@ struct create_pipe_request
{
REQUEST_HEADER; /* request header */
IN int inherit; /* inherit flag */
OUT int handle_read; /* handle to the read-side of the pipe */
OUT int handle_write; /* handle to the write-side of the pipe */
OUT handle_t handle_read; /* handle to the read-side of the pipe */
OUT handle_t handle_write; /* handle to the write-side of the pipe */
};
@ -647,7 +648,7 @@ struct create_socket_request
IN int family; /* family, see socket manpage */
IN int type; /* type, see socket manpage */
IN int protocol; /* protocol, see socket manpage */
OUT int handle; /* handle to the new socket */
OUT handle_t handle; /* handle to the new socket */
};
@ -655,10 +656,10 @@ struct create_socket_request
struct accept_socket_request
{
REQUEST_HEADER; /* request header */
IN int lhandle; /* handle to the listening socket */
IN handle_t lhandle; /* handle to the listening socket */
IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */
OUT int handle; /* handle to the new socket */
OUT handle_t handle; /* handle to the new socket */
};
@ -666,9 +667,9 @@ struct accept_socket_request
struct set_socket_event_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the socket */
IN handle_t handle; /* handle to the socket */
IN unsigned int mask; /* event mask */
IN int event; /* event object */
IN handle_t event; /* event object */
};
@ -676,10 +677,10 @@ struct set_socket_event_request
struct get_socket_event_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the socket */
IN handle_t handle; /* handle to the socket */
IN int service; /* clear pending? */
IN int s_event; /* "expected" event object */
IN int c_event; /* event to clear */
IN handle_t s_event; /* "expected" event object */
IN handle_t c_event; /* event to clear */
OUT unsigned int mask; /* event mask */
OUT unsigned int pmask; /* pending events */
OUT unsigned int state; /* status bits */
@ -691,7 +692,7 @@ struct get_socket_event_request
struct enable_socket_event_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the socket */
IN handle_t handle; /* handle to the socket */
IN unsigned int mask; /* events to re-enable */
IN unsigned int sstate; /* status bits to set */
IN unsigned int cstate; /* status bits to clear */
@ -704,8 +705,8 @@ struct alloc_console_request
REQUEST_HEADER; /* request header */
IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */
OUT int handle_in; /* handle to console input */
OUT int handle_out; /* handle to console output */
OUT handle_t handle_in; /* handle to console input */
OUT handle_t handle_out; /* handle to console output */
};
@ -723,7 +724,7 @@ struct open_console_request
IN int output; /* input or output? */
IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */
OUT int handle; /* handle to the console */
OUT handle_t handle; /* handle to the console */
};
@ -731,8 +732,8 @@ struct open_console_request
struct set_console_fd_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the console */
IN int file_handle; /* handle of file to use as file descriptor */
IN handle_t handle; /* handle to the console */
IN handle_t file_handle; /* handle of file to use as file descriptor */
IN int pid; /* pid of xterm (hack) */
};
@ -741,7 +742,7 @@ struct set_console_fd_request
struct get_console_mode_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the console */
IN handle_t handle; /* handle to the console */
OUT int mode; /* console mode */
};
@ -750,7 +751,7 @@ struct get_console_mode_request
struct set_console_mode_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the console */
IN handle_t handle; /* handle to the console */
IN int mode; /* console mode */
};
@ -759,7 +760,7 @@ struct set_console_mode_request
struct set_console_info_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the console */
IN handle_t handle; /* handle to the console */
IN int mask; /* setting mask (see below) */
IN int cursor_size; /* size of cursor (percentage filled) */
IN int cursor_visible;/* cursor visibility flag */
@ -772,7 +773,7 @@ struct set_console_info_request
struct get_console_info_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the console */
IN handle_t handle; /* handle to the console */
OUT int cursor_size; /* size of cursor (percentage filled) */
OUT int cursor_visible;/* cursor visibility flag */
OUT int pid; /* pid of xterm (hack) */
@ -784,7 +785,7 @@ struct get_console_info_request
struct write_console_input_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the console input */
IN handle_t handle; /* handle to the console input */
OUT int written; /* number of records written */
IN VARARG(rec,input_records); /* input records */
};
@ -793,7 +794,7 @@ struct write_console_input_request
struct read_console_input_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the console input */
IN handle_t handle; /* handle to the console input */
IN int flush; /* flush the retrieved records from the queue? */
OUT int read; /* number of records read */
OUT VARARG(rec,input_records); /* input records */
@ -806,7 +807,7 @@ struct create_change_notification_request
REQUEST_HEADER; /* request header */
IN int subtree; /* watch all the subtree */
IN int filter; /* notification filter */
OUT int handle; /* handle to the change notification */
OUT handle_t handle; /* handle to the change notification */
};
@ -818,8 +819,8 @@ struct create_mapping_request
IN int size_low; /* mapping size */
IN int protect; /* protection flags (see below) */
IN int inherit; /* inherit flag */
IN int file_handle; /* file handle */
OUT int handle; /* handle to the mapping */
IN handle_t file_handle; /* file handle */
OUT handle_t handle; /* handle to the mapping */
IN VARARG(name,unicode_str); /* object name */
};
/* protection flags */
@ -839,7 +840,7 @@ struct open_mapping_request
REQUEST_HEADER; /* request header */
IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */
OUT int handle; /* handle to the mapping */
OUT handle_t handle; /* handle to the mapping */
IN VARARG(name,unicode_str); /* object name */
};
@ -848,13 +849,13 @@ struct open_mapping_request
struct get_mapping_info_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the mapping */
IN handle_t handle; /* handle to the mapping */
OUT int size_high; /* mapping size */
OUT int size_low; /* mapping size */
OUT int protect; /* protection flags */
OUT int header_size; /* header size (for VPROT_IMAGE mapping) */
OUT void* base; /* default base addr (for VPROT_IMAGE mapping) */
OUT int shared_file; /* shared mapping file handle */
OUT handle_t shared_file; /* shared mapping file handle */
OUT int shared_size; /* shared mapping size */
OUT int anonymous; /* anonymous mapping? */
};
@ -867,7 +868,7 @@ struct create_device_request
IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */
IN int id; /* client private id */
OUT int handle; /* handle to the device */
OUT handle_t handle; /* handle to the device */
};
@ -878,7 +879,7 @@ struct create_snapshot_request
IN int inherit; /* inherit flag */
IN int flags; /* snapshot flags (TH32CS_*) */
IN void* pid; /* process id */
OUT int handle; /* handle to the snapshot */
OUT handle_t handle; /* handle to the snapshot */
};
@ -886,7 +887,7 @@ struct create_snapshot_request
struct next_process_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the snapshot */
IN handle_t handle; /* handle to the snapshot */
IN int reset; /* reset snapshot position? */
OUT int count; /* process usage count */
OUT void* pid; /* process id */
@ -899,7 +900,7 @@ struct next_process_request
struct next_thread_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the snapshot */
IN handle_t handle; /* handle to the snapshot */
IN int reset; /* reset snapshot position? */
OUT int count; /* thread usage count */
OUT void* pid; /* process id */
@ -913,7 +914,7 @@ struct next_thread_request
struct next_module_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the snapshot */
IN handle_t handle; /* handle to the snapshot */
IN int reset; /* reset snapshot position? */
OUT void* pid; /* process id */
OUT void* base; /* module base address */
@ -974,7 +975,7 @@ struct debug_process_request
struct read_process_memory_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* process handle */
IN handle_t handle; /* process handle */
IN void* addr; /* addr to read from (must be int-aligned) */
IN int len; /* number of ints to read */
OUT VARARG(data,bytes); /* result data */
@ -985,7 +986,7 @@ struct read_process_memory_request
struct write_process_memory_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* process handle */
IN handle_t handle; /* process handle */
IN void* addr; /* addr to write to (must be int-aligned) */
IN int len; /* number of ints to write */
IN unsigned int first_mask; /* mask for first word */
@ -998,11 +999,11 @@ struct write_process_memory_request
struct create_key_request
{
REQUEST_HEADER; /* request header */
IN int parent; /* handle to the parent key */
IN handle_t parent; /* handle to the parent key */
IN unsigned int access; /* desired access rights */
IN unsigned int options; /* creation options */
IN time_t modif; /* last modification time */
OUT int hkey; /* handle to the created key */
OUT handle_t hkey; /* handle to the created key */
OUT int created; /* has it been newly created? */
IN VARARG(name,unicode_len_str); /* key name */
IN VARARG(class,unicode_str); /* class name */
@ -1012,9 +1013,9 @@ struct create_key_request
struct open_key_request
{
REQUEST_HEADER; /* request header */
IN int parent; /* handle to the parent key */
IN handle_t parent; /* handle to the parent key */
IN unsigned int access; /* desired access rights */
OUT int hkey; /* handle to the open key */
OUT handle_t hkey; /* handle to the open key */
IN VARARG(name,unicode_str); /* key name */
};
@ -1023,7 +1024,7 @@ struct open_key_request
struct delete_key_request
{
REQUEST_HEADER; /* request header */
IN int hkey; /* handle to the key */
IN handle_t hkey; /* handle to the key */
};
@ -1031,7 +1032,7 @@ struct delete_key_request
struct enum_key_request
{
REQUEST_HEADER; /* request header */
IN int hkey; /* handle to registry key */
IN handle_t hkey; /* handle to registry key */
IN int index; /* index of subkey (or -1 for current key) */
IN int full; /* return the full info? */
OUT int subkeys; /* number of subkeys */
@ -1050,7 +1051,7 @@ struct enum_key_request
struct set_key_value_request
{
REQUEST_HEADER; /* request header */
IN int hkey; /* handle to registry key */
IN handle_t hkey; /* handle to registry key */
IN int type; /* value type */
IN unsigned int total; /* total value len */
IN unsigned int offset; /* offset for setting data */
@ -1063,7 +1064,7 @@ struct set_key_value_request
struct get_key_value_request
{
REQUEST_HEADER; /* request header */
IN int hkey; /* handle to registry key */
IN handle_t hkey; /* handle to registry key */
IN unsigned int offset; /* offset for getting data */
OUT int type; /* value type */
OUT int len; /* value data len */
@ -1076,7 +1077,7 @@ struct get_key_value_request
struct enum_key_value_request
{
REQUEST_HEADER; /* request header */
IN int hkey; /* handle to registry key */
IN handle_t hkey; /* handle to registry key */
IN int index; /* value index */
IN unsigned int offset; /* offset for getting data */
OUT int type; /* value type */
@ -1090,7 +1091,7 @@ struct enum_key_value_request
struct delete_key_value_request
{
REQUEST_HEADER; /* request header */
IN int hkey; /* handle to registry key */
IN handle_t hkey; /* handle to registry key */
IN VARARG(name,unicode_str); /* value name */
};
@ -1099,8 +1100,8 @@ struct delete_key_value_request
struct load_registry_request
{
REQUEST_HEADER; /* request header */
IN int hkey; /* root key to load to */
IN int file; /* file to load from */
IN handle_t hkey; /* root key to load to */
IN handle_t file; /* file to load from */
IN VARARG(name,unicode_str); /* subkey name */
};
@ -1109,8 +1110,8 @@ struct load_registry_request
struct save_registry_request
{
REQUEST_HEADER; /* request header */
IN int hkey; /* key to save */
IN int file; /* file to save to */
IN handle_t hkey; /* key to save */
IN handle_t file; /* file to save to */
};
@ -1118,7 +1119,7 @@ struct save_registry_request
struct save_registry_atexit_request
{
REQUEST_HEADER; /* request header */
IN int hkey; /* key to save */
IN handle_t hkey; /* key to save */
IN VARARG(file,string); /* file to save to */
};
@ -1139,7 +1140,7 @@ struct create_timer_request
REQUEST_HEADER; /* request header */
IN int inherit; /* inherit flag */
IN int manual; /* manual reset */
OUT int handle; /* handle to the timer */
OUT handle_t handle; /* handle to the timer */
IN VARARG(name,unicode_str); /* object name */
};
@ -1150,7 +1151,7 @@ struct open_timer_request
REQUEST_HEADER; /* request header */
IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */
OUT int handle; /* handle to the timer */
OUT handle_t handle; /* handle to the timer */
IN VARARG(name,unicode_str); /* object name */
};
@ -1158,7 +1159,7 @@ struct open_timer_request
struct set_timer_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the timer */
IN handle_t handle; /* handle to the timer */
IN int sec; /* next expiration absolute time */
IN int usec; /* next expiration absolute time */
IN int period; /* timer period in ms */
@ -1170,7 +1171,7 @@ struct set_timer_request
struct cancel_timer_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the timer */
IN handle_t handle; /* handle to the timer */
};
@ -1178,7 +1179,7 @@ struct cancel_timer_request
struct get_thread_context_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* thread handle */
IN handle_t handle; /* thread handle */
IN unsigned int flags; /* context flags */
OUT VARARG(context,context); /* thread context */
};
@ -1188,7 +1189,7 @@ struct get_thread_context_request
struct set_thread_context_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* thread handle */
IN handle_t handle; /* thread handle */
IN unsigned int flags; /* context flags */
IN VARARG(context,context); /* thread context */
};
@ -1198,7 +1199,7 @@ struct set_thread_context_request
struct get_selector_entry_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* thread handle */
IN handle_t handle; /* thread handle */
IN int entry; /* LDT entry */
OUT unsigned int base; /* selector base */
OUT unsigned int limit; /* selector limit */
@ -1258,14 +1259,14 @@ struct init_atom_table_request
struct get_msg_queue_request
{
REQUEST_HEADER; /* request header */
OUT int handle; /* handle to the queue */
OUT handle_t handle; /* handle to the queue */
};
/* Wake up a message queue */
struct wake_queue_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to the queue */
IN handle_t handle; /* handle to the queue */
IN unsigned int bits; /* wake bits */
};
@ -1273,9 +1274,9 @@ struct wake_queue_request
struct wait_input_idle_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* process handle */
IN handle_t handle; /* process handle */
IN int timeout; /* timeout */
OUT int event; /* handle to idle event */
OUT handle_t event; /* handle to idle event */
};
struct create_serial_request
@ -1284,14 +1285,14 @@ struct create_serial_request
IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */
IN unsigned int sharing; /* sharing flags */
OUT int handle; /* handle to the port */
OUT handle_t handle; /* handle to the port */
IN VARARG(name,string); /* file name */
};
struct get_serial_info_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to comm port */
IN handle_t handle; /* handle to comm port */
OUT unsigned int readinterval;
OUT unsigned int readconst;
OUT unsigned int readmult;
@ -1304,7 +1305,7 @@ struct get_serial_info_request
struct set_serial_info_request
{
REQUEST_HEADER; /* request header */
IN int handle; /* handle to comm port */
IN handle_t handle; /* handle to comm port */
IN int flags; /* bitmask to set values (see below) */
IN unsigned int readinterval;
IN unsigned int readconst;
@ -1321,13 +1322,13 @@ struct set_serial_info_request
struct create_async_request
{
REQUEST_HEADER; /* request header */
IN int file_handle; /* handle to comm port */
IN handle_t file_handle; /* handle to comm port */
IN void* overlapped;
IN void* buffer;
IN int count;
IN void* func;
IN int type;
OUT int ov_handle;
OUT handle_t ov_handle;
};
#define ASYNC_TYPE_READ 0x01
#define ASYNC_TYPE_WRITE 0x02
@ -1340,7 +1341,7 @@ struct create_async_request
struct async_result_request
{
REQUEST_HEADER; /* request header */
IN int ov_handle;
IN handle_t ov_handle;
IN int result; /* NT status code */
};
@ -1574,7 +1575,7 @@ union generic_request
struct async_result_request async_result;
};
#define SERVER_PROTOCOL_VERSION 31
#define SERVER_PROTOCOL_VERSION 32
/* ### make_requests end ### */
/* Everything above this line is generated automatically by tools/make_requests */

View File

@ -164,7 +164,7 @@ WINE_MODREF *ELF_LoadLibraryExA( LPCSTR libname, DWORD flags)
SNOOP_RegisterDLL(hmod,libname,STUBSIZE/sizeof(ELF_STDCALL_STUB));
wm = PE_CreateModule( hmod, libname, 0, -1, FALSE );
wm = PE_CreateModule( hmod, libname, 0, 0, FALSE );
wm->find_export = ELF_FindExportedFunction;
wm->dlhandle = dlhandle;
return wm;

View File

@ -1089,7 +1089,7 @@ BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine,
if ( !MODULE_GetBinaryType( hFile, name, &type ) )
{
CloseHandle( hFile );
retv = PROCESS_Create( -1, name, tidy_cmdline, lpEnvironment,
retv = PROCESS_Create( 0, name, tidy_cmdline, lpEnvironment,
lpProcessAttributes, lpThreadAttributes,
bInheritHandles, dwCreationFlags,
lpStartupInfo, lpProcessInfo, lpCurrentDirectory );

View File

@ -1019,7 +1019,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
TDB *pTask;
LPSTR cmdline;
WORD cmdShow;
HANDLE hThread = -1;
HANDLE hThread = 0;
int socket = -1;
/* Load module */
@ -1074,7 +1074,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
}
}
SERVER_END_REQ;
if (hThread == -1) return 0;
if (!hThread) return 0;
if (!(teb = THREAD_Create( socket, 0, FALSE ))) goto error;
teb->tibflags &= ~TEBF_WIN32;

View File

@ -533,7 +533,7 @@ HMODULE PE_LoadImage( HANDLE hFile, LPCSTR filename, DWORD flags )
* Note: Assumes that the process critical section is held
*/
WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
HFILE hFile, BOOL builtin )
HANDLE hFile, BOOL builtin )
{
DWORD load_addr = (DWORD)hModule; /* for RVA */
IMAGE_NT_HEADERS *nt = PE_HEADER(hModule);

View File

@ -494,7 +494,7 @@ static LPVOID map_image( HANDLE hmapping, int fd, char *base, DWORD total_size,
{
if ((shared_fd = FILE_GetUnixHandle( shared_file, GENERIC_READ )) == -1) goto error;
CloseHandle( shared_file ); /* we no longer need it */
shared_file = INVALID_HANDLE_VALUE;
shared_file = 0;
}
/* map all the sections */
@ -571,7 +571,7 @@ static LPVOID map_image( HANDLE hmapping, int fd, char *base, DWORD total_size,
if (view) VIRTUAL_DeleteView( view );
close( fd );
if (shared_fd != -1) close( shared_fd );
if (shared_file != INVALID_HANDLE_VALUE) CloseHandle( shared_file );
if (shared_file) CloseHandle( shared_file );
return NULL;
}
@ -1295,6 +1295,7 @@ HANDLE WINAPI CreateFileMappingA(
/* Create the server object */
if (hFile == INVALID_HANDLE_VALUE) hFile = 0;
SERVER_START_REQ
{
struct create_mapping_request *req = server_alloc_req( sizeof(*req),
@ -1310,7 +1311,6 @@ HANDLE WINAPI CreateFileMappingA(
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -1353,6 +1353,7 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa,
/* Create the server object */
if (hFile == INVALID_HANDLE_VALUE) hFile = 0;
SERVER_START_REQ
{
struct create_mapping_request *req = server_alloc_req( sizeof(*req),
@ -1368,7 +1369,6 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa,
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -1404,7 +1404,6 @@ HANDLE WINAPI OpenFileMappingA(
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -1433,7 +1432,6 @@ HANDLE WINAPI OpenFileMappingW( DWORD access, BOOL inherit, LPCWSTR name)
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}

View File

@ -1184,7 +1184,7 @@ static void load_wine_registry(HKEY hkey,LPCSTR fn)
case WINE_REG_VER_2: {
HANDLE file;
if ((file = FILE_CreateFile( fn, GENERIC_READ, 0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, -1, TRUE )) != INVALID_HANDLE_VALUE)
FILE_ATTRIBUTE_NORMAL, 0, TRUE )))
{
SERVER_START_REQ
{

View File

@ -88,7 +88,7 @@ static void load_library( void *base, const char *filename )
MESSAGE( "Warning: loading builtin %s, but native version already present. Expect trouble.\n", filename );
/* Create 32-bit MODREF */
if (!(wm = PE_CreateModule( module, filename, 0, -1, TRUE )))
if (!(wm = PE_CreateModule( module, filename, 0, 0, TRUE )))
{
ERR( "can't load %s\n", filename );
SetLastError( ERROR_OUTOFMEMORY );

View File

@ -602,15 +602,15 @@ int CLIENT_InitThread(void)
/* ignore SIGPIPE so that we get a EPIPE error instead */
signal( SIGPIPE, SIG_IGN );
teb->request_fd = wine_server_recv_fd( -1, 0 );
teb->request_fd = wine_server_recv_fd( 0, 0 );
if (teb->request_fd == -1) server_protocol_error( "no request fd passed on first request\n" );
fcntl( teb->request_fd, F_SETFD, 1 ); /* set close on exec flag */
teb->reply_fd = wine_server_recv_fd( -1, 0 );
teb->reply_fd = wine_server_recv_fd( 0, 0 );
if (teb->reply_fd == -1) server_protocol_error( "no reply fd passed on first request\n" );
fcntl( teb->reply_fd, F_SETFD, 1 ); /* set close on exec flag */
fd = wine_server_recv_fd( -1, 0 );
fd = wine_server_recv_fd( 0, 0 );
if (fd == -1) server_protocol_error( "no fd received for thread buffer\n" );
if ((size = lseek( fd, 0, SEEK_END )) == -1) server_perror( "lseek" );

View File

@ -111,7 +111,7 @@ BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
{
HANDLE ret = INVALID_HANDLE_VALUE;
DuplicateHandle( GetCurrentProcess(), hSrc, (HANDLE)-1, &ret, 0, FALSE,
DuplicateHandle( GetCurrentProcess(), hSrc, GetCurrentProcess(), &ret, 0, FALSE,
DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE );
return ret;
}

View File

@ -95,7 +95,7 @@ PDB current_process;
static char **main_exe_argv;
static char main_exe_name[MAX_PATH];
static HANDLE main_exe_file = INVALID_HANDLE_VALUE;
static HANDLE main_exe_file;
unsigned int server_startticks;
@ -460,7 +460,7 @@ void PROCESS_InitWine( int argc, char *argv[] )
}
}
if (main_exe_file == INVALID_HANDLE_VALUE)
if (!main_exe_file)
{
if ((main_exe_file = CreateFileA( main_exe_name, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, -1 )) == INVALID_HANDLE_VALUE)
@ -484,7 +484,7 @@ void PROCESS_InitWine( int argc, char *argv[] )
current_process.flags |= PDB32_WIN16_PROC;
main_exe_name[0] = 0;
CloseHandle( main_exe_file );
main_exe_file = INVALID_HANDLE_VALUE;
main_exe_file = 0;
_EnterWin16Lock();
found:
@ -731,7 +731,7 @@ static int fork_and_exec( const char *filename, char *cmdline,
* file, and we exec a new copy of wine to load it; otherwise we
* simply exec the specified filename as a Unix process.
*/
BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env,
BOOL PROCESS_Create( HANDLE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env,
LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
BOOL inherit, DWORD flags, LPSTARTUPINFOA startup,
LPPROCESS_INFORMATION info, LPCSTR lpCurrentDirectory )
@ -741,9 +741,9 @@ BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env,
const char *unixfilename = NULL;
const char *unixdir = NULL;
DOS_FULL_NAME full_dir, full_name;
HANDLE load_done_evt = (HANDLE)-1;
HANDLE load_done_evt = 0;
info->hThread = info->hProcess = INVALID_HANDLE_VALUE;
info->hThread = info->hProcess = 0;
if (lpCurrentDirectory)
{
@ -783,7 +783,7 @@ BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env,
}
req->cmd_show = startup->wShowWindow;
if (hFile == -1) /* unix process */
if (!hFile) /* unix process */
{
unixfilename = filename;
if (DOSFS_GetFullName( filename, TRUE, &full_name ))
@ -824,7 +824,7 @@ BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env,
if (!ret || (pid == -1)) goto error;
/* Wait until process is initialized (or initialization failed) */
if (load_done_evt != (HANDLE)-1)
if (load_done_evt)
{
DWORD res;
HANDLE handles[2];
@ -845,9 +845,9 @@ BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env,
return TRUE;
error:
if (load_done_evt != (HANDLE)-1) CloseHandle( load_done_evt );
if (info->hThread != INVALID_HANDLE_VALUE) CloseHandle( info->hThread );
if (info->hProcess != INVALID_HANDLE_VALUE) CloseHandle( info->hProcess );
if (load_done_evt) CloseHandle( load_done_evt );
if (info->hThread) CloseHandle( info->hThread );
if (info->hProcess) CloseHandle( info->hProcess );
return FALSE;
}

View File

@ -58,7 +58,7 @@ TEB *THREAD_IdToTEB( DWORD id )
SERVER_START_REQ
{
struct get_thread_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = -1;
req->handle = 0;
req->tid_in = (void *)id;
if (!server_call_noerr( REQ_GET_THREAD_INFO )) ret = req->teb;
}
@ -284,7 +284,8 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack,
LPTHREAD_START_ROUTINE start, LPVOID param,
DWORD flags, LPDWORD id )
{
int socket = -1, handle = -1;
int socket = -1;
HANDLE handle = 0;
TEB *teb;
void *tid = 0;
@ -302,7 +303,7 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack,
}
}
SERVER_END_REQ;
if (handle == -1) return 0;
if (!handle) return 0;
if (!(teb = THREAD_Create( socket, stack, TRUE )))
{

View File

@ -37,7 +37,6 @@ HANDLE WINAPI CreateWaitableTimerA( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCSTR
ret = req->handle;
}
SERVER_END_REQ;
if (ret == INVALID_HANDLE_VALUE) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -66,7 +65,6 @@ HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWST
ret = req->handle;
}
SERVER_END_REQ;
if (ret == INVALID_HANDLE_VALUE) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -94,7 +92,6 @@ HANDLE WINAPI OpenWaitableTimerA( DWORD access, BOOL inherit, LPCSTR name )
ret = req->handle;
}
SERVER_END_REQ;
if (ret == INVALID_HANDLE_VALUE) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
@ -122,7 +119,6 @@ HANDLE WINAPI OpenWaitableTimerW( DWORD access, BOOL inherit, LPCWSTR name )
ret = req->handle;
}
SERVER_END_REQ;
if (ret == INVALID_HANDLE_VALUE) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}

View File

@ -99,7 +99,7 @@ static void async_destroy( struct object *obj )
ov->timeout = NULL;
}
struct async *get_async_obj( struct process *process, int handle, unsigned int access )
struct async *get_async_obj( struct process *process, handle_t handle, unsigned int access )
{
return (struct async *)get_handle_obj( process, handle, access, &async_ops );
}
@ -162,7 +162,7 @@ DECL_HANDLER(create_async)
struct async *ov = NULL;
int fd;
req->ov_handle = -1;
req->ov_handle = 0;
if (!(obj = get_handle_obj( current->process, req->file_handle, 0, NULL)) )
return;

View File

@ -72,7 +72,7 @@ DECL_HANDLER(create_change_notification)
{
struct change *change;
req->handle = -1;
req->handle = 0;
if ((change = create_change_notification( req->subtree, req->filter )))
{
req->handle = alloc_handle( current->process, change,

View File

@ -167,7 +167,7 @@ int free_console( struct process *process )
return 1;
}
static int set_console_fd( int handle, int fd_in, int fd_out, int pid )
static int set_console_fd( handle_t handle, int fd_in, int fd_out, int pid )
{
struct console_input *input;
struct screen_buffer *output;
@ -206,7 +206,7 @@ static int set_console_fd( int handle, int fd_in, int fd_out, int pid )
return 1;
}
static int get_console_mode( int handle )
static int get_console_mode( handle_t handle )
{
struct object *obj;
int ret = 0;
@ -224,7 +224,7 @@ static int get_console_mode( int handle )
return ret;
}
static int set_console_mode( int handle, int mode )
static int set_console_mode( handle_t handle, int mode )
{
struct object *obj;
int ret = 0;
@ -247,7 +247,7 @@ static int set_console_mode( int handle, int mode )
}
/* set misc console information (output handle only) */
static int set_console_info( int handle, struct set_console_info_request *req,
static int set_console_info( handle_t handle, struct set_console_info_request *req,
const char *title, size_t len )
{
struct screen_buffer *console;
@ -275,7 +275,7 @@ static int set_console_info( int handle, struct set_console_info_request *req,
}
/* add input events to a console input queue */
static int write_console_input( int handle, int count, INPUT_RECORD *records )
static int write_console_input( handle_t handle, int count, INPUT_RECORD *records )
{
INPUT_RECORD *new_rec;
struct console_input *console;
@ -298,7 +298,7 @@ static int write_console_input( int handle, int count, INPUT_RECORD *records )
}
/* retrieve a pointer to the console input records */
static int read_console_input( int handle, int count, INPUT_RECORD *rec, int flush )
static int read_console_input( handle_t handle, int count, INPUT_RECORD *rec, int flush )
{
struct console_input *console;
@ -409,18 +409,18 @@ static void screen_buffer_destroy( struct object *obj )
/* allocate a console for the current process */
DECL_HANDLER(alloc_console)
{
int in = -1, out = -1;
handle_t in = 0, out = 0;
if (!alloc_console( current->process )) goto done;
if ((in = alloc_handle( current->process, current->process->console_in,
req->access, req->inherit )) != -1)
req->access, req->inherit )))
{
if ((out = alloc_handle( current->process, current->process->console_out,
req->access, req->inherit )) != -1)
req->access, req->inherit )))
goto done; /* everything is fine */
close_handle( current->process, in, NULL );
in = -1;
in = 0;
}
free_console( current->process );
@ -440,6 +440,7 @@ DECL_HANDLER(open_console)
{
struct object *obj= req->output ? current->process->console_out : current->process->console_in;
req->handle = 0;
if (obj) req->handle = alloc_handle( current->process, obj, req->access, req->inherit );
else set_error( STATUS_ACCESS_DENIED );
}

View File

@ -92,11 +92,10 @@ static int fill_create_thread_event( struct debug_event *event, void *arg )
{
struct process *debugger = event->debugger->process;
struct thread *thread = event->sender;
int handle;
handle_t handle;
/* documented: THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME */
if ((handle = alloc_handle( debugger, thread, THREAD_ALL_ACCESS, FALSE )) == -1)
return 0;
if (!(handle = alloc_handle( debugger, thread, THREAD_ALL_ACCESS, FALSE ))) return 0;
event->data.info.create_thread.handle = handle;
event->data.info.create_thread.teb = thread->teb;
event->data.info.create_thread.start = arg;
@ -108,25 +107,24 @@ static int fill_create_process_event( struct debug_event *event, void *arg )
struct process *debugger = event->debugger->process;
struct thread *thread = event->sender;
struct process *process = thread->process;
int handle;
handle_t handle;
/* documented: PROCESS_VM_READ | PROCESS_VM_WRITE */
if ((handle = alloc_handle( debugger, process, PROCESS_ALL_ACCESS, FALSE )) == -1)
return 0;
if (!(handle = alloc_handle( debugger, process, PROCESS_ALL_ACCESS, FALSE ))) return 0;
event->data.info.create_process.process = handle;
/* documented: THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME */
if ((handle = alloc_handle( debugger, thread, THREAD_ALL_ACCESS, FALSE )) == -1)
if (!(handle = alloc_handle( debugger, thread, THREAD_ALL_ACCESS, FALSE )))
{
close_handle( debugger, event->data.info.create_process.process, NULL );
return 0;
}
event->data.info.create_process.thread = handle;
handle = -1;
handle = 0;
if (process->exe.file &&
/* the doc says write access too, but this doesn't seem a good idea */
((handle = alloc_handle( debugger, process->exe.file, GENERIC_READ, FALSE )) == -1))
!(handle = alloc_handle( debugger, process->exe.file, GENERIC_READ, FALSE )))
{
close_handle( debugger, event->data.info.create_process.process, NULL );
close_handle( debugger, event->data.info.create_process.thread, NULL );
@ -161,9 +159,9 @@ static int fill_load_dll_event( struct debug_event *event, void *arg )
{
struct process *debugger = event->debugger->process;
struct process_dll *dll = arg;
int handle = -1;
handle_t handle = 0;
if (dll->file && (handle = alloc_handle( debugger, dll->file, GENERIC_READ, FALSE )) == -1)
if (dll->file && !(handle = alloc_handle( debugger, dll->file, GENERIC_READ, FALSE )))
return 0;
event->data.info.load_dll.handle = handle;
event->data.info.load_dll.base = dll->base;
@ -319,13 +317,13 @@ static void debug_event_destroy( struct object *obj )
close_handle( debugger, event->data.info.create_thread.handle, NULL );
break;
case CREATE_PROCESS_DEBUG_EVENT:
if (event->data.info.create_process.file != -1)
if (event->data.info.create_process.file)
close_handle( debugger, event->data.info.create_process.file, NULL );
close_handle( debugger, event->data.info.create_process.thread, NULL );
close_handle( debugger, event->data.info.create_process.process, NULL );
break;
case LOAD_DLL_DEBUG_EVENT:
if (event->data.info.load_dll.handle != -1)
if (event->data.info.load_dll.handle)
close_handle( debugger, event->data.info.load_dll.handle, NULL );
break;
}

View File

@ -86,7 +86,7 @@ DECL_HANDLER(create_device)
{
struct device *dev;
req->handle = -1;
req->handle = 0;
if ((dev = create_device( req->id )))
{
req->handle = alloc_handle( current->process, dev, req->access, req->inherit );

View File

@ -59,7 +59,7 @@ struct event *create_event( const WCHAR *name, size_t len,
return event;
}
struct event *get_event_obj( struct process *process, int handle, unsigned int access )
struct event *get_event_obj( struct process *process, handle_t handle, unsigned int access )
{
return (struct event *)get_handle_obj( process, handle, access, &event_ops );
}
@ -115,7 +115,7 @@ DECL_HANDLER(create_event)
{
struct event *event;
req->handle = -1;
req->handle = 0;
if ((event = create_event( get_req_data(req), get_req_data_size(req),
req->manual_reset, req->initial_state )))
{

View File

@ -320,12 +320,12 @@ void file_set_error(void)
}
}
struct file *get_file_obj( struct process *process, int handle, unsigned int access )
struct file *get_file_obj( struct process *process, handle_t handle, unsigned int access )
{
return (struct file *)get_handle_obj( process, handle, access, &file_ops );
}
static int set_file_pointer( int handle, int *low, int *high, int whence )
static int set_file_pointer( handle_t handle, int *low, int *high, int whence )
{
struct file *file;
int result;
@ -354,7 +354,7 @@ static int set_file_pointer( int handle, int *low, int *high, int whence )
return 1;
}
static int truncate_file( int handle )
static int truncate_file( handle_t handle )
{
struct file *file;
int result;
@ -370,7 +370,6 @@ static int truncate_file( int handle )
}
release_object( file );
return 1;
}
/* try to grow the file to the specified size */
@ -394,7 +393,7 @@ int grow_file( struct file *file, int size_high, int size_low )
return 0;
}
static int set_file_time( int handle, time_t access_time, time_t write_time )
static int set_file_time( handle_t handle, time_t access_time, time_t write_time )
{
struct file *file;
struct utimbuf utimbuf;
@ -438,7 +437,7 @@ DECL_HANDLER(create_file)
{
struct file *file;
req->handle = -1;
req->handle = 0;
if ((file = create_file( get_req_data(req), get_req_data_size(req), req->access,
req->sharing, req->create, req->attrs )))
{
@ -452,7 +451,7 @@ DECL_HANDLER(alloc_file_handle)
{
struct file *file;
req->handle = -1;
req->handle = 0;
if (current->pass_fd != -1)
{
if ((file = create_file_for_fd( current->pass_fd, req->access,

View File

@ -42,25 +42,37 @@ static struct handle_table *global_table;
#define RESERVED_CLOSE_PROTECT (HANDLE_FLAG_PROTECT_FROM_CLOSE << RESERVED_SHIFT)
#define RESERVED_ALL (RESERVED_INHERIT | RESERVED_CLOSE_PROTECT)
/* global handle macros */
#define HANDLE_OBFUSCATOR 0x544a4def
#define HANDLE_IS_GLOBAL(h) (((h) ^ HANDLE_OBFUSCATOR) < 0x10000)
#define HANDLE_LOCAL_TO_GLOBAL(h) ((h) ^ HANDLE_OBFUSCATOR)
#define HANDLE_GLOBAL_TO_LOCAL(h) ((h) ^ HANDLE_OBFUSCATOR)
#define MIN_HANDLE_ENTRIES 32
/* handle to table index conversion */
/* handles are a multiple of 4 under NT; handle 0 is not used */
inline static int index_to_handle( int index )
/* handles are a multiple of 4 under NT; handle 0 is not used */
inline static handle_t index_to_handle( int index )
{
return (index + 1) << 2;
return (handle_t)((index + 1) << 2);
}
inline static int handle_to_index( int handle )
inline static int handle_to_index( handle_t handle )
{
return (handle >> 2) - 1;
return ((unsigned int)handle >> 2) - 1;
}
/* global handle conversion */
#define HANDLE_OBFUSCATOR 0x544a4def
inline static int handle_is_global( handle_t handle)
{
return ((unsigned long)handle ^ HANDLE_OBFUSCATOR) < 0x10000;
}
inline static handle_t handle_local_to_global( handle_t handle )
{
if (!handle) return 0;
return (handle_t)((unsigned long)handle ^ HANDLE_OBFUSCATOR);
}
inline static handle_t handle_global_to_local( handle_t handle )
{
return (handle_t)((unsigned long)handle ^ HANDLE_OBFUSCATOR);
}
@ -99,7 +111,8 @@ static void handle_table_dump( struct object *obj, int verbose )
for (i = 0; i <= table->last; i++, entry++)
{
if (!entry->ptr) continue;
fprintf( stderr, "%9d: %p %08x ", index_to_handle(i), entry->ptr, entry->access );
fprintf( stderr, "%9u: %p %08x ",
(unsigned int)index_to_handle(i), entry->ptr, entry->access );
entry->ptr->ops->dump( entry->ptr, 0 );
}
}
@ -158,7 +171,7 @@ static int grow_handle_table( struct handle_table *table )
}
/* allocate the first free entry in the handle table */
static int alloc_entry( struct handle_table *table, void *obj, unsigned int access )
static handle_t alloc_entry( struct handle_table *table, void *obj, unsigned int access )
{
struct handle_entry *entry = table->entries + table->free;
int i;
@ -166,7 +179,7 @@ static int alloc_entry( struct handle_table *table, void *obj, unsigned int acce
for (i = table->free; i <= table->last; i++, entry++) if (!entry->ptr) goto found;
if (i >= table->count)
{
if (!grow_handle_table( table )) return -1;
if (!grow_handle_table( table )) return 0;
entry = table->entries + i; /* the entries may have moved */
}
table->last = i;
@ -179,8 +192,8 @@ static int alloc_entry( struct handle_table *table, void *obj, unsigned int acce
}
/* allocate a handle for an object, incrementing its refcount */
/* return the handle, or -1 on error */
int alloc_handle( struct process *process, void *obj, unsigned int access, int inherit )
/* return the handle, or 0 on error */
handle_t alloc_handle( struct process *process, void *obj, unsigned int access, int inherit )
{
struct handle_table *table = (struct handle_table *)process->handles;
@ -191,36 +204,34 @@ int alloc_handle( struct process *process, void *obj, unsigned int access, int i
}
/* allocate a global handle for an object, incrementing its refcount */
/* return the handle, or -1 on error */
static int alloc_global_handle( void *obj, unsigned int access )
/* return the handle, or 0 on error */
static handle_t alloc_global_handle( void *obj, unsigned int access )
{
int handle;
if (!global_table)
{
if (!(global_table = (struct handle_table *)alloc_handle_table( NULL, 0 ))) return -1;
if (!(global_table = (struct handle_table *)alloc_handle_table( NULL, 0 )))
return 0;
}
if ((handle = alloc_entry( global_table, obj, access )) != -1)
handle = HANDLE_LOCAL_TO_GLOBAL(handle);
return handle;
return handle_local_to_global( alloc_entry( global_table, obj, access ));
}
/* return a handle entry, or NULL if the handle is invalid */
static struct handle_entry *get_handle( struct process *process, int handle )
static struct handle_entry *get_handle( struct process *process, handle_t handle )
{
struct handle_table *table = (struct handle_table *)process->handles;
struct handle_entry *entry;
int index;
if (HANDLE_IS_GLOBAL(handle))
if (handle_is_global(handle))
{
handle = HANDLE_GLOBAL_TO_LOCAL(handle);
handle = handle_global_to_local(handle);
table = global_table;
}
if (!table) goto error;
handle = handle_to_index( handle );
if (handle < 0) goto error;
if (handle > table->last) goto error;
entry = table->entries + handle;
index = handle_to_index( handle );
if (index < 0) goto error;
if (index > table->last) goto error;
entry = table->entries + index;
if (!entry->ptr) goto error;
return entry;
@ -283,7 +294,7 @@ struct object *copy_handle_table( struct process *process, struct process *paren
/* close a handle and decrement the refcount of the associated object */
/* return 1 if OK, 0 on error */
int close_handle( struct process *process, int handle, int *fd )
int close_handle( struct process *process, handle_t handle, int *fd )
{
struct handle_table *table;
struct handle_entry *entry;
@ -300,7 +311,7 @@ int close_handle( struct process *process, int handle, int *fd )
if (fd) *fd = entry->fd;
else if (entry->fd != -1) return 1; /* silently ignore close attempt if we cannot close the fd */
entry->fd = -1;
table = HANDLE_IS_GLOBAL(handle) ? global_table : (struct handle_table *)process->handles;
table = handle_is_global(handle) ? global_table : (struct handle_table *)process->handles;
if (entry < table->entries + table->free) table->free = entry - table->entries;
if (entry == table->entries + table->last) shrink_handle_table( table );
release_object( obj );
@ -318,9 +329,9 @@ void close_global_handles(void)
}
/* retrieve the object corresponding to one of the magic pseudo-handles */
static inline struct object *get_magic_handle( int handle )
static inline struct object *get_magic_handle( handle_t handle )
{
switch(handle)
switch((unsigned long)handle)
{
case 0xfffffffe: /* current thread pseudo-handle */
return &current->obj;
@ -333,7 +344,7 @@ static inline struct object *get_magic_handle( int handle )
}
/* retrieve the object corresponding to a handle, incrementing its refcount */
struct object *get_handle_obj( struct process *process, int handle,
struct object *get_handle_obj( struct process *process, handle_t handle,
unsigned int access, const struct object_ops *ops )
{
struct handle_entry *entry;
@ -358,7 +369,7 @@ struct object *get_handle_obj( struct process *process, int handle,
}
/* retrieve the cached fd for a given handle */
int get_handle_fd( struct process *process, int handle, unsigned int access )
int get_handle_fd( struct process *process, handle_t handle, unsigned int access )
{
struct handle_entry *entry;
@ -373,7 +384,8 @@ int get_handle_fd( struct process *process, int handle, unsigned int access )
/* get/set the handle reserved flags */
/* return the old flags (or -1 on error) */
static int set_handle_info( struct process *process, int handle, int mask, int flags, int *fd )
static int set_handle_info( struct process *process, handle_t handle,
int mask, int flags, int *fd )
{
struct handle_entry *entry;
unsigned int old_access;
@ -396,13 +408,13 @@ static int set_handle_info( struct process *process, int handle, int mask, int f
}
/* duplicate a handle */
int duplicate_handle( struct process *src, int src_handle, struct process *dst,
unsigned int access, int inherit, int options )
handle_t duplicate_handle( struct process *src, handle_t src_handle, struct process *dst,
unsigned int access, int inherit, int options )
{
int res;
handle_t res;
struct object *obj = get_handle_obj( src, src_handle, 0, NULL );
if (!obj) return -1;
if (!obj) return 0;
if (options & DUP_HANDLE_SAME_ACCESS)
{
struct handle_entry *entry = get_handle( src, src_handle );
@ -424,10 +436,10 @@ int duplicate_handle( struct process *src, int src_handle, struct process *dst,
}
/* open a new handle to an existing object */
int open_object( const WCHAR *name, size_t len, const struct object_ops *ops,
unsigned int access, int inherit )
handle_t open_object( const WCHAR *name, size_t len, const struct object_ops *ops,
unsigned int access, int inherit )
{
int handle = -1;
handle_t handle = 0;
struct object *obj = find_object( name, len );
if (obj)
{
@ -453,7 +465,7 @@ DECL_HANDLER(set_handle_info)
{
int fd = req->fd;
if (HANDLE_IS_GLOBAL(req->handle)) fd = -1; /* no fd cache for global handles */
if (handle_is_global(req->handle)) fd = -1; /* no fd cache for global handles */
req->old_flags = set_handle_info( current->process, req->handle, req->mask, req->flags, &fd );
req->cur_fd = fd;
}
@ -463,7 +475,7 @@ DECL_HANDLER(dup_handle)
{
struct process *src, *dst;
req->handle = -1;
req->handle = 0;
req->fd = -1;
if ((src = get_process_from_handle( req->src_process, PROCESS_DUP_HANDLE )))
{

View File

@ -13,6 +13,7 @@
#include <stdlib.h>
#include "windef.h"
#include "server.h"
struct process;
struct object_ops;
@ -21,16 +22,16 @@ struct object_ops;
/* alloc_handle takes a void *obj for convenience, but you better make sure */
/* that the thing pointed to starts with a struct object... */
extern int alloc_handle( struct process *process, void *obj,
unsigned int access, int inherit );
extern int close_handle( struct process *process, int handle, int *fd );
extern struct object *get_handle_obj( struct process *process, int handle,
extern handle_t alloc_handle( struct process *process, void *obj,
unsigned int access, int inherit );
extern int close_handle( struct process *process, handle_t handle, int *fd );
extern struct object *get_handle_obj( struct process *process, handle_t handle,
unsigned int access, const struct object_ops *ops );
extern int get_handle_fd( struct process *process, int handle, unsigned int access );
extern int duplicate_handle( struct process *src, int src_handle, struct process *dst,
unsigned int access, int inherit, int options );
extern int open_object( const WCHAR *name, size_t len, const struct object_ops *ops,
unsigned int access, int inherit );
extern int get_handle_fd( struct process *process, handle_t handle, unsigned int access );
extern handle_t duplicate_handle( struct process *src, handle_t src_handle, struct process *dst,
unsigned int access, int inherit, int options );
extern handle_t open_object( const WCHAR *name, size_t len, const struct object_ops *ops,
unsigned int access, int inherit );
extern struct object *alloc_handle_table( struct process *process, int count );
extern struct object *copy_handle_table( struct process *process, struct process *parent );
extern void close_global_handles(void);

View File

@ -207,7 +207,7 @@ static int get_image_params( struct mapping *mapping )
static struct object *create_mapping( int size_high, int size_low, int protect,
int handle, const WCHAR *name, size_t len )
handle_t handle, const WCHAR *name, size_t len )
{
struct mapping *mapping;
int access = 0;
@ -227,7 +227,7 @@ static struct object *create_mapping( int size_high, int size_low, int protect,
if (protect & VPROT_READ) access |= GENERIC_READ;
if (protect & VPROT_WRITE) access |= GENERIC_WRITE;
if (handle != -1)
if (handle)
{
if (!(mapping->file = get_file_obj( current->process, handle, access ))) goto error;
if (protect & VPROT_IMAGE)
@ -304,7 +304,7 @@ DECL_HANDLER(create_mapping)
{
struct object *obj;
req->handle = -1;
req->handle = 0;
if ((obj = create_mapping( req->size_high, req->size_low,
req->protect, req->file_handle,
get_req_data(req), get_req_data_size(req) )))
@ -336,7 +336,7 @@ DECL_HANDLER(get_mapping_info)
req->protect = mapping->protect;
req->header_size = mapping->header_size;
req->base = mapping->base;
req->shared_file = -1;
req->shared_file = 0;
req->shared_size = mapping->shared_size;
req->anonymous = !mapping->file;
if (mapping->shared_file)

View File

@ -140,7 +140,7 @@ DECL_HANDLER(create_mutex)
{
struct mutex *mutex;
req->handle = -1;
req->handle = 0;
if ((mutex = create_mutex( get_req_data(req), get_req_data_size(req), req->owned )))
{
req->handle = alloc_handle( current->process, mutex, MUTEX_ALL_ACCESS, req->inherit );

View File

@ -135,7 +135,7 @@ struct event;
extern struct event *create_event( const WCHAR *name, size_t len,
int manual_reset, int initial_state );
extern struct event *get_event_obj( struct process *process, int handle, unsigned int access );
extern struct event *get_event_obj( struct process *process, handle_t handle, unsigned int access );
extern void pulse_event( struct event *event );
extern void set_event( struct event *event );
extern void reset_event( struct event *event );
@ -146,7 +146,7 @@ extern void abandon_mutexes( struct thread *thread );
/* file functions */
extern struct file *get_file_obj( struct process *process, int handle,
extern struct file *get_file_obj( struct process *process, handle_t handle,
unsigned int access );
extern int grow_file( struct file *file, int size_high, int size_low );
extern int create_anonymous_file(void);

View File

@ -152,20 +152,19 @@ static void pipe_destroy( struct object *obj )
DECL_HANDLER(create_pipe)
{
struct object *obj[2];
int hread = -1, hwrite = -1;
handle_t hread = 0, hwrite = 0;
if (create_pipe( obj ))
{
hread = alloc_handle( current->process, obj[0],
STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|GENERIC_READ,
req->inherit );
if (hread != -1)
if (hread)
{
hwrite = alloc_handle( current->process, obj[1],
STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|GENERIC_WRITE,
req->inherit );
if (hwrite == -1)
close_handle( current->process, hread, NULL );
if (!hwrite) close_handle( current->process, hread, NULL );
}
release_object( obj[0] );
release_object( obj[1] );

View File

@ -62,9 +62,9 @@ struct startup_info
int inherit_all; /* inherit all handles from parent */
int create_flags; /* creation flags */
int start_flags; /* flags from startup info */
int hstdin; /* handle for stdin */
int hstdout; /* handle for stdout */
int hstderr; /* handle for stderr */
handle_t hstdin; /* handle for stdin */
handle_t hstdout; /* handle for stdout */
handle_t hstderr; /* handle for stderr */
int cmd_show; /* main window show mode */
struct file *exe_file; /* file handle for main exe */
char *filename; /* file name for main exe */
@ -230,11 +230,11 @@ static void init_process( int ppid, struct init_process_request *req )
if (!process->handles) goto error;
/* retrieve the main exe file */
req->exe_file = -1;
req->exe_file = 0;
if (parent && info->exe_file)
{
process->exe.file = (struct file *)grab_object( info->exe_file );
if ((req->exe_file = alloc_handle( process, process->exe.file, GENERIC_READ, 0 )) == -1)
if (!(req->exe_file = alloc_handle( process, process->exe.file, GENERIC_READ, 0 )))
goto error;
}
@ -356,7 +356,7 @@ static void build_wait_process_reply( struct thread *thread, struct object *obj,
req->event = alloc_handle( thread->process, info->process->init_event,
EVENT_ALL_ACCESS, 0 );
else
req->event = -1;
req->event = 0;
/* FIXME: set_error */
}
@ -375,7 +375,7 @@ struct process *get_process_from_id( void *id )
}
/* get a process from a handle (and increment the refcount) */
struct process *get_process_from_handle( int handle, unsigned int access )
struct process *get_process_from_handle( handle_t handle, unsigned int access )
{
return (struct process *)get_handle_obj( current->process, handle,
access, &process_ops );
@ -734,7 +734,7 @@ DECL_HANDLER(new_process)
info->process = NULL;
info->thread = NULL;
if ((req->exe_file != -1) &&
if (req->exe_file &&
!(info->exe_file = get_file_obj( current->process, req->exe_file, GENERIC_READ )))
{
release_object( info );
@ -761,9 +761,9 @@ DECL_HANDLER(wait_process)
}
req->pid = 0;
req->tid = 0;
req->phandle = -1;
req->thandle = -1;
req->event = -1;
req->phandle = 0;
req->thandle = 0;
req->event = 0;
if (req->cancel)
{
release_object( current->info );
@ -812,7 +812,7 @@ DECL_HANDLER(init_process_done)
DECL_HANDLER(open_process)
{
struct process *process = get_process_from_id( req->pid );
req->handle = -1;
req->handle = 0;
if (process)
{
req->handle = alloc_handle( current->process, process, req->access, req->inherit );
@ -890,9 +890,9 @@ DECL_HANDLER(load_dll)
struct process_dll *dll;
struct file *file = NULL;
if ((req->handle != -1) &&
if (req->handle &&
!(file = get_file_obj( current->process, req->handle, GENERIC_READ ))) return;
if ((dll = process_load_dll( current->process, file, req->base )))
{
dll->dbg_offset = req->dbg_offset;
@ -917,7 +917,7 @@ DECL_HANDLER(wait_input_idle)
{
struct process *process;
req->event = -1;
req->event = 0;
if ((process = get_process_from_handle( req->handle, PROCESS_QUERY_INFORMATION )))
{
if (process->idle_event && process != current->process && process->queue != current->queue)

View File

@ -74,7 +74,7 @@ struct module_snapshot
extern struct thread *create_process( int fd );
extern struct process *get_process_from_id( void *id );
extern struct process *get_process_from_handle( int handle, unsigned int access );
extern struct process *get_process_from_handle( handle_t handle, unsigned int access );
extern int process_set_debugger( struct process *process, struct thread *thread );
extern void add_process_thread( struct process *process,
struct thread *thread );

View File

@ -110,7 +110,7 @@ DECL_HANDLER(get_msg_queue)
{
struct msg_queue *queue = current->queue;
req->handle = -1;
req->handle = 0;
if (!queue) queue = create_msg_queue( current );
if (queue) req->handle = alloc_handle( current->process, queue, SYNCHRONIZE, 0 );
}

View File

@ -71,7 +71,9 @@ struct key_value
#define HKEY_SPECIAL_ROOT_FIRST HKEY_CLASSES_ROOT
#define HKEY_SPECIAL_ROOT_LAST HKEY_DYN_DATA
#define NB_SPECIAL_ROOT_KEYS (HKEY_SPECIAL_ROOT_LAST - HKEY_SPECIAL_ROOT_FIRST + 1)
#define IS_SPECIAL_ROOT_HKEY(h) (((h) >= HKEY_SPECIAL_ROOT_FIRST) && ((h) <= HKEY_SPECIAL_ROOT_LAST))
#define IS_SPECIAL_ROOT_HKEY(h) (((unsigned int)(h) >= HKEY_SPECIAL_ROOT_FIRST) && \
((unsigned int)(h) <= HKEY_SPECIAL_ROOT_LAST))
static struct key *special_root_keys[NB_SPECIAL_ROOT_KEYS];
/* the real root key */
@ -896,18 +898,18 @@ static void delete_value( struct key *key, const WCHAR *name )
}
}
static struct key *create_root_key( int hkey )
static struct key *create_root_key( handle_t hkey )
{
WCHAR keyname[80];
int i, dummy;
struct key *key;
const char *p;
p = special_root_names[hkey - HKEY_SPECIAL_ROOT_FIRST];
p = special_root_names[(unsigned int)hkey - HKEY_SPECIAL_ROOT_FIRST];
i = 0;
while (*p) keyname[i++] = *p++;
if (hkey == HKEY_CURRENT_USER) /* this one is special */
if (hkey == (handle_t)HKEY_CURRENT_USER) /* this one is special */
{
/* get the current user name */
char buffer[10];
@ -925,21 +927,21 @@ static struct key *create_root_key( int hkey )
if ((key = create_key( root_key, keyname, NULL, 0, time(NULL), &dummy )))
{
special_root_keys[hkey - HKEY_SPECIAL_ROOT_FIRST] = key;
special_root_keys[(unsigned int)hkey - HKEY_SPECIAL_ROOT_FIRST] = key;
key->flags |= KEY_ROOT;
}
return key;
}
/* get the registry key corresponding to an hkey handle */
static struct key *get_hkey_obj( int hkey, unsigned int access )
static struct key *get_hkey_obj( handle_t hkey, unsigned int access )
{
struct key *key;
if (!hkey) return (struct key *)grab_object( root_key );
if (IS_SPECIAL_ROOT_HKEY(hkey))
{
if (!(key = special_root_keys[hkey - HKEY_SPECIAL_ROOT_FIRST]))
if (!(key = special_root_keys[(unsigned int)hkey - HKEY_SPECIAL_ROOT_FIRST]))
key = create_root_key( hkey );
else
grab_object( key );
@ -1334,7 +1336,7 @@ static void load_keys( struct key *key, FILE *f )
}
/* load a part of the registry from a file */
static void load_registry( struct key *key, int handle )
static void load_registry( struct key *key, handle_t handle )
{
struct object *obj;
int fd;
@ -1424,7 +1426,7 @@ static void save_all_subkeys( struct key *key, FILE *f )
}
/* save a registry branch to a file handle */
static void save_registry( struct key *key, int handle )
static void save_registry( struct key *key, handle_t handle )
{
struct object *obj;
int fd;
@ -1583,7 +1585,7 @@ DECL_HANDLER(create_key)
size_t len;
if (access & MAXIMUM_ALLOWED) access = KEY_ALL_ACCESS; /* FIXME: needs general solution */
req->hkey = -1;
req->hkey = 0;
if (!(name = copy_req_path( req, &len ))) return;
if ((parent = get_hkey_obj( req->parent, 0 /*FIXME*/ )))
{
@ -1618,7 +1620,7 @@ DECL_HANDLER(open_key)
unsigned int access = req->access;
if (access & MAXIMUM_ALLOWED) access = KEY_ALL_ACCESS; /* FIXME: needs general solution */
req->hkey = -1;
req->hkey = 0;
if ((parent = get_hkey_obj( req->parent, 0 /*FIXME*/ )))
{
WCHAR *name = copy_path( get_req_data(req), get_req_data_size(req) );

View File

@ -255,7 +255,7 @@ int write_request( struct thread *thread )
}
/* send an fd to a client */
int send_client_fd( struct thread *thread, int fd, int handle )
int send_client_fd( struct thread *thread, int fd, handle_t handle )
{
int ret;
@ -382,7 +382,7 @@ struct object *create_request_socket( struct thread *thread )
return NULL;
}
sock->thread = thread;
send_client_fd( thread, fd[1], -1 );
send_client_fd( thread, fd[1], 0 );
close( fd[1] );
set_select_events( &sock->obj, POLLIN );
return &sock->obj;

View File

@ -33,7 +33,7 @@ extern void fatal_perror( const char *err, ... ) WINE_NORETURN;
extern const char *get_config_dir(void);
extern void read_request( struct thread *thread );
extern int write_request( struct thread *thread );
extern int send_client_fd( struct thread *thread, int fd, int handle );
extern int send_client_fd( struct thread *thread, int fd, handle_t handle );
extern void send_reply( struct thread *thread );
extern void open_master_socket(void);
extern void close_master_socket(void);

View File

@ -64,7 +64,7 @@ static struct semaphore *create_semaphore( const WCHAR *name, size_t len,
return sem;
}
static unsigned int release_semaphore( int handle, unsigned int count )
static unsigned int release_semaphore( handle_t handle, unsigned int count )
{
struct semaphore *sem;
unsigned int prev = 0;
@ -123,7 +123,7 @@ DECL_HANDLER(create_semaphore)
{
struct semaphore *sem;
req->handle = -1;
req->handle = 0;
if ((sem = create_semaphore( get_req_data(req), get_req_data_size(req),
req->initial, req->max )))
{

View File

@ -135,7 +135,7 @@ static void serial_dump( struct object *obj, int verbose )
fprintf( stderr, "Port fd=%d mask=%x\n", serial->obj.fd, serial->eventmask );
}
struct serial *get_serial_obj( struct process *process, int handle, unsigned int access )
struct serial *get_serial_obj( struct process *process, handle_t handle, unsigned int access )
{
return (struct serial *)get_handle_obj( process, handle, access, &serial_ops );
}
@ -249,7 +249,7 @@ DECL_HANDLER(create_serial)
{
struct serial *serial;
req->handle = -1;
req->handle = 0;
if ((serial = create_serial( get_req_data(req), get_req_data_size(req), req->access )))
{
req->handle = alloc_handle( current->process, serial, req->access, req->inherit );

View File

@ -198,7 +198,7 @@ DECL_HANDLER(create_snapshot)
{
struct snapshot *snapshot;
req->handle = -1;
req->handle = 0;
if ((snapshot = create_snapshot( req->pid, req->flags )))
{
req->handle = alloc_handle( current->process, snapshot, 0, req->inherit );

View File

@ -304,7 +304,7 @@ static struct object *create_socket( int family, int type, int protocol )
}
/* accept a socket (creates a new fd) */
static struct object *accept_socket( int handle )
static struct object *accept_socket( handle_t handle )
{
struct sock *acceptsock;
struct sock *sock;
@ -429,28 +429,26 @@ static void sock_set_error(void)
DECL_HANDLER(create_socket)
{
struct object *obj;
int s = -1;
req->handle = 0;
if ((obj = create_socket( req->family, req->type, req->protocol )) != NULL)
{
s = alloc_handle( current->process, obj, req->access, req->inherit );
req->handle = alloc_handle( current->process, obj, req->access, req->inherit );
release_object( obj );
}
req->handle = s;
}
/* accept a socket */
DECL_HANDLER(accept_socket)
{
struct object *obj;
int s = -1;
req->handle = 0;
if ((obj = accept_socket( req->lhandle )) != NULL)
{
s = alloc_handle( current->process, obj, req->access, req->inherit );
req->handle = alloc_handle( current->process, obj, req->access, req->inherit );
release_object( obj );
}
req->handle = s;
}
/* set socket event parameters */

View File

@ -113,8 +113,8 @@ static int alloc_client_buffer( struct thread *thread )
/* add it here since send_client_fd may call kill_thread */
add_process_thread( thread->process, thread );
send_client_fd( thread, fd_pipe[0], -1 );
send_client_fd( thread, fd, -1 );
send_client_fd( thread, fd_pipe[0], 0 );
send_client_fd( thread, fd, 0 );
send_reply( thread );
close( fd_pipe[0] );
close( fd );
@ -246,7 +246,7 @@ struct thread *get_thread_from_id( void *id )
}
/* get a thread from a handle (and increment the refcount) */
struct thread *get_thread_from_handle( int handle, unsigned int access )
struct thread *get_thread_from_handle( handle_t handle, unsigned int access )
{
return (struct thread *)get_handle_obj( current->process, handle,
access, &thread_ops );
@ -488,7 +488,7 @@ int sleep_on( int count, struct object *objects[], int flags, int timeout, sleep
}
/* select on a list of handles */
static int select_on( int count, int *handles, int flags, int timeout )
static int select_on( int count, handle_t *handles, int flags, int timeout )
{
int ret = 0;
int i;
@ -697,7 +697,7 @@ DECL_HANDLER(new_thread)
if (req->suspend) thread->suspend++;
req->tid = thread;
if ((req->handle = alloc_handle( current->process, thread,
THREAD_ALL_ACCESS, req->inherit )) != -1)
THREAD_ALL_ACCESS, req->inherit )))
{
send_client_fd( current, sock[1], req->handle );
close( sock[1] );
@ -756,9 +756,9 @@ DECL_HANDLER(terminate_thread)
DECL_HANDLER(get_thread_info)
{
struct thread *thread;
int handle = req->handle;
handle_t handle = req->handle;
if (handle == -1) thread = get_thread_from_id( req->tid_in );
if (!handle) thread = get_thread_from_id( req->tid_in );
else thread = get_thread_from_handle( req->handle, THREAD_QUERY_INFORMATION );
if (thread)

View File

@ -81,7 +81,7 @@ extern struct thread *current;
extern struct thread *create_thread( int fd, struct process *process );
extern struct thread *get_thread_from_id( void *id );
extern struct thread *get_thread_from_handle( int handle, unsigned int access );
extern struct thread *get_thread_from_handle( handle_t handle, unsigned int access );
extern struct thread *get_thread_from_pid( int pid );
extern int suspend_thread( struct thread *thread, int check_limit );
extern int resume_thread( struct thread *thread );

View File

@ -174,7 +174,7 @@ DECL_HANDLER(create_timer)
{
struct timer *timer;
req->handle = -1;
req->handle = 0;
if ((timer = create_timer( get_req_data(req), get_req_data_size(req), req->manual )))
{
req->handle = alloc_handle( current->process, timer, TIMER_ALL_ACCESS, req->inherit );

View File

@ -89,6 +89,21 @@ static size_t dump_varargs_ints( const void *req )
return get_size(req);
}
static size_t dump_varargs_handles( const void *req )
{
const handle_t *data = get_data(req);
size_t len = get_size(req) / sizeof(*data);
fputc( '{', stderr );
while (len > 0)
{
fprintf( stderr, "%d", *data++ );
if (--len) fputc( ',', stderr );
}
fputc( '}', stderr );
return get_size(req);
}
static size_t dump_varargs_ptrs( const void *req )
{
void * const *data = get_data(req);
@ -523,7 +538,7 @@ static void dump_select_request( const struct select_request *req )
fprintf( stderr, " flags=%d,", req->flags );
fprintf( stderr, " timeout=%d,", req->timeout );
fprintf( stderr, " handles=" );
cur_pos += dump_varargs_ints( req );
cur_pos += dump_varargs_handles( req );
}
static void dump_select_reply( const struct select_request *req )

View File

@ -14,7 +14,7 @@
"unsigned int" => "%08x",
"void*" => "%p",
"time_t" => "%ld",
"path_t" => "&dump_path_t",
"handle_t" => "%d",
);
my @requests = ();

View File

@ -611,7 +611,7 @@ static BOOL CONSOLE_make_complex(HANDLE handle)
pty_handle = FILE_DupUnixHandle( slave, GENERIC_READ | GENERIC_WRITE );
close( master );
close( slave );
if (pty_handle == -1) return FALSE;
if (!pty_handle) return FALSE;
/* most xterms like to print their window ID when used with -S;
* read it and continue before the user has a chance...

View File

@ -331,7 +331,7 @@ HANDLE DEVICE_Open( LPCSTR filename, DWORD access,
FIXME( "Unknown VxD %s. Try --winver nt40 !\n", filename);
SetLastError( ERROR_FILE_NOT_FOUND );
return HFILE_ERROR;
return 0;
}
static const struct VxDInfo *DEVICE_GetInfo( HANDLE handle )

View File

@ -438,7 +438,7 @@ void QUEUE_SetExitingQueue( HQUEUE16 hQueue )
static HQUEUE16 QUEUE_CreateMsgQueue( BOOL16 bCreatePerQData )
{
HQUEUE16 hQueue;
HANDLE handle = -1;
HANDLE handle;
MESSAGEQUEUE * msgQueue;
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
@ -455,10 +455,11 @@ static HQUEUE16 QUEUE_CreateMsgQueue( BOOL16 bCreatePerQData )
SERVER_START_REQ
{
struct get_msg_queue_request *req = server_alloc_req( sizeof(*req), 0 );
if (!server_call( REQ_GET_MSG_QUEUE )) handle = req->handle;
server_call( REQ_GET_MSG_QUEUE );
handle = req->handle;
}
SERVER_END_REQ;
if (handle == -1)
if (!handle)
{
ERR_(msg)("Cannot get thread queue");
GlobalFree16( hQueue );
@ -1518,7 +1519,7 @@ DWORD WINAPI WaitForInputIdle (HANDLE hProcess, DWORD dwTimeOut)
}
SERVER_END_REQ;
if (ret) return 0xffffffff; /* error */
if (idle_event == -1) return 0; /* no event to wait on */
if (!idle_event) return 0; /* no event to wait on */
cur_time = GetTickCount();