Commit 9c2370bd authored by Alexandre Julliard's avatar Alexandre Julliard

Added exception handling wrapper to a number of server requests.

Changed a few requests to use the new vararg mechanism.
parent 2951862b
...@@ -184,7 +184,7 @@ FARPROC16 tmp; ...@@ -184,7 +184,7 @@ FARPROC16 tmp;
*/ */
HANDLE WINAPI CreateToolhelp32Snapshot( DWORD flags, DWORD process ) HANDLE WINAPI CreateToolhelp32Snapshot( DWORD flags, DWORD process )
{ {
struct create_snapshot_request *req = get_req_buffer(); HANDLE ret;
TRACE("%lx,%lx\n", flags, process ); TRACE("%lx,%lx\n", flags, process );
if (!(flags & (TH32CS_SNAPPROCESS|TH32CS_SNAPTHREAD|TH32CS_SNAPMODULE))) if (!(flags & (TH32CS_SNAPPROCESS|TH32CS_SNAPTHREAD|TH32CS_SNAPMODULE)))
...@@ -193,13 +193,19 @@ HANDLE WINAPI CreateToolhelp32Snapshot( DWORD flags, DWORD process ) ...@@ -193,13 +193,19 @@ HANDLE WINAPI CreateToolhelp32Snapshot( DWORD flags, DWORD process )
SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} }
/* Now do the snapshot */ /* Now do the snapshot */
req->flags = flags & ~TH32CS_INHERIT; SERVER_START_REQ
req->inherit = (flags & TH32CS_INHERIT) != 0; {
req->pid = (void *)process; struct create_snapshot_request *req = server_alloc_req( sizeof(*req), 0 );
server_call( REQ_CREATE_SNAPSHOT ); req->flags = flags & ~TH32CS_INHERIT;
return req->handle; req->inherit = (flags & TH32CS_INHERIT) != 0;
req->pid = (void *)process;
server_call( REQ_CREATE_SNAPSHOT );
ret = req->handle;
}
SERVER_END_REQ;
return ret;
} }
...@@ -210,7 +216,7 @@ HANDLE WINAPI CreateToolhelp32Snapshot( DWORD flags, DWORD process ) ...@@ -210,7 +216,7 @@ HANDLE WINAPI CreateToolhelp32Snapshot( DWORD flags, DWORD process )
*/ */
static BOOL TOOLHELP_Thread32Next( HANDLE handle, LPTHREADENTRY32 lpte, BOOL first ) static BOOL TOOLHELP_Thread32Next( HANDLE handle, LPTHREADENTRY32 lpte, BOOL first )
{ {
struct next_thread_request *req = get_req_buffer(); BOOL ret;
if (lpte->dwSize < sizeof(THREADENTRY32)) if (lpte->dwSize < sizeof(THREADENTRY32))
{ {
...@@ -218,16 +224,23 @@ static BOOL TOOLHELP_Thread32Next( HANDLE handle, LPTHREADENTRY32 lpte, BOOL fir ...@@ -218,16 +224,23 @@ static BOOL TOOLHELP_Thread32Next( HANDLE handle, LPTHREADENTRY32 lpte, BOOL fir
ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(THREADENTRY32), lpte->dwSize); ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(THREADENTRY32), lpte->dwSize);
return FALSE; return FALSE;
} }
req->handle = handle; SERVER_START_REQ
req->reset = first; {
if (server_call( REQ_NEXT_THREAD )) return FALSE; struct next_thread_request *req = server_alloc_req( sizeof(*req), 0 );
lpte->cntUsage = req->count; req->handle = handle;
lpte->th32ThreadID = (DWORD)req->tid; req->reset = first;
lpte->th32OwnerProcessID = (DWORD)req->pid; if ((ret = !server_call( REQ_NEXT_THREAD )))
lpte->tbBasePri = req->base_pri; {
lpte->tbDeltaPri = req->delta_pri; lpte->cntUsage = req->count;
lpte->dwFlags = 0; /* SDK: "reserved; do not use" */ lpte->th32ThreadID = (DWORD)req->tid;
return TRUE; lpte->th32OwnerProcessID = (DWORD)req->pid;
lpte->tbBasePri = req->base_pri;
lpte->tbDeltaPri = req->delta_pri;
lpte->dwFlags = 0; /* SDK: "reserved; do not use" */
}
}
SERVER_END_REQ;
return ret;
} }
/*********************************************************************** /***********************************************************************
...@@ -257,7 +270,7 @@ BOOL WINAPI Thread32Next(HANDLE hSnapshot, LPTHREADENTRY32 lpte) ...@@ -257,7 +270,7 @@ BOOL WINAPI Thread32Next(HANDLE hSnapshot, LPTHREADENTRY32 lpte)
*/ */
static BOOL TOOLHELP_Process32Next( HANDLE handle, LPPROCESSENTRY32 lppe, BOOL first ) static BOOL TOOLHELP_Process32Next( HANDLE handle, LPPROCESSENTRY32 lppe, BOOL first )
{ {
struct next_process_request *req = get_req_buffer(); BOOL ret;
if (lppe->dwSize < sizeof(PROCESSENTRY32)) if (lppe->dwSize < sizeof(PROCESSENTRY32))
{ {
...@@ -265,19 +278,26 @@ static BOOL TOOLHELP_Process32Next( HANDLE handle, LPPROCESSENTRY32 lppe, BOOL f ...@@ -265,19 +278,26 @@ static BOOL TOOLHELP_Process32Next( HANDLE handle, LPPROCESSENTRY32 lppe, BOOL f
ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(PROCESSENTRY32), lppe->dwSize); ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(PROCESSENTRY32), lppe->dwSize);
return FALSE; return FALSE;
} }
req->handle = handle; SERVER_START_REQ
req->reset = first; {
if (server_call( REQ_NEXT_PROCESS )) return FALSE; struct next_process_request *req = server_alloc_req( sizeof(*req), 0 );
lppe->cntUsage = req->count; req->handle = handle;
lppe->th32ProcessID = (DWORD)req->pid; req->reset = first;
lppe->th32DefaultHeapID = 0; /* FIXME */ if ((ret = !server_call( REQ_NEXT_PROCESS )))
lppe->th32ModuleID = 0; /* FIXME */ {
lppe->cntThreads = req->threads; lppe->cntUsage = req->count;
lppe->th32ParentProcessID = 0; /* FIXME */ lppe->th32ProcessID = (DWORD)req->pid;
lppe->pcPriClassBase = req->priority; lppe->th32DefaultHeapID = 0; /* FIXME */
lppe->dwFlags = -1; /* FIXME */ lppe->th32ModuleID = 0; /* FIXME */
lppe->szExeFile[0] = 0; /* FIXME */ lppe->cntThreads = req->threads;
return TRUE; lppe->th32ParentProcessID = 0; /* FIXME */
lppe->pcPriClassBase = req->priority;
lppe->dwFlags = -1; /* FIXME */
lppe->szExeFile[0] = 0; /* FIXME */
}
}
SERVER_END_REQ;
return ret;
} }
...@@ -309,27 +329,34 @@ BOOL WINAPI Process32Next(HANDLE hSnapshot, LPPROCESSENTRY32 lppe) ...@@ -309,27 +329,34 @@ BOOL WINAPI Process32Next(HANDLE hSnapshot, LPPROCESSENTRY32 lppe)
*/ */
static BOOL TOOLHELP_Module32Next( HANDLE handle, LPMODULEENTRY32 lpme, BOOL first ) static BOOL TOOLHELP_Module32Next( HANDLE handle, LPMODULEENTRY32 lpme, BOOL first )
{ {
struct next_module_request *req = get_req_buffer(); BOOL ret;
if (lpme->dwSize < sizeof (MODULEENTRY32)) if (lpme->dwSize < sizeof (MODULEENTRY32))
{ {
SetLastError( ERROR_INSUFFICIENT_BUFFER ); SetLastError( ERROR_INSUFFICIENT_BUFFER );
ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(MODULEENTRY32), lpme->dwSize); ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(MODULEENTRY32), lpme->dwSize);
return FALSE; return FALSE;
} }
req->handle = handle; SERVER_START_REQ
req->reset = first; {
if (server_call( REQ_NEXT_MODULE )) return FALSE; struct next_module_request *req = server_alloc_req( sizeof(*req), 0 );
lpme->th32ModuleID = 0; /* toolhelp internal id, never used */ req->handle = handle;
lpme->th32ProcessID = (DWORD)req->pid; req->reset = first;
lpme->GlblcntUsage = 0; /* FIXME */ if ((ret = !server_call( REQ_NEXT_MODULE )))
lpme->ProccntUsage = 0; /* FIXME */ {
lpme->modBaseAddr = req->base; lpme->th32ModuleID = 0; /* toolhelp internal id, never used */
lpme->modBaseSize = 0; /* FIXME */ lpme->th32ProcessID = (DWORD)req->pid;
lpme->hModule = (DWORD)req->base; lpme->GlblcntUsage = 0; /* FIXME */
lpme->szModule[0] = 0; /* FIXME */ lpme->ProccntUsage = 0; /* FIXME */
lpme->szExePath[0] = 0; /* FIXME */ lpme->modBaseAddr = req->base;
return TRUE; lpme->modBaseSize = 0; /* FIXME */
lpme->hModule = (DWORD)req->base;
lpme->szModule[0] = 0; /* FIXME */
lpme->szExePath[0] = 0; /* FIXME */
}
}
SERVER_END_REQ;
return ret;
} }
/*********************************************************************** /***********************************************************************
......
...@@ -86,18 +86,24 @@ static DWORD EXC_CallHandler( EXCEPTION_RECORD *record, EXCEPTION_FRAME *frame, ...@@ -86,18 +86,24 @@ static DWORD EXC_CallHandler( EXCEPTION_RECORD *record, EXCEPTION_FRAME *frame,
/********************************************************************** /**********************************************************************
* EXC_SendEvent * send_debug_event
* *
* Send an EXCEPTION_DEBUG_EVENT event to the debugger. * Send an EXCEPTION_DEBUG_EVENT event to the debugger.
*/ */
static inline int send_debug_event( EXCEPTION_RECORD *rec, int first_chance, CONTEXT *context ) static inline int send_debug_event( EXCEPTION_RECORD *rec, int first_chance, CONTEXT *context )
{ {
struct exception_event_request *req = get_req_buffer(); int ret;
req->record = *rec; SERVER_START_REQ
req->first = first_chance; {
req->context = *context; struct exception_event_request *req = server_alloc_req( sizeof(*req), 0 );
if (!server_call_noerr( REQ_EXCEPTION_EVENT )) *context = req->context; req->record = *rec;
return req->status; req->first = first_chance;
req->context = *context;
if (!server_call_noerr( REQ_EXCEPTION_EVENT )) *context = req->context;
ret = req->status;
}
SERVER_END_REQ;
return ret;
} }
......
...@@ -75,10 +75,17 @@ NTSTATUS WINAPI NtQueryTimerResolution(DWORD x1,DWORD x2,DWORD x3) ...@@ -75,10 +75,17 @@ NTSTATUS WINAPI NtQueryTimerResolution(DWORD x1,DWORD x2,DWORD x3)
NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code ) NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
{ {
NTSTATUS ret; NTSTATUS ret;
struct terminate_process_request *req = get_req_buffer(); BOOL self;
req->handle = handle; SERVER_START_REQ
req->exit_code = exit_code; {
if (!(ret = server_call_noerr( REQ_TERMINATE_PROCESS )) && req->self) exit( exit_code ); struct terminate_process_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle;
req->exit_code = exit_code;
ret = server_call_noerr( REQ_TERMINATE_PROCESS );
self = !ret && req->self;
}
SERVER_END_REQ;
if (self) exit( exit_code );
return ret; return ret;
} }
...@@ -134,24 +141,35 @@ NTSTATUS WINAPI NtResumeThread( ...@@ -134,24 +141,35 @@ NTSTATUS WINAPI NtResumeThread(
return 0; return 0;
} }
/****************************************************************************** /******************************************************************************
* NtTerminateThread [NTDLL] * NtTerminateThread [NTDLL]
*/ */
NTSTATUS WINAPI NtTerminateThread( IN HANDLE handle, NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
IN NTSTATUS exit_code )
{ {
NTSTATUS ret; NTSTATUS ret;
struct terminate_thread_request *req = get_req_buffer(); BOOL self, last;
req->handle = handle;
req->exit_code = exit_code; SERVER_START_REQ
if (!(ret = server_call_noerr( REQ_TERMINATE_THREAD )) && req->self)
{ {
if (req->last) exit( exit_code ); struct terminate_thread_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle;
req->exit_code = exit_code;
ret = server_call_noerr( REQ_TERMINATE_THREAD );
self = !ret && req->self;
last = req->last;
}
SERVER_END_REQ;
if (self)
{
if (last) exit( exit_code );
else SYSDEPS_ExitThread( exit_code ); else SYSDEPS_ExitThread( exit_code );
} }
return ret; return ret;
} }
/****************************************************************************** /******************************************************************************
* NtQueryInformationThread [NTDLL.] * NtQueryInformationThread [NTDLL.]
* *
......
...@@ -215,9 +215,15 @@ NTSTATUS WINAPI NtDuplicateObject( ...@@ -215,9 +215,15 @@ NTSTATUS WINAPI NtDuplicateObject(
*/ */
NTSTATUS WINAPI NtClose( HANDLE Handle ) NTSTATUS WINAPI NtClose( HANDLE Handle )
{ {
struct close_handle_request *req = get_req_buffer(); NTSTATUS ret;
req->handle = Handle; SERVER_START_REQ
return server_call_noerr( REQ_CLOSE_HANDLE ); {
struct close_handle_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = Handle;
ret = server_call_noerr( REQ_CLOSE_HANDLE );
}
SERVER_END_REQ;
return ret;
} }
/****************************************************************************** /******************************************************************************
......
...@@ -28,13 +28,19 @@ DEFAULT_DEBUG_CHANNEL(file); ...@@ -28,13 +28,19 @@ DEFAULT_DEBUG_CHANNEL(file);
HANDLE WINAPI FindFirstChangeNotificationA( LPCSTR lpPathName, BOOL bWatchSubtree, HANDLE WINAPI FindFirstChangeNotificationA( LPCSTR lpPathName, BOOL bWatchSubtree,
DWORD dwNotifyFilter ) DWORD dwNotifyFilter )
{ {
struct create_change_notification_request *req = get_req_buffer(); HANDLE ret = -1;
FIXME("this is not supported yet (non-trivial).\n"); FIXME("this is not supported yet (non-trivial).\n");
req->subtree = bWatchSubtree;
req->filter = dwNotifyFilter; SERVER_START_REQ
server_call( REQ_CREATE_CHANGE_NOTIFICATION ); {
return req->handle; struct create_change_notification_request *req = server_alloc_req( sizeof(*req), 0 );
req->subtree = bWatchSubtree;
req->filter = dwNotifyFilter;
if (!server_call( REQ_CREATE_CHANGE_NOTIFICATION )) ret = req->handle;
}
SERVER_END_REQ;
return ret;
} }
/**************************************************************************** /****************************************************************************
......
...@@ -368,14 +368,20 @@ HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing, ...@@ -368,14 +368,20 @@ HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
*/ */
HFILE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa ) HFILE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa )
{ {
struct create_device_request *req = get_req_buffer(); HFILE ret;
SERVER_START_REQ
req->access = access; {
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); struct create_device_request *req = server_alloc_req( sizeof(*req), 0 );
req->id = client_id;
SetLastError(0); req->access = access;
server_call( REQ_CREATE_DEVICE ); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
return req->handle; req->id = client_id;
SetLastError(0);
server_call( REQ_CREATE_DEVICE );
ret = req->handle;
}
SERVER_END_REQ;
return ret;
} }
...@@ -566,22 +572,29 @@ BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info ) ...@@ -566,22 +572,29 @@ BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info )
DWORD WINAPI GetFileInformationByHandle( HANDLE hFile, DWORD WINAPI GetFileInformationByHandle( HANDLE hFile,
BY_HANDLE_FILE_INFORMATION *info ) BY_HANDLE_FILE_INFORMATION *info )
{ {
struct get_file_info_request *req = get_req_buffer(); DWORD ret;
if (!info) return 0; if (!info) return 0;
req->handle = hFile;
if (server_call( REQ_GET_FILE_INFO )) return 0; SERVER_START_REQ
RtlSecondsSince1970ToTime( req->write_time, &info->ftCreationTime ); {
RtlSecondsSince1970ToTime( req->write_time, &info->ftLastWriteTime ); struct get_file_info_request *req = server_alloc_req( sizeof(*req), 0 );
RtlSecondsSince1970ToTime( req->access_time, &info->ftLastAccessTime ); req->handle = hFile;
info->dwFileAttributes = req->attr; if ((ret = !server_call( REQ_GET_FILE_INFO )))
info->dwVolumeSerialNumber = req->serial; {
info->nFileSizeHigh = req->size_high; RtlSecondsSince1970ToTime( req->write_time, &info->ftCreationTime );
info->nFileSizeLow = req->size_low; RtlSecondsSince1970ToTime( req->write_time, &info->ftLastWriteTime );
info->nNumberOfLinks = req->links; RtlSecondsSince1970ToTime( req->access_time, &info->ftLastAccessTime );
info->nFileIndexHigh = req->index_high; info->dwFileAttributes = req->attr;
info->nFileIndexLow = req->index_low; info->dwVolumeSerialNumber = req->serial;
return 1; info->nFileSizeHigh = req->size_high;
info->nFileSizeLow = req->size_low;
info->nNumberOfLinks = req->links;
info->nFileIndexHigh = req->index_high;
info->nFileIndexLow = req->index_low;
}
}
SERVER_END_REQ;
return ret;
} }
...@@ -1271,7 +1284,7 @@ HFILE WINAPI _lcreat( LPCSTR path, INT attr ) ...@@ -1271,7 +1284,7 @@ HFILE WINAPI _lcreat( LPCSTR path, INT attr )
DWORD WINAPI SetFilePointer( HANDLE hFile, LONG distance, LONG *highword, DWORD WINAPI SetFilePointer( HANDLE hFile, LONG distance, LONG *highword,
DWORD method ) DWORD method )
{ {
struct set_file_pointer_request *req = get_req_buffer(); DWORD ret = 0xffffffff;
if (highword && if (highword &&
((distance >= 0 && *highword != 0) || (distance < 0 && *highword != -1))) ((distance >= 0 && *highword != 0) || (distance < 0 && *highword != -1)))
...@@ -1280,20 +1293,28 @@ DWORD WINAPI SetFilePointer( HANDLE hFile, LONG distance, LONG *highword, ...@@ -1280,20 +1293,28 @@ DWORD WINAPI SetFilePointer( HANDLE hFile, LONG distance, LONG *highword,
"SetFilePointer(%08x,%08lx,%08lx,%08lx)\n", "SetFilePointer(%08x,%08lx,%08lx,%08lx)\n",
hFile,distance,*highword,method); hFile,distance,*highword,method);
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError( ERROR_INVALID_PARAMETER );
return 0xffffffff; return ret;
} }
TRACE("handle %d offset %ld origin %ld\n", TRACE("handle %d offset %ld origin %ld\n",
hFile, distance, method ); hFile, distance, method );
req->handle = hFile; SERVER_START_REQ
req->low = distance; {
req->high = highword ? *highword : (distance >= 0) ? 0 : -1; struct set_file_pointer_request *req = server_alloc_req( sizeof(*req), 0 );
/* FIXME: assumes 1:1 mapping between Windows and Unix seek constants */ req->handle = hFile;
req->whence = method; req->low = distance;
SetLastError( 0 ); req->high = highword ? *highword : (distance >= 0) ? 0 : -1;
if (server_call( REQ_SET_FILE_POINTER )) return 0xffffffff; /* FIXME: assumes 1:1 mapping between Windows and Unix seek constants */
if (highword) *highword = req->new_high; req->whence = method;
return req->new_low; SetLastError( 0 );
if (!server_call( REQ_SET_FILE_POINTER ))
{
ret = req->new_low;
if (highword) *highword = req->new_high;
}
}
SERVER_END_REQ;
return ret;
} }
...@@ -1480,9 +1501,15 @@ UINT WINAPI SetHandleCount( UINT count ) ...@@ -1480,9 +1501,15 @@ UINT WINAPI SetHandleCount( UINT count )
*/ */
BOOL WINAPI FlushFileBuffers( HANDLE hFile ) BOOL WINAPI FlushFileBuffers( HANDLE hFile )
{ {
struct flush_file_request *req = get_req_buffer(); BOOL ret;
req->handle = hFile; SERVER_START_REQ
return !server_call( REQ_FLUSH_FILE ); {
struct flush_file_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hFile;
ret = !server_call( REQ_FLUSH_FILE );
}
SERVER_END_REQ;
return ret;
} }
...@@ -1491,9 +1518,15 @@ BOOL WINAPI FlushFileBuffers( HANDLE hFile ) ...@@ -1491,9 +1518,15 @@ BOOL WINAPI FlushFileBuffers( HANDLE hFile )
*/ */
BOOL WINAPI SetEndOfFile( HANDLE hFile ) BOOL WINAPI SetEndOfFile( HANDLE hFile )
{ {
struct truncate_file_request *req = get_req_buffer(); BOOL ret;
req->handle = hFile; SERVER_START_REQ
return !server_call( REQ_TRUNCATE_FILE ); {
struct truncate_file_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hFile;
ret = !server_call( REQ_TRUNCATE_FILE );
}
SERVER_END_REQ;
return ret;
} }
...@@ -1645,10 +1678,15 @@ int FILE_munmap( LPVOID start, DWORD size_high, DWORD size_low ) ...@@ -1645,10 +1678,15 @@ int FILE_munmap( LPVOID start, DWORD size_high, DWORD size_low )
*/ */
DWORD WINAPI GetFileType( HANDLE hFile ) DWORD WINAPI GetFileType( HANDLE hFile )
{ {
struct get_file_info_request *req = get_req_buffer(); DWORD ret = FILE_TYPE_UNKNOWN;
req->handle = hFile; SERVER_START_REQ
if (server_call( REQ_GET_FILE_INFO )) return FILE_TYPE_UNKNOWN; {
return req->type; struct get_file_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hFile;
if (!server_call( REQ_GET_FILE_INFO )) ret = req->type;
}
SERVER_END_REQ;
return ret;
} }
...@@ -1931,18 +1969,23 @@ BOOL WINAPI SetFileTime( HANDLE hFile, ...@@ -1931,18 +1969,23 @@ BOOL WINAPI SetFileTime( HANDLE hFile,
const FILETIME *lpLastAccessTime, const FILETIME *lpLastAccessTime,
const FILETIME *lpLastWriteTime ) const FILETIME *lpLastWriteTime )
{ {
struct set_file_time_request *req = get_req_buffer(); BOOL ret;
SERVER_START_REQ
req->handle = hFile; {
if (lpLastAccessTime) struct set_file_time_request *req = server_alloc_req( sizeof(*req), 0 );
req->access_time = DOSFS_FileTimeToUnixTime(lpLastAccessTime, NULL); req->handle = hFile;
else if (lpLastAccessTime)
req->access_time = 0; /* FIXME */ req->access_time = DOSFS_FileTimeToUnixTime(lpLastAccessTime, NULL);
if (lpLastWriteTime) else
req->write_time = DOSFS_FileTimeToUnixTime(lpLastWriteTime, NULL); req->access_time = 0; /* FIXME */
else if (lpLastWriteTime)
req->write_time = 0; /* FIXME */ req->write_time = DOSFS_FileTimeToUnixTime(lpLastWriteTime, NULL);
return !server_call( REQ_SET_FILE_TIME ); else
req->write_time = 0; /* FIXME */
ret = !server_call( REQ_SET_FILE_TIME );
}
SERVER_END_REQ;
return ret;
} }
...@@ -1952,14 +1995,20 @@ BOOL WINAPI SetFileTime( HANDLE hFile, ...@@ -1952,14 +1995,20 @@ BOOL WINAPI SetFileTime( HANDLE hFile,
BOOL WINAPI LockFile( HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, BOOL WINAPI LockFile( HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh ) DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh )
{ {
struct lock_file_request *req = get_req_buffer(); BOOL ret;
SERVER_START_REQ
req->handle = hFile; {
req->offset_low = dwFileOffsetLow; struct lock_file_request *req = server_alloc_req( sizeof(*req), 0 );
req->offset_high = dwFileOffsetHigh;
req->count_low = nNumberOfBytesToLockLow; req->handle = hFile;
req->count_high = nNumberOfBytesToLockHigh; req->offset_low = dwFileOffsetLow;
return !server_call( REQ_LOCK_FILE ); req->offset_high = dwFileOffsetHigh;
req->count_low = nNumberOfBytesToLockLow;
req->count_high = nNumberOfBytesToLockHigh;
ret = !server_call( REQ_LOCK_FILE );
}
SERVER_END_REQ;
return ret;
} }
/************************************************************************** /**************************************************************************
...@@ -1999,14 +2048,20 @@ BOOL WINAPI LockFileEx( HANDLE hFile, DWORD flags, DWORD reserved, ...@@ -1999,14 +2048,20 @@ BOOL WINAPI LockFileEx( HANDLE hFile, DWORD flags, DWORD reserved,
BOOL WINAPI UnlockFile( HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, BOOL WINAPI UnlockFile( HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh ) DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh )
{ {
struct unlock_file_request *req = get_req_buffer(); BOOL ret;
SERVER_START_REQ
req->handle = hFile; {
req->offset_low = dwFileOffsetLow; struct unlock_file_request *req = server_alloc_req( sizeof(*req), 0 );
req->offset_high = dwFileOffsetHigh;
req->count_low = nNumberOfBytesToUnlockLow; req->handle = hFile;
req->count_high = nNumberOfBytesToUnlockHigh; req->offset_low = dwFileOffsetLow;
return !server_call( REQ_UNLOCK_FILE ); req->offset_high = dwFileOffsetHigh;
req->count_low = nNumberOfBytesToUnlockLow;
req->count_high = nNumberOfBytesToUnlockHigh;
ret = !server_call( REQ_UNLOCK_FILE );
}
SERVER_END_REQ;
return ret;
} }
......
...@@ -910,12 +910,10 @@ NTSTATUS WINAPI NtClose( ...@@ -910,12 +910,10 @@ NTSTATUS WINAPI NtClose(
HANDLE Handle); HANDLE Handle);
NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code ); NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code );
NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code );
NTSTATUS WINAPI NtCreateSemaphore( OUT PHANDLE SemaphoreHandle, NTSTATUS WINAPI NtCreateEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *,BOOLEAN,BOOLEAN);
IN ACCESS_MASK DesiredAccess, NTSTATUS WINAPI NtCreateSemaphore(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,ULONG);
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
IN ULONG InitialCount,
IN ULONG MaximumCount);
NTSTATUS WINAPI NtReleaseSemaphore( IN HANDLE SemaphoreHandle, NTSTATUS WINAPI NtReleaseSemaphore( IN HANDLE SemaphoreHandle,
IN ULONG ReleaseCount, IN ULONG ReleaseCount,
IN PULONG PreviousCount); IN PULONG PreviousCount);
......
...@@ -350,8 +350,7 @@ struct get_apc_request ...@@ -350,8 +350,7 @@ struct get_apc_request
REQUEST_HEADER; /* request header */ REQUEST_HEADER; /* request header */
OUT void* func; /* function to call */ OUT void* func; /* function to call */
OUT int type; /* function type */ OUT int type; /* function type */
OUT int nb_args; /* number of arguments */ OUT VARARG(args,ptrs); /* function arguments */
OUT void* args[1]; /* function arguments */
}; };
enum apc_type { APC_NONE, APC_USER, APC_TIMER }; enum apc_type { APC_NONE, APC_USER, APC_TIMER };
...@@ -415,11 +414,10 @@ struct open_process_request ...@@ -415,11 +414,10 @@ struct open_process_request
struct select_request struct select_request
{ {
REQUEST_HEADER; /* request header */ REQUEST_HEADER; /* request header */
IN int count; /* handles count */
IN int flags; /* wait flags (see below) */ IN int flags; /* wait flags (see below) */
IN int timeout; /* timeout in ms */ IN int timeout; /* timeout in ms */
OUT int signaled; /* signaled handle */ OUT int signaled; /* signaled handle */
IN int handles[1]; /* handles to select on */ IN VARARG(handles,ints); /* handles to select on */
}; };
#define SELECT_ALL 1 #define SELECT_ALL 1
#define SELECT_ALERTABLE 2 #define SELECT_ALERTABLE 2
...@@ -434,7 +432,7 @@ struct create_event_request ...@@ -434,7 +432,7 @@ struct create_event_request
IN int initial_state; /* initial state of the event */ IN int initial_state; /* initial state of the event */
IN int inherit; /* inherit flag */ IN int inherit; /* inherit flag */
OUT int handle; /* handle to the event */ OUT int handle; /* handle to the event */
IN WCHAR name[1]; /* event name */ IN VARARG(name,unicode_str); /* object name */
}; };
/* Event operation */ /* Event operation */
...@@ -454,7 +452,7 @@ struct open_event_request ...@@ -454,7 +452,7 @@ struct open_event_request
IN unsigned int access; /* wanted access rights */ IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */ IN int inherit; /* inherit flag */
OUT int handle; /* handle to the event */ OUT int handle; /* handle to the event */
IN WCHAR name[1]; /* object name */ IN VARARG(name,unicode_str); /* object name */
}; };
...@@ -465,7 +463,7 @@ struct create_mutex_request ...@@ -465,7 +463,7 @@ struct create_mutex_request
IN int owned; /* initially owned? */ IN int owned; /* initially owned? */
IN int inherit; /* inherit flag */ IN int inherit; /* inherit flag */
OUT int handle; /* handle to the mutex */ OUT int handle; /* handle to the mutex */
IN WCHAR name[1]; /* mutex name */ IN VARARG(name,unicode_str); /* object name */
}; };
...@@ -484,7 +482,7 @@ struct open_mutex_request ...@@ -484,7 +482,7 @@ struct open_mutex_request
IN unsigned int access; /* wanted access rights */ IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */ IN int inherit; /* inherit flag */
OUT int handle; /* handle to the mutex */ OUT int handle; /* handle to the mutex */
IN WCHAR name[1]; /* object name */ IN VARARG(name,unicode_str); /* object name */
}; };
...@@ -496,7 +494,7 @@ struct create_semaphore_request ...@@ -496,7 +494,7 @@ struct create_semaphore_request
IN unsigned int max; /* maximum count */ IN unsigned int max; /* maximum count */
IN int inherit; /* inherit flag */ IN int inherit; /* inherit flag */
OUT int handle; /* handle to the semaphore */ OUT int handle; /* handle to the semaphore */
IN WCHAR name[1]; /* semaphore name */ IN VARARG(name,unicode_str); /* object name */
}; };
...@@ -517,7 +515,7 @@ struct open_semaphore_request ...@@ -517,7 +515,7 @@ struct open_semaphore_request
IN unsigned int access; /* wanted access rights */ IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */ IN int inherit; /* inherit flag */
OUT int handle; /* handle to the semaphore */ OUT int handle; /* handle to the semaphore */
IN WCHAR name[1]; /* object name */ IN VARARG(name,unicode_str); /* object name */
}; };
...@@ -835,7 +833,7 @@ struct create_mapping_request ...@@ -835,7 +833,7 @@ struct create_mapping_request
IN int inherit; /* inherit flag */ IN int inherit; /* inherit flag */
IN int file_handle; /* file handle */ IN int file_handle; /* file handle */
OUT int handle; /* handle to the mapping */ OUT int handle; /* handle to the mapping */
IN WCHAR name[1]; /* object name */ IN VARARG(name,unicode_str); /* object name */
}; };
/* protection flags */ /* protection flags */
#define VPROT_READ 0x01 #define VPROT_READ 0x01
...@@ -855,7 +853,7 @@ struct open_mapping_request ...@@ -855,7 +853,7 @@ struct open_mapping_request
IN unsigned int access; /* wanted access rights */ IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */ IN int inherit; /* inherit flag */
OUT int handle; /* handle to the mapping */ OUT int handle; /* handle to the mapping */
IN WCHAR name[1]; /* object name */ IN VARARG(name,unicode_str); /* object name */
}; };
...@@ -941,7 +939,7 @@ struct wait_debug_event_request ...@@ -941,7 +939,7 @@ struct wait_debug_event_request
IN int timeout; /* timeout in ms */ IN int timeout; /* timeout in ms */
OUT void* pid; /* process id */ OUT void* pid; /* process id */
OUT void* tid; /* thread id */ OUT void* tid; /* thread id */
OUT debug_event_t event; /* debug event data */ OUT VARARG(event,debug_event); /* debug event data */
}; };
...@@ -1175,7 +1173,7 @@ struct create_timer_request ...@@ -1175,7 +1173,7 @@ struct create_timer_request
IN int inherit; /* inherit flag */ IN int inherit; /* inherit flag */
IN int manual; /* manual reset */ IN int manual; /* manual reset */
OUT int handle; /* handle to the timer */ OUT int handle; /* handle to the timer */
IN WCHAR name[1]; /* timer name */ IN VARARG(name,unicode_str); /* object name */
}; };
...@@ -1186,7 +1184,7 @@ struct open_timer_request ...@@ -1186,7 +1184,7 @@ struct open_timer_request
IN unsigned int access; /* wanted access rights */ IN unsigned int access; /* wanted access rights */
IN int inherit; /* inherit flag */ IN int inherit; /* inherit flag */
OUT int handle; /* handle to the timer */ OUT int handle; /* handle to the timer */
IN WCHAR name[1]; /* timer name */ IN VARARG(name,unicode_str); /* object name */
}; };
/* Set a waitable timer */ /* Set a waitable timer */
...@@ -1247,7 +1245,7 @@ struct add_atom_request ...@@ -1247,7 +1245,7 @@ struct add_atom_request
REQUEST_HEADER; /* request header */ REQUEST_HEADER; /* request header */
IN int local; /* is atom in local process table? */ IN int local; /* is atom in local process table? */
OUT int atom; /* resulting atom */ OUT int atom; /* resulting atom */
IN WCHAR name[1]; /* atom name */ IN VARARG(name,unicode_str); /* atom name */
}; };
...@@ -1266,7 +1264,7 @@ struct find_atom_request ...@@ -1266,7 +1264,7 @@ struct find_atom_request
REQUEST_HEADER; /* request header */ REQUEST_HEADER; /* request header */
IN int local; /* is atom in local process table? */ IN int local; /* is atom in local process table? */
OUT int atom; /* atom handle */ OUT int atom; /* atom handle */
IN WCHAR name[1]; /* atom name */ IN VARARG(name,unicode_str); /* atom name */
}; };
...@@ -1277,7 +1275,7 @@ struct get_atom_name_request ...@@ -1277,7 +1275,7 @@ struct get_atom_name_request
IN int atom; /* atom handle */ IN int atom; /* atom handle */
IN int local; /* is atom in local process table? */ IN int local; /* is atom in local process table? */
OUT int count; /* atom lock count */ OUT int count; /* atom lock count */
OUT WCHAR name[1]; /* atom name */ OUT VARARG(name,unicode_str); /* atom name */
}; };
...@@ -1542,7 +1540,7 @@ union generic_request ...@@ -1542,7 +1540,7 @@ union generic_request
struct wait_input_idle_request wait_input_idle; struct wait_input_idle_request wait_input_idle;
}; };
#define SERVER_PROTOCOL_VERSION 18 #define SERVER_PROTOCOL_VERSION 19
/* ### make_requests end ### */ /* ### make_requests end ### */
/* Everything above this line is generated automatically by tools/make_requests */ /* Everything above this line is generated automatically by tools/make_requests */
...@@ -1621,6 +1619,12 @@ inline static void *server_data_ptr( void *req ) ...@@ -1621,6 +1619,12 @@ inline static void *server_data_ptr( void *req )
return (union generic_request *)req + 1; return (union generic_request *)req + 1;
} }
/* get the size of the variable part of the request */
inline static size_t server_data_size( void *req )
{
return ((struct request_header *)req)->var_size;
}
/* exception support for server calls */ /* exception support for server calls */
......
...@@ -1526,12 +1526,14 @@ BOOL MODULE_FreeLibrary( WINE_MODREF *wm ) ...@@ -1526,12 +1526,14 @@ BOOL MODULE_FreeLibrary( WINE_MODREF *wm )
/* Call process detach notifications */ /* Call process detach notifications */
if ( PROCESS_Current()->free_lib_count <= 1 ) if ( PROCESS_Current()->free_lib_count <= 1 )
{ {
struct unload_dll_request *req = get_req_buffer();
MODULE_DllProcessDetach( FALSE, NULL ); MODULE_DllProcessDetach( FALSE, NULL );
req->base = (void *)wm->module; SERVER_START_REQ
server_call_noerr( REQ_UNLOAD_DLL ); {
struct unload_dll_request *req = server_alloc_req( sizeof(*req), 0 );
req->base = (void *)wm->module;
server_call_noerr( REQ_UNLOAD_DLL );
}
SERVER_END_REQ;
MODULE_FlushModrefs(); MODULE_FlushModrefs();
} }
......
...@@ -992,7 +992,6 @@ static HINSTANCE16 MODULE_LoadModule16( LPCSTR libname, BOOL implicit, BOOL lib_ ...@@ -992,7 +992,6 @@ static HINSTANCE16 MODULE_LoadModule16( LPCSTR libname, BOOL implicit, BOOL lib_
*/ */
HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock ) HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
{ {
struct new_thread_request *req = get_req_buffer();
TEB *teb = NULL; TEB *teb = NULL;
BOOL lib_only = !paramBlock || (paramBlock == (LPVOID)-1); BOOL lib_only = !paramBlock || (paramBlock == (LPVOID)-1);
LOADPARAMS16 *params; LOADPARAMS16 *params;
...@@ -1003,7 +1002,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock ) ...@@ -1003,7 +1002,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
TDB *pTask; TDB *pTask;
LPSTR cmdline; LPSTR cmdline;
WORD cmdShow; WORD cmdShow;
HANDLE hThread; HANDLE hThread = -1;
int socket; int socket;
/* Load module */ /* Load module */
...@@ -1046,10 +1045,15 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock ) ...@@ -1046,10 +1045,15 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
/* Create the main thread */ /* Create the main thread */
req->suspend = 0; SERVER_START_REQ
req->inherit = 0; {
if (server_call_fd( REQ_NEW_THREAD, -1, &socket )) return 0; struct new_thread_request *req = server_alloc_req( sizeof(*req), 0 );
hThread = req->handle; req->suspend = 0;
req->inherit = 0;
if (!server_call_fd( REQ_NEW_THREAD, -1, &socket )) hThread = req->handle;
}
SERVER_END_REQ;
if (hThread == -1) return 0;
if (!(teb = THREAD_Create( socket, 0, FALSE ))) goto error; if (!(teb = THREAD_Create( socket, 0, FALSE ))) goto error;
teb->startup = NE_InitProcess; teb->startup = NE_InitProcess;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
* NE_MODULE.module32. * NE_MODULE.module32.
*/ */
#include <sys/types.h>
#ifdef HAVE_SYS_MMAN_H #ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h> #include <sys/mman.h>
#endif #endif
...@@ -682,13 +683,17 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags, ...@@ -682,13 +683,17 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
if (nt->FileHeader.Characteristics & IMAGE_FILE_DLL) if (nt->FileHeader.Characteristics & IMAGE_FILE_DLL)
{ {
struct load_dll_request *req = get_req_buffer(); SERVER_START_REQ
req->handle = hFile; {
req->base = (void *)hModule; struct load_dll_request *req = server_alloc_req( sizeof(*req), 0 );
req->dbg_offset = nt->FileHeader.PointerToSymbolTable; req->handle = hFile;
req->dbg_size = nt->FileHeader.NumberOfSymbols; req->base = (void *)hModule;
req->name = &wm->filename; req->dbg_offset = nt->FileHeader.PointerToSymbolTable;
server_call_noerr( REQ_LOAD_DLL ); req->dbg_size = nt->FileHeader.NumberOfSymbols;
req->name = &wm->filename;
server_call_noerr( REQ_LOAD_DLL );
}
SERVER_END_REQ;
} }
return wm; return wm;
......
...@@ -401,9 +401,15 @@ UINT16 WINAPI GetAtomName16( ATOM atom, LPSTR buffer, INT16 count ) ...@@ -401,9 +401,15 @@ UINT16 WINAPI GetAtomName16( ATOM atom, LPSTR buffer, INT16 count )
*/ */
BOOL WINAPI InitAtomTable( DWORD entries ) BOOL WINAPI InitAtomTable( DWORD entries )
{ {
struct init_atom_table_request *req = get_req_buffer(); BOOL ret;
req->entries = entries; SERVER_START_REQ
return !server_call( REQ_INIT_ATOM_TABLE ); {
struct init_atom_table_request *req = server_alloc_req( sizeof(*req), 0 );
req->entries = entries;
ret = !server_call( REQ_INIT_ATOM_TABLE );
}
SERVER_END_REQ;
return ret;
} }
...@@ -412,10 +418,20 @@ static ATOM ATOM_AddAtomA( LPCSTR str, BOOL local ) ...@@ -412,10 +418,20 @@ static ATOM ATOM_AddAtomA( LPCSTR str, BOOL local )
ATOM atom = 0; ATOM atom = 0;
if (!ATOM_IsIntAtomA( str, &atom )) if (!ATOM_IsIntAtomA( str, &atom ))
{ {
struct add_atom_request *req = get_req_buffer(); DWORD len = MultiByteToWideChar( CP_ACP, 0, str, strlen(str), NULL, 0 );
server_strcpyAtoW( req->name, str ); if (len > MAX_ATOM_LEN)
req->local = local; {
if (!server_call( REQ_ADD_ATOM )) atom = req->atom + MIN_STR_ATOM; SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
SERVER_START_REQ
{
struct add_atom_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, str, strlen(str), server_data_ptr(req), len );
req->local = local;
if (!server_call( REQ_ADD_ATOM )) atom = req->atom + MIN_STR_ATOM;
}
SERVER_END_REQ;
} }
TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_a(str), atom ); TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_a(str), atom );
return atom; return atom;
...@@ -458,10 +474,20 @@ static ATOM ATOM_AddAtomW( LPCWSTR str, BOOL local ) ...@@ -458,10 +474,20 @@ static ATOM ATOM_AddAtomW( LPCWSTR str, BOOL local )
ATOM atom = 0; ATOM atom = 0;
if (!ATOM_IsIntAtomW( str, &atom )) if (!ATOM_IsIntAtomW( str, &atom ))
{ {
struct add_atom_request *req = get_req_buffer(); DWORD len = strlenW(str);
server_strcpyW( req->name, str ); if (len > MAX_ATOM_LEN)
req->local = local; {
if (!server_call( REQ_ADD_ATOM )) atom = req->atom + MIN_STR_ATOM; SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
SERVER_START_REQ
{
struct add_atom_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
memcpy( server_data_ptr(req), str, len * sizeof(WCHAR) );
req->local = local;
if (!server_call( REQ_ADD_ATOM )) atom = req->atom + MIN_STR_ATOM;
}
SERVER_END_REQ;
} }
TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_w(str), atom ); TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_w(str), atom );
return atom; return atom;
...@@ -492,10 +518,14 @@ static ATOM ATOM_DeleteAtom( ATOM atom, BOOL local) ...@@ -492,10 +518,14 @@ static ATOM ATOM_DeleteAtom( ATOM atom, BOOL local)
if (atom < MIN_STR_ATOM) atom = 0; if (atom < MIN_STR_ATOM) atom = 0;
else else
{ {
struct delete_atom_request *req = get_req_buffer(); SERVER_START_REQ
req->atom = atom - MIN_STR_ATOM; {
req->local = local; struct delete_atom_request *req = server_alloc_req( sizeof(*req), 0 );
if (!server_call( REQ_DELETE_ATOM )) atom = 0; req->atom = atom - MIN_STR_ATOM;
req->local = local;
if (!server_call( REQ_DELETE_ATOM )) atom = 0;
}
SERVER_END_REQ;
} }
return atom; return atom;
} }
...@@ -536,10 +566,20 @@ static ATOM ATOM_FindAtomA( LPCSTR str, BOOL local ) ...@@ -536,10 +566,20 @@ static ATOM ATOM_FindAtomA( LPCSTR str, BOOL local )
ATOM atom = 0; ATOM atom = 0;
if (!ATOM_IsIntAtomA( str, &atom )) if (!ATOM_IsIntAtomA( str, &atom ))
{ {
struct find_atom_request *req = get_req_buffer(); DWORD len = MultiByteToWideChar( CP_ACP, 0, str, strlen(str), NULL, 0 );
server_strcpyAtoW( req->name, str ); if (len > MAX_ATOM_LEN)
req->local = local; {
if (!server_call( REQ_FIND_ATOM )) atom = req->atom + MIN_STR_ATOM; SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
SERVER_START_REQ
{
struct find_atom_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, str, strlen(str), server_data_ptr(req), len );
req->local = local;
if (!server_call( REQ_ADD_ATOM )) atom = req->atom + MIN_STR_ATOM;
}
SERVER_END_REQ;
} }
TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_a(str), atom ); TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_a(str), atom );
return atom; return atom;
...@@ -581,10 +621,20 @@ static ATOM ATOM_FindAtomW( LPCWSTR str, BOOL local ) ...@@ -581,10 +621,20 @@ static ATOM ATOM_FindAtomW( LPCWSTR str, BOOL local )
ATOM atom = 0; ATOM atom = 0;
if (!ATOM_IsIntAtomW( str, &atom )) if (!ATOM_IsIntAtomW( str, &atom ))
{ {
struct find_atom_request *req = get_req_buffer(); DWORD len = strlenW(str);
server_strcpyW( req->name, str ); if (len > MAX_ATOM_LEN)
req->local = local; {
if (!server_call( REQ_FIND_ATOM )) atom = req->atom + MIN_STR_ATOM; SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
SERVER_START_REQ
{
struct find_atom_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
memcpy( server_data_ptr(req), str, len * sizeof(WCHAR) );
req->local = local;
if (!server_call( REQ_FIND_ATOM )) atom = req->atom + MIN_STR_ATOM;
}
SERVER_END_REQ;
} }
TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_w(str), atom ); TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_w(str), atom );
return atom; return atom;
...@@ -612,6 +662,12 @@ ATOM WINAPI FindAtomW( LPCWSTR str ) ...@@ -612,6 +662,12 @@ ATOM WINAPI FindAtomW( LPCWSTR str )
static UINT ATOM_GetAtomNameA( ATOM atom, LPSTR buffer, INT count, BOOL local ) static UINT ATOM_GetAtomNameA( ATOM atom, LPSTR buffer, INT count, BOOL local )
{ {
INT len; INT len;
if (count <= 0)
{
SetLastError( ERROR_MORE_DATA );
return 0;
}
if (atom < MIN_STR_ATOM) if (atom < MIN_STR_ATOM)
{ {
char name[8]; char name[8];
...@@ -625,16 +681,28 @@ static UINT ATOM_GetAtomNameA( ATOM atom, LPSTR buffer, INT count, BOOL local ) ...@@ -625,16 +681,28 @@ static UINT ATOM_GetAtomNameA( ATOM atom, LPSTR buffer, INT count, BOOL local )
} }
else else
{ {
struct get_atom_name_request *req = get_req_buffer(); len = 0;
req->atom = atom - MIN_STR_ATOM; SERVER_START_REQ
req->local = local; {
if (server_call( REQ_GET_ATOM_NAME )) return 0; struct get_atom_name_request *req = server_alloc_req( sizeof(*req),
lstrcpynWtoA( buffer, req->name, count ); MAX_ATOM_LEN * sizeof(WCHAR) );
len = strlenW( req->name ); req->atom = atom - MIN_STR_ATOM;
req->local = local;
if (!server_call( REQ_GET_ATOM_NAME ))
{
len = WideCharToMultiByte( CP_ACP, 0, server_data_ptr(req), server_data_size(req),
buffer, count - 1, NULL, NULL );
if (!len) len = count; /* overflow */
else buffer[len] = 0;
}
}
SERVER_END_REQ;
} }
if (count <= len)
if (len && count <= len)
{ {
SetLastError( ERROR_MORE_DATA ); SetLastError( ERROR_MORE_DATA );
buffer[count-1] = 0;
return 0; return 0;
} }
TRACE( "(%s) %x -> %s\n", local ? "local" : "global", atom, debugstr_a(buffer) ); TRACE( "(%s) %x -> %s\n", local ? "local" : "global", atom, debugstr_a(buffer) );
...@@ -680,6 +748,12 @@ UINT WINAPI GetAtomNameA( ...@@ -680,6 +748,12 @@ UINT WINAPI GetAtomNameA(
static UINT ATOM_GetAtomNameW( ATOM atom, LPWSTR buffer, INT count, BOOL local ) static UINT ATOM_GetAtomNameW( ATOM atom, LPWSTR buffer, INT count, BOOL local )
{ {
INT len; INT len;
if (count <= 0)
{
SetLastError( ERROR_MORE_DATA );
return 0;
}
if (atom < MIN_STR_ATOM) if (atom < MIN_STR_ATOM)
{ {
char name[8]; char name[8];
...@@ -688,17 +762,29 @@ static UINT ATOM_GetAtomNameW( ATOM atom, LPWSTR buffer, INT count, BOOL local ) ...@@ -688,17 +762,29 @@ static UINT ATOM_GetAtomNameW( ATOM atom, LPWSTR buffer, INT count, BOOL local )
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError( ERROR_INVALID_PARAMETER );
return 0; return 0;
} }
len = sprintf( name, "#%d", atom ); sprintf( name, "#%d", atom );
lstrcpynAtoW( buffer, name, count ); len = MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, count );
if (!len) buffer[count-1] = 0; /* overflow */
} }
else else
{ {
struct get_atom_name_request *req = get_req_buffer(); len = 0;
req->atom = atom - MIN_STR_ATOM; SERVER_START_REQ
req->local = local; {
if (server_call( REQ_GET_ATOM_NAME )) return 0; struct get_atom_name_request *req = server_alloc_req( sizeof(*req),
lstrcpynW( buffer, req->name, count ); MAX_ATOM_LEN * sizeof(WCHAR) );
len = strlenW( req->name ); req->atom = atom - MIN_STR_ATOM;
req->local = local;
if (!server_call( REQ_GET_ATOM_NAME ))
{
len = server_data_size(req) / sizeof(WCHAR);
if (count > len) count = len + 1;
memcpy( buffer, server_data_ptr(req), (count-1) * sizeof(WCHAR) );
buffer[count-1] = 0;
}
}
SERVER_END_REQ;
if (!len) return 0;
} }
if (count <= len) if (count <= len)
{ {
......
...@@ -606,7 +606,7 @@ void WINAPI UnMapLS( SEGPTR sptr ) ...@@ -606,7 +606,7 @@ void WINAPI UnMapLS( SEGPTR sptr )
BOOL WINAPI GetThreadSelectorEntry( HANDLE hthread, DWORD sel, LPLDT_ENTRY ldtent) BOOL WINAPI GetThreadSelectorEntry( HANDLE hthread, DWORD sel, LPLDT_ENTRY ldtent)
{ {
#ifdef __i386__ #ifdef __i386__
struct get_selector_entry_request *req = get_req_buffer(); BOOL ret;
if (!(sel & 4)) /* GDT selector */ if (!(sel & 4)) /* GDT selector */
{ {
...@@ -639,29 +639,39 @@ BOOL WINAPI GetThreadSelectorEntry( HANDLE hthread, DWORD sel, LPLDT_ENTRY ldten ...@@ -639,29 +639,39 @@ BOOL WINAPI GetThreadSelectorEntry( HANDLE hthread, DWORD sel, LPLDT_ENTRY ldten
return FALSE; return FALSE;
} }
req->handle = hthread; SERVER_START_REQ
req->entry = sel >> __AHSHIFT;
if (server_call( REQ_GET_SELECTOR_ENTRY )) return FALSE;
if (!(req->flags & LDT_FLAGS_ALLOCATED))
{ {
SetLastError( ERROR_MR_MID_NOT_FOUND ); /* sic */ struct get_selector_entry_request *req = server_alloc_req( sizeof(*req), 0 );
return FALSE;
req->handle = hthread;
req->entry = sel >> __AHSHIFT;
if ((ret = !server_call( REQ_GET_SELECTOR_ENTRY )))
{
if (!(req->flags & LDT_FLAGS_ALLOCATED))
{
SetLastError( ERROR_MR_MID_NOT_FOUND ); /* sic */
ret = FALSE;
}
else
{
if (req->flags & LDT_FLAGS_BIG) req->limit >>= 12;
ldtent->BaseLow = req->base & 0x0000ffff;
ldtent->HighWord.Bits.BaseMid = (req->base & 0x00ff0000) >> 16;
ldtent->HighWord.Bits.BaseHi = (req->base & 0xff000000) >> 24;
ldtent->LimitLow = req->limit & 0x0000ffff;
ldtent->HighWord.Bits.LimitHi = (req->limit & 0x000f0000) >> 16;
ldtent->HighWord.Bits.Dpl = 3;
ldtent->HighWord.Bits.Sys = 0;
ldtent->HighWord.Bits.Pres = 1;
ldtent->HighWord.Bits.Granularity = (req->flags & LDT_FLAGS_BIG) !=0;
ldtent->HighWord.Bits.Default_Big = (req->flags & LDT_FLAGS_32BIT) != 0;
ldtent->HighWord.Bits.Type = ((req->flags & LDT_FLAGS_TYPE) << 2) | 0x10;
if (!(req->flags & LDT_FLAGS_READONLY)) ldtent->HighWord.Bits.Type |= 0x2;
}
}
} }
if (req->flags & LDT_FLAGS_BIG) req->limit >>= 12; SERVER_END_REQ;
ldtent->BaseLow = req->base & 0x0000ffff; return ret;
ldtent->HighWord.Bits.BaseMid = (req->base & 0x00ff0000) >> 16;
ldtent->HighWord.Bits.BaseHi = (req->base & 0xff000000) >> 24;
ldtent->LimitLow = req->limit & 0x0000ffff;
ldtent->HighWord.Bits.LimitHi = (req->limit & 0x000f0000) >> 16;
ldtent->HighWord.Bits.Dpl = 3;
ldtent->HighWord.Bits.Sys = 0;
ldtent->HighWord.Bits.Pres = 1;
ldtent->HighWord.Bits.Granularity = (req->flags & LDT_FLAGS_BIG) !=0;
ldtent->HighWord.Bits.Default_Big = (req->flags & LDT_FLAGS_32BIT) != 0;
ldtent->HighWord.Bits.Type = ((req->flags & LDT_FLAGS_TYPE) << 2) | 0x10;
if (!(req->flags & LDT_FLAGS_READONLY)) ldtent->HighWord.Bits.Type |= 0x2;
return TRUE;
#else #else
SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
return FALSE; return FALSE;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#endif #endif
#include "winbase.h" #include "winbase.h"
#include "wine/exception.h" #include "wine/exception.h"
#include "wine/unicode.h"
#include "winerror.h" #include "winerror.h"
#include "file.h" #include "file.h"
#include "process.h" #include "process.h"
...@@ -1195,14 +1196,20 @@ HANDLE WINAPI CreateFileMappingA( ...@@ -1195,14 +1196,20 @@ HANDLE WINAPI CreateFileMappingA(
DWORD size_low, /* [in] Low-order 32 bits of object size */ DWORD size_low, /* [in] Low-order 32 bits of object size */
LPCSTR name /* [in] Name of file-mapping object */ ) LPCSTR name /* [in] Name of file-mapping object */ )
{ {
struct create_mapping_request *req = get_req_buffer(); HANDLE ret;
BYTE vprot; BYTE vprot;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
/* Check parameters */ /* Check parameters */
TRACE("(%x,%p,%08lx,%08lx%08lx,%s)\n", TRACE("(%x,%p,%08lx,%08lx%08lx,%s)\n",
hFile, sa, protect, size_high, size_low, debugstr_a(name) ); hFile, sa, protect, size_high, size_low, debugstr_a(name) );
if (len > MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
vprot = VIRTUAL_GetProt( protect ); vprot = VIRTUAL_GetProt( protect );
if (protect & SEC_RESERVE) if (protect & SEC_RESERVE)
{ {
...@@ -1218,16 +1225,23 @@ HANDLE WINAPI CreateFileMappingA( ...@@ -1218,16 +1225,23 @@ HANDLE WINAPI CreateFileMappingA(
/* Create the server object */ /* Create the server object */
req->file_handle = hFile; SERVER_START_REQ
req->size_high = size_high; {
req->size_low = size_low; struct create_mapping_request *req = server_alloc_req( sizeof(*req),
req->protect = vprot; len * sizeof(WCHAR) );
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->file_handle = hFile;
server_strcpyAtoW( req->name, name ); req->size_high = size_high;
SetLastError(0); req->size_low = size_low;
server_call( REQ_CREATE_MAPPING ); req->protect = vprot;
if (req->handle == -1) return 0; req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
return req->handle; if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0);
server_call( REQ_CREATE_MAPPING );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -1239,14 +1253,21 @@ HANDLE WINAPI CreateFileMappingW( HFILE hFile, LPSECURITY_ATTRIBUTES sa, ...@@ -1239,14 +1253,21 @@ HANDLE WINAPI CreateFileMappingW( HFILE hFile, LPSECURITY_ATTRIBUTES sa,
DWORD protect, DWORD size_high, DWORD protect, DWORD size_high,
DWORD size_low, LPCWSTR name ) DWORD size_low, LPCWSTR name )
{ {
struct create_mapping_request *req = get_req_buffer(); HANDLE ret;
BYTE vprot; BYTE vprot;
DWORD len = name ? strlenW(name) : 0;
/* Check parameters */ /* Check parameters */
TRACE("(%x,%p,%08lx,%08lx%08lx,%s)\n", TRACE("(%x,%p,%08lx,%08lx%08lx,%s)\n",
hFile, sa, protect, size_high, size_low, debugstr_w(name) ); hFile, sa, protect, size_high, size_low, debugstr_w(name) );
if (len > MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
vprot = VIRTUAL_GetProt( protect ); vprot = VIRTUAL_GetProt( protect );
if (protect & SEC_RESERVE) if (protect & SEC_RESERVE)
{ {
...@@ -1262,16 +1283,23 @@ HANDLE WINAPI CreateFileMappingW( HFILE hFile, LPSECURITY_ATTRIBUTES sa, ...@@ -1262,16 +1283,23 @@ HANDLE WINAPI CreateFileMappingW( HFILE hFile, LPSECURITY_ATTRIBUTES sa,
/* Create the server object */ /* Create the server object */
req->file_handle = hFile; SERVER_START_REQ
req->size_high = size_high; {
req->size_low = size_low; struct create_mapping_request *req = server_alloc_req( sizeof(*req),
req->protect = vprot; len * sizeof(WCHAR) );
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->file_handle = hFile;
server_strcpyW( req->name, name ); req->size_high = size_high;
SetLastError(0); req->size_low = size_low;
server_call( REQ_CREATE_MAPPING ); req->protect = vprot;
if (req->handle == -1) return 0; req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
return req->handle; memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_MAPPING );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -1288,14 +1316,26 @@ HANDLE WINAPI OpenFileMappingA( ...@@ -1288,14 +1316,26 @@ HANDLE WINAPI OpenFileMappingA(
BOOL inherit, /* [in] Inherit flag */ BOOL inherit, /* [in] Inherit flag */
LPCSTR name ) /* [in] Name of file-mapping object */ LPCSTR name ) /* [in] Name of file-mapping object */
{ {
struct open_mapping_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
req->access = access; if (len > MAX_PATH)
req->inherit = inherit; {
server_strcpyAtoW( req->name, name ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
server_call( REQ_OPEN_MAPPING ); return 0;
if (req->handle == -1) return 0; /* must return 0 on failure, not -1 */ }
return req->handle; SERVER_START_REQ
{
struct open_mapping_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_MAPPING );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -1305,14 +1345,26 @@ HANDLE WINAPI OpenFileMappingA( ...@@ -1305,14 +1345,26 @@ HANDLE WINAPI OpenFileMappingA(
*/ */
HANDLE WINAPI OpenFileMappingW( DWORD access, BOOL inherit, LPCWSTR name) HANDLE WINAPI OpenFileMappingW( DWORD access, BOOL inherit, LPCWSTR name)
{ {
struct open_mapping_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
req->access = access; if (len > MAX_PATH)
req->inherit = inherit; {
server_strcpyW( req->name, name ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
server_call( REQ_OPEN_MAPPING ); return 0;
if (req->handle == -1) return 0; /* must return 0 on failure, not -1 */ }
return req->handle; SERVER_START_REQ
{
struct open_mapping_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_MAPPING );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
......
...@@ -1323,16 +1323,19 @@ void _w31_loadreg(void) { ...@@ -1323,16 +1323,19 @@ void _w31_loadreg(void) {
/* configure save files and start the periodic saving timer */ /* configure save files and start the periodic saving timer */
static void SHELL_InitRegistrySaving( HKEY hkey_users_default ) static void SHELL_InitRegistrySaving( HKEY hkey_users_default )
{ {
struct set_registry_levels_request *req = get_req_buffer();
int all = PROFILE_GetWineIniBool( "registry", "SaveOnlyUpdatedKeys", 1 ); int all = PROFILE_GetWineIniBool( "registry", "SaveOnlyUpdatedKeys", 1 );
int period = PROFILE_GetWineIniInt( "registry", "PeriodicSave", 0 ); int period = PROFILE_GetWineIniInt( "registry", "PeriodicSave", 0 );
/* set saving level (0 for saving everything, 1 for saving only modified keys) */ /* set saving level (0 for saving everything, 1 for saving only modified keys) */
req->current = 1; SERVER_START_REQ
req->saving = !all; {
req->period = period * 1000; struct set_registry_levels_request *req = server_alloc_req( sizeof(*req), 0 );
server_call( REQ_SET_REGISTRY_LEVELS ); req->current = 1;
req->saving = !all;
req->period = period * 1000;
server_call( REQ_SET_REGISTRY_LEVELS );
}
SERVER_END_REQ;
if (PROFILE_GetWineIniBool("registry","WritetoHomeRegistries",1)) if (PROFILE_GetWineIniBool("registry","WritetoHomeRegistries",1))
{ {
...@@ -1377,12 +1380,16 @@ static void SHELL_InitRegistrySaving( HKEY hkey_users_default ) ...@@ -1377,12 +1380,16 @@ static void SHELL_InitRegistrySaving( HKEY hkey_users_default )
*/ */
static void SetLoadLevel(int level) static void SetLoadLevel(int level)
{ {
struct set_registry_levels_request *req = get_req_buffer(); SERVER_START_REQ
{
struct set_registry_levels_request *req = server_alloc_req( sizeof(*req), 0 );
req->current = level; req->current = level;
req->saving = 0; req->saving = 0;
req->period = 0; req->period = 0;
server_call( REQ_SET_REGISTRY_LEVELS ); server_call( REQ_SET_REGISTRY_LEVELS );
}
SERVER_END_REQ;
} }
/********************************************************************************** /**********************************************************************************
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include "winerror.h" #include "winerror.h"
#include "wine/unicode.h"
#include "syslevel.h" #include "syslevel.h"
#include "server.h" #include "server.h"
...@@ -17,16 +18,28 @@ ...@@ -17,16 +18,28 @@
HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset, HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
BOOL initial_state, LPCSTR name ) BOOL initial_state, LPCSTR name )
{ {
struct create_event_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
req->manual_reset = manual_reset; if (len >= MAX_PATH)
req->initial_state = initial_state; {
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); SetLastError( ERROR_FILENAME_EXCED_RANGE );
server_strcpyAtoW( req->name, name ); return 0;
SetLastError(0); }
server_call( REQ_CREATE_EVENT ); SERVER_START_REQ
if (req->handle == -1) return 0; {
return req->handle; struct create_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->manual_reset = manual_reset;
req->initial_state = initial_state;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0);
server_call( REQ_CREATE_EVENT );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -36,16 +49,28 @@ HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset, ...@@ -36,16 +49,28 @@ HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset, HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
BOOL initial_state, LPCWSTR name ) BOOL initial_state, LPCWSTR name )
{ {
struct create_event_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
req->manual_reset = manual_reset; if (len >= MAX_PATH)
req->initial_state = initial_state; {
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); SetLastError( ERROR_FILENAME_EXCED_RANGE );
server_strcpyW( req->name, name ); return 0;
SetLastError(0); }
server_call( REQ_CREATE_EVENT ); SERVER_START_REQ
if (req->handle == -1) return 0; {
return req->handle; struct create_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->manual_reset = manual_reset;
req->initial_state = initial_state;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_EVENT );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
/*********************************************************************** /***********************************************************************
...@@ -62,14 +87,26 @@ HANDLE WINAPI WIN16_CreateEvent( BOOL manual_reset, BOOL initial_state ) ...@@ -62,14 +87,26 @@ HANDLE WINAPI WIN16_CreateEvent( BOOL manual_reset, BOOL initial_state )
*/ */
HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name ) HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name )
{ {
struct open_event_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
req->access = access; if (len >= MAX_PATH)
req->inherit = inherit; {
server_strcpyAtoW( req->name, name ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
server_call( REQ_OPEN_EVENT ); return 0;
if (req->handle == -1) return 0; /* must return 0 on failure, not -1 */ }
return req->handle; SERVER_START_REQ
{
struct open_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_EVENT );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -78,14 +115,26 @@ HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name ) ...@@ -78,14 +115,26 @@ HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name )
*/ */
HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name ) HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name )
{ {
struct open_event_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
req->access = access; if (len >= MAX_PATH)
req->inherit = inherit; {
server_strcpyW( req->name, name ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
server_call( REQ_OPEN_EVENT ); return 0;
if (req->handle == -1) return 0; /* must return 0 on failure, not -1 */ }
return req->handle; SERVER_START_REQ
{
struct open_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_EVENT );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -96,10 +145,16 @@ HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name ) ...@@ -96,10 +145,16 @@ HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name )
*/ */
static BOOL EVENT_Operation( HANDLE handle, enum event_op op ) static BOOL EVENT_Operation( HANDLE handle, enum event_op op )
{ {
struct event_op_request *req = get_req_buffer(); BOOL ret;
req->handle = handle; SERVER_START_REQ
req->op = op; {
return !server_call( REQ_EVENT_OP ); struct event_op_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle;
req->op = op;
ret = !server_call( REQ_EVENT_OP );
}
SERVER_END_REQ;
return ret;
} }
......
...@@ -18,14 +18,17 @@ DEFAULT_DEBUG_CHANNEL(win32) ...@@ -18,14 +18,17 @@ DEFAULT_DEBUG_CHANNEL(win32)
*/ */
BOOL WINAPI CloseHandle( HANDLE handle ) BOOL WINAPI CloseHandle( HANDLE handle )
{ {
struct close_handle_request *req = get_req_buffer(); NTSTATUS status;
/* stdio handles need special treatment */ /* stdio handles need special treatment */
if ((handle == STD_INPUT_HANDLE) || if ((handle == STD_INPUT_HANDLE) ||
(handle == STD_OUTPUT_HANDLE) || (handle == STD_OUTPUT_HANDLE) ||
(handle == STD_ERROR_HANDLE)) (handle == STD_ERROR_HANDLE))
handle = GetStdHandle( handle ); handle = GetStdHandle( handle );
req->handle = handle;
return !server_call( REQ_CLOSE_HANDLE ); status = NtClose( handle );
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
} }
...@@ -34,11 +37,16 @@ BOOL WINAPI CloseHandle( HANDLE handle ) ...@@ -34,11 +37,16 @@ BOOL WINAPI CloseHandle( HANDLE handle )
*/ */
BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags ) BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
{ {
struct get_handle_info_request *req = get_req_buffer(); BOOL ret;
req->handle = handle; SERVER_START_REQ
if (server_call( REQ_GET_HANDLE_INFO )) return FALSE; {
if (flags) *flags = req->flags; struct get_handle_info_request *req = server_alloc_req( sizeof(*req), 0 );
return TRUE; req->handle = handle;
ret = !server_call( REQ_GET_HANDLE_INFO );
if (ret && flags) *flags = req->flags;
}
SERVER_END_REQ;
return ret;
} }
...@@ -47,11 +55,17 @@ BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags ) ...@@ -47,11 +55,17 @@ BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
*/ */
BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags ) BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
{ {
struct set_handle_info_request *req = get_req_buffer(); BOOL ret;
req->handle = handle; SERVER_START_REQ
req->flags = flags; {
req->mask = mask; struct set_handle_info_request *req = server_alloc_req( sizeof(*req), 0 );
return !server_call( REQ_SET_HANDLE_INFO ); req->handle = handle;
req->flags = flags;
req->mask = mask;
ret = !server_call( REQ_SET_HANDLE_INFO );
}
SERVER_END_REQ;
return ret;
} }
...@@ -62,18 +76,23 @@ BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source, ...@@ -62,18 +76,23 @@ BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
HANDLE dest_process, HANDLE *dest, HANDLE dest_process, HANDLE *dest,
DWORD access, BOOL inherit, DWORD options ) DWORD access, BOOL inherit, DWORD options )
{ {
struct dup_handle_request *req = get_req_buffer(); BOOL ret;
SERVER_START_REQ
req->src_process = source_process; {
req->src_handle = source; struct dup_handle_request *req = server_alloc_req( sizeof(*req), 0 );
req->dst_process = dest_process;
req->access = access; req->src_process = source_process;
req->inherit = inherit; req->src_handle = source;
req->options = options; req->dst_process = dest_process;
req->access = access;
if (server_call( REQ_DUP_HANDLE )) return FALSE; req->inherit = inherit;
if (dest) *dest = req->handle; req->options = options;
return TRUE;
ret = !server_call( REQ_DUP_HANDLE );
if (ret && dest) *dest = req->handle;
}
SERVER_END_REQ;
return ret;
} }
...@@ -82,17 +101,10 @@ BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source, ...@@ -82,17 +101,10 @@ BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
*/ */
HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc) HANDLE WINAPI ConvertToGlobalHandle(HANDLE hSrc)
{ {
struct dup_handle_request *req = get_req_buffer(); HANDLE ret = -1;
DuplicateHandle( GetCurrentProcess(), hSrc, (HANDLE)-1, &ret, 0, FALSE,
req->src_process = GetCurrentProcess(); DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE );
req->src_handle = hSrc; return ret;
req->dst_process = -1;
req->access = 0;
req->inherit = FALSE;
req->options = DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE;
server_call( REQ_DUP_HANDLE );
return req->handle;
} }
/*********************************************************************** /***********************************************************************
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include "winerror.h" #include "winerror.h"
#include "wine/unicode.h"
#include "server.h" #include "server.h"
...@@ -15,15 +16,27 @@ ...@@ -15,15 +16,27 @@
*/ */
HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name ) HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name )
{ {
struct create_mutex_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct create_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->owned = owner; req->owned = owner;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
server_strcpyAtoW( req->name, name ); if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0); SetLastError(0);
server_call( REQ_CREATE_MUTEX ); server_call( REQ_CREATE_MUTEX );
if (req->handle == -1) return 0; ret = req->handle;
return req->handle; }
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -32,15 +45,27 @@ HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name ) ...@@ -32,15 +45,27 @@ HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name )
*/ */
HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name ) HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name )
{ {
struct create_mutex_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct create_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->owned = owner; req->owned = owner;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
server_strcpyW( req->name, name ); memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0); SetLastError(0);
server_call( REQ_CREATE_MUTEX ); server_call( REQ_CREATE_MUTEX );
if (req->handle == -1) return 0; ret = req->handle;
return req->handle; }
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -49,14 +74,26 @@ HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name ) ...@@ -49,14 +74,26 @@ HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name )
*/ */
HANDLE WINAPI OpenMutexA( DWORD access, BOOL inherit, LPCSTR name ) HANDLE WINAPI OpenMutexA( DWORD access, BOOL inherit, LPCSTR name )
{ {
struct open_mutex_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct open_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access; req->access = access;
req->inherit = inherit; req->inherit = inherit;
server_strcpyAtoW( req->name, name ); if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_MUTEX ); server_call( REQ_OPEN_MUTEX );
if (req->handle == -1) return 0; /* must return 0 on failure, not -1 */ ret = req->handle;
return req->handle; }
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -65,14 +102,26 @@ HANDLE WINAPI OpenMutexA( DWORD access, BOOL inherit, LPCSTR name ) ...@@ -65,14 +102,26 @@ HANDLE WINAPI OpenMutexA( DWORD access, BOOL inherit, LPCSTR name )
*/ */
HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name ) HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name )
{ {
struct open_mutex_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct open_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access; req->access = access;
req->inherit = inherit; req->inherit = inherit;
server_strcpyW( req->name, name ); memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_MUTEX ); server_call( REQ_OPEN_MUTEX );
if (req->handle == -1) return 0; /* must return 0 on failure, not -1 */ ret = req->handle;
return req->handle; }
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -81,7 +130,13 @@ HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name ) ...@@ -81,7 +130,13 @@ HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name )
*/ */
BOOL WINAPI ReleaseMutex( HANDLE handle ) BOOL WINAPI ReleaseMutex( HANDLE handle )
{ {
struct release_mutex_request *req = get_req_buffer(); BOOL ret;
req->handle = handle; SERVER_START_REQ
return !server_call( REQ_RELEASE_MUTEX ); {
struct release_mutex_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle;
ret = !server_call( REQ_RELEASE_MUTEX );
}
SERVER_END_REQ;
return ret;
} }
...@@ -16,11 +16,18 @@ ...@@ -16,11 +16,18 @@
BOOL WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe, BOOL WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
LPSECURITY_ATTRIBUTES sa, DWORD size ) LPSECURITY_ATTRIBUTES sa, DWORD size )
{ {
struct create_pipe_request *req = get_req_buffer(); BOOL ret;
SERVER_START_REQ
{
struct create_pipe_request *req = server_alloc_req( sizeof(*req), 0 );
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (server_call( REQ_CREATE_PIPE )) return FALSE; if ((ret = !server_call( REQ_CREATE_PIPE )))
*hReadPipe = req->handle_read; {
*hWritePipe = req->handle_write; *hReadPipe = req->handle_read;
return TRUE; *hWritePipe = req->handle_write;
}
}
SERVER_END_REQ;
return ret;
} }
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include "winerror.h" #include "winerror.h"
#include "wine/unicode.h"
#include "server.h" #include "server.h"
...@@ -15,7 +16,8 @@ ...@@ -15,7 +16,8 @@
*/ */
HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, LPCSTR name ) HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, LPCSTR name )
{ {
struct create_semaphore_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
/* Check parameters */ /* Check parameters */
...@@ -24,15 +26,28 @@ HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, ...@@ -24,15 +26,28 @@ HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max,
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError( ERROR_INVALID_PARAMETER );
return 0; return 0;
} }
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
req->initial = (unsigned int)initial; SERVER_START_REQ
req->max = (unsigned int)max; {
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); struct create_semaphore_request *req = server_alloc_req( sizeof(*req),
server_strcpyAtoW( req->name, name ); len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_SEMAPHORE ); req->initial = (unsigned int)initial;
if (req->handle == -1) return 0; req->max = (unsigned int)max;
return req->handle; req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0);
server_call( REQ_CREATE_SEMAPHORE );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -42,7 +57,8 @@ HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, ...@@ -42,7 +57,8 @@ HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max,
HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial, HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
LONG max, LPCWSTR name ) LONG max, LPCWSTR name )
{ {
struct create_semaphore_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
/* Check parameters */ /* Check parameters */
...@@ -51,15 +67,28 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial, ...@@ -51,15 +67,28 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError( ERROR_INVALID_PARAMETER );
return 0; return 0;
} }
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
req->initial = (unsigned int)initial; SERVER_START_REQ
req->max = (unsigned int)max; {
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); struct create_semaphore_request *req = server_alloc_req( sizeof(*req),
server_strcpyW( req->name, name ); len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_SEMAPHORE ); req->initial = (unsigned int)initial;
if (req->handle == -1) return 0; req->max = (unsigned int)max;
return req->handle; req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_SEMAPHORE );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -68,14 +97,26 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial, ...@@ -68,14 +97,26 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
*/ */
HANDLE WINAPI OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name ) HANDLE WINAPI OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name )
{ {
struct open_semaphore_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
req->access = access; if (len >= MAX_PATH)
req->inherit = inherit; {
server_strcpyAtoW( req->name, name ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
server_call( REQ_OPEN_SEMAPHORE ); return 0;
if (req->handle == -1) return 0; /* must return 0 on failure, not -1 */ }
return req->handle; SERVER_START_REQ
{
struct open_semaphore_request *req = server_alloc_req( sizeof(*req),
len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_SEMAPHORE );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -84,14 +125,25 @@ HANDLE WINAPI OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name ) ...@@ -84,14 +125,25 @@ HANDLE WINAPI OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name )
*/ */
HANDLE WINAPI OpenSemaphoreW( DWORD access, BOOL inherit, LPCWSTR name ) HANDLE WINAPI OpenSemaphoreW( DWORD access, BOOL inherit, LPCWSTR name )
{ {
struct open_semaphore_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
req->access = access; if (len >= MAX_PATH)
req->inherit = inherit; {
server_strcpyW( req->name, name ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
server_call( REQ_OPEN_SEMAPHORE ); return 0;
if (req->handle == -1) return 0; /* must return 0 on failure, not -1 */ }
return req->handle; SERVER_START_REQ
{
struct open_semaphore_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_SEMAPHORE );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -100,20 +152,7 @@ HANDLE WINAPI OpenSemaphoreW( DWORD access, BOOL inherit, LPCWSTR name ) ...@@ -100,20 +152,7 @@ HANDLE WINAPI OpenSemaphoreW( DWORD access, BOOL inherit, LPCWSTR name )
*/ */
BOOL WINAPI ReleaseSemaphore( HANDLE handle, LONG count, LONG *previous ) BOOL WINAPI ReleaseSemaphore( HANDLE handle, LONG count, LONG *previous )
{ {
BOOL ret = FALSE; NTSTATUS status = NtReleaseSemaphore( handle, count, previous );
struct release_semaphore_request *req = get_req_buffer(); if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
if (count < 0)
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
req->handle = handle;
req->count = (unsigned int)count;
if (!server_call( REQ_RELEASE_SEMAPHORE ))
{
if (previous) *previous = req->prev_count;
ret = TRUE;
}
return ret;
} }
...@@ -23,33 +23,39 @@ ...@@ -23,33 +23,39 @@
*/ */
static void call_apcs(void) static void call_apcs(void)
{ {
FARPROC proc; FARPROC proc = NULL;
struct get_apc_request *req = get_req_buffer(); FILETIME ft;
void *args[4];
for (;;) for (;;)
{ {
if (server_call( REQ_GET_APC )) return; int type = APC_NONE;
switch(req->type) SERVER_START_REQ
{
struct get_apc_request *req = server_alloc_req( sizeof(*req), sizeof(args) );
if (!server_call( REQ_GET_APC ))
{
type = req->type;
proc = req->func;
memcpy( args, server_data_ptr(req), server_data_size(req) );
}
}
SERVER_END_REQ;
switch(type)
{ {
case APC_NONE: case APC_NONE:
return; /* no more APCs */ return; /* no more APCs */
case APC_USER: case APC_USER:
if ((proc = req->func)) proc( args[0] );
{
proc( req->args[0] );
}
break; break;
case APC_TIMER: case APC_TIMER:
if ((proc = req->func)) /* convert sec/usec to NT time */
{ DOSFS_UnixTimeToFileTime( (time_t)args[0], &ft, (DWORD)args[1] * 10 );
FILETIME ft; proc( args[2], ft.dwLowDateTime, ft.dwHighDateTime );
/* convert sec/usec to NT time */
DOSFS_UnixTimeToFileTime( (time_t)req->args[0], &ft, (DWORD)req->args[1] * 10 );
proc( req->args[2], ft.dwLowDateTime, ft.dwHighDateTime );
}
break; break;
default: default:
server_protocol_error( "get_apc_request: bad type %d\n", req->type ); server_protocol_error( "get_apc_request: bad type %d\n", type );
break; break;
} }
} }
...@@ -110,7 +116,6 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, ...@@ -110,7 +116,6 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
BOOL wait_all, DWORD timeout, BOOL wait_all, DWORD timeout,
BOOL alertable ) BOOL alertable )
{ {
struct select_request *req = get_req_buffer();
int i, ret; int i, ret;
if (count > MAXIMUM_WAIT_OBJECTS) if (count > MAXIMUM_WAIT_OBJECTS)
...@@ -119,17 +124,24 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, ...@@ -119,17 +124,24 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
return WAIT_FAILED; return WAIT_FAILED;
} }
req->count = count; SERVER_START_REQ
req->flags = 0; {
req->timeout = timeout; struct select_request *req = server_alloc_req( sizeof(*req), count * sizeof(int) );
for (i = 0; i < count; i++) req->handles[i] = handles[i]; int *data = server_data_ptr( req );
req->flags = 0;
req->timeout = timeout;
for (i = 0; i < count; i++) data[i] = handles[i];
if (wait_all) req->flags |= SELECT_ALL; if (wait_all) req->flags |= SELECT_ALL;
if (alertable) req->flags |= SELECT_ALERTABLE; if (alertable) req->flags |= SELECT_ALERTABLE;
if (timeout != INFINITE) req->flags |= SELECT_TIMEOUT; if (timeout != INFINITE) req->flags |= SELECT_TIMEOUT;
server_call( REQ_SELECT ); server_call( REQ_SELECT );
if ((ret = req->signaled) == STATUS_USER_APC) call_apcs(); ret = req->signaled;
}
SERVER_END_REQ;
if (ret == STATUS_USER_APC) call_apcs();
return ret; return ret;
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include "winerror.h" #include "winerror.h"
#include "wine/unicode.h"
#include "file.h" /* for FILETIME routines */ #include "file.h" /* for FILETIME routines */
#include "server.h" #include "server.h"
...@@ -16,15 +17,27 @@ ...@@ -16,15 +17,27 @@
*/ */
HANDLE WINAPI CreateWaitableTimerA( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCSTR name ) HANDLE WINAPI CreateWaitableTimerA( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCSTR name )
{ {
struct create_timer_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
req->manual = manual; if (len >= MAX_PATH)
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); {
server_strcpyAtoW( req->name, name ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
SetLastError(0); return 0;
server_call( REQ_CREATE_TIMER ); }
if (req->handle == -1) return 0; SERVER_START_REQ
return req->handle; {
struct create_timer_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->manual = manual;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0);
server_call( REQ_CREATE_TIMER );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -33,15 +46,27 @@ HANDLE WINAPI CreateWaitableTimerA( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCSTR ...@@ -33,15 +46,27 @@ HANDLE WINAPI CreateWaitableTimerA( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCSTR
*/ */
HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWSTR name ) HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWSTR name )
{ {
struct create_timer_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
req->manual = manual; if (len >= MAX_PATH)
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); {
server_strcpyW( req->name, name ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
SetLastError(0); return 0;
server_call( REQ_CREATE_TIMER ); }
if (req->handle == -1) return 0; SERVER_START_REQ
return req->handle; {
struct create_timer_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->manual = manual;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_TIMER );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -50,14 +75,26 @@ HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWST ...@@ -50,14 +75,26 @@ HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWST
*/ */
HANDLE WINAPI OpenWaitableTimerA( DWORD access, BOOL inherit, LPCSTR name ) HANDLE WINAPI OpenWaitableTimerA( DWORD access, BOOL inherit, LPCSTR name )
{ {
struct open_timer_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
req->access = access; if (len >= MAX_PATH)
req->inherit = inherit; {
server_strcpyAtoW( req->name, name ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
server_call( REQ_OPEN_TIMER ); return 0;
if (req->handle == -1) return 0; /* must return 0 on failure, not -1 */ }
return req->handle; SERVER_START_REQ
{
struct open_timer_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_TIMER );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -66,14 +103,26 @@ HANDLE WINAPI OpenWaitableTimerA( DWORD access, BOOL inherit, LPCSTR name ) ...@@ -66,14 +103,26 @@ HANDLE WINAPI OpenWaitableTimerA( DWORD access, BOOL inherit, LPCSTR name )
*/ */
HANDLE WINAPI OpenWaitableTimerW( DWORD access, BOOL inherit, LPCWSTR name ) HANDLE WINAPI OpenWaitableTimerW( DWORD access, BOOL inherit, LPCWSTR name )
{ {
struct open_timer_request *req = get_req_buffer(); HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
req->access = access; if (len >= MAX_PATH)
req->inherit = inherit; {
server_strcpyW( req->name, name ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
server_call( REQ_OPEN_TIMER ); return 0;
if (req->handle == -1) return 0; /* must return 0 on failure, not -1 */ }
return req->handle; SERVER_START_REQ
{
struct open_timer_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_TIMER );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
} }
...@@ -83,9 +132,9 @@ HANDLE WINAPI OpenWaitableTimerW( DWORD access, BOOL inherit, LPCWSTR name ) ...@@ -83,9 +132,9 @@ HANDLE WINAPI OpenWaitableTimerW( DWORD access, BOOL inherit, LPCWSTR name )
BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG period, BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG period,
PTIMERAPCROUTINE callback, LPVOID arg, BOOL resume ) PTIMERAPCROUTINE callback, LPVOID arg, BOOL resume )
{ {
BOOL ret;
FILETIME ft; FILETIME ft;
DWORD remainder; DWORD remainder;
struct set_timer_request *req = get_req_buffer();
if (when->s.HighPart < 0) /* relative time */ if (when->s.HighPart < 0) /* relative time */
{ {
...@@ -102,23 +151,30 @@ BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG per ...@@ -102,23 +151,30 @@ BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG per
ft.dwHighDateTime = when->s.HighPart; ft.dwHighDateTime = when->s.HighPart;
} }
if (!ft.dwLowDateTime && !ft.dwHighDateTime) SERVER_START_REQ
{
/* special case to start timeout on now+period without too many calculations */
req->sec = 0;
req->usec = 0;
}
else
{ {
req->sec = DOSFS_FileTimeToUnixTime( &ft, &remainder ); struct set_timer_request *req = server_alloc_req( sizeof(*req), 0 );
req->usec = remainder / 10; /* convert from 100-ns to us units */
if (!ft.dwLowDateTime && !ft.dwHighDateTime)
{
/* special case to start timeout on now+period without too many calculations */
req->sec = 0;
req->usec = 0;
}
else
{
req->sec = DOSFS_FileTimeToUnixTime( &ft, &remainder );
req->usec = remainder / 10; /* convert from 100-ns to us units */
}
req->handle = handle;
req->period = period;
req->callback = callback;
req->arg = arg;
if (resume) SetLastError( ERROR_NOT_SUPPORTED ); /* set error but can still succeed */
ret = !server_call( REQ_SET_TIMER );
} }
req->handle = handle; SERVER_END_REQ;
req->period = period; return ret;
req->callback = callback;
req->arg = arg;
if (resume) SetLastError( ERROR_NOT_SUPPORTED ); /* set error but can still succeed */
return !server_call( REQ_SET_TIMER );
} }
...@@ -127,7 +183,13 @@ BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG per ...@@ -127,7 +183,13 @@ BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG per
*/ */
BOOL WINAPI CancelWaitableTimer( HANDLE handle ) BOOL WINAPI CancelWaitableTimer( HANDLE handle )
{ {
struct cancel_timer_request *req = get_req_buffer(); BOOL ret;
req->handle = handle; SERVER_START_REQ
return !server_call( REQ_CANCEL_TIMER ); {
struct cancel_timer_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle;
ret = !server_call( REQ_CANCEL_TIMER );
}
SERVER_END_REQ;
return ret;
} }
...@@ -65,13 +65,17 @@ static struct atom_table *global_table; ...@@ -65,13 +65,17 @@ static struct atom_table *global_table;
/* copy an atom name to a temporary area */ /* copy an atom name to a temporary area */
static const WCHAR *copy_name( const WCHAR *str ) static const WCHAR *copy_name( const WCHAR *str, size_t len )
{ {
static WCHAR buffer[MAX_ATOM_LEN+1]; static WCHAR buffer[MAX_ATOM_LEN+1];
WCHAR *p = buffer;
while (p < buffer + sizeof(buffer) - 1) if (!(*p++ = *str++)) break; if (len > MAX_ATOM_LEN*sizeof(WCHAR))
*p = 0; {
set_error( STATUS_INVALID_PARAMETER );
return NULL;
}
memcpy( buffer, str, len );
buffer[len / sizeof(WCHAR)] = 0;
return buffer; return buffer;
} }
...@@ -261,16 +265,24 @@ static int find_atom( struct atom_table *table, const WCHAR *str ) ...@@ -261,16 +265,24 @@ static int find_atom( struct atom_table *table, const WCHAR *str )
} }
/* get an atom name and refcount*/ /* get an atom name and refcount*/
static int get_atom_name( struct atom_table *table, int atom, WCHAR *str ) static size_t get_atom_name( struct atom_table *table, int atom,
WCHAR *str, size_t maxsize, int *count )
{ {
int count = -1; int len = 0;
struct atom_entry *entry = get_atom_entry( table, atom ); struct atom_entry *entry = get_atom_entry( table, atom );
*count = -1;
if (entry) if (entry)
{ {
strcpyW( str, entry->str ); *count = entry->count;
count = entry->count; len = strlenW( entry->str ) * sizeof(WCHAR);
if (len <= maxsize) memcpy( str, entry->str, len );
else
{
set_error( STATUS_BUFFER_OVERFLOW );
len = 0;
}
} }
return count; return len;
} }
/* add a global atom */ /* add a global atom */
...@@ -279,29 +291,34 @@ DECL_HANDLER(add_atom) ...@@ -279,29 +291,34 @@ DECL_HANDLER(add_atom)
struct atom_table **table_ptr = req->local ? &current->process->atom_table : &global_table; struct atom_table **table_ptr = req->local ? &current->process->atom_table : &global_table;
if (!*table_ptr) *table_ptr = create_table(0); if (!*table_ptr) *table_ptr = create_table(0);
if (*table_ptr) req->atom = add_atom( *table_ptr, copy_name( req->name ) ); if (*table_ptr)
{
const WCHAR *name = copy_name( get_req_data(req), get_req_data_size(req) );
if (name) req->atom = add_atom( *table_ptr, name );
}
} }
/* delete a global atom */ /* delete a global atom */
DECL_HANDLER(delete_atom) DECL_HANDLER(delete_atom)
{ {
delete_atom( req->local ? current->process->atom_table : global_table, delete_atom( req->local ? current->process->atom_table : global_table, req->atom );
req->atom );
} }
/* find a global atom */ /* find a global atom */
DECL_HANDLER(find_atom) DECL_HANDLER(find_atom)
{ {
req->atom = find_atom( req->local ? current->process->atom_table : global_table, const WCHAR *name = copy_name( get_req_data(req), get_req_data_size(req) );
copy_name( req->name ) ); if (name)
req->atom = find_atom( req->local ? current->process->atom_table : global_table, name );
} }
/* get global atom name */ /* get global atom name */
DECL_HANDLER(get_atom_name) DECL_HANDLER(get_atom_name)
{ {
req->name[0] = 0; WCHAR *name = get_req_data(req);
req->count = get_atom_name( req->local ? current->process->atom_table : global_table, size_t size = get_atom_name( req->local ? current->process->atom_table : global_table,
req->atom, req->name ); req->atom, name, get_req_data_size(req), &req->count );
set_req_data_size( req, size );
} }
/* init the process atom table */ /* init the process atom table */
......
...@@ -254,6 +254,7 @@ static void build_wait_debug_reply( struct thread *thread, struct object *obj, i ...@@ -254,6 +254,7 @@ static void build_wait_debug_reply( struct thread *thread, struct object *obj, i
{ {
struct debug_ctx *debug_ctx = (struct debug_ctx *)obj; struct debug_ctx *debug_ctx = (struct debug_ctx *)obj;
struct debug_event *event = find_event_to_send( debug_ctx ); struct debug_event *event = find_event_to_send( debug_ctx );
size_t size = get_req_data_size(req);
/* the object that woke us has to be our debug context */ /* the object that woke us has to be our debug context */
assert( obj->ops == &debug_ctx_ops ); assert( obj->ops == &debug_ctx_ops );
...@@ -261,14 +262,15 @@ static void build_wait_debug_reply( struct thread *thread, struct object *obj, i ...@@ -261,14 +262,15 @@ static void build_wait_debug_reply( struct thread *thread, struct object *obj, i
event->state = EVENT_SENT; event->state = EVENT_SENT;
event->sender->debug_event = event; event->sender->debug_event = event;
req->event.code = event->data.code; req->pid = event->sender->process;
req->pid = event->sender->process; req->tid = event->sender;
req->tid = event->sender; if (size > sizeof(debug_event_t)) size = sizeof(debug_event_t);
memcpy( &req->event, &event->data, sizeof(req->event) ); memcpy( get_req_data(req), &event->data, size );
set_req_data_size( req, size );
} }
else /* timeout or error */ else /* timeout or error */
{ {
req->event.code = 0; set_req_data_size( req, 0 );
req->pid = 0; req->pid = 0;
req->tid = 0; req->tid = 0;
} }
...@@ -536,9 +538,9 @@ DECL_HANDLER(wait_debug_event) ...@@ -536,9 +538,9 @@ DECL_HANDLER(wait_debug_event)
{ {
if (!wait_for_debug_event( req->timeout )) if (!wait_for_debug_event( req->timeout ))
{ {
req->event.code = 0;
req->pid = NULL; req->pid = NULL;
req->tid = NULL; req->tid = NULL;
set_req_data_size( req, 0 );
} }
} }
......
...@@ -114,11 +114,11 @@ static int event_satisfied( struct object *obj, struct thread *thread ) ...@@ -114,11 +114,11 @@ static int event_satisfied( struct object *obj, struct thread *thread )
/* create an event */ /* create an event */
DECL_HANDLER(create_event) DECL_HANDLER(create_event)
{ {
size_t len = get_req_strlenW( req, req->name );
struct event *event; struct event *event;
req->handle = -1; req->handle = -1;
if ((event = create_event( req->name, len, req->manual_reset, req->initial_state ))) if ((event = create_event( get_req_data(req), get_req_data_size(req),
req->manual_reset, req->initial_state )))
{ {
req->handle = alloc_handle( current->process, event, EVENT_ALL_ACCESS, req->inherit ); req->handle = alloc_handle( current->process, event, EVENT_ALL_ACCESS, req->inherit );
release_object( event ); release_object( event );
...@@ -128,8 +128,8 @@ DECL_HANDLER(create_event) ...@@ -128,8 +128,8 @@ DECL_HANDLER(create_event)
/* open a handle to an event */ /* open a handle to an event */
DECL_HANDLER(open_event) DECL_HANDLER(open_event)
{ {
size_t len = get_req_strlenW( req, req->name ); req->handle = open_object( get_req_data(req), get_req_data_size(req),
req->handle = open_object( req->name, len, &event_ops, req->access, req->inherit ); &event_ops, req->access, req->inherit );
} }
/* do an event operation */ /* do an event operation */
......
...@@ -281,12 +281,12 @@ int get_page_size(void) ...@@ -281,12 +281,12 @@ int get_page_size(void)
/* create a file mapping */ /* create a file mapping */
DECL_HANDLER(create_mapping) DECL_HANDLER(create_mapping)
{ {
size_t len = get_req_strlenW( req, req->name );
struct object *obj; struct object *obj;
req->handle = -1; req->handle = -1;
if ((obj = create_mapping( req->size_high, req->size_low, if ((obj = create_mapping( req->size_high, req->size_low,
req->protect, req->file_handle, req->name, len ))) req->protect, req->file_handle,
get_req_data(req), get_req_data_size(req) )))
{ {
int access = FILE_MAP_ALL_ACCESS; int access = FILE_MAP_ALL_ACCESS;
if (!(req->protect & VPROT_WRITE)) access &= ~FILE_MAP_WRITE; if (!(req->protect & VPROT_WRITE)) access &= ~FILE_MAP_WRITE;
...@@ -298,8 +298,8 @@ DECL_HANDLER(create_mapping) ...@@ -298,8 +298,8 @@ DECL_HANDLER(create_mapping)
/* open a handle to a mapping */ /* open a handle to a mapping */
DECL_HANDLER(open_mapping) DECL_HANDLER(open_mapping)
{ {
size_t len = get_req_strlenW( req, req->name ); req->handle = open_object( get_req_data(req), get_req_data_size(req),
req->handle = open_object( req->name, len, &mapping_ops, req->access, req->inherit ); &mapping_ops, req->access, req->inherit );
} }
/* get a mapping information */ /* get a mapping information */
......
...@@ -139,11 +139,10 @@ static void mutex_destroy( struct object *obj ) ...@@ -139,11 +139,10 @@ static void mutex_destroy( struct object *obj )
/* create a mutex */ /* create a mutex */
DECL_HANDLER(create_mutex) DECL_HANDLER(create_mutex)
{ {
size_t len = get_req_strlenW( req, req->name );
struct mutex *mutex; struct mutex *mutex;
req->handle = -1; req->handle = -1;
if ((mutex = create_mutex( req->name, len, req->owned ))) 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 ); req->handle = alloc_handle( current->process, mutex, MUTEX_ALL_ACCESS, req->inherit );
release_object( mutex ); release_object( mutex );
...@@ -153,8 +152,8 @@ DECL_HANDLER(create_mutex) ...@@ -153,8 +152,8 @@ DECL_HANDLER(create_mutex)
/* open a handle to a mutex */ /* open a handle to a mutex */
DECL_HANDLER(open_mutex) DECL_HANDLER(open_mutex)
{ {
size_t len = get_req_strlenW( req, req->name ); req->handle = open_object( get_req_data(req), get_req_data_size(req),
req->handle = open_object( req->name, len, &mutex_ops, req->access, req->inherit ); &mutex_ops, req->access, req->inherit );
} }
/* release a mutex */ /* release a mutex */
......
...@@ -70,6 +70,7 @@ void *memdup( const void *data, size_t len ) ...@@ -70,6 +70,7 @@ void *memdup( const void *data, size_t len )
static int get_name_hash( const WCHAR *name, size_t len ) static int get_name_hash( const WCHAR *name, size_t len )
{ {
WCHAR hash = 0; WCHAR hash = 0;
len /= sizeof(WCHAR);
while (len--) hash ^= *name++; while (len--) hash ^= *name++;
return hash % NAME_HASH_SIZE; return hash % NAME_HASH_SIZE;
} }
...@@ -79,11 +80,10 @@ static struct object_name *alloc_name( const WCHAR *name, size_t len ) ...@@ -79,11 +80,10 @@ static struct object_name *alloc_name( const WCHAR *name, size_t len )
{ {
struct object_name *ptr; struct object_name *ptr;
if ((ptr = mem_alloc( sizeof(*ptr) + len * sizeof(ptr->name[0]) ))) if ((ptr = mem_alloc( sizeof(*ptr) + len - sizeof(ptr->name) )))
{ {
ptr->len = len; ptr->len = len;
memcpy( ptr->name, name, len * sizeof(ptr->name[0]) ); memcpy( ptr->name, name, len );
ptr->name[len] = 0;
} }
return ptr; return ptr;
} }
...@@ -186,7 +186,7 @@ void dump_object_name( struct object *obj ) ...@@ -186,7 +186,7 @@ void dump_object_name( struct object *obj )
else else
{ {
fprintf( stderr, "name=L\"" ); fprintf( stderr, "name=L\"" );
dump_strW( obj->name->name, strlenW(obj->name->name), stderr, "\"\"" ); dump_strW( obj->name->name, obj->name->len/sizeof(WCHAR), stderr, "\"\"" );
fputc( '\"', stderr ); fputc( '\"', stderr );
} }
} }
...@@ -228,11 +228,12 @@ void release_object( void *ptr ) ...@@ -228,11 +228,12 @@ void release_object( void *ptr )
struct object *find_object( const WCHAR *name, size_t len ) struct object *find_object( const WCHAR *name, size_t len )
{ {
struct object_name *ptr; struct object_name *ptr;
if (!name || !len) return NULL; if (!name || !len) return NULL;
for (ptr = names[ get_name_hash( name, len ) ]; ptr; ptr = ptr->next) for (ptr = names[ get_name_hash( name, len ) ]; ptr; ptr = ptr->next)
{ {
if (ptr->len != len) continue; if (ptr->len != len) continue;
if (!memcmp( ptr->name, name, len*sizeof(WCHAR) )) return grab_object( ptr->obj ); if (!memcmp( ptr->name, name, len )) return grab_object( ptr->obj );
} }
return NULL; return NULL;
} }
......
...@@ -54,6 +54,18 @@ inline static void *get_req_data( const void *req ) ...@@ -54,6 +54,18 @@ inline static void *get_req_data( const void *req )
return ((union generic_request *)req + 1); return ((union generic_request *)req + 1);
} }
/* get the request vararg size */
inline static size_t get_req_data_size( const void *req )
{
return ((struct request_header *)req)->var_size;
}
/* set the request vararg size */
inline static void set_req_data_size( const void *req, size_t size )
{
((struct request_header *)req)->var_size = size;
}
#define REQUEST_END(req) ((char *)(req) + MAX_REQUEST_LENGTH - sizeof(struct server_buffer_info)) #define REQUEST_END(req) ((char *)(req) + MAX_REQUEST_LENGTH - sizeof(struct server_buffer_info))
......
...@@ -122,11 +122,11 @@ static int semaphore_satisfied( struct object *obj, struct thread *thread ) ...@@ -122,11 +122,11 @@ static int semaphore_satisfied( struct object *obj, struct thread *thread )
/* create a semaphore */ /* create a semaphore */
DECL_HANDLER(create_semaphore) DECL_HANDLER(create_semaphore)
{ {
size_t len = get_req_strlenW( req, req->name );
struct semaphore *sem; struct semaphore *sem;
req->handle = -1; req->handle = -1;
if ((sem = create_semaphore( req->name, len, req->initial, req->max ))) if ((sem = create_semaphore( get_req_data(req), get_req_data_size(req),
req->initial, req->max )))
{ {
req->handle = alloc_handle( current->process, sem, SEMAPHORE_ALL_ACCESS, req->inherit ); req->handle = alloc_handle( current->process, sem, SEMAPHORE_ALL_ACCESS, req->inherit );
release_object( sem ); release_object( sem );
...@@ -136,8 +136,8 @@ DECL_HANDLER(create_semaphore) ...@@ -136,8 +136,8 @@ DECL_HANDLER(create_semaphore)
/* open a handle to a semaphore */ /* open a handle to a semaphore */
DECL_HANDLER(open_semaphore) DECL_HANDLER(open_semaphore)
{ {
size_t len = get_req_strlenW( req, req->name ); req->handle = open_object( get_req_data(req), get_req_data_size(req),
req->handle = open_object( req->name, len, &semaphore_ops, req->access, req->inherit ); &semaphore_ops, req->access, req->inherit );
} }
/* release a semaphore */ /* release a semaphore */
......
...@@ -787,7 +787,8 @@ DECL_HANDLER(resume_thread) ...@@ -787,7 +787,8 @@ DECL_HANDLER(resume_thread)
/* select on a handle list */ /* select on a handle list */
DECL_HANDLER(select) DECL_HANDLER(select)
{ {
if (!select_on( req->count, req->handles, req->flags, req->timeout )) int count = get_req_data_size(req) / sizeof(int);
if (!select_on( count, get_req_data(req), req->flags, req->timeout ))
req->signaled = -1; req->signaled = -1;
} }
...@@ -806,21 +807,31 @@ DECL_HANDLER(queue_apc) ...@@ -806,21 +807,31 @@ DECL_HANDLER(queue_apc)
DECL_HANDLER(get_apc) DECL_HANDLER(get_apc)
{ {
struct thread_apc *apc; struct thread_apc *apc;
size_t size;
if ((apc = thread_dequeue_apc( current ))) for (;;)
{ {
req->func = apc->func; if (!(apc = thread_dequeue_apc( current )))
req->type = apc->type; {
req->nb_args = apc->nb_args; /* no more APCs */
memcpy( req->args, apc->args, apc->nb_args * sizeof(req->args[0]) ); req->func = NULL;
req->type = APC_NONE;
set_req_data_size( req, 0 );
return;
}
/* Optimization: ignore APCs that have a NULL func; they are only used
* to wake up a thread, but since we got here the thread woke up already.
*/
if (apc->func) break;
free( apc ); free( apc );
} }
else size = apc->nb_args * sizeof(apc->args[0]);
{ if (size > get_req_data_size(req)) size = get_req_data_size(req);
req->func = NULL; req->func = apc->func;
req->type = APC_NONE; req->type = apc->type;
req->nb_args = 0; memcpy( get_req_data(req), apc->args, size );
} set_req_data_size( req, size );
free( apc );
} }
/* fetch a selector entry for a thread */ /* fetch a selector entry for a thread */
......
...@@ -173,11 +173,10 @@ static void timer_destroy( struct object *obj ) ...@@ -173,11 +173,10 @@ static void timer_destroy( struct object *obj )
/* create a timer */ /* create a timer */
DECL_HANDLER(create_timer) DECL_HANDLER(create_timer)
{ {
size_t len = get_req_strlenW( req, req->name );
struct timer *timer; struct timer *timer;
req->handle = -1; req->handle = -1;
if ((timer = create_timer( req->name, len, req->manual ))) 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 ); req->handle = alloc_handle( current->process, timer, TIMER_ALL_ACCESS, req->inherit );
release_object( timer ); release_object( timer );
...@@ -187,8 +186,8 @@ DECL_HANDLER(create_timer) ...@@ -187,8 +186,8 @@ DECL_HANDLER(create_timer)
/* open a handle to a timer */ /* open a handle to a timer */
DECL_HANDLER(open_timer) DECL_HANDLER(open_timer)
{ {
size_t len = get_req_strlenW( req, req->name ); req->handle = open_object( get_req_data(req), get_req_data_size(req),
req->handle = open_object( req->name, len, &timer_ops, req->access, req->inherit ); &timer_ops, req->access, req->inherit );
} }
/* set a waitable timer */ /* set a waitable timer */
......
...@@ -100,13 +100,50 @@ static void dump_exc_record( const void *req, const EXCEPTION_RECORD *rec ) ...@@ -100,13 +100,50 @@ static void dump_exc_record( const void *req, const EXCEPTION_RECORD *rec )
fputc( '}', stderr ); fputc( '}', stderr );
} }
static void dump_debug_event_t( const void *req, const debug_event_t *event ) static void dump_varargs_ints( const void *ptr, size_t len )
{ {
const int *data = ptr;
len /= sizeof(*data);
fputc( '{', stderr );
while (len > 0)
{
fprintf( stderr, "%d", *data++ );
if (--len) fputc( ',', stderr );
}
fputc( '}', stderr );
}
static void dump_varargs_ptrs( const void *ptr, size_t len )
{
void * const *data = ptr;
len /= sizeof(*data);
fputc( '{', stderr );
while (len > 0)
{
fprintf( stderr, "%p", *data++ );
if (--len) fputc( ',', stderr );
}
fputc( '}', stderr );
}
static void dump_varargs_unicode_str( const void *ptr, size_t len )
{
fprintf( stderr, "L\"" );
dump_strW( ptr, len / sizeof(WCHAR), stderr, "\"\"" );
fputc( '\"', stderr );
}
static void dump_varargs_debug_event( const void *ptr, size_t len )
{
const debug_event_t *event = ptr;
switch(event->code) switch(event->code)
{ {
case EXCEPTION_DEBUG_EVENT: case EXCEPTION_DEBUG_EVENT:
fprintf( stderr, "{exception," ); fprintf( stderr, "{exception," );
dump_exc_record( req, &event->info.exception.record ); dump_exc_record( ptr, &event->info.exception.record );
fprintf( stderr, ",first=%d}", event->info.exception.first ); fprintf( stderr, ",first=%d}", event->info.exception.first );
break; break;
case CREATE_THREAD_DEBUG_EVENT: case CREATE_THREAD_DEBUG_EVENT:
...@@ -156,23 +193,8 @@ static void dump_debug_event_t( const void *req, const debug_event_t *event ) ...@@ -156,23 +193,8 @@ static void dump_debug_event_t( const void *req, const debug_event_t *event )
} }
} }
/* dumping for functions for requests that have a variable part */ /* dumping for functions for requests that have a variable part */
static void dump_varargs_select_request( const struct select_request *req )
{
int count = min( req->count, get_req_size( req, req->handles, sizeof(int) ));
dump_ints( req->handles, count );
}
static void dump_varargs_get_apc_reply( const struct get_apc_request *req )
{
int i;
for (i = 0; i < req->nb_args; i++)
fprintf( stderr, "%c%p", i ? ',' : '{', req->args[i] );
fprintf( stderr, "}" );
}
static void dump_varargs_get_socket_event_reply( const struct get_socket_event_request *req ) static void dump_varargs_get_socket_event_reply( const struct get_socket_event_request *req )
{ {
dump_ints( req->errors, FD_MAX_EVENTS ); dump_ints( req->errors, FD_MAX_EVENTS );
...@@ -430,9 +452,8 @@ static void dump_get_apc_reply( const struct get_apc_request *req ) ...@@ -430,9 +452,8 @@ static void dump_get_apc_reply( const struct get_apc_request *req )
{ {
fprintf( stderr, " func=%p,", req->func ); fprintf( stderr, " func=%p,", req->func );
fprintf( stderr, " type=%d,", req->type ); fprintf( stderr, " type=%d,", req->type );
fprintf( stderr, " nb_args=%d,", req->nb_args );
fprintf( stderr, " args=" ); fprintf( stderr, " args=" );
dump_varargs_get_apc_reply( req ); dump_varargs_ptrs( get_req_data(req), get_req_data_size(req) );
} }
static void dump_close_handle_request( const struct close_handle_request *req ) static void dump_close_handle_request( const struct close_handle_request *req )
...@@ -486,11 +507,10 @@ static void dump_open_process_reply( const struct open_process_request *req ) ...@@ -486,11 +507,10 @@ static void dump_open_process_reply( const struct open_process_request *req )
static void dump_select_request( const struct select_request *req ) static void dump_select_request( const struct select_request *req )
{ {
fprintf( stderr, " count=%d,", req->count );
fprintf( stderr, " flags=%d,", req->flags ); fprintf( stderr, " flags=%d,", req->flags );
fprintf( stderr, " timeout=%d,", req->timeout ); fprintf( stderr, " timeout=%d,", req->timeout );
fprintf( stderr, " handles=" ); fprintf( stderr, " handles=" );
dump_varargs_select_request( req ); dump_varargs_ints( get_req_data(req), get_req_data_size(req) );
} }
static void dump_select_reply( const struct select_request *req ) static void dump_select_reply( const struct select_request *req )
...@@ -504,7 +524,7 @@ static void dump_create_event_request( const struct create_event_request *req ) ...@@ -504,7 +524,7 @@ static void dump_create_event_request( const struct create_event_request *req )
fprintf( stderr, " initial_state=%d,", req->initial_state ); fprintf( stderr, " initial_state=%d,", req->initial_state );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req, req->name ); dump_varargs_unicode_str( get_req_data(req), get_req_data_size(req) );
} }
static void dump_create_event_reply( const struct create_event_request *req ) static void dump_create_event_reply( const struct create_event_request *req )
...@@ -523,7 +543,7 @@ static void dump_open_event_request( const struct open_event_request *req ) ...@@ -523,7 +543,7 @@ static void dump_open_event_request( const struct open_event_request *req )
fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req, req->name ); dump_varargs_unicode_str( get_req_data(req), get_req_data_size(req) );
} }
static void dump_open_event_reply( const struct open_event_request *req ) static void dump_open_event_reply( const struct open_event_request *req )
...@@ -536,7 +556,7 @@ static void dump_create_mutex_request( const struct create_mutex_request *req ) ...@@ -536,7 +556,7 @@ static void dump_create_mutex_request( const struct create_mutex_request *req )
fprintf( stderr, " owned=%d,", req->owned ); fprintf( stderr, " owned=%d,", req->owned );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req, req->name ); dump_varargs_unicode_str( get_req_data(req), get_req_data_size(req) );
} }
static void dump_create_mutex_reply( const struct create_mutex_request *req ) static void dump_create_mutex_reply( const struct create_mutex_request *req )
...@@ -554,7 +574,7 @@ static void dump_open_mutex_request( const struct open_mutex_request *req ) ...@@ -554,7 +574,7 @@ static void dump_open_mutex_request( const struct open_mutex_request *req )
fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req, req->name ); dump_varargs_unicode_str( get_req_data(req), get_req_data_size(req) );
} }
static void dump_open_mutex_reply( const struct open_mutex_request *req ) static void dump_open_mutex_reply( const struct open_mutex_request *req )
...@@ -568,7 +588,7 @@ static void dump_create_semaphore_request( const struct create_semaphore_request ...@@ -568,7 +588,7 @@ static void dump_create_semaphore_request( const struct create_semaphore_request
fprintf( stderr, " max=%08x,", req->max ); fprintf( stderr, " max=%08x,", req->max );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req, req->name ); dump_varargs_unicode_str( get_req_data(req), get_req_data_size(req) );
} }
static void dump_create_semaphore_reply( const struct create_semaphore_request *req ) static void dump_create_semaphore_reply( const struct create_semaphore_request *req )
...@@ -592,7 +612,7 @@ static void dump_open_semaphore_request( const struct open_semaphore_request *re ...@@ -592,7 +612,7 @@ static void dump_open_semaphore_request( const struct open_semaphore_request *re
fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req, req->name ); dump_varargs_unicode_str( get_req_data(req), get_req_data_size(req) );
} }
static void dump_open_semaphore_reply( const struct open_semaphore_request *req ) static void dump_open_semaphore_reply( const struct open_semaphore_request *req )
...@@ -890,7 +910,7 @@ static void dump_create_mapping_request( const struct create_mapping_request *re ...@@ -890,7 +910,7 @@ static void dump_create_mapping_request( const struct create_mapping_request *re
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " file_handle=%d,", req->file_handle ); fprintf( stderr, " file_handle=%d,", req->file_handle );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req, req->name ); dump_varargs_unicode_str( get_req_data(req), get_req_data_size(req) );
} }
static void dump_create_mapping_reply( const struct create_mapping_request *req ) static void dump_create_mapping_reply( const struct create_mapping_request *req )
...@@ -903,7 +923,7 @@ static void dump_open_mapping_request( const struct open_mapping_request *req ) ...@@ -903,7 +923,7 @@ static void dump_open_mapping_request( const struct open_mapping_request *req )
fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req, req->name ); dump_varargs_unicode_str( get_req_data(req), get_req_data_size(req) );
} }
static void dump_open_mapping_reply( const struct open_mapping_request *req ) static void dump_open_mapping_reply( const struct open_mapping_request *req )
...@@ -1002,7 +1022,7 @@ static void dump_wait_debug_event_reply( const struct wait_debug_event_request * ...@@ -1002,7 +1022,7 @@ static void dump_wait_debug_event_reply( const struct wait_debug_event_request *
fprintf( stderr, " pid=%p,", req->pid ); fprintf( stderr, " pid=%p,", req->pid );
fprintf( stderr, " tid=%p,", req->tid ); fprintf( stderr, " tid=%p,", req->tid );
fprintf( stderr, " event=" ); fprintf( stderr, " event=" );
dump_debug_event_t( req, &req->event ); dump_varargs_debug_event( get_req_data(req), get_req_data_size(req) );
} }
static void dump_exception_event_request( const struct exception_event_request *req ) static void dump_exception_event_request( const struct exception_event_request *req )
...@@ -1232,7 +1252,7 @@ static void dump_create_timer_request( const struct create_timer_request *req ) ...@@ -1232,7 +1252,7 @@ static void dump_create_timer_request( const struct create_timer_request *req )
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " manual=%d,", req->manual ); fprintf( stderr, " manual=%d,", req->manual );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req, req->name ); dump_varargs_unicode_str( get_req_data(req), get_req_data_size(req) );
} }
static void dump_create_timer_reply( const struct create_timer_request *req ) static void dump_create_timer_reply( const struct create_timer_request *req )
...@@ -1245,7 +1265,7 @@ static void dump_open_timer_request( const struct open_timer_request *req ) ...@@ -1245,7 +1265,7 @@ static void dump_open_timer_request( const struct open_timer_request *req )
fprintf( stderr, " access=%08x,", req->access ); fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req, req->name ); dump_varargs_unicode_str( get_req_data(req), get_req_data_size(req) );
} }
static void dump_open_timer_reply( const struct open_timer_request *req ) static void dump_open_timer_reply( const struct open_timer_request *req )
...@@ -1305,7 +1325,7 @@ static void dump_add_atom_request( const struct add_atom_request *req ) ...@@ -1305,7 +1325,7 @@ static void dump_add_atom_request( const struct add_atom_request *req )
{ {
fprintf( stderr, " local=%d,", req->local ); fprintf( stderr, " local=%d,", req->local );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req, req->name ); dump_varargs_unicode_str( get_req_data(req), get_req_data_size(req) );
} }
static void dump_add_atom_reply( const struct add_atom_request *req ) static void dump_add_atom_reply( const struct add_atom_request *req )
...@@ -1323,7 +1343,7 @@ static void dump_find_atom_request( const struct find_atom_request *req ) ...@@ -1323,7 +1343,7 @@ static void dump_find_atom_request( const struct find_atom_request *req )
{ {
fprintf( stderr, " local=%d,", req->local ); fprintf( stderr, " local=%d,", req->local );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req, req->name ); dump_varargs_unicode_str( get_req_data(req), get_req_data_size(req) );
} }
static void dump_find_atom_reply( const struct find_atom_request *req ) static void dump_find_atom_reply( const struct find_atom_request *req )
...@@ -1341,7 +1361,7 @@ static void dump_get_atom_name_reply( const struct get_atom_name_request *req ) ...@@ -1341,7 +1361,7 @@ static void dump_get_atom_name_reply( const struct get_atom_name_request *req )
{ {
fprintf( stderr, " count=%d,", req->count ); fprintf( stderr, " count=%d,", req->count );
fprintf( stderr, " name=" ); fprintf( stderr, " name=" );
dump_unicode_string( req, req->name ); dump_varargs_unicode_str( get_req_data(req), get_req_data_size(req) );
} }
static void dump_init_atom_table_request( const struct init_atom_table_request *req ) static void dump_init_atom_table_request( const struct init_atom_table_request *req )
......
...@@ -121,7 +121,7 @@ sub DO_REQUEST ...@@ -121,7 +121,7 @@ sub DO_REQUEST
{ {
$dir = $1; $dir = $1;
$var = $2; $var = $2;
$type = "&" . $3; $type = "&dump_varargs_" . $3;
} }
elsif (/^\s*(IN|OUT)\s*(\w+\**(\s+\w+\**)*)\s+(\w+)(\[[1]\])?;/) elsif (/^\s*(IN|OUT)\s*(\w+\**(\s+\w+\**)*)\s+(\w+)(\[[1]\])?;/)
{ {
...@@ -178,8 +178,17 @@ sub DO_DUMP_FUNC ...@@ -178,8 +178,17 @@ sub DO_DUMP_FUNC
} }
else # must be some varargs format else # must be some varargs format
{ {
push @trace_lines, " fprintf( stderr, \" $var=\" );\n"; if ($type =~ /^&(.*)/)
push @trace_lines, " dump_varargs_${name}_${req}( req );\n"; {
my $func = $1;
push @trace_lines, " fprintf( stderr, \" $var=\" );\n";
push @trace_lines, " $func( get_req_data(req), get_req_data_size(req) );\n";
}
else
{
push @trace_lines, " fprintf( stderr, \" $var=\" );\n";
push @trace_lines, " dump_varargs_${name}_${req}( req );\n";
}
} }
} }
push @trace_lines, "}\n\n"; push @trace_lines, "}\n\n";
......
...@@ -647,14 +647,15 @@ UINT WINAPI GetConsoleOutputCP(VOID) ...@@ -647,14 +647,15 @@ UINT WINAPI GetConsoleOutputCP(VOID)
*/ */
BOOL WINAPI GetConsoleMode(HANDLE hcon,LPDWORD mode) BOOL WINAPI GetConsoleMode(HANDLE hcon,LPDWORD mode)
{ {
BOOL ret = FALSE; BOOL ret;
struct get_console_mode_request *req = get_req_buffer(); SERVER_START_REQ
req->handle = hcon;
if (!server_call( REQ_GET_CONSOLE_MODE ))
{ {
if (mode) *mode = req->mode; struct get_console_mode_request *req = server_alloc_req( sizeof(*req), 0 );
ret = TRUE; req->handle = hcon;
ret = !server_call( REQ_GET_CONSOLE_MODE );
if (ret && mode) *mode = req->mode;
} }
SERVER_END_REQ;
return ret; return ret;
} }
...@@ -672,10 +673,16 @@ BOOL WINAPI GetConsoleMode(HANDLE hcon,LPDWORD mode) ...@@ -672,10 +673,16 @@ BOOL WINAPI GetConsoleMode(HANDLE hcon,LPDWORD mode)
*/ */
BOOL WINAPI SetConsoleMode( HANDLE hcon, DWORD mode ) BOOL WINAPI SetConsoleMode( HANDLE hcon, DWORD mode )
{ {
struct set_console_mode_request *req = get_req_buffer(); BOOL ret;
req->handle = hcon; SERVER_START_REQ
req->mode = mode; {
return !server_call( REQ_SET_CONSOLE_MODE ); struct set_console_mode_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hcon;
req->mode = mode;
ret = !server_call( REQ_SET_CONSOLE_MODE );
}
SERVER_END_REQ;
return ret;
} }
......
...@@ -330,18 +330,22 @@ HANDLE DEVICE_Open( LPCSTR filename, DWORD access, ...@@ -330,18 +330,22 @@ HANDLE DEVICE_Open( LPCSTR filename, DWORD access,
static const struct VxDInfo *DEVICE_GetInfo( HANDLE handle ) static const struct VxDInfo *DEVICE_GetInfo( HANDLE handle )
{ {
struct get_file_info_request *req = get_req_buffer(); const struct VxDInfo *info = NULL;
SERVER_START_REQ
req->handle = handle;
if (!server_call( REQ_GET_FILE_INFO ) &&
(req->type == FILE_TYPE_UNKNOWN) &&
(req->attr & 0x10000))
{ {
const struct VxDInfo *info; struct get_file_info_request *req = server_alloc_req( sizeof(*req), 0 );
for (info = VxDList; info->name; info++)
if (info->id == LOWORD(req->attr)) return info; req->handle = handle;
if (!server_call( REQ_GET_FILE_INFO ) &&
(req->type == FILE_TYPE_UNKNOWN) &&
(req->attr & 0x10000))
{
for (info = VxDList; info->name; info++)
if (info->id == LOWORD(req->attr)) break;
}
} }
return NULL; SERVER_END_REQ;
return info;
} }
/**************************************************************************** /****************************************************************************
......
...@@ -441,9 +441,9 @@ void QUEUE_SetExitingQueue( HQUEUE16 hQueue ) ...@@ -441,9 +441,9 @@ void QUEUE_SetExitingQueue( HQUEUE16 hQueue )
static HQUEUE16 QUEUE_CreateMsgQueue( BOOL16 bCreatePerQData ) static HQUEUE16 QUEUE_CreateMsgQueue( BOOL16 bCreatePerQData )
{ {
HQUEUE16 hQueue; HQUEUE16 hQueue;
HANDLE handle = -1;
MESSAGEQUEUE * msgQueue; MESSAGEQUEUE * msgQueue;
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() ); TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
struct get_msg_queue_request *req = get_req_buffer();
TRACE_(msg)("(): Creating message queue...\n"); TRACE_(msg)("(): Creating message queue...\n");
...@@ -455,13 +455,19 @@ static HQUEUE16 QUEUE_CreateMsgQueue( BOOL16 bCreatePerQData ) ...@@ -455,13 +455,19 @@ static HQUEUE16 QUEUE_CreateMsgQueue( BOOL16 bCreatePerQData )
if ( !msgQueue ) if ( !msgQueue )
return 0; return 0;
if (server_call( REQ_GET_MSG_QUEUE )) 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_END_REQ;
if (handle == -1)
{ {
ERR_(msg)("Cannot get thread queue"); ERR_(msg)("Cannot get thread queue");
GlobalFree16( hQueue ); GlobalFree16( hQueue );
return 0; return 0;
} }
msgQueue->server_queue = req->handle; msgQueue->server_queue = handle;
msgQueue->server_queue = ConvertToGlobalHandle( msgQueue->server_queue ); msgQueue->server_queue = ConvertToGlobalHandle( msgQueue->server_queue );
msgQueue->self = hQueue; msgQueue->self = hQueue;
...@@ -629,7 +635,7 @@ void QUEUE_SetWakeBit( MESSAGEQUEUE *queue, WORD bit ) ...@@ -629,7 +635,7 @@ void QUEUE_SetWakeBit( MESSAGEQUEUE *queue, WORD bit )
if (queue->wakeMask & bit) if (queue->wakeMask & bit)
{ {
queue->wakeMask = 0; queue->wakeMask = 0;
/* Wake up thread waiting for message */ /* Wake up thread waiting for message */
if ( THREAD_IsWin16( queue->teb ) ) if ( THREAD_IsWin16( queue->teb ) )
{ {
...@@ -639,10 +645,14 @@ void QUEUE_SetWakeBit( MESSAGEQUEUE *queue, WORD bit ) ...@@ -639,10 +645,14 @@ void QUEUE_SetWakeBit( MESSAGEQUEUE *queue, WORD bit )
} }
else else
{ {
struct wake_queue_request *req = get_req_buffer(); SERVER_START_REQ
req->handle = queue->server_queue; {
req->bits = bit; struct wake_queue_request *req = server_alloc_req( sizeof(*req), 0 );
server_call( REQ_WAKE_QUEUE ); req->handle = queue->server_queue;
req->bits = bit;
server_call( REQ_WAKE_QUEUE );
}
SERVER_END_REQ;
} }
} }
} }
...@@ -1500,16 +1510,21 @@ BOOL16 WINAPI GetInputState16(void) ...@@ -1500,16 +1510,21 @@ BOOL16 WINAPI GetInputState16(void)
DWORD WINAPI WaitForInputIdle (HANDLE hProcess, DWORD dwTimeOut) DWORD WINAPI WaitForInputIdle (HANDLE hProcess, DWORD dwTimeOut)
{ {
DWORD cur_time, ret; DWORD cur_time, ret;
HANDLE idle_event; HANDLE idle_event = -1;
struct wait_input_idle_request *req = get_req_buffer();
req->handle = hProcess; SERVER_START_REQ
req->timeout = dwTimeOut; {
if (server_call( REQ_WAIT_INPUT_IDLE )) return 0xffffffff; struct wait_input_idle_request *req = server_alloc_req( sizeof(*req), 0 );
if ((idle_event = req->event) == -1) return 0; /* no event to wait on */ req->handle = hProcess;
req->timeout = dwTimeOut;
if (!(ret = server_call( REQ_WAIT_INPUT_IDLE ))) idle_event = req->event;
}
SERVER_END_REQ;
if (ret) return 0xffffffff; /* error */
if (idle_event == -1) return 0; /* no event to wait on */
cur_time = GetTickCount(); cur_time = GetTickCount();
TRACE_(msg)("waiting for %x\n", idle_event ); TRACE_(msg)("waiting for %x\n", idle_event );
while ( dwTimeOut > GetTickCount() - cur_time || dwTimeOut == INFINITE ) { while ( dwTimeOut > GetTickCount() - cur_time || dwTimeOut == INFINITE ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment